Merge pull request #12 from OvyFlash/bot-api-7.0
Start implementing 7.0 Bot API changespull/13/head
commit
9cb877e695
30
bot_test.go
30
bot_test.go
|
@ -84,7 +84,7 @@ func TestSendWithMessageReply(t *testing.T) {
|
||||||
bot, _ := getBot(t)
|
bot, _ := getBot(t)
|
||||||
|
|
||||||
msg := NewMessage(ChatID, "A test message from the test library in telegram-bot-api")
|
msg := NewMessage(ChatID, "A test message from the test library in telegram-bot-api")
|
||||||
msg.ReplyToMessageID = ReplyToMessageID
|
msg.ReplyParameters.MessageID = ReplyToMessageID
|
||||||
_, err := bot.Send(msg)
|
_, err := bot.Send(msg)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -169,7 +169,7 @@ func TestSendWithNewPhotoReply(t *testing.T) {
|
||||||
bot, _ := getBot(t)
|
bot, _ := getBot(t)
|
||||||
|
|
||||||
msg := NewPhoto(ChatID, FilePath("tests/image.jpg"))
|
msg := NewPhoto(ChatID, FilePath("tests/image.jpg"))
|
||||||
msg.ReplyToMessageID = ReplyToMessageID
|
msg.ReplyParameters.MessageID = ReplyToMessageID
|
||||||
|
|
||||||
_, err := bot.Send(msg)
|
_, err := bot.Send(msg)
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ func ExampleNewBotAPI() {
|
||||||
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
|
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
|
||||||
|
|
||||||
msg := NewMessage(update.Message.Chat.ID, update.Message.Text)
|
msg := NewMessage(update.Message.Chat.ID, update.Message.Text)
|
||||||
msg.ReplyToMessageID = update.Message.MessageID
|
msg.ReplyParameters.MessageID = update.Message.MessageID
|
||||||
|
|
||||||
bot.Send(msg)
|
bot.Send(msg)
|
||||||
}
|
}
|
||||||
|
@ -827,8 +827,12 @@ func TestDeleteMessage(t *testing.T) {
|
||||||
message, _ := bot.Send(msg)
|
message, _ := bot.Send(msg)
|
||||||
|
|
||||||
deleteMessageConfig := DeleteMessageConfig{
|
deleteMessageConfig := DeleteMessageConfig{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: message.Chat.ID,
|
ChatID: message.Chat.ID,
|
||||||
|
},
|
||||||
MessageID: message.MessageID,
|
MessageID: message.MessageID,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
_, err := bot.Request(deleteMessageConfig)
|
_, err := bot.Request(deleteMessageConfig)
|
||||||
|
|
||||||
|
@ -845,8 +849,12 @@ func TestPinChatMessage(t *testing.T) {
|
||||||
message, _ := bot.Send(msg)
|
message, _ := bot.Send(msg)
|
||||||
|
|
||||||
pinChatMessageConfig := PinChatMessageConfig{
|
pinChatMessageConfig := PinChatMessageConfig{
|
||||||
ChatID: message.Chat.ID,
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
|
ChatID: ChatID,
|
||||||
|
},
|
||||||
MessageID: message.MessageID,
|
MessageID: message.MessageID,
|
||||||
|
},
|
||||||
DisableNotification: false,
|
DisableNotification: false,
|
||||||
}
|
}
|
||||||
_, err := bot.Request(pinChatMessageConfig)
|
_, err := bot.Request(pinChatMessageConfig)
|
||||||
|
@ -865,8 +873,12 @@ func TestUnpinChatMessage(t *testing.T) {
|
||||||
|
|
||||||
// We need pin message to unpin something
|
// We need pin message to unpin something
|
||||||
pinChatMessageConfig := PinChatMessageConfig{
|
pinChatMessageConfig := PinChatMessageConfig{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: message.Chat.ID,
|
ChatID: message.Chat.ID,
|
||||||
|
},
|
||||||
MessageID: message.MessageID,
|
MessageID: message.MessageID,
|
||||||
|
},
|
||||||
DisableNotification: false,
|
DisableNotification: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,8 +887,12 @@ func TestUnpinChatMessage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unpinChatMessageConfig := UnpinChatMessageConfig{
|
unpinChatMessageConfig := UnpinChatMessageConfig{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: message.Chat.ID,
|
ChatID: message.Chat.ID,
|
||||||
|
},
|
||||||
MessageID: message.MessageID,
|
MessageID: message.MessageID,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := bot.Request(unpinChatMessageConfig); err != nil {
|
if _, err := bot.Request(unpinChatMessageConfig); err != nil {
|
||||||
|
@ -892,8 +908,12 @@ func TestUnpinAllChatMessages(t *testing.T) {
|
||||||
message, _ := bot.Send(msg)
|
message, _ := bot.Send(msg)
|
||||||
|
|
||||||
pinChatMessageConfig := PinChatMessageConfig{
|
pinChatMessageConfig := PinChatMessageConfig{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: message.Chat.ID,
|
ChatID: message.Chat.ID,
|
||||||
|
},
|
||||||
MessageID: message.MessageID,
|
MessageID: message.MessageID,
|
||||||
|
},
|
||||||
DisableNotification: true,
|
DisableNotification: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,7 +922,7 @@ func TestUnpinAllChatMessages(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unpinAllChatMessagesConfig := UnpinAllChatMessagesConfig{
|
unpinAllChatMessagesConfig := UnpinAllChatMessagesConfig{
|
||||||
ChatID: message.Chat.ID,
|
ChatConfig: ChatConfig{ChatID: message.Chat.ID},
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := bot.Request(unpinAllChatMessagesConfig); err != nil {
|
if _, err := bot.Request(unpinAllChatMessagesConfig); err != nil {
|
||||||
|
|
644
configs.go
644
configs.go
File diff suppressed because it is too large
Load Diff
|
@ -17,19 +17,26 @@ import (
|
||||||
func NewMessage(chatID int64, text string) MessageConfig {
|
func NewMessage(chatID int64, text string) MessageConfig {
|
||||||
return MessageConfig{
|
return MessageConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
ReplyToMessageID: 0,
|
},
|
||||||
},
|
},
|
||||||
Text: text,
|
Text: text,
|
||||||
DisableWebPagePreview: false,
|
LinkPreviewOptions: LinkPreviewOptions{
|
||||||
|
IsDisabled: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDeleteMessage creates a request to delete a message.
|
// NewDeleteMessage creates a request to delete a message.
|
||||||
func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig {
|
func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig {
|
||||||
return DeleteMessageConfig{
|
return DeleteMessageConfig{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +48,9 @@ func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig {
|
||||||
func NewMessageToChannel(username string, text string) MessageConfig {
|
func NewMessageToChannel(username string, text string) MessageConfig {
|
||||||
return MessageConfig{
|
return MessageConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChannelUsername: username,
|
ChannelUsername: username,
|
||||||
},
|
}},
|
||||||
Text: text,
|
Text: text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +61,8 @@ func NewMessageToChannel(username string, text string) MessageConfig {
|
||||||
// and messageID is the ID of the original message.
|
// and messageID is the ID of the original message.
|
||||||
func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
|
func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
|
||||||
return ForwardConfig{
|
return ForwardConfig{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
FromChatID: fromChatID,
|
FromChat: ChatConfig{ChatID: fromChatID},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +73,8 @@ func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
|
||||||
// and messageID is the ID of the original message.
|
// and messageID is the ID of the original message.
|
||||||
func NewCopyMessage(chatID int64, fromChatID int64, messageID int) CopyMessageConfig {
|
func NewCopyMessage(chatID int64, fromChatID int64, messageID int) CopyMessageConfig {
|
||||||
return CopyMessageConfig{
|
return CopyMessageConfig{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
FromChatID: fromChatID,
|
FromChat: ChatConfig{ChatID: fromChatID},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +88,7 @@ func NewCopyMessage(chatID int64, fromChatID int64, messageID int) CopyMessageCo
|
||||||
func NewPhoto(chatID int64, file RequestFileData) PhotoConfig {
|
func NewPhoto(chatID int64, file RequestFileData) PhotoConfig {
|
||||||
return PhotoConfig{
|
return PhotoConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -92,9 +100,7 @@ func NewPhoto(chatID int64, file RequestFileData) PhotoConfig {
|
||||||
func NewPhotoToChannel(username string, file RequestFileData) PhotoConfig {
|
func NewPhotoToChannel(username string, file RequestFileData) PhotoConfig {
|
||||||
return PhotoConfig{
|
return PhotoConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChannelUsername: username}},
|
||||||
ChannelUsername: username,
|
|
||||||
},
|
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -104,7 +110,7 @@ func NewPhotoToChannel(username string, file RequestFileData) PhotoConfig {
|
||||||
func NewAudio(chatID int64, file RequestFileData) AudioConfig {
|
func NewAudio(chatID int64, file RequestFileData) AudioConfig {
|
||||||
return AudioConfig{
|
return AudioConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -114,7 +120,7 @@ func NewAudio(chatID int64, file RequestFileData) AudioConfig {
|
||||||
func NewDocument(chatID int64, file RequestFileData) DocumentConfig {
|
func NewDocument(chatID int64, file RequestFileData) DocumentConfig {
|
||||||
return DocumentConfig{
|
return DocumentConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -124,7 +130,7 @@ func NewDocument(chatID int64, file RequestFileData) DocumentConfig {
|
||||||
func NewSticker(chatID int64, file RequestFileData) StickerConfig {
|
func NewSticker(chatID int64, file RequestFileData) StickerConfig {
|
||||||
return StickerConfig{
|
return StickerConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -157,7 +163,7 @@ func NewDeleteStickerSet(name, title string) DeleteStickerSetConfig {
|
||||||
func NewVideo(chatID int64, file RequestFileData) VideoConfig {
|
func NewVideo(chatID int64, file RequestFileData) VideoConfig {
|
||||||
return VideoConfig{
|
return VideoConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -167,7 +173,7 @@ func NewVideo(chatID int64, file RequestFileData) VideoConfig {
|
||||||
func NewAnimation(chatID int64, file RequestFileData) AnimationConfig {
|
func NewAnimation(chatID int64, file RequestFileData) AnimationConfig {
|
||||||
return AnimationConfig{
|
return AnimationConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -180,7 +186,7 @@ func NewAnimation(chatID int64, file RequestFileData) AnimationConfig {
|
||||||
func NewVideoNote(chatID int64, length int, file RequestFileData) VideoNoteConfig {
|
func NewVideoNote(chatID int64, length int, file RequestFileData) VideoNoteConfig {
|
||||||
return VideoNoteConfig{
|
return VideoNoteConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
Length: length,
|
Length: length,
|
||||||
|
@ -191,7 +197,7 @@ func NewVideoNote(chatID int64, length int, file RequestFileData) VideoNoteConfi
|
||||||
func NewVoice(chatID int64, file RequestFileData) VoiceConfig {
|
func NewVoice(chatID int64, file RequestFileData) VoiceConfig {
|
||||||
return VoiceConfig{
|
return VoiceConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
File: file,
|
File: file,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -202,7 +208,7 @@ func NewVoice(chatID int64, file RequestFileData) VoiceConfig {
|
||||||
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig {
|
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig {
|
||||||
return MediaGroupConfig{
|
return MediaGroupConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
Media: files,
|
Media: files,
|
||||||
}
|
}
|
||||||
|
@ -262,7 +268,7 @@ func NewInputMediaDocument(media RequestFileData) InputMediaDocument {
|
||||||
func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig {
|
func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig {
|
||||||
return ContactConfig{
|
return ContactConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
PhoneNumber: phoneNumber,
|
PhoneNumber: phoneNumber,
|
||||||
FirstName: firstName,
|
FirstName: firstName,
|
||||||
|
@ -275,7 +281,7 @@ func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig {
|
||||||
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
|
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
|
||||||
return LocationConfig{
|
return LocationConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
Latitude: latitude,
|
Latitude: latitude,
|
||||||
Longitude: longitude,
|
Longitude: longitude,
|
||||||
|
@ -286,7 +292,7 @@ func NewLocation(chatID int64, latitude float64, longitude float64) LocationConf
|
||||||
func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig {
|
func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig {
|
||||||
return VenueConfig{
|
return VenueConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
Title: title,
|
Title: title,
|
||||||
Address: address,
|
Address: address,
|
||||||
|
@ -301,7 +307,7 @@ func NewVenue(chatID int64, title, address string, latitude, longitude float64)
|
||||||
// chatID is where to send it, action should be set via Chat constants.
|
// chatID is where to send it, action should be set via Chat constants.
|
||||||
func NewChatAction(chatID int64, action string) ChatActionConfig {
|
func NewChatAction(chatID int64, action string) ChatActionConfig {
|
||||||
return ChatActionConfig{
|
return ChatActionConfig{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{ChatConfig: ChatConfig{ChatID: chatID}},
|
||||||
Action: action,
|
Action: action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,9 +598,13 @@ func NewInlineQueryResultVenue(id, title, address string, latitude, longitude fl
|
||||||
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
|
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
|
||||||
return EditMessageTextConfig{
|
return EditMessageTextConfig{
|
||||||
BaseEdit: BaseEdit{
|
BaseEdit: BaseEdit{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
Text: text,
|
Text: text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -603,8 +613,12 @@ func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTex
|
||||||
func NewEditMessageTextAndMarkup(chatID int64, messageID int, text string, replyMarkup InlineKeyboardMarkup) EditMessageTextConfig {
|
func NewEditMessageTextAndMarkup(chatID int64, messageID int, text string, replyMarkup InlineKeyboardMarkup) EditMessageTextConfig {
|
||||||
return EditMessageTextConfig{
|
return EditMessageTextConfig{
|
||||||
BaseEdit: BaseEdit{
|
BaseEdit: BaseEdit{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
|
},
|
||||||
ReplyMarkup: &replyMarkup,
|
ReplyMarkup: &replyMarkup,
|
||||||
},
|
},
|
||||||
Text: text,
|
Text: text,
|
||||||
|
@ -615,9 +629,13 @@ func NewEditMessageTextAndMarkup(chatID int64, messageID int, text string, reply
|
||||||
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
|
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
|
||||||
return EditMessageCaptionConfig{
|
return EditMessageCaptionConfig{
|
||||||
BaseEdit: BaseEdit{
|
BaseEdit: BaseEdit{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
Caption: caption,
|
Caption: caption,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -627,8 +645,12 @@ func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMess
|
||||||
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
|
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
|
||||||
return EditMessageReplyMarkupConfig{
|
return EditMessageReplyMarkupConfig{
|
||||||
BaseEdit: BaseEdit{
|
BaseEdit: BaseEdit{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
|
},
|
||||||
ReplyMarkup: &replyMarkup,
|
ReplyMarkup: &replyMarkup,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -801,7 +823,9 @@ func NewCallbackWithAlert(id, text string) CallbackConfig {
|
||||||
// NewInvoice creates a new Invoice request to the user.
|
// NewInvoice creates a new Invoice request to the user.
|
||||||
func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices []LabeledPrice) InvoiceConfig {
|
func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices []LabeledPrice) InvoiceConfig {
|
||||||
return InvoiceConfig{
|
return InvoiceConfig{
|
||||||
BaseChat: BaseChat{ChatID: chatID},
|
BaseChat: BaseChat{
|
||||||
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
|
},
|
||||||
Title: title,
|
Title: title,
|
||||||
Description: description,
|
Description: description,
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
|
@ -814,7 +838,9 @@ func NewInvoice(chatID int64, title, description, payload, providerToken, startP
|
||||||
// NewChatTitle allows you to update the title of a chat.
|
// NewChatTitle allows you to update the title of a chat.
|
||||||
func NewChatTitle(chatID int64, title string) SetChatTitleConfig {
|
func NewChatTitle(chatID int64, title string) SetChatTitleConfig {
|
||||||
return SetChatTitleConfig{
|
return SetChatTitleConfig{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
Title: title,
|
Title: title,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -822,7 +848,9 @@ func NewChatTitle(chatID int64, title string) SetChatTitleConfig {
|
||||||
// NewChatDescription allows you to update the description of a chat.
|
// NewChatDescription allows you to update the description of a chat.
|
||||||
func NewChatDescription(chatID int64, description string) SetChatDescriptionConfig {
|
func NewChatDescription(chatID int64, description string) SetChatDescriptionConfig {
|
||||||
return SetChatDescriptionConfig{
|
return SetChatDescriptionConfig{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
Description: description,
|
Description: description,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -832,7 +860,7 @@ func NewChatPhoto(chatID int64, photo RequestFileData) SetChatPhotoConfig {
|
||||||
return SetChatPhotoConfig{
|
return SetChatPhotoConfig{
|
||||||
BaseFile: BaseFile{
|
BaseFile: BaseFile{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
File: photo,
|
File: photo,
|
||||||
},
|
},
|
||||||
|
@ -842,7 +870,9 @@ func NewChatPhoto(chatID int64, photo RequestFileData) SetChatPhotoConfig {
|
||||||
// NewDeleteChatPhoto allows you to delete the photo for a chat.
|
// NewDeleteChatPhoto allows you to delete the photo for a chat.
|
||||||
func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig {
|
func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig {
|
||||||
return DeleteChatPhotoConfig{
|
return DeleteChatPhotoConfig{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -850,7 +880,7 @@ func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig {
|
||||||
func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
|
func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
|
||||||
return SendPollConfig{
|
return SendPollConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
Question: question,
|
Question: question,
|
||||||
Options: options,
|
Options: options,
|
||||||
|
@ -862,9 +892,13 @@ func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
|
||||||
func NewStopPoll(chatID int64, messageID int) StopPollConfig {
|
func NewStopPoll(chatID int64, messageID int) StopPollConfig {
|
||||||
return StopPollConfig{
|
return StopPollConfig{
|
||||||
BaseEdit{
|
BaseEdit{
|
||||||
|
BaseChatMessage: BaseChatMessage{
|
||||||
|
ChatConfig: ChatConfig{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
MessageID: messageID,
|
MessageID: messageID,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,7 +906,7 @@ func NewStopPoll(chatID int64, messageID int) StopPollConfig {
|
||||||
func NewDice(chatID int64) DiceConfig {
|
func NewDice(chatID int64) DiceConfig {
|
||||||
return DiceConfig{
|
return DiceConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -883,7 +917,7 @@ func NewDice(chatID int64) DiceConfig {
|
||||||
func NewDiceWithEmoji(chatID int64, emoji string) DiceConfig {
|
func NewDiceWithEmoji(chatID int64, emoji string) DiceConfig {
|
||||||
return DiceConfig{
|
return DiceConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
},
|
},
|
||||||
Emoji: emoji,
|
Emoji: emoji,
|
||||||
}
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package tgbotapi
|
||||||
|
|
||||||
|
// ChatConfig is a base type for all chat identifiers
|
||||||
|
type ChatConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
ChannelUsername string
|
||||||
|
SuperGroupUsername string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (base ChatConfig) params() (Params, error) {
|
||||||
|
return base.paramsWithKey("chat_id")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (base ChatConfig) paramsWithKey(key string) (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
return params, params.AddFirstValid(key, base.ChatID, base.ChannelUsername, base.SuperGroupUsername)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseChat is base type for all chat config types.
|
||||||
|
type BaseChat struct {
|
||||||
|
ChatConfig
|
||||||
|
MessageThreadID int
|
||||||
|
ProtectContent bool
|
||||||
|
ReplyMarkup interface{}
|
||||||
|
DisableNotification bool
|
||||||
|
ReplyParameters ReplyParameters
|
||||||
|
}
|
||||||
|
|
||||||
|
func (chat *BaseChat) params() (Params, error) {
|
||||||
|
params, err := chat.ChatConfig.params()
|
||||||
|
if err != nil {
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
|
||||||
|
params.AddNonZero("message_thread_id", chat.MessageThreadID)
|
||||||
|
params.AddBool("disable_notification", chat.DisableNotification)
|
||||||
|
params.AddBool("protect_content", chat.ProtectContent)
|
||||||
|
|
||||||
|
err = params.AddInterface("reply_markup", chat.ReplyMarkup)
|
||||||
|
if err != nil {
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
err = params.AddInterface("reply_parameters", chat.ReplyParameters)
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseFile is a base type for all file config types.
|
||||||
|
type BaseFile struct {
|
||||||
|
BaseChat
|
||||||
|
File RequestFileData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (file BaseFile) params() (Params, error) {
|
||||||
|
return file.BaseChat.params()
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseEdit is base type of all chat edits.
|
||||||
|
type BaseEdit struct {
|
||||||
|
BaseChatMessage
|
||||||
|
InlineMessageID string
|
||||||
|
ReplyMarkup *InlineKeyboardMarkup
|
||||||
|
}
|
||||||
|
|
||||||
|
func (edit BaseEdit) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
if edit.InlineMessageID != "" {
|
||||||
|
params["inline_message_id"] = edit.InlineMessageID
|
||||||
|
} else {
|
||||||
|
p1, err := edit.BaseChatMessage.params()
|
||||||
|
if err != nil {
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
params.Merge(p1)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := params.AddInterface("reply_markup", edit.ReplyMarkup)
|
||||||
|
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseSpoiler is base type of structures with spoilers.
|
||||||
|
type BaseSpoiler struct {
|
||||||
|
HasSpoiler bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (spoiler BaseSpoiler) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
if spoiler.HasSpoiler {
|
||||||
|
params.AddBool("has_spoiler", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseChatMessage is a base type for all messages in chats.
|
||||||
|
type BaseChatMessage struct {
|
||||||
|
ChatConfig
|
||||||
|
MessageID int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (base BaseChatMessage) params() (Params, error) {
|
||||||
|
params, err := base.ChatConfig.params()
|
||||||
|
if err != nil {
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
params.AddNonZero("message_id", base.MessageID)
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseChatMessages is a base type for all messages in chats.
|
||||||
|
type BaseChatMessages struct {
|
||||||
|
ChatConfig
|
||||||
|
MessageIDs []int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (base BaseChatMessages) params() (Params, error) {
|
||||||
|
params, err := base.ChatConfig.params()
|
||||||
|
if err != nil {
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
err = params.AddInterface("message_ids", base.MessageIDs)
|
||||||
|
|
||||||
|
return params, err
|
||||||
|
}
|
661
types.go
661
types.go
|
@ -61,6 +61,14 @@ type Update struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
|
EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
|
||||||
|
// MessageReaction is a reaction to a message was changed by a user.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
MessageReaction *MessageReactionUpdated `json:"message_reaction,omitempty"`
|
||||||
|
// MessageReactionCount reactions to a message with anonymous reactions were changed.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
MessageReactionCount *MessageReactionCountUpdated `json:"message_reaction_count,omitempty"`
|
||||||
// InlineQuery new incoming inline query
|
// InlineQuery new incoming inline query
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -151,15 +159,15 @@ func (u *Update) CallbackData() string {
|
||||||
func (u *Update) FromChat() *Chat {
|
func (u *Update) FromChat() *Chat {
|
||||||
switch {
|
switch {
|
||||||
case u.Message != nil:
|
case u.Message != nil:
|
||||||
return u.Message.Chat
|
return &u.Message.Chat
|
||||||
case u.EditedMessage != nil:
|
case u.EditedMessage != nil:
|
||||||
return u.EditedMessage.Chat
|
return &u.EditedMessage.Chat
|
||||||
case u.ChannelPost != nil:
|
case u.ChannelPost != nil:
|
||||||
return u.ChannelPost.Chat
|
return &u.ChannelPost.Chat
|
||||||
case u.EditedChannelPost != nil:
|
case u.EditedChannelPost != nil:
|
||||||
return u.EditedChannelPost.Chat
|
return &u.EditedChannelPost.Chat
|
||||||
case u.CallbackQuery != nil && u.CallbackQuery.Message != nil:
|
case u.CallbackQuery != nil && u.CallbackQuery.Message != nil:
|
||||||
return u.CallbackQuery.Message.Chat
|
return &u.CallbackQuery.Message.Chat
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -276,16 +284,44 @@ type Chat struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
ActiveUsernames []string `json:"active_usernames,omitempty"`
|
ActiveUsernames []string `json:"active_usernames,omitempty"`
|
||||||
// Custom emoji identifier of emoji status of the other party
|
// AvailableReactions is a list of available reactions allowed in the chat.
|
||||||
|
// If omitted, then all emoji reactions are allowed. Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
AvailableReactions []ReactionType `json:"available_reactions,omitempty"`
|
||||||
|
// AccentColorID is an identifier of the accent color for the chat name and backgrounds of
|
||||||
|
// the chat photo, reply header, and link preview.
|
||||||
|
// See accent colors for more details. Returned only in getChat.
|
||||||
|
// Always returned in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
AccentColorID int `json:"accent_color_id,omitempty"`
|
||||||
|
// BackgroundCustomEmojiID is a custom emoji identifier of emoji chosen by
|
||||||
|
// the chat for the reply header and link preview background.
|
||||||
|
// Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
BackgroundCustomEmojiID string `json:"background_custom_emoji_id,omitempty"`
|
||||||
|
// ProfileAccentColorID is ani dentifier of the accent color for the chat's profile background.
|
||||||
|
// See profile accent colors for more details. Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ProfileAccentColorID int `json:"profile_accent_color_id,omitempty"`
|
||||||
|
// ProfileBackgroundCustomEmojiID is a custom emoji identifier of the emoji chosen by
|
||||||
|
// the chat for its profile background. Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ProfileBackgroundCustomEmojiID string `json:"profile_background_custom_emoji_id,omitempty"`
|
||||||
|
// EmojiStatusCustomEmojiID is a custom emoji identifier of emoji status of the other party
|
||||||
// in a private chat. Returned only in getChat.
|
// in a private chat. Returned only in getChat.
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"`
|
EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"`
|
||||||
// Expiration date of the emoji status of the chat or the other party
|
// EmojiStatusExpirationDate is a date of the emoji status of the chat or the other party
|
||||||
// in a private chat, in Unix time, if any. Returned only in getChat.
|
// in a private chat, in Unix time, if any. Returned only in getChat.
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
EmojiStatusCustomEmojiDate int64 `json:"emoji_status_expiration_date,omitempty"`
|
EmojiStatusExpirationDate int64 `json:"emoji_status_expiration_date,omitempty"`
|
||||||
// Bio is the bio of the other party in a private chat. Returned only in
|
// Bio is the bio of the other party in a private chat. Returned only in
|
||||||
// getChat
|
// getChat
|
||||||
//
|
//
|
||||||
|
@ -361,6 +397,11 @@ type Chat struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
HasProtectedContent bool `json:"has_protected_content,omitempty"`
|
HasProtectedContent bool `json:"has_protected_content,omitempty"`
|
||||||
|
// HasVisibleHistory is True, if new chat members will have access to old messages;
|
||||||
|
// available only to chat administrators. Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
HasVisibleHistory bool `json:"has_visible_history,omitempty"`
|
||||||
// StickerSetName is for supergroups, name of group sticker set.Returned
|
// StickerSetName is for supergroups, name of group sticker set.Returned
|
||||||
// only in getChat.
|
// only in getChat.
|
||||||
//
|
//
|
||||||
|
@ -409,6 +450,16 @@ func (c Chat) ChatConfig() ChatConfig {
|
||||||
return ChatConfig{ChatID: c.ID}
|
return ChatConfig{ChatID: c.ID}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InaccessibleMessage describes a message that was deleted or is otherwise inaccessible to the bot.
|
||||||
|
type InaccessibleMessage struct {
|
||||||
|
// Chat the message belonged to
|
||||||
|
Chat Chat `json:"chat"`
|
||||||
|
// MessageID is unique message identifier inside the chat
|
||||||
|
MessageID int `json:"message_id"`
|
||||||
|
// Date is always 0. The field can be used to differentiate regular and inaccessible messages.
|
||||||
|
Date int `json:"date"`
|
||||||
|
}
|
||||||
|
|
||||||
// Message represents a message.
|
// Message represents a message.
|
||||||
type Message struct {
|
type Message struct {
|
||||||
// MessageID is a unique message identifier inside this chat
|
// MessageID is a unique message identifier inside this chat
|
||||||
|
@ -432,35 +483,11 @@ type Message struct {
|
||||||
// Date of the message was sent in Unix time
|
// Date of the message was sent in Unix time
|
||||||
Date int `json:"date"`
|
Date int `json:"date"`
|
||||||
// Chat is the conversation the message belongs to
|
// Chat is the conversation the message belongs to
|
||||||
Chat *Chat `json:"chat"`
|
Chat Chat `json:"chat"`
|
||||||
// ForwardFrom for forwarded messages, sender of the original message;
|
// ForwardOrigin is information about the original message for forwarded messages
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
ForwardFrom *User `json:"forward_from,omitempty"`
|
ForwardOrigin *MessageOrigin `json:"forward_origin,omitempty"`
|
||||||
// ForwardFromChat for messages forwarded from channels,
|
|
||||||
// information about the original channel;
|
|
||||||
//
|
|
||||||
// optional
|
|
||||||
ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
|
|
||||||
// ForwardFromMessageID for messages forwarded from channels,
|
|
||||||
// identifier of the original message in the channel;
|
|
||||||
//
|
|
||||||
// optional
|
|
||||||
ForwardFromMessageID int `json:"forward_from_message_id,omitempty"`
|
|
||||||
// ForwardSignature for messages forwarded from channels, signature of the
|
|
||||||
// post author if present
|
|
||||||
//
|
|
||||||
// optional
|
|
||||||
ForwardSignature string `json:"forward_signature,omitempty"`
|
|
||||||
// ForwardSenderName is the sender's name for messages forwarded from users
|
|
||||||
// who disallow adding a link to their account in forwarded messages
|
|
||||||
//
|
|
||||||
// optional
|
|
||||||
ForwardSenderName string `json:"forward_sender_name,omitempty"`
|
|
||||||
// ForwardDate for forwarded messages, date the original message was sent in Unix time;
|
|
||||||
//
|
|
||||||
// optional
|
|
||||||
ForwardDate int `json:"forward_date,omitempty"`
|
|
||||||
// IsTopicMessage true if the message is sent to a forum topic
|
// IsTopicMessage true if the message is sent to a forum topic
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -476,6 +503,15 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
|
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
|
||||||
|
// ExternalReply is an information about the message that is being replied to,
|
||||||
|
// which may come from another chat or forum topic.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ExternalReply *ExternalReplyInfo `json:"external_reply,omitempty"`
|
||||||
|
// Quote for replies that quote part of the original message, the quoted part of the message
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Quote *TextQuote `json:"text_quote,omitempty"`
|
||||||
// ViaBot through which the message was sent;
|
// ViaBot through which the message was sent;
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -505,6 +541,11 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
Entities []MessageEntity `json:"entities,omitempty"`
|
Entities []MessageEntity `json:"entities,omitempty"`
|
||||||
|
// LinkPreviewOptions are options used for link preview generation for the message,
|
||||||
|
// if it is a text message and link preview options were changed
|
||||||
|
//
|
||||||
|
// Optional
|
||||||
|
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
|
||||||
// Animation message is an animation, information about the animation.
|
// Animation message is an animation, information about the animation.
|
||||||
// For backward compatibility, when this field is set, the document field will also be set;
|
// For backward compatibility, when this field is set, the document field will also be set;
|
||||||
//
|
//
|
||||||
|
@ -648,9 +689,9 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
|
MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
|
||||||
// PinnedMessage is a specified message was pinned.
|
// Specified message was pinned.
|
||||||
// Note that the Message object in this field will not contain further ReplyToMessage
|
// Note that the Message object in this field will not contain
|
||||||
// fields even if it is itself a reply;
|
// further reply_to_message fields even if it itself is a reply.
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
PinnedMessage *Message `json:"pinned_message,omitempty"`
|
PinnedMessage *Message `json:"pinned_message,omitempty"`
|
||||||
|
@ -663,10 +704,10 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
|
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
|
||||||
// UserShared is a service message: a user was shared with the bot
|
// UsersShared is a service message: the users were shared with the bot
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
UserShared *UserShared `json:"user_shared,omitempty"`
|
UsersShared *UsersShared `json:"users_shared,omitempty"`
|
||||||
// ChatShared is a service message: a chat was shared with the bot
|
// ChatShared is a service message: a chat was shared with the bot
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -714,6 +755,22 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
GeneralForumTopicUnhidden *GeneralForumTopicUnhidden `json:"general_forum_topic_unhidden,omitempty"`
|
GeneralForumTopicUnhidden *GeneralForumTopicUnhidden `json:"general_forum_topic_unhidden,omitempty"`
|
||||||
|
// GiveawayCreated is as service message: a scheduled giveaway was created
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
GiveawayCreated *GiveawayCreated `json:"giveaway_created,omitempty"`
|
||||||
|
// Giveaway is a scheduled giveaway message
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Giveaway *Giveaway `json:"giveaway,omitempty"`
|
||||||
|
// GiveawayWinners is a giveaway with public winners was completed
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"`
|
||||||
|
// GiveawayCompleted is a service message: a giveaway without public winners was completed
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
GiveawayCompleted *GiveawayCompleted `json:"giveaway_completed,omitempty"`
|
||||||
// VideoChatScheduled is a service message: video chat scheduled.
|
// VideoChatScheduled is a service message: video chat scheduled.
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -832,6 +889,7 @@ type MessageEntity struct {
|
||||||
// “underline” (underlined text),
|
// “underline” (underlined text),
|
||||||
// “strikethrough” (strikethrough text),
|
// “strikethrough” (strikethrough text),
|
||||||
// "spoiler" (spoiler message),
|
// "spoiler" (spoiler message),
|
||||||
|
// “blockquote” (block quotation),
|
||||||
// “code” (monowidth string),
|
// “code” (monowidth string),
|
||||||
// “pre” (monowidth block),
|
// “pre” (monowidth block),
|
||||||
// “text_link” (for clickable text URLs),
|
// “text_link” (for clickable text URLs),
|
||||||
|
@ -925,6 +983,214 @@ func (e MessageEntity) IsTextLink() bool {
|
||||||
return e.Type == "text_link"
|
return e.Type == "text_link"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TextQuote contains information about the quoted part of a message
|
||||||
|
// that is replied to by the given message
|
||||||
|
type TextQuote struct {
|
||||||
|
// Text of the quoted part of a message that is replied to by the given message
|
||||||
|
Text string `json:"text"`
|
||||||
|
// Entities special entities that appear in the quote.
|
||||||
|
// Currently, only bold, italic, underline, strikethrough, spoiler,
|
||||||
|
// and custom_emoji entities are kept in quotes.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Entities []MessageEntity `json:"entities,omitempty"`
|
||||||
|
// Position is approximate quote position in the original message
|
||||||
|
// in UTF-16 code units as specified by the sender
|
||||||
|
Position int `json:"position"`
|
||||||
|
// IsManual True, if the quote was chosen manually by the message sender.
|
||||||
|
// Otherwise, the quote was added automatically by the server.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsManual bool `json:"is_manual,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExternalReplyInfo contains information about a message that is being replied to,
|
||||||
|
// which may come from another chat or forum topic.
|
||||||
|
type ExternalReplyInfo struct {
|
||||||
|
// Origin of the message replied to by the given message
|
||||||
|
Origin MessageOrigin `json:"origin"`
|
||||||
|
// Chat is the conversation the message belongs to
|
||||||
|
Chat *Chat `json:"chat"`
|
||||||
|
// MessageID is a unique message identifier inside this chat
|
||||||
|
MessageID int `json:"message_id"`
|
||||||
|
// LinkPreviewOptions used for link preview generation for the original message,
|
||||||
|
// if it is a text message
|
||||||
|
//
|
||||||
|
// Optional
|
||||||
|
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
|
||||||
|
// Animation message is an animation, information about the animation.
|
||||||
|
// For backward compatibility, when this field is set, the document field will also be set;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Animation *Animation `json:"animation,omitempty"`
|
||||||
|
// Audio message is an audio file, information about the file;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Audio *Audio `json:"audio,omitempty"`
|
||||||
|
// Document message is a general file, information about the file;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Document *Document `json:"document,omitempty"`
|
||||||
|
// Photo message is a photo, available sizes of the photo;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Photo []PhotoSize `json:"photo,omitempty"`
|
||||||
|
// Sticker message is a sticker, information about the sticker;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Sticker *Sticker `json:"sticker,omitempty"`
|
||||||
|
// Story message is a forwarded story;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Story *Story `json:"story,omitempty"`
|
||||||
|
// Video message is a video, information about the video;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Video *Video `json:"video,omitempty"`
|
||||||
|
// VideoNote message is a video note, information about the video message;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
VideoNote *VideoNote `json:"video_note,omitempty"`
|
||||||
|
// Voice message is a voice message, information about the file;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Voice *Voice `json:"voice,omitempty"`
|
||||||
|
// HasMediaSpoiler True, if the message media is covered by a spoiler animation
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"`
|
||||||
|
// Contact message is a shared contact, information about the contact;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Contact *Contact `json:"contact,omitempty"`
|
||||||
|
// Dice is a dice with random value;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Dice *Dice `json:"dice,omitempty"`
|
||||||
|
// Game message is a game, information about the game;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Game *Game `json:"game,omitempty"`
|
||||||
|
// Giveaway is information about the giveaway
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Giveaway *Giveaway `json:"giveaway,omitempty"`
|
||||||
|
// GiveawayWinners a giveaway with public winners was completed
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
GiveawayWinners *GiveawayWinners `json:"giveaway_winners,omitempty"`
|
||||||
|
// Invoice message is an invoice for a payment;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Invoice *Invoice `json:"invoice,omitempty"`
|
||||||
|
// Location message is a shared location, information about the location;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Location *Location `json:"location,omitempty"`
|
||||||
|
// Poll is a native poll, information about the poll;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Poll *Poll `json:"poll,omitempty"`
|
||||||
|
// Venue message is a venue, information about the venue.
|
||||||
|
// For backward compatibility, when this field is set, the location field
|
||||||
|
// will also be set;
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Venue *Venue `json:"venue,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplyParameters describes reply parameters for the message that is being sent.
|
||||||
|
type ReplyParameters struct {
|
||||||
|
// MessageID identifier of the message that will be replied to in
|
||||||
|
// the current chat, or in the chat chat_id if it is specified
|
||||||
|
MessageID int `json:"message_id"`
|
||||||
|
// ChatID if the message to be replied to is from a different chat,
|
||||||
|
// unique identifier for the chat or username of the channel (in the format @channelusername)
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ChatID interface{} `json:"chat_id,omitempty"`
|
||||||
|
// AllowSendingWithoutReply true if the message should be sent even
|
||||||
|
// if the specified message to be replied to is not found;
|
||||||
|
// can be used only for replies in the same chat and forum topic.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
|
||||||
|
// Quote is a quoted part of the message to be replied to;
|
||||||
|
// 0-1024 characters after entities parsing. The quote must be
|
||||||
|
// an exact substring of the message to be replied to,
|
||||||
|
// including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities.
|
||||||
|
// The message will fail to send if the quote isn't found in the original message.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
Quote string `json:"quote,omitempty"`
|
||||||
|
// QuoteParseMode mode for parsing entities in the quote.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
QuoteParseMode string `json:"quote_parse_mode,omitempty"`
|
||||||
|
// QuoteEntities a JSON-serialized list of special entities that appear in the quote.
|
||||||
|
// It can be specified instead of quote_parse_mode.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
QuoteEntities []MessageEntity `json:"quote_entities,omitempty"`
|
||||||
|
// QuotePosition is a position of the quote in the original message in UTF-16 code units
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
QuotePosition int `json:"quote_position,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
MessageOriginUser = "user"
|
||||||
|
MessageOriginHiddenUser = "hidden_user"
|
||||||
|
MessageOriginChat = "chat"
|
||||||
|
MessageOriginChannel = "channel"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MessageOrigin describes the origin of a message. It can be one of: "user", "hidden_user", "origin_chat", "origin_channel"
|
||||||
|
type MessageOrigin struct {
|
||||||
|
// Type of the message origin.
|
||||||
|
Type string `json:"type"`
|
||||||
|
// Date the message was sent originally in Unix time
|
||||||
|
Date int64 `json:"date"`
|
||||||
|
// SenderUser "user" only.
|
||||||
|
// Is a user that sent the message originally
|
||||||
|
SenderUser *User `json:"sender_user,omitempty"`
|
||||||
|
// SenderUserName "hidden_user" only.
|
||||||
|
// Name of the user that sent the message originally
|
||||||
|
SenderUserName string `json:"sender_user_name,omitempty"`
|
||||||
|
// SenderChat "chat" and "channel".
|
||||||
|
// For "chat": Chat that sent the message originally
|
||||||
|
// For "channel": Channel chat to which the message was originally sent
|
||||||
|
SenderChat *Chat `json:"sender_chat,omitempty"`
|
||||||
|
// AuthorSignature "chat" and "channel".
|
||||||
|
// For "chat": For messages originally sent by an anonymous chat administrator,
|
||||||
|
// original message author signature.
|
||||||
|
// For "channel": Signature of the original post author
|
||||||
|
//
|
||||||
|
// Optional
|
||||||
|
AuthorSignature string `json:"author_signature,omitempty"`
|
||||||
|
// MessageID "channel" only.
|
||||||
|
// Unique message identifier inside the chat
|
||||||
|
//
|
||||||
|
// Optional
|
||||||
|
MessageID int `json:"message_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m MessageOrigin) IsUser() bool {
|
||||||
|
return m.Type == MessageOriginUser
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m MessageOrigin) IsHiddenUser() bool {
|
||||||
|
return m.Type == MessageOriginHiddenUser
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m MessageOrigin) IsChat() bool {
|
||||||
|
return m.Type == MessageOriginChat
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m MessageOrigin) IsChannel() bool {
|
||||||
|
return m.Type == MessageOriginChannel
|
||||||
|
}
|
||||||
|
|
||||||
// PhotoSize represents one size of a photo or a file / sticker thumbnail.
|
// PhotoSize represents one size of a photo or a file / sticker thumbnail.
|
||||||
type PhotoSize struct {
|
type PhotoSize struct {
|
||||||
// FileID identifier for this file, which can be used to download or reuse
|
// FileID identifier for this file, which can be used to download or reuse
|
||||||
|
@ -1351,13 +1617,13 @@ type GeneralForumTopicHidden struct {
|
||||||
type GeneralForumTopicUnhidden struct {
|
type GeneralForumTopicUnhidden struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserShared object contains information about the user whose identifier
|
// UsersShared object contains information about the user whose identifier
|
||||||
// was shared with the bot using a KeyboardButtonRequestUser button.
|
// was shared with the bot using a KeyboardButtonRequestUser button.
|
||||||
type UserShared struct {
|
type UsersShared struct {
|
||||||
// RequestID is an indentifier of the request.
|
// RequestID is an indentifier of the request.
|
||||||
RequestID int `json:"request_id"`
|
RequestID int `json:"request_id"`
|
||||||
// UserID in an identifier of the shared user.
|
// UserIDs are identifiers of the shared user.
|
||||||
UserID int64 `json:"user_id"`
|
UserIDs []int64 `json:"user_ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatShared contains information about the chat whose identifier
|
// ChatShared contains information about the chat whose identifier
|
||||||
|
@ -1423,6 +1689,132 @@ type VideoChatParticipantsInvited struct {
|
||||||
Users []User `json:"users,omitempty"`
|
Users []User `json:"users,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This object represents a service message about the creation of a scheduled giveaway. Currently holds no information.
|
||||||
|
type GiveawayCreated struct{}
|
||||||
|
|
||||||
|
// Giveaway represents a message about a scheduled giveaway.
|
||||||
|
type Giveaway struct {
|
||||||
|
// Chats is the list of chats which the user must join to participate in the giveaway
|
||||||
|
Chats []Chat `json:"chats"`
|
||||||
|
// WinnersSelectionDate is point in time (Unix timestamp) when
|
||||||
|
// winners of the giveaway will be selected
|
||||||
|
WinnersSelectionDate int64 `json:"winners_selection_date"`
|
||||||
|
// WinnerCount is the number of users which are supposed
|
||||||
|
// to be selected as winners of the giveaway
|
||||||
|
WinnerCount int `json:"winner_count"`
|
||||||
|
// OnlyNewMembers True, if only users who join the chats after
|
||||||
|
// the giveaway started should be eligible to win
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
OnlyNewMembers bool `json:"only_new_members,omitempty"`
|
||||||
|
// HasPublicWinners True, if the list of giveaway winners will be visible to everyone
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
HasPublicWinners bool `json:"has_public_winners,omitempty"`
|
||||||
|
// PrizeDescription is description of additional giveaway prize
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
PrizeDescription string `json:"prize_description,omitempty"`
|
||||||
|
// CountryCodes is a list of two-letter ISO 3166-1 alpha-2 country codes
|
||||||
|
// indicating the countries from which eligible users for the giveaway must come.
|
||||||
|
// If empty, then all users can participate in the giveaway.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
CountryCodes []string `json:"country_codes,omitempty"`
|
||||||
|
// PremiumSubscriptionMonthCount the number of months the Telegram Premium
|
||||||
|
// subscription won from the giveaway will be active for
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Giveaway represents a message about a scheduled giveaway.
|
||||||
|
type GiveawayWinners struct {
|
||||||
|
// Chat that created the giveaway
|
||||||
|
Chat Chat `json:"chat"`
|
||||||
|
// GiveawayMessageID is the identifier of the messsage with the giveaway in the chat
|
||||||
|
GiveawayMessageID int `json:"giveaway_message_id"`
|
||||||
|
// WinnersSelectionDate is point in time (Unix timestamp) when
|
||||||
|
// winners of the giveaway will be selected
|
||||||
|
WinnersSelectionDate int64 `json:"winners_selection_date"`
|
||||||
|
// WinnerCount is the number of users which are supposed
|
||||||
|
// to be selected as winners of the giveaway
|
||||||
|
WinnerCount int `json:"winner_count"`
|
||||||
|
// Winners is a list of up to 100 winners of the giveaway
|
||||||
|
Winners []User `json:"winners"`
|
||||||
|
// AdditionalChatCount is the number of other chats
|
||||||
|
// the user had to join in order to be eligible for the giveaway
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
AdditionalChatCount int `json:"additional_chat_count,omitempty"`
|
||||||
|
// PremiumSubscriptionMonthCount the number of months the Telegram Premium
|
||||||
|
// subscription won from the giveaway will be active for
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"`
|
||||||
|
// UnclaimedPrizeCount is the number of undistributed prizes
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"`
|
||||||
|
// OnlyNewMembers True, if only users who join the chats after
|
||||||
|
// the giveaway started should be eligible to win
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
OnlyNewMembers bool `json:"only_new_members,omitempty"`
|
||||||
|
// WasRefunded True, if the giveaway was canceled because the payment for it was refunded
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
WasRefunded bool `json:"was_refunded,omitempty"`
|
||||||
|
// PrizeDescription is description of additional giveaway prize
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
PrizeDescription string `json:"prize_description,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// This object represents a service message about the completion of a giveaway without public winners.
|
||||||
|
type GiveawayCompleted struct {
|
||||||
|
// Number of winners in the giveaway
|
||||||
|
WinnerCount int `json:"winner_count"`
|
||||||
|
// Number of undistributed prizes
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"`
|
||||||
|
// Message with the giveaway that was completed, if it wasn't deleted
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
GiveawayMessage *Message `json:"giveaway_message,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkPreviewOptions describes the options used for link preview generation.
|
||||||
|
type LinkPreviewOptions struct {
|
||||||
|
// IsDisabled True, if the link preview is disabled
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsDisabled bool `json:"is_disabled,omitempty"`
|
||||||
|
// URL to use for the link preview. If empty,
|
||||||
|
// then the first URL found in the message text will be used
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
// PreferSmallMedia True, if the media in the link preview is suppposed
|
||||||
|
// to be shrunk; ignored if the URL isn't explicitly specified
|
||||||
|
// or media size change isn't supported for the preview
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
PreferSmallMedia bool `json:"prefer_small_media,omitempty"`
|
||||||
|
// PreferLargeMedia True, if the media in the link preview is suppposed
|
||||||
|
// to be enlarged; ignored if the URL isn't explicitly specified
|
||||||
|
// or media size change isn't supported for the preview
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
PreferLargeMedia bool `json:"prefer_large_media,omitempty"`
|
||||||
|
// ShowAboveText True, if the link preview must be shown above the message text;
|
||||||
|
// otherwise, the link preview will be shown below the message text
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ShowAboveText bool `json:"show_above_text,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// UserProfilePhotos contains a set of user profile photos.
|
// UserProfilePhotos contains a set of user profile photos.
|
||||||
type UserProfilePhotos struct {
|
type UserProfilePhotos struct {
|
||||||
// TotalCount total number of profile pictures the target user has
|
// TotalCount total number of profile pictures the target user has
|
||||||
|
@ -1516,13 +1908,13 @@ type KeyboardButton struct {
|
||||||
// Text of the button. If none of the optional fields are used,
|
// Text of the button. If none of the optional fields are used,
|
||||||
// it will be sent as a message when the button is pressed.
|
// it will be sent as a message when the button is pressed.
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
// RequestUser if specified, pressing the button will open
|
// RequestUsers if specified, pressing the button will open
|
||||||
// a list of suitable users. Tapping on any user will send
|
// a list of suitable users. Tapping on any user will send
|
||||||
// their identifier to the bot in a "user_shared" service message.
|
// their identifier to the bot in a "user_shared" service message.
|
||||||
// Available in private chats only.
|
// Available in private chats only.
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
RequestUser *KeyboardButtonRequestUser `json:"request_user,omitempty"`
|
RequestUsers *KeyboardButtonRequestUsers `json:"request_users,omitempty"`
|
||||||
// RequestChat if specified, pressing the button will open
|
// RequestChat if specified, pressing the button will open
|
||||||
// a list of suitable chats. Tapping on a chat will send
|
// a list of suitable chats. Tapping on a chat will send
|
||||||
// its identifier to the bot in a "chat_shared" service message.
|
// its identifier to the bot in a "chat_shared" service message.
|
||||||
|
@ -1555,10 +1947,10 @@ type KeyboardButton struct {
|
||||||
WebApp *WebAppInfo `json:"web_app,omitempty"`
|
WebApp *WebAppInfo `json:"web_app,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyboardButtonRequestUser defines the criteria used to request
|
// KeyboardButtonRequestUsers defines the criteria used to request
|
||||||
// a suitable user. The identifier of the selected user will be shared
|
// a suitable user. The identifier of the selected user will be shared
|
||||||
// with the bot when the corresponding button is pressed.
|
// with the bot when the corresponding button is pressed.
|
||||||
type KeyboardButtonRequestUser struct {
|
type KeyboardButtonRequestUsers struct {
|
||||||
// RequestID is a signed 32-bit identifier of the request.
|
// RequestID is a signed 32-bit identifier of the request.
|
||||||
RequestID int `json:"request_id"`
|
RequestID int `json:"request_id"`
|
||||||
// UserIsBot pass True to request a bot,
|
// UserIsBot pass True to request a bot,
|
||||||
|
@ -1573,6 +1965,11 @@ type KeyboardButtonRequestUser struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
UserIsPremium bool `json:"user_is_premium,omitempty"`
|
UserIsPremium bool `json:"user_is_premium,omitempty"`
|
||||||
|
// MaxQuantity is the maximum number of users to be selected.
|
||||||
|
// 1-10. Defaults to 1
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
MaxQuantity int `json:"max_quantity,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyboardButtonRequestChat defines the criteria used to request
|
// KeyboardButtonRequestChat defines the criteria used to request
|
||||||
|
@ -1775,9 +2172,7 @@ type CallbackQuery struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
// From sender
|
// From sender
|
||||||
From *User `json:"from"`
|
From *User `json:"from"`
|
||||||
// Message with the callback button that originated the query.
|
// Message sent by the bot with the callback button that originated the query
|
||||||
// Note that message content and message date will not be available if the
|
|
||||||
// message is too old.
|
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
Message *Message `json:"message,omitempty"`
|
Message *Message `json:"message,omitempty"`
|
||||||
|
@ -1801,6 +2196,21 @@ type CallbackQuery struct {
|
||||||
GameShortName string `json:"game_short_name,omitempty"`
|
GameShortName string `json:"game_short_name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsInaccessibleMessage method that shows whether message is inaccessible
|
||||||
|
func (c CallbackQuery) IsInaccessibleMessage() bool {
|
||||||
|
return c.Message != nil && c.Message.Date == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c CallbackQuery) GetInaccessibleMessage() InaccessibleMessage {
|
||||||
|
if c.Message == nil {
|
||||||
|
return InaccessibleMessage{}
|
||||||
|
}
|
||||||
|
return InaccessibleMessage{
|
||||||
|
Chat: c.Message.Chat,
|
||||||
|
MessageID: c.Message.MessageID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ForceReply when receiving a message with this object, Telegram clients will
|
// ForceReply when receiving a message with this object, Telegram clients will
|
||||||
// display a reply interface to the user (act as if the user has selected the
|
// display a reply interface to the user (act as if the user has selected the
|
||||||
// bot's message and tapped 'Reply'). This can be extremely useful if you want
|
// bot's message and tapped 'Reply'). This can be extremely useful if you want
|
||||||
|
@ -2242,6 +2652,72 @@ type ChatLocation struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReactionTypeEmoji = "emoji"
|
||||||
|
ReactionTypeCustomEmoji = "custom_emoji"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ReactionType describes the type of a reaction. Currently, it can be one of: "emoji", "custom_emoji"
|
||||||
|
type ReactionType struct {
|
||||||
|
// Type of the reaction. Can be "emoji", "custom_emoji"
|
||||||
|
Type string `json:"type"`
|
||||||
|
// Emoji type "emoji" only. Is a reaction emoji.
|
||||||
|
Emoji string `json:"emoji"`
|
||||||
|
// CustomEmoji type "custom_emoji" only. Is a custom emoji identifier.
|
||||||
|
CustomEmoji string `json:"custom_emoji"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r ReactionType) IsEmoji() bool {
|
||||||
|
return r.Type == ReactionTypeEmoji
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r ReactionType) IsCustomEmoji() bool {
|
||||||
|
return r.Type == ReactionTypeCustomEmoji
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReactionCount represents a reaction added to a message along with the number of times it was added.
|
||||||
|
type ReactionCount struct {
|
||||||
|
// Type of the reaction
|
||||||
|
Type ReactionType `json:"type"`
|
||||||
|
// TotalCount number of times the reaction was added
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MessageReactionUpdated represents a change of a reaction on a message performed by a user.
|
||||||
|
type MessageReactionUpdated struct {
|
||||||
|
// Chat containing the message the user reacted to.
|
||||||
|
Chat Chat `json:"chat"`
|
||||||
|
// MessageID unique identifier of the message inside the chat.
|
||||||
|
MessageID int `json:"message_id"`
|
||||||
|
// User that changed the reaction, if the user isn't anonymous.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
User *User `json:"user"`
|
||||||
|
// ActorChat the chat on behalf of which the reaction was changed,
|
||||||
|
// if the user is anonymous.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ActorChat *Chat `json:"actor_chat"`
|
||||||
|
// Date of the change in Unix time.
|
||||||
|
Date int64 `json:"date"`
|
||||||
|
// OldReaction is a previous list of reaction types that were set by the user.
|
||||||
|
OldReaction []ReactionType `json:"old_reaction"`
|
||||||
|
// NewReaction is a new list of reaction types that have been set by the user.
|
||||||
|
NewReaction []ReactionType `json:"new_reaction"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MessageReactionCountUpdated represents reaction changes on a message with anonymous reactions.
|
||||||
|
type MessageReactionCountUpdated struct {
|
||||||
|
// Chat containing the message.
|
||||||
|
Chat Chat `json:"chat"`
|
||||||
|
// MessageID unique identifier of the message inside the chat.
|
||||||
|
MessageID int `json:"message_id"`
|
||||||
|
// Date of the change in Unix time.
|
||||||
|
Date int64 `json:"date"`
|
||||||
|
// Reactions is a list of reactions that are present on the message.
|
||||||
|
Reactions []ReactionCount `json:"reactions"`
|
||||||
|
}
|
||||||
|
|
||||||
// ForumTopic represents a forum topic.
|
// ForumTopic represents a forum topic.
|
||||||
type ForumTopic struct {
|
type ForumTopic struct {
|
||||||
// MessageThreadID is the unique identifier of the forum topic
|
// MessageThreadID is the unique identifier of the forum topic
|
||||||
|
@ -2305,6 +2781,83 @@ type MenuButton struct {
|
||||||
WebApp *WebAppInfo `json:"web_app,omitempty"`
|
WebApp *WebAppInfo `json:"web_app,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
ChatBoostSourcePremium = "premium"
|
||||||
|
ChatBoostSourceGiftCode = "gift_code"
|
||||||
|
ChatBoostSourceGiveaway = "giveaway"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChatBoostSource describes the source of a chat boost
|
||||||
|
type ChatBoostSource struct {
|
||||||
|
// Source of the boost, It can be one of:
|
||||||
|
// "premium", "gift_code", "giveaway"
|
||||||
|
Source string `json:"source"`
|
||||||
|
// For "premium": User that boosted the chat
|
||||||
|
// For "gift_code": User for which the gift code was created
|
||||||
|
// Optional for "giveaway": User that won the prize in the giveaway if any
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
// GiveawayMessageID "giveaway" only.
|
||||||
|
// Is an identifier of a message in the chat with the giveaway;
|
||||||
|
// the message could have been deleted already. May be 0 if the message isn't sent yet.
|
||||||
|
GiveawayMessageID int `json:"giveaway_message_id,omitempty"`
|
||||||
|
// IsUnclaimed "giveaway" only.
|
||||||
|
// True, if the giveaway was completed, but there was no user to win the prize
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsUnclaimed bool `json:"is_unclaimed,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c ChatBoostSource) IsPremium() bool {
|
||||||
|
return c.Source == ChatBoostSourcePremium
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c ChatBoostSource) IsGiftCode() bool {
|
||||||
|
return c.Source == ChatBoostSourceGiftCode
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c ChatBoostSource) IsGiveaway() bool {
|
||||||
|
return c.Source == ChatBoostSourceGiveaway
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChatBoost contains information about a chat boost.
|
||||||
|
type ChatBoost struct {
|
||||||
|
// BoostID is an unique identifier of the boost
|
||||||
|
BoostID string `json:"boost_id"`
|
||||||
|
// AddDate is a point in time (Unix timestamp) when the chat was boosted
|
||||||
|
AddDate int64 `json:"add_date"`
|
||||||
|
// ExpirationDate is a point in time (Unix timestamp) when the boost will
|
||||||
|
// automatically expire, unless the booster's Telegram Premium subscription is prolonged
|
||||||
|
ExpirationDate int64 `json:"expiration_date"`
|
||||||
|
// Source of the added boost
|
||||||
|
Source ChatBoostSource `json:"source"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChatBoostUpdated represents a boost added to a chat or changed.
|
||||||
|
type ChatBoostUpdated struct {
|
||||||
|
// Chat which was boosted
|
||||||
|
Chat Chat `json:"chat"`
|
||||||
|
// Boost infomation about the chat boost
|
||||||
|
Boost ChatBoost `json:"boost"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChatBoostRemoved represents a boost removed from a chat.
|
||||||
|
type ChatBoostRemoved struct {
|
||||||
|
// Chat which was boosted
|
||||||
|
Chat Chat `json:"chat"`
|
||||||
|
// BoostID unique identifier of the boost
|
||||||
|
BoostID string `json:"boost_id"`
|
||||||
|
// RemoveDate point in time (Unix timestamp) when the boost was removed
|
||||||
|
RemoveDate int64 `json:"remove_date"`
|
||||||
|
// Source of the removed boost
|
||||||
|
Source ChatBoostSource `json:"source"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserChatBoosts represents a list of boosts added to a chat by a user.
|
||||||
|
type UserChatBoosts struct {
|
||||||
|
// Boosts is the list of boosts added to the chat by the user
|
||||||
|
Boosts []ChatBoost `json:"boosts"`
|
||||||
|
}
|
||||||
|
|
||||||
// ResponseParameters are various errors that can be returned in APIResponse.
|
// ResponseParameters are various errors that can be returned in APIResponse.
|
||||||
type ResponseParameters struct {
|
type ResponseParameters struct {
|
||||||
// The group has been migrated to a supergroup with the specified identifier.
|
// The group has been migrated to a supergroup with the specified identifier.
|
||||||
|
@ -3576,10 +4129,10 @@ type InputTextMessageContent struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
Entities []MessageEntity `json:"entities,omitempty"`
|
Entities []MessageEntity `json:"entities,omitempty"`
|
||||||
// DisableWebPagePreview disables link previews for links in the sent message
|
// LinkPreviewOptions used for link preview generation for the original message
|
||||||
//
|
//
|
||||||
// optional
|
// Optional
|
||||||
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
|
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InputLocationMessageContent contains a location for displaying
|
// InputLocationMessageContent contains a location for displaying
|
||||||
|
|
|
@ -341,6 +341,7 @@ var (
|
||||||
_ Chattable = UnbanChatSenderChatConfig{}
|
_ Chattable = UnbanChatSenderChatConfig{}
|
||||||
_ Chattable = UnpinChatMessageConfig{}
|
_ Chattable = UnpinChatMessageConfig{}
|
||||||
_ Chattable = UpdateConfig{}
|
_ Chattable = UpdateConfig{}
|
||||||
|
_ Chattable = SetMessageReactionConfig{}
|
||||||
_ Chattable = UserProfilePhotosConfig{}
|
_ Chattable = UserProfilePhotosConfig{}
|
||||||
_ Chattable = VenueConfig{}
|
_ Chattable = VenueConfig{}
|
||||||
_ Chattable = VideoConfig{}
|
_ Chattable = VideoConfig{}
|
||||||
|
@ -359,6 +360,7 @@ var (
|
||||||
_ Chattable = ReopenGeneralForumTopicConfig{}
|
_ Chattable = ReopenGeneralForumTopicConfig{}
|
||||||
_ Chattable = HideGeneralForumTopicConfig{}
|
_ Chattable = HideGeneralForumTopicConfig{}
|
||||||
_ Chattable = UnhideGeneralForumTopicConfig{}
|
_ Chattable = UnhideGeneralForumTopicConfig{}
|
||||||
|
_ Chattable = UnpinAllGeneralForumTopicMessagesConfig{}
|
||||||
_ Chattable = SetCustomEmojiStickerSetThumbnailConfig{}
|
_ Chattable = SetCustomEmojiStickerSetThumbnailConfig{}
|
||||||
_ Chattable = SetStickerSetTitleConfig{}
|
_ Chattable = SetStickerSetTitleConfig{}
|
||||||
_ Chattable = DeleteStickerSetConfig{}
|
_ Chattable = DeleteStickerSetConfig{}
|
||||||
|
|
Loading…
Reference in New Issue