tg/command.go

186 lines
5.7 KiB
Go
Raw Normal View History

2018-04-03 09:51:06 +00:00
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"
// BError is an error the broker occurred while fulfilling a request
BError BrokerUpdateType = "error"
)
// BrokerUpdate is what is sent by the broker as update
type BrokerUpdate struct {
Type BrokerUpdateType
Callback *int `json:",omitempty"`
Error *string `json:",omitempty"`
Data *APIUpdate `json:",omitempty"`
Bytes *string `json:",omitempty"`
2018-04-03 09:51:06 +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"
// CmdForwardMessage requests the broker to forward a message between chats
CmdForwardMessage ClientCommandType = "forwardMessage"
// CmdGetFile requests the broker to get a file from Telegram
CmdGetFile ClientCommandType = "getFile"
// CmdSendChatAction requests the broker to set a chat action (typing, etc.)
CmdSendChatAction ClientCommandType = "sendChatAction"
// CmdAnswerInlineQuery requests the broker sends results of an inline query
CmdAnswerInlineQuery ClientCommandType = "answerInlineQuery"
2018-10-16 13:29:27 +00:00
// CmdSendAlbum requests the broker sends an album of photos or videos
CmdSendAlbum ClientCommandType = "sendAlbum"
2018-12-13 12:41:58 +00:00
// CmdAnswerCallback requests the broker to reply to a incoming callback query
CmdAnswerCallback ClientCommandType = "answerCallback"
2018-12-13 13:23:50 +00:00
// CmdEditCaption requests to broker to replace the caption of a media (photo, doc, etc) message
CmdEditCaption ClientCommandType = "editCaption"
2018-12-13 12:41:58 +00:00
// CmdEditMedia requests to broker to replace the media contents of a message
CmdEditMedia ClientCommandType = "editMedia"
2018-04-03 09:51:06 +00:00
)
// ClientTextMessageData is the required data for a CmdSendTextMessage request
type ClientTextMessageData struct {
ChatID int64
Text string
ReplyID *int64 `json:",omitempty"`
ReplyMarkup interface{} `json:",omitempty"`
2018-04-03 09:51:06 +00:00
}
// ClientPhotoData is the required data for a CmdSendPhoto request
type ClientPhotoData struct {
2022-03-27 20:22:20 +00:00
ChatID int64
Bytes []byte
Filename string
Caption string `json:",omitempty"`
ReplyID *int64 `json:",omitempty"`
}
// ClientPhotoDataNet is the required data for a CmdSendPhoto request over the wire
type ClientPhotoDataNet struct {
2018-04-03 09:51:06 +00:00
ChatID int64
Bytes string
Filename string
Caption string `json:",omitempty"`
ReplyID *int64 `json:",omitempty"`
}
// ClientForwardMessageData is the required data for a CmdForwardMessage request
type ClientForwardMessageData struct {
ChatID int64
FromChatID int64
MessageID int64
}
// ClientChatActionData is the required data for a CmdSendChatAction request
type ClientChatActionData struct {
ChatID int64
Action ChatAction
}
2018-12-13 10:51:11 +00:00
// ClientCallbackQueryData is the required data for a CmdAnswerCallback request
type ClientCallbackQueryData struct {
QueryID string
Text string
ShowAlert bool
URL string
CacheTime int64
}
2018-10-16 13:29:27 +00:00
// ClientAlbumData is the required data for a CmdSendAlbum request
type ClientAlbumData struct {
ChatID int64
Media interface{}
Silent bool
ReplyID *int64 `json:",omitempty"`
}
// ClientEditTextData is the required data for a CmdEditText request
type ClientEditTextData struct {
ChatID int64
MessageID int64
InlineID string
Text string
ReplyMarkup interface{} `json:",omitempty"`
}
2018-12-13 13:23:50 +00:00
// ClientEditCaptionData is the required data for a CmdEditCaption request
type ClientEditCaptionData struct {
ChatID int64
MessageID int64
InlineID string
Caption string
ReplyMarkup interface{} `json:",omitempty"`
}
2018-12-13 12:41:58 +00:00
// ClientEditMediaData is the required data for a CmdEditMedia request
type ClientEditMediaData struct {
ChatID int64
MessageID int64
InlineID string
2018-12-13 12:41:58 +00:00
Media interface{}
ReplyMarkup interface{} `json:",omitempty"`
}
2018-04-03 09:51:06 +00:00
// ChatAction is the action name for CmdSendChatAction requests
type ChatAction string
// Telegram chat actions
2018-04-03 09:51:06 +00:00
const (
ActionTyping ChatAction = "typing"
ActionUploadingPhoto ChatAction = "upload_photo"
ActionRecordingVideo ChatAction = "record_video"
ActionUploadingVideo ChatAction = "upload_video"
ActionRecordingAudio ChatAction = "record_audio"
ActionUploadingAudio ChatAction = "upload_audio"
ActionUploadingDocument ChatAction = "upload_document"
ActionFindingLocation ChatAction = "find_location"
)
// FileRequestData is the required data for a CmdGetFile request
type FileRequestData struct {
FileID string
}
// ClientCommand is a request sent by clients to the broker
type ClientCommand struct {
Type ClientCommandType
TextMessageData *ClientTextMessageData `json:",omitempty"`
2022-03-27 20:22:20 +00:00
PhotoData *ClientPhotoDataNet `json:",omitempty"`
2018-04-03 09:51:06 +00:00
ForwardMessageData *ClientForwardMessageData `json:",omitempty"`
ChatActionData *ClientChatActionData `json:",omitempty"`
InlineQueryResults *InlineQueryResponse `json:",omitempty"`
2018-04-03 09:51:06 +00:00
FileRequestData *FileRequestData `json:",omitempty"`
Callback *int `json:",omitempty"`
}
// InlineQueryResponse is the response to an inline query
type InlineQueryResponse struct {
QueryID string
2018-09-17 10:33:47 +00:00
Results interface{}
CacheTime *int `json:",omitempty"`
IsPersonal bool `json:",omitempty"`
NextOffset string `json:",omitempty"`
PMText string `json:",omitempty"`
PMParam string `json:",omitempty"`
}