telegram

package
v0.0.0-...-313507d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2022 License: MPL-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateNew int = iota
	StateWork
	StateDone

	ButtonNext = 1 << iota
	ButtonBack
	ButtonCancel
)

Variables

View Source
var (
	Confs *conf.CommonConf
)
View Source
var IsRun int32

Functions

func GetHash

func GetHash(pass string) string

Types

type Article

type Article struct {
	Subject     string
	Body        string
	ContentType string
}

type BaseEvent

type BaseEvent struct {
	EndTask map[string][]func()
}

type BaseTask

type BaseTask struct {
	BaseEvent

	UUID *uuid.UUID

	ChatID int64
	// contains filtered or unexported fields
}

func (*BaseTask) AppendDescription

func (B *BaseTask) AppendDescription(txt string)

func (*BaseTask) Cancel

func (B *BaseTask) Cancel()

func (*BaseTask) Continue

func (B *BaseTask) Continue(task ITask)

func (*BaseTask) CurrentStep

func (B *BaseTask) CurrentStep() IStep

func (*BaseTask) Daemon

func (this *BaseTask) Daemon()

func (*BaseTask) DeleteMsg

func (this *BaseTask) DeleteMsg(MessageID int)

func (*BaseTask) GetCallBack

func (B *BaseTask) GetCallBack() map[string]func()

func (*BaseTask) GetChatID

func (B *BaseTask) GetChatID() int64

func (*BaseTask) GetDescription

func (B *BaseTask) GetDescription() (result string)

func (*BaseTask) GetHook

func (B *BaseTask) GetHook() func(*tgbotapi.Update) bool

func (*BaseTask) GetKey

func (B *BaseTask) GetKey() string

func (*BaseTask) GetMessage

func (B *BaseTask) GetMessage() *tgbotapi.Message

func (*BaseTask) GetName

func (B *BaseTask) GetName() string

func (*BaseTask) GetState

func (B *BaseTask) GetState() int

func (*BaseTask) GetUUID

func (B *BaseTask) GetUUID() *uuid.UUID

func (*BaseTask) InfoWrapper

func (B *BaseTask) InfoWrapper(task ITask)

func (*BaseTask) Initialise

func (B *BaseTask) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func())

func (*BaseTask) IsExclusively

func (B *BaseTask) IsExclusively() bool

func (*BaseTask) JsonUnmarshal

func (B *BaseTask) JsonUnmarshal(JSON string, v interface{}) error

func (*BaseTask) Lock

func (B *BaseTask) Lock(busy func())

func (*BaseTask) RestHook

func (B *BaseTask) RestHook()

func (*BaseTask) SetName

func (B *BaseTask) SetName(name string)

func (*BaseTask) SetState

func (B *BaseTask) SetState(newState int)

func (*BaseTask) SetUUID

func (B *BaseTask) SetUUID(UUID *uuid.UUID)

func (*BaseTask) Unlock

func (B *BaseTask) Unlock()

type Bases

type Bases struct {
	Caption  string `json:"Caption"`
	Name     string `json:"Name"`
	UUID     string `json:"UUID"`
	UserName string `json:"UserName"`
	UserPass string `json:"UserPass"`
	Cluster  *struct {
		MainServer string `json:"MainServer"`
		RASServer  string `json:"RASServer"`
		RASPort    int    `json:"RASPort"`
	} `json:"Cluster"`
	URL             string `json:"URL"`
	Conf            string `json:"Conf"`
	PlatformVersion string `json:"PlatformVersion"`
}

type BuilAndUploadCf

type BuilAndUploadCf struct {
	BuildCf
	// contains filtered or unexported fields
}

func (*BuilAndUploadCf) ChoseMC

func (B *BuilAndUploadCf) ChoseMC(ChoseData string)

func (*BuilAndUploadCf) InfoWrapper

func (B *BuilAndUploadCf) InfoWrapper(task ITask)

func (*BuilAndUploadCf) Initialise

func (B *BuilAndUploadCf) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*BuilAndUploadCf) Start

func (B *BuilAndUploadCf) Start()

type BuilAndUploadCfe

type BuilAndUploadCfe struct {
	BuildCfe
	EventBuilAndUploadCfe

	OverriteChoseMC func(ChoseData string) // для того что бы можно было переопределить действия после выбора МС при вызове из потомка
	// contains filtered or unexported fields
}

func (*BuilAndUploadCfe) ChoseMC

func (B *BuilAndUploadCfe) ChoseMC(ChoseData string)

func (*BuilAndUploadCfe) InfoWrapper

func (B *BuilAndUploadCfe) InfoWrapper(task ITask)

func (*BuilAndUploadCfe) Initialise

func (B *BuilAndUploadCfe) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*BuilAndUploadCfe) Start

func (B *BuilAndUploadCfe) Start()

type BuildCf

type BuildCf struct {
	BaseTask
	EventBuildCf

	//repName    string
	ChoseRep *cf.Repository

	ReadVersion bool
	// contains filtered or unexported fields
}

func (*BuildCf) GetCallBack

func (B *BuildCf) GetCallBack() map[string]func()

func (*BuildCf) GetCfConf

func (B *BuildCf) GetCfConf() *cf.ConfCommonData

func (*BuildCf) InfoWrapper

func (B *BuildCf) InfoWrapper(task ITask)

func (*BuildCf) Initialise

func (B *BuildCf) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*BuildCf) Invoke

func (B *BuildCf) Invoke()

func (*BuildCf) ProcessChose

func (B *BuildCf) ProcessChose(ChoseData string)

func (*BuildCf) Start

func (B *BuildCf) Start()

type BuildCfe

type BuildCfe struct {
	BaseTask
	EventBuildCfe

	ChoseExtName []string
	//HideAllButtun bool
	Ext          *cf.ConfCommonData
	ChosedBranch string
	// contains filtered or unexported fields
}

func (*BuildCfe) ChoseAll

func (B *BuildCfe) ChoseAll()

func (*BuildCfe) ChoseBranch

func (B *BuildCfe) ChoseBranch(Branch string)

func (*BuildCfe) ChoseExt

func (B *BuildCfe) ChoseExt(choseData string)

func (*BuildCfe) InfoWrapper

func (B *BuildCfe) InfoWrapper(task ITask)

func (*BuildCfe) Initialise

func (B *BuildCfe) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*BuildCfe) Invoke

func (B *BuildCfe) Invoke()

func (*BuildCfe) Start

func (B *BuildCfe) Start()

type Charts

type Charts struct {
	BaseTask
}

func (*Charts) InfoWrapper

func (B *Charts) InfoWrapper(task ITask)

func (*Charts) Initialise

func (this *Charts) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*Charts) Start

func (this *Charts) Start()

type DeployExtension

type DeployExtension struct {
	BuilAndUploadCfe
	EventDeployExtension
	// contains filtered or unexported fields
}

func (*DeployExtension) CommitAndPush

func (this *DeployExtension) CommitAndPush(filePath, branchName string) (err error)

GIT

func (*DeployExtension) GetBaseSM

func (this *DeployExtension) GetBaseSM() (result *Bases, err error)

func (*DeployExtension) InfoWrapper

func (B *DeployExtension) InfoWrapper(task ITask)

func (*DeployExtension) Initialise

func (this *DeployExtension) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*DeployExtension) InvokeJobJenkins

func (this *DeployExtension) InvokeJobJenkins(status *string, exclusive bool) (err error)

Jenkins

func (*DeployExtension) Start

func (this *DeployExtension) Start()

type DisableZabbixMonitoring

type DisableZabbixMonitoring struct {
	BaseTask
	// contains filtered or unexported fields
}

func (*DisableZabbixMonitoring) InfoWrapper

func (this *DisableZabbixMonitoring) InfoWrapper(task ITask)

func (*DisableZabbixMonitoring) Initialise

func (this *DisableZabbixMonitoring) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*DisableZabbixMonitoring) Start

func (this *DisableZabbixMonitoring) Start()

type EventBuilAndUploadCfe

type EventBuilAndUploadCfe struct {
	BeforeUploadFresh   []func(cf.IConfiguration)
	AfterUploadFresh    []func(cf.IConfiguration, string)
	AfterAllUploadFresh []func()
}

type EventBuildCf

type EventBuildCf struct {
	BeforeBuild []func()
	AfterBuild  []func()
}

type EventBuildCfe

type EventBuildCfe struct {
	// События которые вызываются после сборки одного расширения
	BeforeBuild []func(cf.IConfiguration)
	// События которые вызываются до сборки расширений
	AfterBuild []func(ext cf.IConfiguration)
	// События которые вызываются после сборки всех расширений
	AfterAllBuild []func() // Событие которое вызывается при сборе всех расширений
}

type EventDeployExtension

type EventDeployExtension struct {
}

type EventWorkRep

type EventWorkRep struct {
	BeforeBuild []func()
	AfterBuild  []func()
}

type GetListUpdateState

type GetListUpdateState struct {
	BaseTask
	// contains filtered or unexported fields
}

func (*GetListUpdateState) Cancel

func (B *GetListUpdateState) Cancel(key string)

func (*GetListUpdateState) ChoseAgent

func (B *GetListUpdateState) ChoseAgent(ChoseData string)

func (*GetListUpdateState) DecDate

func (B *GetListUpdateState) DecDate()

func (*GetListUpdateState) IncDate

func (B *GetListUpdateState) IncDate()

func (*GetListUpdateState) InfoWrapper

func (B *GetListUpdateState) InfoWrapper(task ITask)

func (*GetListUpdateState) Initialise

func (B *GetListUpdateState) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*GetListUpdateState) MonitoringState

func (B *GetListUpdateState) MonitoringState(UUIDs []string, key string)

func (*GetListUpdateState) Start

func (B *GetListUpdateState) Start()

type Group

type Group struct {
	BaseTask
}

func (*Group) Initialise

func (this *Group) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*Group) Start

func (this *Group) Start()

type IChart

type IChart interface {
	Build() ([]string, error)
}

type IStep

type IStep interface {
	String() string

	GetMessageID() int
	GetName() string
	// contains filtered or unexported methods
}

type ITask

type ITask interface {
	Initialise(*tgbotapi.BotAPI, *tgbotapi.Update, func()) ITask
	Start()
	InfoWrapper(ITask)
	GetCallBack() map[string]func()
	GetHook() func(*tgbotapi.Update) bool
	RestHook()
	GetName() string
	GetState() int
	SetState(int)
	GetChatID() int64
	GetUUID() *uuid.UUID
	SetUUID(*uuid.UUID)
	SetName(string)

	GetDescription() string
	GetMessage() *tgbotapi.Message
	IsExclusively() bool
	Lock(func())
	Unlock()
	CurrentStep() IStep

	// Метод который запускается один раз при старте бота. Запус происходит в горутине
	Daemon()
	// contains filtered or unexported methods
}

type IvokeUpdate

type IvokeUpdate struct {
	SetPlanUpdate
}

func (*IvokeUpdate) InfoWrapper

func (B *IvokeUpdate) InfoWrapper(task ITask)

func (*IvokeUpdate) Initialise

func (this *IvokeUpdate) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*IvokeUpdate) Start

func (this *IvokeUpdate) Start()

type IvokeUpdateActualCFE

type IvokeUpdateActualCFE struct {
	SetPlanUpdate   // из-за BuildButtonsByBase
	DeployExtension // из-за InvokeJobJenkins
	// contains filtered or unexported fields
}

func (*IvokeUpdateActualCFE) ChoseExt

func (this *IvokeUpdateActualCFE) ChoseExt(extentions []*conf.Extension, Base []*Bases)

func (*IvokeUpdateActualCFE) ChoseMC

func (this *IvokeUpdateActualCFE) ChoseMC(ChoseData string)

func (*IvokeUpdateActualCFE) InfoWrapper

func (B *IvokeUpdateActualCFE) InfoWrapper(task ITask)

func (*IvokeUpdateActualCFE) Initialise

func (this *IvokeUpdateActualCFE) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*IvokeUpdateActualCFE) Start

func (this *IvokeUpdateActualCFE) Start()

type MonitoringData

type MonitoringData struct {
	Base  []map[string]string `json:"data"`
	Count int                 `json:"Count"`
	List  []int               `json:"List"`
}

type QueueMessageData

type QueueMessageData struct {
	Count     int                 `json:"count"`
	Data      []*QueueMessageData `json:"data"`
	Direction string              `json:"direction"`
	Base      string              `json:"base"`
}

type Repository

type Repository struct {
	BinPath string
}

type RepositoryInfo

type RepositoryInfo struct {
	Version int
	Author  string
	Date    time.Time
	Comment string
}

type RequestDTO

type RequestDTO struct {
	UserLogin    string
	Password     string
	Ticket       *Ticket
	Article      *Article
	DynamicField []struct {
		Name  string
		Value string
	}
}

type SUI

type SUI struct {
	BaseTask
	GetListUpdateState
	// contains filtered or unexported fields
}

func (*SUI) Daemon

func (this *SUI) Daemon()

func (*SUI) InfoWrapper

func (this *SUI) InfoWrapper(task ITask)

func (*SUI) Initialise

func (this *SUI) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*SUI) Start

func (this *SUI) Start()

type SendMsg

type SendMsg struct {
	BaseTask
	// contains filtered or unexported fields
}

func (*SendMsg) InfoWrapper

func (B *SendMsg) InfoWrapper(task ITask)

func (*SendMsg) Initialise

func (this *SendMsg) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*SendMsg) Start

func (this *SendMsg) Start()

type SetPlanUpdate

type SetPlanUpdate struct {
	BaseTask

	MinuteShift   int
	InvokeChoseDB func(BD *Bases)
	MessagesID    []int
	// contains filtered or unexported fields
}

func (*SetPlanUpdate) AllUpdates

func (B *SetPlanUpdate) AllUpdates(UUIDBase string)

func (*SetPlanUpdate) BuildButtonsByBase

func (this *SetPlanUpdate) BuildButtonsByBase(JSON_Base string, step IStep, ChoseBD func(Bases *Bases), all bool) (result string)

func (*SetPlanUpdate) ChoseBD

func (B *SetPlanUpdate) ChoseBD(BD *Bases)

func (*SetPlanUpdate) ChoseMC

func (this *SetPlanUpdate) ChoseMC(ChoseData string)

func (*SetPlanUpdate) ChoseManyDB

func (B *SetPlanUpdate) ChoseManyDB(Bases []*Bases)

func (*SetPlanUpdate) ChoseUpdate

func (B *SetPlanUpdate) ChoseUpdate(ChoseData, name, UUIDBase string)

func (*SetPlanUpdate) ForceUpdate

func (B *SetPlanUpdate) ForceUpdate(UUIDUpdate, name, UUIDBase string)

func (*SetPlanUpdate) InfoWrapper

func (B *SetPlanUpdate) InfoWrapper(task ITask)

func (*SetPlanUpdate) Initialise

func (this *SetPlanUpdate) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*SetPlanUpdate) Start

func (B *SetPlanUpdate) Start()

type TaskFactory

type TaskFactory struct {
}

func (*TaskFactory) BuilAndUploadCf

func (this *TaskFactory) BuilAndUploadCf() ITask

func (*TaskFactory) BuilAndUploadCfe

func (this *TaskFactory) BuilAndUploadCfe() ITask

func (*TaskFactory) BuildCf

func (this *TaskFactory) BuildCf() ITask

func (*TaskFactory) BuildCfe

func (this *TaskFactory) BuildCfe() ITask

func (*TaskFactory) Charts

func (this *TaskFactory) Charts() ITask

func (*TaskFactory) DeployExtension

func (this *TaskFactory) DeployExtension(mu *sync.Mutex) ITask

func (*TaskFactory) DisableZabbixMonitoring

func (this *TaskFactory) DisableZabbixMonitoring() ITask

func (*TaskFactory) GetListUpdateState

func (this *TaskFactory) GetListUpdateState() ITask

func (*TaskFactory) GetRepositoryReport

func (this *TaskFactory) GetRepositoryReport() ITask

func (*TaskFactory) Group

func (this *TaskFactory) Group() ITask

func (*TaskFactory) InvokeUpdateActualCFE

func (this *TaskFactory) InvokeUpdateActualCFE() ITask

func (*TaskFactory) IvokeUpdate

func (this *TaskFactory) IvokeUpdate() ITask

func (*TaskFactory) SUI

func (this *TaskFactory) SUI() ITask

func (*TaskFactory) SendMsg

func (this *TaskFactory) SendMsg() ITask

func (*TaskFactory) SetPlanUpdate

func (this *TaskFactory) SetPlanUpdate() ITask

type Tasks

type Tasks struct {
	SessManager *settings.SessionManager
	// contains filtered or unexported fields
}

func (*Tasks) Append

func (B *Tasks) Append(t ITask, UserID int) error

func (*Tasks) AppendTask

func (B *Tasks) AppendTask(task ITask, UserID int) ITask

func (*Tasks) CheckPass

func (B *Tasks) CheckPass(User *tgbotapi.User, pass string) bool

func (*Tasks) CheckSession

func (B *Tasks) CheckSession(User *tgbotapi.User, pass string) bool

функция возвращает первый bool когда текущая сессия активна

func (*Tasks) Delete

func (B *Tasks) Delete(UserID int)

func (*Tasks) ExecuteHook

func (B *Tasks) ExecuteHook(update *tgbotapi.Update) bool

func (*Tasks) GetPss

func (B *Tasks) GetPss() string

func (*Tasks) GetTasks

func (B *Tasks) GetTasks(UserID int) []ITask

func (*Tasks) Initialise

func (B *Tasks) Initialise() *Tasks

func (*Tasks) ReadSettings

func (B *Tasks) ReadSettings() (err error)

func (*Tasks) Reset

func (B *Tasks) Reset(fromID int, bot *tgbotapi.BotAPI, update *tgbotapi.Update, clear bool)

func (*Tasks) Reuse

func (B *Tasks) Reuse(command string, UserID int) ITask

func (*Tasks) SetPass

func (B *Tasks) SetPass(pass string) error

type Ticket

type Ticket struct {
	Title        string
	Type         string
	Queue        string
	State        string
	Priority     string
	Service      string
	SLA          string
	Owner        string
	Responsible  string
	CustomerUser string
}

type TicketInfo

type TicketInfo struct {
	ArticleID    string `json:"ArticleID"`
	TicketNumber string `json:"TicketNumber"`
	TicketID     string `json:"TicketID"`
	Error        *struct {
		ErrorCode    string `json:"ErrorCode"`
		ErrorMessage string `json:"ErrorMessage"`
	} `json:"Error"`
}

type UpdateData

type UpdateData struct {
	Task       string `json:"Task"`
	Error      bool   `json:"Error"`
	State      string `json:"State"`
	UUID       string `json:"UUID"`
	LastAction string `json:"LastAction"`
	End        bool   `json:"End"`
	Base       string `json:"Base"`
	ToVersion  string `json:"ToVersion"`
	Conf       string `json:"Conf"`
}

func (*UpdateData) Hash

func (d *UpdateData) Hash() string

type Updates

type Updates struct {
	Name        string `json:"Name"`
	FromVervion string `json:"FromVervion"`
	ToVervion   string `json:"ToVervion"`
	UUID        string `json:"UUID"`
	NameDB      string `json:"NameDB"`
}

type WorkRep

type WorkRep struct {
	BaseTask
	EventWorkRep

	//repName    string
	ChoseRep *cf.Repository
	// contains filtered or unexported fields
}

func (*WorkRep) GetCallBack

func (W *WorkRep) GetCallBack() map[string]func()

func (*WorkRep) GetRepositoryReport

func (W *WorkRep) GetRepositoryReport()

func (*WorkRep) InfoWrapper

func (W *WorkRep) InfoWrapper(task ITask)

func (*WorkRep) Initialise

func (W *WorkRep) Initialise(bot *tgbotapi.BotAPI, update *tgbotapi.Update, finish func()) ITask

func (*WorkRep) ProcessChose

func (W *WorkRep) ProcessChose(ChoseData string)

func (*WorkRep) Start

func (W *WorkRep) Start()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL