leobot

Simple Telegram Logging Bot
git clone git://bsandro.tech/leobot
Log | Files | Refs | README | LICENSE

helpers.go (25418B)


      1 package tgbotapi
      2 
      3 import (
      4 	"net/url"
      5 )
      6 
      7 // NewMessage creates a new Message.
      8 //
      9 // chatID is where to send it, text is the message text.
     10 func NewMessage(chatID int64, text string) MessageConfig {
     11 	return MessageConfig{
     12 		BaseChat: BaseChat{
     13 			ChatID:           chatID,
     14 			ReplyToMessageID: 0,
     15 		},
     16 		Text:                  text,
     17 		DisableWebPagePreview: false,
     18 	}
     19 }
     20 
     21 // NewDeleteMessage creates a request to delete a message.
     22 func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig {
     23 	return DeleteMessageConfig{
     24 		ChatID:    chatID,
     25 		MessageID: messageID,
     26 	}
     27 }
     28 
     29 // NewMessageToChannel creates a new Message that is sent to a channel
     30 // by username.
     31 //
     32 // username is the username of the channel, text is the message text,
     33 // and the username should be in the form of `@username`.
     34 func NewMessageToChannel(username string, text string) MessageConfig {
     35 	return MessageConfig{
     36 		BaseChat: BaseChat{
     37 			ChannelUsername: username,
     38 		},
     39 		Text: text,
     40 	}
     41 }
     42 
     43 // NewForward creates a new forward.
     44 //
     45 // chatID is where to send it, fromChatID is the source chat,
     46 // and messageID is the ID of the original message.
     47 func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
     48 	return ForwardConfig{
     49 		BaseChat:   BaseChat{ChatID: chatID},
     50 		FromChatID: fromChatID,
     51 		MessageID:  messageID,
     52 	}
     53 }
     54 
     55 // NewCopyMessage creates a new copy message.
     56 //
     57 // chatID is where to send it, fromChatID is the source chat,
     58 // and messageID is the ID of the original message.
     59 func NewCopyMessage(chatID int64, fromChatID int64, messageID int) CopyMessageConfig {
     60 	return CopyMessageConfig{
     61 		BaseChat:   BaseChat{ChatID: chatID},
     62 		FromChatID: fromChatID,
     63 		MessageID:  messageID,
     64 	}
     65 }
     66 
     67 // NewPhoto creates a new sendPhoto request.
     68 //
     69 // chatID is where to send it, file is a string path to the file,
     70 // FileReader, or FileBytes.
     71 //
     72 // Note that you must send animated GIFs as a document.
     73 func NewPhoto(chatID int64, file RequestFileData) PhotoConfig {
     74 	return PhotoConfig{
     75 		BaseFile: BaseFile{
     76 			BaseChat: BaseChat{ChatID: chatID},
     77 			File:     file,
     78 		},
     79 	}
     80 }
     81 
     82 // NewPhotoToChannel creates a new photo uploader to send a photo to a channel.
     83 //
     84 // Note that you must send animated GIFs as a document.
     85 func NewPhotoToChannel(username string, file RequestFileData) PhotoConfig {
     86 	return PhotoConfig{
     87 		BaseFile: BaseFile{
     88 			BaseChat: BaseChat{
     89 				ChannelUsername: username,
     90 			},
     91 			File: file,
     92 		},
     93 	}
     94 }
     95 
     96 // NewAudio creates a new sendAudio request.
     97 func NewAudio(chatID int64, file RequestFileData) AudioConfig {
     98 	return AudioConfig{
     99 		BaseFile: BaseFile{
    100 			BaseChat: BaseChat{ChatID: chatID},
    101 			File:     file,
    102 		},
    103 	}
    104 }
    105 
    106 // NewDocument creates a new sendDocument request.
    107 func NewDocument(chatID int64, file RequestFileData) DocumentConfig {
    108 	return DocumentConfig{
    109 		BaseFile: BaseFile{
    110 			BaseChat: BaseChat{ChatID: chatID},
    111 			File:     file,
    112 		},
    113 	}
    114 }
    115 
    116 // NewSticker creates a new sendSticker request.
    117 func NewSticker(chatID int64, file RequestFileData) StickerConfig {
    118 	return StickerConfig{
    119 		BaseFile: BaseFile{
    120 			BaseChat: BaseChat{ChatID: chatID},
    121 			File:     file,
    122 		},
    123 	}
    124 }
    125 
    126 // NewVideo creates a new sendVideo request.
    127 func NewVideo(chatID int64, file RequestFileData) VideoConfig {
    128 	return VideoConfig{
    129 		BaseFile: BaseFile{
    130 			BaseChat: BaseChat{ChatID: chatID},
    131 			File:     file,
    132 		},
    133 	}
    134 }
    135 
    136 // NewAnimation creates a new sendAnimation request.
    137 func NewAnimation(chatID int64, file RequestFileData) AnimationConfig {
    138 	return AnimationConfig{
    139 		BaseFile: BaseFile{
    140 			BaseChat: BaseChat{ChatID: chatID},
    141 			File:     file,
    142 		},
    143 	}
    144 }
    145 
    146 // NewVideoNote creates a new sendVideoNote request.
    147 //
    148 // chatID is where to send it, file is a string path to the file,
    149 // FileReader, or FileBytes.
    150 func NewVideoNote(chatID int64, length int, file RequestFileData) VideoNoteConfig {
    151 	return VideoNoteConfig{
    152 		BaseFile: BaseFile{
    153 			BaseChat: BaseChat{ChatID: chatID},
    154 			File:     file,
    155 		},
    156 		Length: length,
    157 	}
    158 }
    159 
    160 // NewVoice creates a new sendVoice request.
    161 func NewVoice(chatID int64, file RequestFileData) VoiceConfig {
    162 	return VoiceConfig{
    163 		BaseFile: BaseFile{
    164 			BaseChat: BaseChat{ChatID: chatID},
    165 			File:     file,
    166 		},
    167 	}
    168 }
    169 
    170 // NewMediaGroup creates a new media group. Files should be an array of
    171 // two to ten InputMediaPhoto or InputMediaVideo.
    172 func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig {
    173 	return MediaGroupConfig{
    174 		ChatID: chatID,
    175 		Media:  files,
    176 	}
    177 }
    178 
    179 // NewInputMediaPhoto creates a new InputMediaPhoto.
    180 func NewInputMediaPhoto(media RequestFileData) InputMediaPhoto {
    181 	return InputMediaPhoto{
    182 		BaseInputMedia{
    183 			Type:  "photo",
    184 			Media: media,
    185 		},
    186 	}
    187 }
    188 
    189 // NewInputMediaVideo creates a new InputMediaVideo.
    190 func NewInputMediaVideo(media RequestFileData) InputMediaVideo {
    191 	return InputMediaVideo{
    192 		BaseInputMedia: BaseInputMedia{
    193 			Type:  "video",
    194 			Media: media,
    195 		},
    196 	}
    197 }
    198 
    199 // NewInputMediaAnimation creates a new InputMediaAnimation.
    200 func NewInputMediaAnimation(media RequestFileData) InputMediaAnimation {
    201 	return InputMediaAnimation{
    202 		BaseInputMedia: BaseInputMedia{
    203 			Type:  "animation",
    204 			Media: media,
    205 		},
    206 	}
    207 }
    208 
    209 // NewInputMediaAudio creates a new InputMediaAudio.
    210 func NewInputMediaAudio(media RequestFileData) InputMediaAudio {
    211 	return InputMediaAudio{
    212 		BaseInputMedia: BaseInputMedia{
    213 			Type:  "audio",
    214 			Media: media,
    215 		},
    216 	}
    217 }
    218 
    219 // NewInputMediaDocument creates a new InputMediaDocument.
    220 func NewInputMediaDocument(media RequestFileData) InputMediaDocument {
    221 	return InputMediaDocument{
    222 		BaseInputMedia: BaseInputMedia{
    223 			Type:  "document",
    224 			Media: media,
    225 		},
    226 	}
    227 }
    228 
    229 // NewContact allows you to send a shared contact.
    230 func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig {
    231 	return ContactConfig{
    232 		BaseChat: BaseChat{
    233 			ChatID: chatID,
    234 		},
    235 		PhoneNumber: phoneNumber,
    236 		FirstName:   firstName,
    237 	}
    238 }
    239 
    240 // NewLocation shares your location.
    241 //
    242 // chatID is where to send it, latitude and longitude are coordinates.
    243 func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig {
    244 	return LocationConfig{
    245 		BaseChat: BaseChat{
    246 			ChatID: chatID,
    247 		},
    248 		Latitude:  latitude,
    249 		Longitude: longitude,
    250 	}
    251 }
    252 
    253 // NewVenue allows you to send a venue and its location.
    254 func NewVenue(chatID int64, title, address string, latitude, longitude float64) VenueConfig {
    255 	return VenueConfig{
    256 		BaseChat: BaseChat{
    257 			ChatID: chatID,
    258 		},
    259 		Title:     title,
    260 		Address:   address,
    261 		Latitude:  latitude,
    262 		Longitude: longitude,
    263 	}
    264 }
    265 
    266 // NewChatAction sets a chat action.
    267 // Actions last for 5 seconds, or until your next action.
    268 //
    269 // chatID is where to send it, action should be set via Chat constants.
    270 func NewChatAction(chatID int64, action string) ChatActionConfig {
    271 	return ChatActionConfig{
    272 		BaseChat: BaseChat{ChatID: chatID},
    273 		Action:   action,
    274 	}
    275 }
    276 
    277 // NewUserProfilePhotos gets user profile photos.
    278 //
    279 // userID is the ID of the user you wish to get profile photos from.
    280 func NewUserProfilePhotos(userID int64) UserProfilePhotosConfig {
    281 	return UserProfilePhotosConfig{
    282 		UserID: userID,
    283 		Offset: 0,
    284 		Limit:  0,
    285 	}
    286 }
    287 
    288 // NewUpdate gets updates since the last Offset.
    289 //
    290 // offset is the last Update ID to include.
    291 // You likely want to set this to the last Update ID plus 1.
    292 func NewUpdate(offset int) UpdateConfig {
    293 	return UpdateConfig{
    294 		Offset:  offset,
    295 		Limit:   0,
    296 		Timeout: 0,
    297 	}
    298 }
    299 
    300 // NewWebhook creates a new webhook.
    301 //
    302 // link is the url parsable link you wish to get the updates.
    303 func NewWebhook(link string) (WebhookConfig, error) {
    304 	u, err := url.Parse(link)
    305 
    306 	if err != nil {
    307 		return WebhookConfig{}, err
    308 	}
    309 
    310 	return WebhookConfig{
    311 		URL: u,
    312 	}, nil
    313 }
    314 
    315 // NewWebhookWithCert creates a new webhook with a certificate.
    316 //
    317 // link is the url you wish to get webhooks,
    318 // file contains a string to a file, FileReader, or FileBytes.
    319 func NewWebhookWithCert(link string, file RequestFileData) (WebhookConfig, error) {
    320 	u, err := url.Parse(link)
    321 
    322 	if err != nil {
    323 		return WebhookConfig{}, err
    324 	}
    325 
    326 	return WebhookConfig{
    327 		URL:         u,
    328 		Certificate: file,
    329 	}, nil
    330 }
    331 
    332 // NewInlineQueryResultArticle creates a new inline query article.
    333 func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle {
    334 	return InlineQueryResultArticle{
    335 		Type:  "article",
    336 		ID:    id,
    337 		Title: title,
    338 		InputMessageContent: InputTextMessageContent{
    339 			Text: messageText,
    340 		},
    341 	}
    342 }
    343 
    344 // NewInlineQueryResultArticleMarkdown creates a new inline query article with Markdown parsing.
    345 func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle {
    346 	return InlineQueryResultArticle{
    347 		Type:  "article",
    348 		ID:    id,
    349 		Title: title,
    350 		InputMessageContent: InputTextMessageContent{
    351 			Text:      messageText,
    352 			ParseMode: "Markdown",
    353 		},
    354 	}
    355 }
    356 
    357 // NewInlineQueryResultArticleMarkdownV2 creates a new inline query article with MarkdownV2 parsing.
    358 func NewInlineQueryResultArticleMarkdownV2(id, title, messageText string) InlineQueryResultArticle {
    359 	return InlineQueryResultArticle{
    360 		Type:  "article",
    361 		ID:    id,
    362 		Title: title,
    363 		InputMessageContent: InputTextMessageContent{
    364 			Text:      messageText,
    365 			ParseMode: "MarkdownV2",
    366 		},
    367 	}
    368 }
    369 
    370 // NewInlineQueryResultArticleHTML creates a new inline query article with HTML parsing.
    371 func NewInlineQueryResultArticleHTML(id, title, messageText string) InlineQueryResultArticle {
    372 	return InlineQueryResultArticle{
    373 		Type:  "article",
    374 		ID:    id,
    375 		Title: title,
    376 		InputMessageContent: InputTextMessageContent{
    377 			Text:      messageText,
    378 			ParseMode: "HTML",
    379 		},
    380 	}
    381 }
    382 
    383 // NewInlineQueryResultGIF creates a new inline query GIF.
    384 func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF {
    385 	return InlineQueryResultGIF{
    386 		Type: "gif",
    387 		ID:   id,
    388 		URL:  url,
    389 	}
    390 }
    391 
    392 // NewInlineQueryResultCachedGIF create a new inline query with cached photo.
    393 func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF {
    394 	return InlineQueryResultCachedGIF{
    395 		Type:  "gif",
    396 		ID:    id,
    397 		GIFID: gifID,
    398 	}
    399 }
    400 
    401 // NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
    402 func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
    403 	return InlineQueryResultMPEG4GIF{
    404 		Type: "mpeg4_gif",
    405 		ID:   id,
    406 		URL:  url,
    407 	}
    408 }
    409 
    410 // NewInlineQueryResultCachedMPEG4GIF create a new inline query with cached MPEG4 GIF.
    411 func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GIFID string) InlineQueryResultCachedMPEG4GIF {
    412 	return InlineQueryResultCachedMPEG4GIF{
    413 		Type:        "mpeg4_gif",
    414 		ID:          id,
    415 		MPEG4FileID: MPEG4GIFID,
    416 	}
    417 }
    418 
    419 // NewInlineQueryResultPhoto creates a new inline query photo.
    420 func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto {
    421 	return InlineQueryResultPhoto{
    422 		Type: "photo",
    423 		ID:   id,
    424 		URL:  url,
    425 	}
    426 }
    427 
    428 // NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
    429 func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto {
    430 	return InlineQueryResultPhoto{
    431 		Type:     "photo",
    432 		ID:       id,
    433 		URL:      url,
    434 		ThumbURL: thumb,
    435 	}
    436 }
    437 
    438 // NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
    439 func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto {
    440 	return InlineQueryResultCachedPhoto{
    441 		Type:    "photo",
    442 		ID:      id,
    443 		PhotoID: photoID,
    444 	}
    445 }
    446 
    447 // NewInlineQueryResultVideo creates a new inline query video.
    448 func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo {
    449 	return InlineQueryResultVideo{
    450 		Type: "video",
    451 		ID:   id,
    452 		URL:  url,
    453 	}
    454 }
    455 
    456 // NewInlineQueryResultCachedVideo create a new inline query with cached video.
    457 func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo {
    458 	return InlineQueryResultCachedVideo{
    459 		Type:    "video",
    460 		ID:      id,
    461 		VideoID: videoID,
    462 		Title:   title,
    463 	}
    464 }
    465 
    466 // NewInlineQueryResultCachedSticker create a new inline query with cached sticker.
    467 func NewInlineQueryResultCachedSticker(id, stickerID, title string) InlineQueryResultCachedSticker {
    468 	return InlineQueryResultCachedSticker{
    469 		Type:      "sticker",
    470 		ID:        id,
    471 		StickerID: stickerID,
    472 		Title:     title,
    473 	}
    474 }
    475 
    476 // NewInlineQueryResultAudio creates a new inline query audio.
    477 func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio {
    478 	return InlineQueryResultAudio{
    479 		Type:  "audio",
    480 		ID:    id,
    481 		URL:   url,
    482 		Title: title,
    483 	}
    484 }
    485 
    486 // NewInlineQueryResultCachedAudio create a new inline query with cached photo.
    487 func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio {
    488 	return InlineQueryResultCachedAudio{
    489 		Type:    "audio",
    490 		ID:      id,
    491 		AudioID: audioID,
    492 	}
    493 }
    494 
    495 // NewInlineQueryResultVoice creates a new inline query voice.
    496 func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice {
    497 	return InlineQueryResultVoice{
    498 		Type:  "voice",
    499 		ID:    id,
    500 		URL:   url,
    501 		Title: title,
    502 	}
    503 }
    504 
    505 // NewInlineQueryResultCachedVoice create a new inline query with cached photo.
    506 func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice {
    507 	return InlineQueryResultCachedVoice{
    508 		Type:    "voice",
    509 		ID:      id,
    510 		VoiceID: voiceID,
    511 		Title:   title,
    512 	}
    513 }
    514 
    515 // NewInlineQueryResultDocument creates a new inline query document.
    516 func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument {
    517 	return InlineQueryResultDocument{
    518 		Type:     "document",
    519 		ID:       id,
    520 		URL:      url,
    521 		Title:    title,
    522 		MimeType: mimeType,
    523 	}
    524 }
    525 
    526 // NewInlineQueryResultCachedDocument create a new inline query with cached photo.
    527 func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument {
    528 	return InlineQueryResultCachedDocument{
    529 		Type:       "document",
    530 		ID:         id,
    531 		DocumentID: documentID,
    532 		Title:      title,
    533 	}
    534 }
    535 
    536 // NewInlineQueryResultLocation creates a new inline query location.
    537 func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation {
    538 	return InlineQueryResultLocation{
    539 		Type:      "location",
    540 		ID:        id,
    541 		Title:     title,
    542 		Latitude:  latitude,
    543 		Longitude: longitude,
    544 	}
    545 }
    546 
    547 // NewInlineQueryResultVenue creates a new inline query venue.
    548 func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue {
    549 	return InlineQueryResultVenue{
    550 		Type:      "venue",
    551 		ID:        id,
    552 		Title:     title,
    553 		Address:   address,
    554 		Latitude:  latitude,
    555 		Longitude: longitude,
    556 	}
    557 }
    558 
    559 // NewEditMessageText allows you to edit the text of a message.
    560 func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig {
    561 	return EditMessageTextConfig{
    562 		BaseEdit: BaseEdit{
    563 			ChatID:    chatID,
    564 			MessageID: messageID,
    565 		},
    566 		Text: text,
    567 	}
    568 }
    569 
    570 // NewEditMessageTextAndMarkup allows you to edit the text and replymarkup of a message.
    571 func NewEditMessageTextAndMarkup(chatID int64, messageID int, text string, replyMarkup InlineKeyboardMarkup) EditMessageTextConfig {
    572 	return EditMessageTextConfig{
    573 		BaseEdit: BaseEdit{
    574 			ChatID:      chatID,
    575 			MessageID:   messageID,
    576 			ReplyMarkup: &replyMarkup,
    577 		},
    578 		Text: text,
    579 	}
    580 }
    581 
    582 // NewEditMessageCaption allows you to edit the caption of a message.
    583 func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig {
    584 	return EditMessageCaptionConfig{
    585 		BaseEdit: BaseEdit{
    586 			ChatID:    chatID,
    587 			MessageID: messageID,
    588 		},
    589 		Caption: caption,
    590 	}
    591 }
    592 
    593 // NewEditMessageReplyMarkup allows you to edit the inline
    594 // keyboard markup.
    595 func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig {
    596 	return EditMessageReplyMarkupConfig{
    597 		BaseEdit: BaseEdit{
    598 			ChatID:      chatID,
    599 			MessageID:   messageID,
    600 			ReplyMarkup: &replyMarkup,
    601 		},
    602 	}
    603 }
    604 
    605 // NewRemoveKeyboard hides the keyboard, with the option for being selective
    606 // or hiding for everyone.
    607 func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove {
    608 	return ReplyKeyboardRemove{
    609 		RemoveKeyboard: true,
    610 		Selective:      selective,
    611 	}
    612 }
    613 
    614 // NewKeyboardButton creates a regular keyboard button.
    615 func NewKeyboardButton(text string) KeyboardButton {
    616 	return KeyboardButton{
    617 		Text: text,
    618 	}
    619 }
    620 
    621 // NewKeyboardButtonContact creates a keyboard button that requests
    622 // user contact information upon click.
    623 func NewKeyboardButtonContact(text string) KeyboardButton {
    624 	return KeyboardButton{
    625 		Text:           text,
    626 		RequestContact: true,
    627 	}
    628 }
    629 
    630 // NewKeyboardButtonLocation creates a keyboard button that requests
    631 // user location information upon click.
    632 func NewKeyboardButtonLocation(text string) KeyboardButton {
    633 	return KeyboardButton{
    634 		Text:            text,
    635 		RequestLocation: true,
    636 	}
    637 }
    638 
    639 // NewKeyboardButtonRow creates a row of keyboard buttons.
    640 func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton {
    641 	var row []KeyboardButton
    642 
    643 	row = append(row, buttons...)
    644 
    645 	return row
    646 }
    647 
    648 // NewReplyKeyboard creates a new regular keyboard with sane defaults.
    649 func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
    650 	var keyboard [][]KeyboardButton
    651 
    652 	keyboard = append(keyboard, rows...)
    653 
    654 	return ReplyKeyboardMarkup{
    655 		ResizeKeyboard: true,
    656 		Keyboard:       keyboard,
    657 	}
    658 }
    659 
    660 // NewOneTimeReplyKeyboard creates a new one time keyboard.
    661 func NewOneTimeReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup {
    662 	markup := NewReplyKeyboard(rows...)
    663 	markup.OneTimeKeyboard = true
    664 	return markup
    665 }
    666 
    667 // NewInlineKeyboardButtonData creates an inline keyboard button with text
    668 // and data for a callback.
    669 func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton {
    670 	return InlineKeyboardButton{
    671 		Text:         text,
    672 		CallbackData: &data,
    673 	}
    674 }
    675 
    676 // NewInlineKeyboardButtonLoginURL creates an inline keyboard button with text
    677 // which goes to a LoginURL.
    678 func NewInlineKeyboardButtonLoginURL(text string, loginURL LoginURL) InlineKeyboardButton {
    679 	return InlineKeyboardButton{
    680 		Text:     text,
    681 		LoginURL: &loginURL,
    682 	}
    683 }
    684 
    685 // NewInlineKeyboardButtonURL creates an inline keyboard button with text
    686 // which goes to a URL.
    687 func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
    688 	return InlineKeyboardButton{
    689 		Text: text,
    690 		URL:  &url,
    691 	}
    692 }
    693 
    694 // NewInlineKeyboardButtonSwitch creates an inline keyboard button with
    695 // text which allows the user to switch to a chat or return to a chat.
    696 func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton {
    697 	return InlineKeyboardButton{
    698 		Text:              text,
    699 		SwitchInlineQuery: &sw,
    700 	}
    701 }
    702 
    703 // NewInlineKeyboardRow creates an inline keyboard row with buttons.
    704 func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
    705 	var row []InlineKeyboardButton
    706 
    707 	row = append(row, buttons...)
    708 
    709 	return row
    710 }
    711 
    712 // NewInlineKeyboardMarkup creates a new inline keyboard.
    713 func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup {
    714 	var keyboard [][]InlineKeyboardButton
    715 
    716 	keyboard = append(keyboard, rows...)
    717 
    718 	return InlineKeyboardMarkup{
    719 		InlineKeyboard: keyboard,
    720 	}
    721 }
    722 
    723 // NewCallback creates a new callback message.
    724 func NewCallback(id, text string) CallbackConfig {
    725 	return CallbackConfig{
    726 		CallbackQueryID: id,
    727 		Text:            text,
    728 		ShowAlert:       false,
    729 	}
    730 }
    731 
    732 // NewCallbackWithAlert creates a new callback message that alerts
    733 // the user.
    734 func NewCallbackWithAlert(id, text string) CallbackConfig {
    735 	return CallbackConfig{
    736 		CallbackQueryID: id,
    737 		Text:            text,
    738 		ShowAlert:       true,
    739 	}
    740 }
    741 
    742 // NewInvoice creates a new Invoice request to the user.
    743 func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices []LabeledPrice) InvoiceConfig {
    744 	return InvoiceConfig{
    745 		BaseChat:       BaseChat{ChatID: chatID},
    746 		Title:          title,
    747 		Description:    description,
    748 		Payload:        payload,
    749 		ProviderToken:  providerToken,
    750 		StartParameter: startParameter,
    751 		Currency:       currency,
    752 		Prices:         prices}
    753 }
    754 
    755 // NewChatTitle allows you to update the title of a chat.
    756 func NewChatTitle(chatID int64, title string) SetChatTitleConfig {
    757 	return SetChatTitleConfig{
    758 		ChatID: chatID,
    759 		Title:  title,
    760 	}
    761 }
    762 
    763 // NewChatDescription allows you to update the description of a chat.
    764 func NewChatDescription(chatID int64, description string) SetChatDescriptionConfig {
    765 	return SetChatDescriptionConfig{
    766 		ChatID:      chatID,
    767 		Description: description,
    768 	}
    769 }
    770 
    771 // NewChatPhoto allows you to update the photo for a chat.
    772 func NewChatPhoto(chatID int64, photo RequestFileData) SetChatPhotoConfig {
    773 	return SetChatPhotoConfig{
    774 		BaseFile: BaseFile{
    775 			BaseChat: BaseChat{
    776 				ChatID: chatID,
    777 			},
    778 			File: photo,
    779 		},
    780 	}
    781 }
    782 
    783 // NewDeleteChatPhoto allows you to delete the photo for a chat.
    784 func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig {
    785 	return DeleteChatPhotoConfig{
    786 		ChatID: chatID,
    787 	}
    788 }
    789 
    790 // NewPoll allows you to create a new poll.
    791 func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
    792 	return SendPollConfig{
    793 		BaseChat: BaseChat{
    794 			ChatID: chatID,
    795 		},
    796 		Question:    question,
    797 		Options:     options,
    798 		IsAnonymous: true, // This is Telegram's default.
    799 	}
    800 }
    801 
    802 // NewStopPoll allows you to stop a poll.
    803 func NewStopPoll(chatID int64, messageID int) StopPollConfig {
    804 	return StopPollConfig{
    805 		BaseEdit{
    806 			ChatID:    chatID,
    807 			MessageID: messageID,
    808 		},
    809 	}
    810 }
    811 
    812 // NewDice allows you to send a random dice roll.
    813 func NewDice(chatID int64) DiceConfig {
    814 	return DiceConfig{
    815 		BaseChat: BaseChat{
    816 			ChatID: chatID,
    817 		},
    818 	}
    819 }
    820 
    821 // NewDiceWithEmoji allows you to send a random roll of one of many types.
    822 //
    823 // Emoji may be 🎲 (1-6), 🎯 (1-6), or 🏀 (1-5).
    824 func NewDiceWithEmoji(chatID int64, emoji string) DiceConfig {
    825 	return DiceConfig{
    826 		BaseChat: BaseChat{
    827 			ChatID: chatID,
    828 		},
    829 		Emoji: emoji,
    830 	}
    831 }
    832 
    833 // NewBotCommandScopeDefault represents the default scope of bot commands.
    834 func NewBotCommandScopeDefault() BotCommandScope {
    835 	return BotCommandScope{Type: "default"}
    836 }
    837 
    838 // NewBotCommandScopeAllPrivateChats represents the scope of bot commands,
    839 // covering all private chats.
    840 func NewBotCommandScopeAllPrivateChats() BotCommandScope {
    841 	return BotCommandScope{Type: "all_private_chats"}
    842 }
    843 
    844 // NewBotCommandScopeAllGroupChats represents the scope of bot commands,
    845 // covering all group and supergroup chats.
    846 func NewBotCommandScopeAllGroupChats() BotCommandScope {
    847 	return BotCommandScope{Type: "all_group_chats"}
    848 }
    849 
    850 // NewBotCommandScopeAllChatAdministrators represents the scope of bot commands,
    851 // covering all group and supergroup chat administrators.
    852 func NewBotCommandScopeAllChatAdministrators() BotCommandScope {
    853 	return BotCommandScope{Type: "all_chat_administrators"}
    854 }
    855 
    856 // NewBotCommandScopeChat represents the scope of bot commands, covering a
    857 // specific chat.
    858 func NewBotCommandScopeChat(chatID int64) BotCommandScope {
    859 	return BotCommandScope{
    860 		Type:   "chat",
    861 		ChatID: chatID,
    862 	}
    863 }
    864 
    865 // NewBotCommandScopeChatAdministrators represents the scope of bot commands,
    866 // covering all administrators of a specific group or supergroup chat.
    867 func NewBotCommandScopeChatAdministrators(chatID int64) BotCommandScope {
    868 	return BotCommandScope{
    869 		Type:   "chat_administrators",
    870 		ChatID: chatID,
    871 	}
    872 }
    873 
    874 // NewBotCommandScopeChatMember represents the scope of bot commands, covering a
    875 // specific member of a group or supergroup chat.
    876 func NewBotCommandScopeChatMember(chatID, userID int64) BotCommandScope {
    877 	return BotCommandScope{
    878 		Type:   "chat_member",
    879 		ChatID: chatID,
    880 		UserID: userID,
    881 	}
    882 }
    883 
    884 // NewGetMyCommandsWithScope allows you to set the registered commands for a
    885 // given scope.
    886 func NewGetMyCommandsWithScope(scope BotCommandScope) GetMyCommandsConfig {
    887 	return GetMyCommandsConfig{Scope: &scope}
    888 }
    889 
    890 // NewGetMyCommandsWithScopeAndLanguage allows you to set the registered
    891 // commands for a given scope and language code.
    892 func NewGetMyCommandsWithScopeAndLanguage(scope BotCommandScope, languageCode string) GetMyCommandsConfig {
    893 	return GetMyCommandsConfig{Scope: &scope, LanguageCode: languageCode}
    894 }
    895 
    896 // NewSetMyCommands allows you to set the registered commands.
    897 func NewSetMyCommands(commands ...BotCommand) SetMyCommandsConfig {
    898 	return SetMyCommandsConfig{Commands: commands}
    899 }
    900 
    901 // NewSetMyCommandsWithScope allows you to set the registered commands for a given scope.
    902 func NewSetMyCommandsWithScope(scope BotCommandScope, commands ...BotCommand) SetMyCommandsConfig {
    903 	return SetMyCommandsConfig{Commands: commands, Scope: &scope}
    904 }
    905 
    906 // NewSetMyCommandsWithScopeAndLanguage allows you to set the registered commands for a given scope
    907 // and language code.
    908 func NewSetMyCommandsWithScopeAndLanguage(scope BotCommandScope, languageCode string, commands ...BotCommand) SetMyCommandsConfig {
    909 	return SetMyCommandsConfig{Commands: commands, Scope: &scope, LanguageCode: languageCode}
    910 }
    911 
    912 // NewDeleteMyCommands allows you to delete the registered commands.
    913 func NewDeleteMyCommands() DeleteMyCommandsConfig {
    914 	return DeleteMyCommandsConfig{}
    915 }
    916 
    917 // NewDeleteMyCommandsWithScope allows you to delete the registered commands for a given
    918 // scope.
    919 func NewDeleteMyCommandsWithScope(scope BotCommandScope) DeleteMyCommandsConfig {
    920 	return DeleteMyCommandsConfig{Scope: &scope}
    921 }
    922 
    923 // NewDeleteMyCommandsWithScopeAndLanguage allows you to delete the registered commands for a given
    924 // scope and language code.
    925 func NewDeleteMyCommandsWithScopeAndLanguage(scope BotCommandScope, languageCode string) DeleteMyCommandsConfig {
    926 	return DeleteMyCommandsConfig{Scope: &scope, LanguageCode: languageCode}
    927 }