2018-10-12 09:33:50 +00:00
package telegram
type (
// EditMessageTextParameters represents data for EditMessageText method.
2020-01-09 15:27:00 +00:00
EditMessageText struct {
2018-10-12 09:33:50 +00:00
// Required if inline_message_id is not specified. Unique identifier for the
// target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 ` json:"chat_id,omitempty" `
// Required if inline_message_id is not specified. Identifier of the sent
// message
MessageID int ` json:"message_id,omitempty" `
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string ` json:"inline_message_id,omitempty" `
// New text of the message
Text string ` json:"text" `
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in your bot's message.
ParseMode string ` json:"parse_mode,omitempty" `
// Disables link previews for links in this message
DisableWebPagePreview bool ` json:"disable_web_page_preview,omitempty" `
// A JSON-serialized object for an inline keyboard.
ReplyMarkup * InlineKeyboardMarkup ` json:"reply_markup,omitempty" `
}
// EditMessageCaptionParameters represents data for EditMessageCaption method.
2020-01-09 15:27:00 +00:00
EditMessageCaption struct {
2018-10-12 09:33:50 +00:00
// Required if inline_message_id is not specified. Unique identifier for the
// target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 ` json:"chat_id,omitempty" `
// Required if inline_message_id is not specified. Identifier of
// the sent message
MessageID int ` json:"message_id,omitempty" `
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string ` json:"inline_message_id,omitempty" `
// New caption of the message
Caption string ` json:"caption,omitempty" `
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string ` json:"parse_mode,omitempty" `
// A JSON-serialized object for an inline keyboard.
ReplyMarkup * InlineKeyboardMarkup ` json:"reply_markup,omitempty" `
}
// EditMessageMediaParameters represents data for EditMessageMedia method.
2020-01-09 15:27:00 +00:00
EditMessageMedia struct {
2018-10-12 09:33:50 +00:00
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID int64 ` json:"chat_id,omitempty" `
// Required if inline_message_id is not specified. Identifier of the sent message
MessageID int ` json:"message_id,omitempty" `
// Required if chat_id and message_id are not specified. Identifier of the inline message
InlineMessageID string ` json:"inline_message_id,omitempty" `
// A JSON-serialized object for a new media content of the message
Media interface { } ` json:"media" `
// A JSON-serialized object for a new inline keyboard.
ReplyMarkup * InlineKeyboardMarkup ` json:"reply_markup,omitempty" `
}
// EditMessageReplyMarkupParameters represents data for EditMessageReplyMarkup method.
2020-01-09 15:27:00 +00:00
EditMessageReplyMarkup struct {
2018-10-12 09:33:50 +00:00
// Required if inline_message_id is not specified. Unique identifier for the
// target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 ` json:"chat_id,omitempty" `
// Required if inline_message_id is not specified. Identifier of the sent
// message
MessageID int ` json:"message_id,omitempty" `
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string ` json:"inline_message_id,omitempty" `
// A JSON-serialized object for an inline keyboard.
ReplyMarkup * InlineKeyboardMarkup ` json:"reply_markup,omitempty" `
}
2020-01-09 15:27:00 +00:00
StopPoll struct {
// Unique identifier for the target chat. A native poll can't be sent to a private chat.
ChatID int64 ` json:"chat_id" `
2018-10-12 09:33:50 +00:00
2020-01-09 15:27:00 +00:00
// Identifier of the original message with the poll
MessageID int ` json:"message_id" `
2018-10-12 09:33:50 +00:00
2020-01-09 15:27:00 +00:00
// A JSON-serialized object for a new message inline keyboard.
ReplyMarkup * InlineKeyboardMarkup ` json:"reply_markup,omitempty" `
2019-07-23 13:45:57 +00:00
}
2020-01-09 15:27:00 +00:00
// DeleteMessageParameters represents data for DeleteMessage method.
DeleteMessage struct {
// Unique identifier for the target chat
ChatID int64 ` json:"chat_id" `
2019-07-23 13:45:57 +00:00
2020-01-09 15:27:00 +00:00
// Identifier of the message to delete
MessageID int ` json:"message_id" `
}
)
2019-07-23 13:45:57 +00:00
2018-10-12 09:33:50 +00:00
// EditMessageText edit text and game messages sent by the bot or via the bot
// (for inline bots). On success, if edited message is sent by the bot, the
// edited Message is returned, otherwise True is returned.
2020-01-09 15:27:00 +00:00
func ( b * Bot ) EditMessageText ( p * EditMessageText ) ( * Message , error ) {
src , err := b . Do ( MethodEditMessageText , p )
2018-10-12 09:33:50 +00:00
if err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
resp := new ( Response )
if err = b . marshler . Unmarshal ( src , resp ) ; err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
result := new ( Message )
if err = b . marshler . Unmarshal ( resp . Result , result ) ; err != nil {
return nil , err
}
return result , nil
2018-10-12 09:33:50 +00:00
}
// EditMessageCaption edit captions of messages sent by the bot or via the bot
// (for inline bots). On success, if edited message is sent by the bot, the
// edited Message is returned, otherwise True is returned.
2020-01-09 15:27:00 +00:00
func ( b * Bot ) EditMessageCaption ( p * EditMessageCaption ) ( * Message , error ) {
src , err := b . Do ( MethodEditMessageCaption , p )
2018-10-12 09:33:50 +00:00
if err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
resp := new ( Response )
if err = b . marshler . Unmarshal ( src , resp ) ; err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
result := new ( Message )
if err = b . marshler . Unmarshal ( resp . Result , result ) ; err != nil {
return nil , err
}
return result , nil
2018-10-12 09:33:50 +00:00
}
// EditMessageMedia edit audio, document, photo, or video messages. If a message
// is a part of a message album, then it can be edited only to a photo or a video.
// Otherwise, message type can be changed arbitrarily. When inline message is
// edited, new file can't be uploaded. Use previously uploaded file via its
// file_id or specify a URL. On success, if the edited message was sent by the
// bot, the edited Message is returned, otherwise True is returned.
2020-01-09 15:27:00 +00:00
func ( b * Bot ) EditMessageMedia ( p EditMessageMedia ) ( * Message , error ) {
src , err := b . Do ( MethodEditMessageMedia , p )
2018-10-12 09:33:50 +00:00
if err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
resp := new ( Response )
if err = b . marshler . Unmarshal ( src , resp ) ; err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
result := new ( Message )
if err = b . marshler . Unmarshal ( resp . Result , result ) ; err != nil {
return nil , err
}
return result , nil
2018-10-12 09:33:50 +00:00
}
// EditMessageReplyMarkup edit only the reply markup of messages sent by the bot
// or via the bot (for inline bots). On success, if edited message is sent by the
// bot, the edited Message is returned, otherwise True is returned.
2020-01-09 15:27:00 +00:00
func ( b * Bot ) EditMessageReplyMarkup ( p EditMessageReplyMarkup ) ( * Message , error ) {
src , err := b . Do ( MethodEditMessageReplyMarkup , p )
2018-10-12 09:33:50 +00:00
if err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
resp := new ( Response )
if err = b . marshler . Unmarshal ( src , resp ) ; err != nil {
return nil , err
}
result := new ( Message )
if err = b . marshler . Unmarshal ( resp . Result , result ) ; err != nil {
return nil , err
}
return result , nil
}
func ( b * Bot ) StopPoll ( p StopPoll ) ( * Poll , error ) {
src , err := b . Do ( MethodStopPoll , p )
2018-10-12 09:33:50 +00:00
if err != nil {
2019-07-26 10:09:49 +00:00
return nil , err
2018-10-12 09:33:50 +00:00
}
2020-01-09 15:27:00 +00:00
resp := new ( Response )
if err = b . marshler . Unmarshal ( src , resp ) ; err != nil {
return nil , err
}
result := new ( Poll )
if err = b . marshler . Unmarshal ( resp . Result , result ) ; err != nil {
return nil , err
}
return result , nil
}
// DeleteMessage delete a message, including service messages, with the following limitations:
//
// - A message can only be deleted if it was sent less than 48 hours ago.
// - Bots can delete outgoing messages in private chats, groups, and supergroups.
// - Bots can delete incoming messages in private chats.
// - Bots granted can_post_messages permissions can delete outgoing messages in channels.
// - If the bot is an administrator of a group, it can delete any message there.
// - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
//
// Returns True on success.
func ( b * Bot ) DeleteMessage ( chatID int64 , messageID int ) ( bool , error ) {
src , err := b . Do ( MethodDeleteMessage , DeleteMessage {
ChatID : chatID ,
MessageID : messageID ,
} )
if err != nil {
return false , err
}
resp := new ( Response )
if err = b . marshler . Unmarshal ( src , resp ) ; err != nil {
return false , err
}
var result bool
if err = b . marshler . Unmarshal ( resp . Result , & result ) ; err != nil {
return false , err
}
return result , nil
2018-10-12 09:33:50 +00:00
}