2016-02-08 13:47:10 +00:00
|
|
|
package tg
|
|
|
|
|
2016-02-19 11:20:13 +00:00
|
|
|
// BrokerUpdateType distinguishes update types coming from the broker
|
|
|
|
type BrokerUpdateType string
|
2016-02-08 16:52:13 +00:00
|
|
|
|
|
|
|
const (
|
2016-02-19 11:20:13 +00:00
|
|
|
// BMessage is a message update (mostly webhook updates)
|
|
|
|
BMessage BrokerUpdateType = "message"
|
|
|
|
|
|
|
|
// BFile is a file retrieval response update
|
|
|
|
BFile BrokerUpdateType = "file"
|
2016-02-20 20:40:24 +00:00
|
|
|
|
|
|
|
// BError is an error the broker occurred while fulfilling a request
|
|
|
|
BError BrokerUpdateType = "error"
|
2016-02-08 16:52:13 +00:00
|
|
|
)
|
|
|
|
|
2016-02-19 11:20:13 +00:00
|
|
|
// BrokerUpdate is what is sent by the broker as update
|
|
|
|
type BrokerUpdate struct {
|
|
|
|
Type BrokerUpdateType
|
2016-02-20 20:40:24 +00:00
|
|
|
Callback *int `json:",omitempty"`
|
|
|
|
Error *string `json:",omitempty"`
|
|
|
|
Message *APIMessage `json:",omitempty"`
|
|
|
|
Bytes *string `json:",omitempty"`
|
2016-02-19 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
2017-05-04 15:11:41 +00:00
|
|
|
// CmdForwardMessage requests the broker to forward a message between chats
|
|
|
|
CmdForwardMessage ClientCommandType = "forwardMessage"
|
|
|
|
|
2016-02-19 11:20:13 +00:00
|
|
|
// CmdGetFile requests the broker to get a file from Telegram
|
|
|
|
CmdGetFile ClientCommandType = "getFile"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ClientTextMessageData is the required data for a CmdSendTextMessage request
|
2016-02-09 10:01:05 +00:00
|
|
|
type ClientTextMessageData struct {
|
2016-09-01 12:05:32 +00:00
|
|
|
ChatID int64
|
2016-02-09 10:33:38 +00:00
|
|
|
Text string
|
2016-09-01 12:05:32 +00:00
|
|
|
ReplyID *int64 `json:",omitempty"`
|
2016-02-08 16:52:13 +00:00
|
|
|
}
|
|
|
|
|
2016-02-19 16:54:25 +00:00
|
|
|
// ClientPhotoData is the required data for a CmdSendPhoto request
|
|
|
|
type ClientPhotoData struct {
|
2016-09-01 12:05:32 +00:00
|
|
|
ChatID int64
|
2016-02-20 21:49:50 +00:00
|
|
|
Bytes string
|
|
|
|
Filename string
|
2016-09-01 12:05:32 +00:00
|
|
|
Caption string `json:",omitempty"`
|
|
|
|
ReplyID *int64 `json:",omitempty"`
|
2016-02-19 16:54:25 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 15:11:41 +00:00
|
|
|
// ClientForwardMessageData is the required data for a CmdForwardMessage request
|
|
|
|
type ClientForwardMessageData struct {
|
|
|
|
ChatID int64
|
|
|
|
FromChatID int64
|
|
|
|
MessageID int64
|
|
|
|
}
|
|
|
|
|
2016-02-19 11:20:13 +00:00
|
|
|
// FileRequestData is the required data for a CmdGetFile request
|
|
|
|
type FileRequestData struct {
|
2016-02-20 20:40:24 +00:00
|
|
|
FileID string
|
2016-02-19 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ClientCommand is a request sent by clients to the broker
|
2016-02-08 13:47:10 +00:00
|
|
|
type ClientCommand struct {
|
2017-05-04 15:11:41 +00:00
|
|
|
Type ClientCommandType
|
|
|
|
TextMessageData *ClientTextMessageData `json:",omitempty"`
|
|
|
|
PhotoData *ClientPhotoData `json:",omitempty"`
|
|
|
|
ForwardMessageData *ClientForwardMessageData `json:",omitempty"`
|
|
|
|
FileRequestData *FileRequestData `json:",omitempty"`
|
|
|
|
Callback *int `json:",omitempty"`
|
2016-02-08 13:47:10 +00:00
|
|
|
}
|