This repository has been archived on 2023-07-05. You can view files and clone it, but cannot push or open issues or pull requests.
clessy/tg/command.go

63 lines
1.6 KiB
Go

package tg
// BrokerUpdateType distinguishes update types coming from the broker
type BrokerUpdateType string
const (
// BMessage is a message update (mostly webhook updates)
BMessage BrokerUpdateType = "message"
// BFile is a file retrieval response update
BFile BrokerUpdateType = "file"
)
// BrokerUpdate is what is sent by the broker as update
type BrokerUpdate struct {
Type BrokerUpdateType
Callback *int
Message *APIMessage
Bytes *string
}
// ClientCommandType distinguishes requests sent by clients to the broker
type ClientCommandType string
const (
// CmdSendTextMessage requests the broker to send a text message to a chat
CmdSendTextMessage ClientCommandType = "sendText"
// CmdSendPhoto requests the broker to send a photo to a chat
CmdSendPhoto ClientCommandType = "sendPhoto"
// CmdGetFile requests the broker to get a file from Telegram
CmdGetFile ClientCommandType = "getFile"
)
// ClientTextMessageData is the required data for a CmdSendTextMessage request
type ClientTextMessageData struct {
ChatID int
Text string
ReplyID *int
}
// ClientPhotoData is the required data for a CmdSendPhoto request
type ClientPhotoData struct {
ChatID int
Bytes string
Caption *string
ReplyID *int
}
// FileRequestData is the required data for a CmdGetFile request
type FileRequestData struct {
FileID int
}
// ClientCommand is a request sent by clients to the broker
type ClientCommand struct {
Type ClientCommandType
TextMessageData *ClientTextMessageData
PhotoData *ClientPhotoData
FileRequestData *FileRequestData
Callback *int
}