├── .gitignore ├── LICENSE ├── NOTICE ├── README.md ├── README.ru.md ├── bot.go ├── checklist.todo ├── constants.go ├── demo └── main.go ├── go.mod ├── go.sum ├── requests ├── add_sticker_to_set.go ├── answer_callback_query.go ├── answer_inline_query.go ├── answer_pre_checkout_query.go ├── answer_shipping_query.go ├── answer_web_app_query.go ├── approve_chat_join_request.go ├── ban_chat_member.go ├── ban_chat_sender_chat.go ├── close.go ├── close_forum_topic.go ├── close_general_forum_topic.go ├── convert_gift_to_stars.go ├── copy_message.go ├── copy_messages.go ├── create_chat_invite_link.go ├── create_chat_subscription_invite_link.go ├── create_forum_topic.go ├── create_invoice_link.go ├── create_new_sticker_set.go ├── decline_chat_join_request.go ├── delete_business_messages.go ├── delete_chat_photo.go ├── delete_chat_sticker_set.go ├── delete_forum_topic.go ├── delete_message.go ├── delete_messages.go ├── delete_my_commands.go ├── delete_sticker_from_set.go ├── delete_sticker_set.go ├── delete_story.go ├── delete_webhook.go ├── edit_chat_invite_link.go ├── edit_chat_subscription_invite_link.go ├── edit_forum_topic.go ├── edit_general_forum_topic.go ├── edit_message_caption.go ├── edit_message_live_location.go ├── edit_message_media.go ├── edit_message_reply_markup.go ├── edit_message_text.go ├── edit_story.go ├── edit_user_star_subscription.go ├── export_chat_invite_link.go ├── forward_message.go ├── forward_messages.go ├── get_available_gifts.go ├── get_business_account_gifts.go ├── get_business_account_star_balance.go ├── get_business_connection.go ├── get_chat.go ├── get_chat_administrators.go ├── get_chat_member.go ├── get_chat_member_count.go ├── get_chat_menu_button.go ├── get_custom_emoji_stickers.go ├── get_file.go ├── get_forum_topic_icon_stickers.go ├── get_game_high_scores.go ├── get_me.go ├── get_my_commands.go ├── get_my_default_administrator_rights.go ├── get_my_description.go ├── get_my_name.go ├── get_my_short_description.go ├── get_star_transactions.go ├── get_sticker_set.go ├── get_updates.go ├── get_user_chat_boosts.go ├── get_user_profile_photos.go ├── get_webhook_info.go ├── gift_premium_subscription.go ├── hide_general_forum_topic.go ├── leave_chat.go ├── log_out.go ├── pin_chat_message.go ├── post_story.go ├── promote_chat_member.go ├── read_business_message.go ├── refund_star_payment.go ├── remove_business_account_profile_photo.go ├── remove_chat_verification.go ├── remove_user_verification.go ├── reopen_forum_topic.go ├── reopen_general_forum_topic.go ├── replace_sticker_in_set.go ├── restrict_chat_member.go ├── revoke_chat_invite_link.go ├── save_prepared_inline_message.go ├── send_animation.go ├── send_audio.go ├── send_chat_action.go ├── send_contact.go ├── send_dice.go ├── send_document.go ├── send_game.go ├── send_gift.go ├── send_invoice.go ├── send_location.go ├── send_media_group.go ├── send_message.go ├── send_paid_media.go ├── send_photo.go ├── send_poll.go ├── send_sticker.go ├── send_venue.go ├── send_video.go ├── send_video_note.go ├── send_voice.go ├── set_business_account_bio.go ├── set_business_account_gift_settings.go ├── set_business_account_name.go ├── set_business_account_profile_photo.go ├── set_business_account_username.go ├── set_chat_administrator_custom_title.go ├── set_chat_description.go ├── set_chat_menu_button.go ├── set_chat_permissions.go ├── set_chat_photo.go ├── set_chat_sticker_set.go ├── set_chat_title.go ├── set_custom_emoji_sticker_set_thumbnail.go ├── set_game_score.go ├── set_message_reaction.go ├── set_my_commands.go ├── set_my_default_administrator_rights.go ├── set_my_description.go ├── set_my_name.go ├── set_my_short_description.go ├── set_passport_data_errors.go ├── set_sticker_emoji_list.go ├── set_sticker_keywords.go ├── set_sticker_mask_position.go ├── set_sticker_position_in_set.go ├── set_sticker_set_thumbnail.go ├── set_sticker_set_title.go ├── set_user_emoji_status.go ├── set_webhook.go ├── stop_message_live_location.go ├── stop_poll.go ├── transfer_business_account_stars.go ├── transfer_gift.go ├── unban_chat_member.go ├── unban_chat_sender_chat.go ├── unhide_general_forum_topic.go ├── unpin_all_chat_messages.go ├── unpin_all_forum_topic_messages.go ├── unpin_all_general_forum_topic_messages.go ├── unpin_chat_message.go ├── upgrade_gift.go ├── upload_sticker_file.go ├── verify_chat.go └── verify_user.go ├── type_chat_id.go ├── type_input_file.go └── types.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | 3 | # Test binary, built with `go test -c` 4 | *.test 5 | 6 | # Output of the go coverage tool, specifically when used with LiteIDE 7 | *.out 8 | 9 | # Go workspace file 10 | go.work 11 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright © 2024 Artem Novikov (https://github.com/temoon/). 2 | Licensed under the Apache License, Version 2.0 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Telegram Bots API: Go implementation 2 | 3 | Read an [official documentation](https://core.telegram.org/bots/api) for more information. 4 | 5 | Currently work in progress... -------------------------------------------------------------------------------- /checklist.todo: -------------------------------------------------------------------------------- 1 | New Telegram API version: 2 | 3 | ☐ Up version at `constants.go` 4 | ☐ Copy requests and types from generator 5 | ☐ Make code changes, if needed 6 | ☐ Run `Reformat Code` at Goland editor 7 | ☐ Commit changes to git 8 | ☐ Add git tag 9 | ☐ Push changes to git 10 | -------------------------------------------------------------------------------- /constants.go: -------------------------------------------------------------------------------- 1 | package telegram 2 | 3 | const Name = "Telegram Bots API" 4 | const Version = "9.0.0" 5 | 6 | const ParseModeMarkdown = "Markdown" 7 | const ParseModeMarkdownV2 = "MarkdownV2" 8 | const ParseModeHTML = "HTML" 9 | 10 | const ChatTypeSender = "sender" 11 | const ChatTypePrivate = "private" 12 | const ChatTypeGroup = "group" 13 | const ChatTypeSupergroup = "supergroup" 14 | const ChatTypeChannel = "channel" 15 | 16 | const MessageEntityTypeMention = "mention" 17 | const MessageEntityTypeHashtag = "hashtag" 18 | const MessageEntityTypeCashtag = "cashtag" 19 | const MessageEntityTypeBotCommand = "bot_command" 20 | const MessageEntityTypeUrl = "url" 21 | const MessageEntityTypeEmail = "email" 22 | const MessageEntityTypePhoneNumber = "phone_number" 23 | const MessageEntityTypeBold = "bold" 24 | const MessageEntityTypeItalic = "italic" 25 | const MessageEntityTypeUnderline = "underline" 26 | const MessageEntityTypeStrikethrough = "strikethrough" 27 | const MessageEntityTypeSpoiler = "spoiler" 28 | const MessageEntityTypeCode = "code" 29 | const MessageEntityTypePre = "pre" 30 | const MessageEntityTypeTextLink = "text_link" 31 | const MessageEntityTypeTextMention = "text_mention" 32 | const MessageEntityTypeCustomEmoji = "custom_emoji" 33 | 34 | const ChatMemberStatusCreator = "creator" 35 | const ChatMemberStatusAdministrator = "administrator" 36 | const ChatMemberStatusMember = "member" 37 | const ChatMemberStatusRestricted = "restricted" 38 | const ChatMemberStatusLeft = "left" 39 | const ChatMemberStatusKicked = "kicked" 40 | 41 | const MaskPositionPointForehead = "forehead" 42 | const MaskPositionPointEyes = "eyes" 43 | const MaskPositionPointMouth = "mouth" 44 | const MaskPositionPointChin = "chin" 45 | 46 | const ChatActionTyping = "typing" 47 | const ChatActionUploadPhoto = "upload_photo" 48 | const ChatActionRecordVideo = "record_video" 49 | const ChatActionUploadVideo = "upload_video" 50 | const ChatActionRecordAudio = "record_audio" 51 | const ChatActionUploadAudio = "upload_audio" 52 | const ChatActionUploadDocument = "upload_document" 53 | const ChatActionChooseSticker = "choose_sticker" 54 | const ChatActionFindLocation = "find_location" 55 | const ChatActionRecordVideoNote = "record_video_note" 56 | const ChatActionUploadVideoNote = "upload_video_note" 57 | 58 | const UpdatesAllowedMessage = "message" 59 | const UpdatesAllowedEditedMessage = "edited_message" 60 | const UpdatesAllowedChannelPost = "channel_post" 61 | const UpdatesAllowedEditedChannelPost = "edited_channel_post" 62 | const UpdatesAllowedInlineQuery = "inline_query" 63 | const UpdatesAllowedChosenInlineResult = "chosen_inline_result" 64 | const UpdatesAllowedCallbackQuery = "callback_query" 65 | const UpdatesAllowedShippingQuery = "shipping_query" 66 | const UpdatesAllowedPreCheckoutQuery = "pre_checkout_query" 67 | 68 | const InlineQueryResultTypeArticle = "article" 69 | const InlineQueryResultTypePhoto = "photo" 70 | const InlineQueryResultTypeGif = "gif" 71 | const InlineQueryResultTypeMpeg4Gif = "mpeg4_gif" 72 | const InlineQueryResultTypeVideo = "video" 73 | const InlineQueryResultTypeAudio = "audio" 74 | const InlineQueryResultTypeVoice = "voice" 75 | const InlineQueryResultTypeDocument = "document" 76 | const InlineQueryResultTypeLocation = "location" 77 | const InlineQueryResultTypeVenue = "venue" 78 | const InlineQueryResultTypeContact = "contact" 79 | const InlineQueryResultTypeGame = "game" 80 | 81 | const EncryptedPassportElementTypePersonalDetails = "personal_details" 82 | const EncryptedPassportElementTypePassport = "passport" 83 | const EncryptedPassportElementTypeDriverLicense = "driver_license" 84 | const EncryptedPassportElementTypeIdentityCard = "identity_card" 85 | const EncryptedPassportElementTypeInternalPassport = "internal_passport" 86 | const EncryptedPassportElementTypeAddress = "address" 87 | const EncryptedPassportElementTypeUtilityBill = "utility_bill" 88 | const EncryptedPassportElementTypeBankStatement = "bank_statement" 89 | const EncryptedPassportElementTypeRentalAgreement = "rental_agreement" 90 | const EncryptedPassportElementTypePassportRegistration = "passport_registration" 91 | const EncryptedPassportElementTypeTemporaryRegistration = "temporary_registration" 92 | const EncryptedPassportElementTypePhoneNumber = "phone_number" 93 | const EncryptedPassportElementTypeEmail = "email" 94 | 95 | const StickerTypeRegular = "regular" 96 | const StickerTypeMask = "mask" 97 | const StickerTypeCustomEmoji = "custom_emoji" 98 | -------------------------------------------------------------------------------- /demo/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "github.com/temoon/telegram-bots-api/requests" 7 | "log" 8 | "os" 9 | "time" 10 | ) 11 | 12 | func main() { 13 | botOpts := telegram.BotOpts{ 14 | Token: os.Getenv("TELEGRAM_TOKEN"), 15 | Timeout: time.Minute, 16 | } 17 | 18 | bot := telegram.NewBot(&botOpts) 19 | 20 | reqGetMe := requests.GetMe{} 21 | 22 | var err error 23 | var res interface{} 24 | if res, err = reqGetMe.Call(context.Background(), bot); err != nil { 25 | log.Fatalln(err) 26 | } 27 | 28 | if user, ok := res.(*telegram.User); ok { 29 | if user.Username != nil { 30 | log.Println(*user.Username) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/temoon/telegram-bots-api 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/temoon/telegram-bots-api/92bcefbeae43e6747052a6ea3ca6e36b341a5fa8/go.sum -------------------------------------------------------------------------------- /requests/add_sticker_to_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type AddStickerToSet struct { 12 | Name string 13 | Sticker telegram.InputSticker 14 | UserId int64 15 | } 16 | 17 | func (r *AddStickerToSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "addStickerToSet", r, response) 20 | return 21 | } 22 | 23 | func (r *AddStickerToSet) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["name"] = r.Name 27 | 28 | var dataSticker []byte 29 | if dataSticker, err = json.Marshal(r.Sticker); err != nil { 30 | return 31 | } 32 | 33 | values["sticker"] = string(dataSticker) 34 | 35 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 36 | 37 | return 38 | } 39 | 40 | func (r *AddStickerToSet) GetFiles() (files map[string]io.Reader) { 41 | files = make(map[string]io.Reader) 42 | 43 | if r.Sticker.Sticker.HasFile() { 44 | files[r.Sticker.Sticker.GetFormFieldName()] = r.Sticker.Sticker.GetFile() 45 | } 46 | 47 | return 48 | } 49 | -------------------------------------------------------------------------------- /requests/answer_callback_query.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type AnswerCallbackQuery struct { 11 | CallbackQueryId string 12 | CacheTime *int64 13 | ShowAlert *bool 14 | Text *string 15 | Url *string 16 | } 17 | 18 | func (r *AnswerCallbackQuery) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 19 | response = new(bool) 20 | err = b.CallMethod(ctx, "answerCallbackQuery", r, response) 21 | return 22 | } 23 | 24 | func (r *AnswerCallbackQuery) GetValues() (values map[string]interface{}, err error) { 25 | values = make(map[string]interface{}) 26 | 27 | values["callback_query_id"] = r.CallbackQueryId 28 | 29 | if r.CacheTime != nil { 30 | values["cache_time"] = strconv.FormatInt(*r.CacheTime, 10) 31 | } 32 | 33 | if r.ShowAlert != nil { 34 | if *r.ShowAlert { 35 | values["show_alert"] = "1" 36 | } else { 37 | values["show_alert"] = "0" 38 | } 39 | } 40 | 41 | if r.Text != nil { 42 | values["text"] = *r.Text 43 | } 44 | 45 | if r.Url != nil { 46 | values["url"] = *r.Url 47 | } 48 | 49 | return 50 | } 51 | 52 | func (r *AnswerCallbackQuery) GetFiles() (files map[string]io.Reader) { 53 | return 54 | } 55 | -------------------------------------------------------------------------------- /requests/answer_inline_query.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type AnswerInlineQuery struct { 12 | InlineQueryId string 13 | Results []interface{} 14 | Button *telegram.InlineQueryResultsButton 15 | CacheTime *int64 16 | IsPersonal *bool 17 | NextOffset *string 18 | } 19 | 20 | func (r *AnswerInlineQuery) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new(bool) 22 | err = b.CallMethod(ctx, "answerInlineQuery", r, response) 23 | return 24 | } 25 | 26 | func (r *AnswerInlineQuery) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | values["inline_query_id"] = r.InlineQueryId 30 | 31 | var dataResults []byte 32 | if dataResults, err = json.Marshal(r.Results); err != nil { 33 | return 34 | } 35 | 36 | values["results"] = string(dataResults) 37 | 38 | if r.Button != nil { 39 | var dataButton []byte 40 | if dataButton, err = json.Marshal(r.Button); err != nil { 41 | return 42 | } 43 | 44 | values["button"] = string(dataButton) 45 | } 46 | 47 | if r.CacheTime != nil { 48 | values["cache_time"] = strconv.FormatInt(*r.CacheTime, 10) 49 | } 50 | 51 | if r.IsPersonal != nil { 52 | if *r.IsPersonal { 53 | values["is_personal"] = "1" 54 | } else { 55 | values["is_personal"] = "0" 56 | } 57 | } 58 | 59 | if r.NextOffset != nil { 60 | values["next_offset"] = *r.NextOffset 61 | } 62 | 63 | return 64 | } 65 | 66 | func (r *AnswerInlineQuery) GetFiles() (files map[string]io.Reader) { 67 | return 68 | } 69 | -------------------------------------------------------------------------------- /requests/answer_pre_checkout_query.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type AnswerPreCheckoutQuery struct { 10 | Ok bool 11 | PreCheckoutQueryId string 12 | ErrorMessage *string 13 | } 14 | 15 | func (r *AnswerPreCheckoutQuery) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "answerPreCheckoutQuery", r, response) 18 | return 19 | } 20 | 21 | func (r *AnswerPreCheckoutQuery) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | if r.Ok { 25 | values["ok"] = "1" 26 | } else { 27 | values["ok"] = "0" 28 | } 29 | 30 | values["pre_checkout_query_id"] = r.PreCheckoutQueryId 31 | 32 | if r.ErrorMessage != nil { 33 | values["error_message"] = *r.ErrorMessage 34 | } 35 | 36 | return 37 | } 38 | 39 | func (r *AnswerPreCheckoutQuery) GetFiles() (files map[string]io.Reader) { 40 | return 41 | } 42 | -------------------------------------------------------------------------------- /requests/answer_shipping_query.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type AnswerShippingQuery struct { 11 | Ok bool 12 | ShippingQueryId string 13 | ErrorMessage *string 14 | ShippingOptions []telegram.ShippingOption 15 | } 16 | 17 | func (r *AnswerShippingQuery) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "answerShippingQuery", r, response) 20 | return 21 | } 22 | 23 | func (r *AnswerShippingQuery) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | if r.Ok { 27 | values["ok"] = "1" 28 | } else { 29 | values["ok"] = "0" 30 | } 31 | 32 | values["shipping_query_id"] = r.ShippingQueryId 33 | 34 | if r.ErrorMessage != nil { 35 | values["error_message"] = *r.ErrorMessage 36 | } 37 | 38 | if r.ShippingOptions != nil { 39 | var dataShippingOptions []byte 40 | if dataShippingOptions, err = json.Marshal(r.ShippingOptions); err != nil { 41 | return 42 | } 43 | 44 | values["shipping_options"] = string(dataShippingOptions) 45 | } 46 | 47 | return 48 | } 49 | 50 | func (r *AnswerShippingQuery) GetFiles() (files map[string]io.Reader) { 51 | return 52 | } 53 | -------------------------------------------------------------------------------- /requests/answer_web_app_query.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type AnswerWebAppQuery struct { 11 | Result interface{} 12 | WebAppQueryId string 13 | } 14 | 15 | func (r *AnswerWebAppQuery) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(telegram.SentWebAppMessage) 17 | err = b.CallMethod(ctx, "answerWebAppQuery", r, response) 18 | return 19 | } 20 | 21 | func (r *AnswerWebAppQuery) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | var dataResult []byte 25 | if dataResult, err = json.Marshal(r.Result); err != nil { 26 | return 27 | } 28 | 29 | values["result"] = string(dataResult) 30 | 31 | values["web_app_query_id"] = r.WebAppQueryId 32 | 33 | return 34 | } 35 | 36 | func (r *AnswerWebAppQuery) GetFiles() (files map[string]io.Reader) { 37 | return 38 | } 39 | -------------------------------------------------------------------------------- /requests/approve_chat_join_request.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type ApproveChatJoinRequest struct { 11 | ChatId telegram.ChatId 12 | UserId int64 13 | } 14 | 15 | func (r *ApproveChatJoinRequest) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "approveChatJoinRequest", r, response) 18 | return 19 | } 20 | 21 | func (r *ApproveChatJoinRequest) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *ApproveChatJoinRequest) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/ban_chat_member.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type BanChatMember struct { 11 | ChatId telegram.ChatId 12 | UserId int64 13 | RevokeMessages *bool 14 | UntilDate *int64 15 | } 16 | 17 | func (r *BanChatMember) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "banChatMember", r, response) 20 | return 21 | } 22 | 23 | func (r *BanChatMember) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["chat_id"] = r.ChatId.String() 27 | 28 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 29 | 30 | if r.RevokeMessages != nil { 31 | if *r.RevokeMessages { 32 | values["revoke_messages"] = "1" 33 | } else { 34 | values["revoke_messages"] = "0" 35 | } 36 | } 37 | 38 | if r.UntilDate != nil { 39 | values["until_date"] = strconv.FormatInt(*r.UntilDate, 10) 40 | } 41 | 42 | return 43 | } 44 | 45 | func (r *BanChatMember) GetFiles() (files map[string]io.Reader) { 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /requests/ban_chat_sender_chat.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type BanChatSenderChat struct { 11 | ChatId telegram.ChatId 12 | SenderChatId int64 13 | } 14 | 15 | func (r *BanChatSenderChat) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "banChatSenderChat", r, response) 18 | return 19 | } 20 | 21 | func (r *BanChatSenderChat) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["sender_chat_id"] = strconv.FormatInt(r.SenderChatId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *BanChatSenderChat) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/close.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type Close struct { 10 | } 11 | 12 | func (r *Close) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 13 | response = new(bool) 14 | err = b.CallMethod(ctx, "close", r, response) 15 | return 16 | } 17 | 18 | func (r *Close) GetValues() (values map[string]interface{}, err error) { 19 | return 20 | } 21 | 22 | func (r *Close) GetFiles() (files map[string]io.Reader) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /requests/close_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type CloseForumTopic struct { 11 | ChatId telegram.ChatId 12 | MessageThreadId int64 13 | } 14 | 15 | func (r *CloseForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "closeForumTopic", r, response) 18 | return 19 | } 20 | 21 | func (r *CloseForumTopic) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["message_thread_id"] = strconv.FormatInt(r.MessageThreadId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *CloseForumTopic) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/close_general_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type CloseGeneralForumTopic struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *CloseGeneralForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "closeGeneralForumTopic", r, response) 16 | return 17 | } 18 | 19 | func (r *CloseGeneralForumTopic) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *CloseGeneralForumTopic) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/convert_gift_to_stars.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type ConvertGiftToStars struct { 10 | BusinessConnectionId string 11 | OwnedGiftId string 12 | } 13 | 14 | func (r *ConvertGiftToStars) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "convertGiftToStars", r, response) 17 | return 18 | } 19 | 20 | func (r *ConvertGiftToStars) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["business_connection_id"] = r.BusinessConnectionId 24 | 25 | values["owned_gift_id"] = r.OwnedGiftId 26 | 27 | return 28 | } 29 | 30 | func (r *ConvertGiftToStars) GetFiles() (files map[string]io.Reader) { 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /requests/copy_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type CopyMessage struct { 13 | ChatId telegram.ChatId 14 | FromChatId telegram.ChatId 15 | MessageId int64 16 | AllowPaidBroadcast *bool 17 | Caption *string 18 | CaptionEntities []telegram.MessageEntity 19 | DisableNotification *bool 20 | MessageThreadId *int64 21 | ParseMode *string 22 | ProtectContent *bool 23 | ReplyMarkup interface{} 24 | ReplyParameters *telegram.ReplyParameters 25 | ShowCaptionAboveMedia *bool 26 | VideoStartTimestamp *int64 27 | } 28 | 29 | func (r *CopyMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 30 | response = new(telegram.MessageId) 31 | err = b.CallMethod(ctx, "copyMessage", r, response) 32 | return 33 | } 34 | 35 | func (r *CopyMessage) GetValues() (values map[string]interface{}, err error) { 36 | values = make(map[string]interface{}) 37 | 38 | values["chat_id"] = r.ChatId.String() 39 | 40 | values["from_chat_id"] = r.FromChatId.String() 41 | 42 | values["message_id"] = strconv.FormatInt(r.MessageId, 10) 43 | 44 | if r.AllowPaidBroadcast != nil { 45 | if *r.AllowPaidBroadcast { 46 | values["allow_paid_broadcast"] = "1" 47 | } else { 48 | values["allow_paid_broadcast"] = "0" 49 | } 50 | } 51 | 52 | if r.Caption != nil { 53 | values["caption"] = *r.Caption 54 | } 55 | 56 | if r.CaptionEntities != nil { 57 | var dataCaptionEntities []byte 58 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 59 | return 60 | } 61 | 62 | values["caption_entities"] = string(dataCaptionEntities) 63 | } 64 | 65 | if r.DisableNotification != nil { 66 | if *r.DisableNotification { 67 | values["disable_notification"] = "1" 68 | } else { 69 | values["disable_notification"] = "0" 70 | } 71 | } 72 | 73 | if r.MessageThreadId != nil { 74 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 75 | } 76 | 77 | if r.ParseMode != nil { 78 | values["parse_mode"] = *r.ParseMode 79 | } 80 | 81 | if r.ProtectContent != nil { 82 | if *r.ProtectContent { 83 | values["protect_content"] = "1" 84 | } else { 85 | values["protect_content"] = "0" 86 | } 87 | } 88 | 89 | if r.ReplyMarkup != nil { 90 | switch value := r.ReplyMarkup.(type) { 91 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 92 | var data []byte 93 | if data, err = json.Marshal(value); err != nil { 94 | return 95 | } 96 | 97 | values["reply_markup"] = string(data) 98 | default: 99 | err = errors.New("unsupported reply_markup field type") 100 | return 101 | } 102 | } 103 | 104 | if r.ReplyParameters != nil { 105 | var dataReplyParameters []byte 106 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 107 | return 108 | } 109 | 110 | values["reply_parameters"] = string(dataReplyParameters) 111 | } 112 | 113 | if r.ShowCaptionAboveMedia != nil { 114 | if *r.ShowCaptionAboveMedia { 115 | values["show_caption_above_media"] = "1" 116 | } else { 117 | values["show_caption_above_media"] = "0" 118 | } 119 | } 120 | 121 | if r.VideoStartTimestamp != nil { 122 | values["video_start_timestamp"] = strconv.FormatInt(*r.VideoStartTimestamp, 10) 123 | } 124 | 125 | return 126 | } 127 | 128 | func (r *CopyMessage) GetFiles() (files map[string]io.Reader) { 129 | return 130 | } 131 | -------------------------------------------------------------------------------- /requests/copy_messages.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type CopyMessages struct { 12 | ChatId telegram.ChatId 13 | FromChatId telegram.ChatId 14 | MessageIds []int64 15 | DisableNotification *bool 16 | MessageThreadId *int64 17 | ProtectContent *bool 18 | RemoveCaption *bool 19 | } 20 | 21 | func (r *CopyMessages) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 22 | response = new([]telegram.MessageId) 23 | err = b.CallMethod(ctx, "copyMessages", r, response) 24 | return 25 | } 26 | 27 | func (r *CopyMessages) GetValues() (values map[string]interface{}, err error) { 28 | values = make(map[string]interface{}) 29 | 30 | values["chat_id"] = r.ChatId.String() 31 | 32 | values["from_chat_id"] = r.FromChatId.String() 33 | 34 | var dataMessageIds []byte 35 | if dataMessageIds, err = json.Marshal(r.MessageIds); err != nil { 36 | return 37 | } 38 | 39 | values["message_ids"] = string(dataMessageIds) 40 | 41 | if r.DisableNotification != nil { 42 | if *r.DisableNotification { 43 | values["disable_notification"] = "1" 44 | } else { 45 | values["disable_notification"] = "0" 46 | } 47 | } 48 | 49 | if r.MessageThreadId != nil { 50 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 51 | } 52 | 53 | if r.ProtectContent != nil { 54 | if *r.ProtectContent { 55 | values["protect_content"] = "1" 56 | } else { 57 | values["protect_content"] = "0" 58 | } 59 | } 60 | 61 | if r.RemoveCaption != nil { 62 | if *r.RemoveCaption { 63 | values["remove_caption"] = "1" 64 | } else { 65 | values["remove_caption"] = "0" 66 | } 67 | } 68 | 69 | return 70 | } 71 | 72 | func (r *CopyMessages) GetFiles() (files map[string]io.Reader) { 73 | return 74 | } 75 | -------------------------------------------------------------------------------- /requests/create_chat_invite_link.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type CreateChatInviteLink struct { 11 | ChatId telegram.ChatId 12 | CreatesJoinRequest *bool 13 | ExpireDate *int64 14 | MemberLimit *int64 15 | Name *string 16 | } 17 | 18 | func (r *CreateChatInviteLink) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 19 | response = new(telegram.ChatInviteLink) 20 | err = b.CallMethod(ctx, "createChatInviteLink", r, response) 21 | return 22 | } 23 | 24 | func (r *CreateChatInviteLink) GetValues() (values map[string]interface{}, err error) { 25 | values = make(map[string]interface{}) 26 | 27 | values["chat_id"] = r.ChatId.String() 28 | 29 | if r.CreatesJoinRequest != nil { 30 | if *r.CreatesJoinRequest { 31 | values["creates_join_request"] = "1" 32 | } else { 33 | values["creates_join_request"] = "0" 34 | } 35 | } 36 | 37 | if r.ExpireDate != nil { 38 | values["expire_date"] = strconv.FormatInt(*r.ExpireDate, 10) 39 | } 40 | 41 | if r.MemberLimit != nil { 42 | values["member_limit"] = strconv.FormatInt(*r.MemberLimit, 10) 43 | } 44 | 45 | if r.Name != nil { 46 | values["name"] = *r.Name 47 | } 48 | 49 | return 50 | } 51 | 52 | func (r *CreateChatInviteLink) GetFiles() (files map[string]io.Reader) { 53 | return 54 | } 55 | -------------------------------------------------------------------------------- /requests/create_chat_subscription_invite_link.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type CreateChatSubscriptionInviteLink struct { 11 | ChatId telegram.ChatId 12 | SubscriptionPeriod int64 13 | SubscriptionPrice int64 14 | Name *string 15 | } 16 | 17 | func (r *CreateChatSubscriptionInviteLink) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(telegram.ChatInviteLink) 19 | err = b.CallMethod(ctx, "createChatSubscriptionInviteLink", r, response) 20 | return 21 | } 22 | 23 | func (r *CreateChatSubscriptionInviteLink) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["chat_id"] = r.ChatId.String() 27 | 28 | values["subscription_period"] = strconv.FormatInt(r.SubscriptionPeriod, 10) 29 | 30 | values["subscription_price"] = strconv.FormatInt(r.SubscriptionPrice, 10) 31 | 32 | if r.Name != nil { 33 | values["name"] = *r.Name 34 | } 35 | 36 | return 37 | } 38 | 39 | func (r *CreateChatSubscriptionInviteLink) GetFiles() (files map[string]io.Reader) { 40 | return 41 | } 42 | -------------------------------------------------------------------------------- /requests/create_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type CreateForumTopic struct { 11 | ChatId telegram.ChatId 12 | Name string 13 | IconColor *int64 14 | IconCustomEmojiId *string 15 | } 16 | 17 | func (r *CreateForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(telegram.ForumTopic) 19 | err = b.CallMethod(ctx, "createForumTopic", r, response) 20 | return 21 | } 22 | 23 | func (r *CreateForumTopic) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["chat_id"] = r.ChatId.String() 27 | 28 | values["name"] = r.Name 29 | 30 | if r.IconColor != nil { 31 | values["icon_color"] = strconv.FormatInt(*r.IconColor, 10) 32 | } 33 | 34 | if r.IconCustomEmojiId != nil { 35 | values["icon_custom_emoji_id"] = *r.IconCustomEmojiId 36 | } 37 | 38 | return 39 | } 40 | 41 | func (r *CreateForumTopic) GetFiles() (files map[string]io.Reader) { 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /requests/create_new_sticker_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type CreateNewStickerSet struct { 12 | Name string 13 | Stickers []telegram.InputSticker 14 | Title string 15 | UserId int64 16 | NeedsRepainting *bool 17 | StickerType *string 18 | } 19 | 20 | func (r *CreateNewStickerSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new(bool) 22 | err = b.CallMethod(ctx, "createNewStickerSet", r, response) 23 | return 24 | } 25 | 26 | func (r *CreateNewStickerSet) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | values["name"] = r.Name 30 | 31 | var dataStickers []byte 32 | if dataStickers, err = json.Marshal(r.Stickers); err != nil { 33 | return 34 | } 35 | 36 | values["stickers"] = string(dataStickers) 37 | 38 | values["title"] = r.Title 39 | 40 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 41 | 42 | if r.NeedsRepainting != nil { 43 | if *r.NeedsRepainting { 44 | values["needs_repainting"] = "1" 45 | } else { 46 | values["needs_repainting"] = "0" 47 | } 48 | } 49 | 50 | if r.StickerType != nil { 51 | values["sticker_type"] = *r.StickerType 52 | } 53 | 54 | return 55 | } 56 | 57 | func (r *CreateNewStickerSet) GetFiles() (files map[string]io.Reader) { 58 | files = make(map[string]io.Reader) 59 | 60 | for _, item := range r.Stickers { 61 | if item.Sticker.HasFile() { 62 | files[item.Sticker.GetFormFieldName()] = item.Sticker.GetFile() 63 | } 64 | } 65 | 66 | return 67 | } 68 | -------------------------------------------------------------------------------- /requests/decline_chat_join_request.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type DeclineChatJoinRequest struct { 11 | ChatId telegram.ChatId 12 | UserId int64 13 | } 14 | 15 | func (r *DeclineChatJoinRequest) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "declineChatJoinRequest", r, response) 18 | return 19 | } 20 | 21 | func (r *DeclineChatJoinRequest) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *DeclineChatJoinRequest) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/delete_business_messages.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type DeleteBusinessMessages struct { 11 | BusinessConnectionId string 12 | MessageIds []int64 13 | } 14 | 15 | func (r *DeleteBusinessMessages) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "deleteBusinessMessages", r, response) 18 | return 19 | } 20 | 21 | func (r *DeleteBusinessMessages) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["business_connection_id"] = r.BusinessConnectionId 25 | 26 | var dataMessageIds []byte 27 | if dataMessageIds, err = json.Marshal(r.MessageIds); err != nil { 28 | return 29 | } 30 | 31 | values["message_ids"] = string(dataMessageIds) 32 | 33 | return 34 | } 35 | 36 | func (r *DeleteBusinessMessages) GetFiles() (files map[string]io.Reader) { 37 | return 38 | } 39 | -------------------------------------------------------------------------------- /requests/delete_chat_photo.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type DeleteChatPhoto struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *DeleteChatPhoto) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "deleteChatPhoto", r, response) 16 | return 17 | } 18 | 19 | func (r *DeleteChatPhoto) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *DeleteChatPhoto) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/delete_chat_sticker_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type DeleteChatStickerSet struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *DeleteChatStickerSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "deleteChatStickerSet", r, response) 16 | return 17 | } 18 | 19 | func (r *DeleteChatStickerSet) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *DeleteChatStickerSet) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/delete_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type DeleteForumTopic struct { 11 | ChatId telegram.ChatId 12 | MessageThreadId int64 13 | } 14 | 15 | func (r *DeleteForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "deleteForumTopic", r, response) 18 | return 19 | } 20 | 21 | func (r *DeleteForumTopic) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["message_thread_id"] = strconv.FormatInt(r.MessageThreadId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *DeleteForumTopic) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/delete_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type DeleteMessage struct { 11 | ChatId telegram.ChatId 12 | MessageId int64 13 | } 14 | 15 | func (r *DeleteMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "deleteMessage", r, response) 18 | return 19 | } 20 | 21 | func (r *DeleteMessage) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["message_id"] = strconv.FormatInt(r.MessageId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *DeleteMessage) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/delete_messages.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type DeleteMessages struct { 11 | ChatId telegram.ChatId 12 | MessageIds []int64 13 | } 14 | 15 | func (r *DeleteMessages) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "deleteMessages", r, response) 18 | return 19 | } 20 | 21 | func (r *DeleteMessages) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | var dataMessageIds []byte 27 | if dataMessageIds, err = json.Marshal(r.MessageIds); err != nil { 28 | return 29 | } 30 | 31 | values["message_ids"] = string(dataMessageIds) 32 | 33 | return 34 | } 35 | 36 | func (r *DeleteMessages) GetFiles() (files map[string]io.Reader) { 37 | return 38 | } 39 | -------------------------------------------------------------------------------- /requests/delete_my_commands.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type DeleteMyCommands struct { 11 | LanguageCode *string 12 | Scope interface{} 13 | } 14 | 15 | func (r *DeleteMyCommands) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "deleteMyCommands", r, response) 18 | return 19 | } 20 | 21 | func (r *DeleteMyCommands) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | if r.LanguageCode != nil { 25 | values["language_code"] = *r.LanguageCode 26 | } 27 | 28 | if r.Scope != nil { 29 | var dataScope []byte 30 | if dataScope, err = json.Marshal(r.Scope); err != nil { 31 | return 32 | } 33 | 34 | values["scope"] = string(dataScope) 35 | } 36 | 37 | return 38 | } 39 | 40 | func (r *DeleteMyCommands) GetFiles() (files map[string]io.Reader) { 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /requests/delete_sticker_from_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type DeleteStickerFromSet struct { 10 | Sticker string 11 | } 12 | 13 | func (r *DeleteStickerFromSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "deleteStickerFromSet", r, response) 16 | return 17 | } 18 | 19 | func (r *DeleteStickerFromSet) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["sticker"] = r.Sticker 23 | 24 | return 25 | } 26 | 27 | func (r *DeleteStickerFromSet) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/delete_sticker_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type DeleteStickerSet struct { 10 | Name string 11 | } 12 | 13 | func (r *DeleteStickerSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "deleteStickerSet", r, response) 16 | return 17 | } 18 | 19 | func (r *DeleteStickerSet) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["name"] = r.Name 23 | 24 | return 25 | } 26 | 27 | func (r *DeleteStickerSet) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/delete_story.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type DeleteStory struct { 11 | BusinessConnectionId string 12 | StoryId int64 13 | } 14 | 15 | func (r *DeleteStory) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "deleteStory", r, response) 18 | return 19 | } 20 | 21 | func (r *DeleteStory) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["business_connection_id"] = r.BusinessConnectionId 25 | 26 | values["story_id"] = strconv.FormatInt(r.StoryId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *DeleteStory) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/delete_webhook.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type DeleteWebhook struct { 10 | DropPendingUpdates *bool 11 | } 12 | 13 | func (r *DeleteWebhook) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "deleteWebhook", r, response) 16 | return 17 | } 18 | 19 | func (r *DeleteWebhook) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | if r.DropPendingUpdates != nil { 23 | if *r.DropPendingUpdates { 24 | values["drop_pending_updates"] = "1" 25 | } else { 26 | values["drop_pending_updates"] = "0" 27 | } 28 | } 29 | 30 | return 31 | } 32 | 33 | func (r *DeleteWebhook) GetFiles() (files map[string]io.Reader) { 34 | return 35 | } 36 | -------------------------------------------------------------------------------- /requests/edit_chat_invite_link.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type EditChatInviteLink struct { 11 | ChatId telegram.ChatId 12 | InviteLink string 13 | CreatesJoinRequest *bool 14 | ExpireDate *int64 15 | MemberLimit *int64 16 | Name *string 17 | } 18 | 19 | func (r *EditChatInviteLink) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 20 | response = new(telegram.ChatInviteLink) 21 | err = b.CallMethod(ctx, "editChatInviteLink", r, response) 22 | return 23 | } 24 | 25 | func (r *EditChatInviteLink) GetValues() (values map[string]interface{}, err error) { 26 | values = make(map[string]interface{}) 27 | 28 | values["chat_id"] = r.ChatId.String() 29 | 30 | values["invite_link"] = r.InviteLink 31 | 32 | if r.CreatesJoinRequest != nil { 33 | if *r.CreatesJoinRequest { 34 | values["creates_join_request"] = "1" 35 | } else { 36 | values["creates_join_request"] = "0" 37 | } 38 | } 39 | 40 | if r.ExpireDate != nil { 41 | values["expire_date"] = strconv.FormatInt(*r.ExpireDate, 10) 42 | } 43 | 44 | if r.MemberLimit != nil { 45 | values["member_limit"] = strconv.FormatInt(*r.MemberLimit, 10) 46 | } 47 | 48 | if r.Name != nil { 49 | values["name"] = *r.Name 50 | } 51 | 52 | return 53 | } 54 | 55 | func (r *EditChatInviteLink) GetFiles() (files map[string]io.Reader) { 56 | return 57 | } 58 | -------------------------------------------------------------------------------- /requests/edit_chat_subscription_invite_link.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type EditChatSubscriptionInviteLink struct { 10 | ChatId telegram.ChatId 11 | InviteLink string 12 | Name *string 13 | } 14 | 15 | func (r *EditChatSubscriptionInviteLink) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(telegram.ChatInviteLink) 17 | err = b.CallMethod(ctx, "editChatSubscriptionInviteLink", r, response) 18 | return 19 | } 20 | 21 | func (r *EditChatSubscriptionInviteLink) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["invite_link"] = r.InviteLink 27 | 28 | if r.Name != nil { 29 | values["name"] = *r.Name 30 | } 31 | 32 | return 33 | } 34 | 35 | func (r *EditChatSubscriptionInviteLink) GetFiles() (files map[string]io.Reader) { 36 | return 37 | } 38 | -------------------------------------------------------------------------------- /requests/edit_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type EditForumTopic struct { 11 | ChatId telegram.ChatId 12 | MessageThreadId int64 13 | IconCustomEmojiId *string 14 | Name *string 15 | } 16 | 17 | func (r *EditForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "editForumTopic", r, response) 20 | return 21 | } 22 | 23 | func (r *EditForumTopic) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["chat_id"] = r.ChatId.String() 27 | 28 | values["message_thread_id"] = strconv.FormatInt(r.MessageThreadId, 10) 29 | 30 | if r.IconCustomEmojiId != nil { 31 | values["icon_custom_emoji_id"] = *r.IconCustomEmojiId 32 | } 33 | 34 | if r.Name != nil { 35 | values["name"] = *r.Name 36 | } 37 | 38 | return 39 | } 40 | 41 | func (r *EditForumTopic) GetFiles() (files map[string]io.Reader) { 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /requests/edit_general_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type EditGeneralForumTopic struct { 10 | ChatId telegram.ChatId 11 | Name string 12 | } 13 | 14 | func (r *EditGeneralForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "editGeneralForumTopic", r, response) 17 | return 18 | } 19 | 20 | func (r *EditGeneralForumTopic) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["chat_id"] = r.ChatId.String() 24 | 25 | values["name"] = r.Name 26 | 27 | return 28 | } 29 | 30 | func (r *EditGeneralForumTopic) GetFiles() (files map[string]io.Reader) { 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /requests/edit_message_caption.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type EditMessageCaption struct { 12 | BusinessConnectionId *string 13 | Caption *string 14 | CaptionEntities []telegram.MessageEntity 15 | ChatId *telegram.ChatId 16 | InlineMessageId *string 17 | MessageId *int64 18 | ParseMode *string 19 | ReplyMarkup *telegram.InlineKeyboardMarkup 20 | ShowCaptionAboveMedia *bool 21 | } 22 | 23 | func (r *EditMessageCaption) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 24 | response = new(telegram.Message) 25 | err = b.CallMethod(ctx, "editMessageCaption", r, response) 26 | return 27 | } 28 | 29 | func (r *EditMessageCaption) GetValues() (values map[string]interface{}, err error) { 30 | values = make(map[string]interface{}) 31 | 32 | if r.BusinessConnectionId != nil { 33 | values["business_connection_id"] = *r.BusinessConnectionId 34 | } 35 | 36 | if r.Caption != nil { 37 | values["caption"] = *r.Caption 38 | } 39 | 40 | if r.CaptionEntities != nil { 41 | var dataCaptionEntities []byte 42 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 43 | return 44 | } 45 | 46 | values["caption_entities"] = string(dataCaptionEntities) 47 | } 48 | 49 | if r.ChatId != nil { 50 | values["chat_id"] = r.ChatId.String() 51 | } 52 | 53 | if r.InlineMessageId != nil { 54 | values["inline_message_id"] = *r.InlineMessageId 55 | } 56 | 57 | if r.MessageId != nil { 58 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 59 | } 60 | 61 | if r.ParseMode != nil { 62 | values["parse_mode"] = *r.ParseMode 63 | } 64 | 65 | if r.ReplyMarkup != nil { 66 | var dataReplyMarkup []byte 67 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 68 | return 69 | } 70 | 71 | values["reply_markup"] = string(dataReplyMarkup) 72 | } 73 | 74 | if r.ShowCaptionAboveMedia != nil { 75 | if *r.ShowCaptionAboveMedia { 76 | values["show_caption_above_media"] = "1" 77 | } else { 78 | values["show_caption_above_media"] = "0" 79 | } 80 | } 81 | 82 | return 83 | } 84 | 85 | func (r *EditMessageCaption) GetFiles() (files map[string]io.Reader) { 86 | return 87 | } 88 | -------------------------------------------------------------------------------- /requests/edit_message_live_location.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type EditMessageLiveLocation struct { 12 | Latitude float64 13 | Longitude float64 14 | BusinessConnectionId *string 15 | ChatId *telegram.ChatId 16 | Heading *int64 17 | HorizontalAccuracy *float64 18 | InlineMessageId *string 19 | LivePeriod *int64 20 | MessageId *int64 21 | ProximityAlertRadius *int64 22 | ReplyMarkup *telegram.InlineKeyboardMarkup 23 | } 24 | 25 | func (r *EditMessageLiveLocation) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 26 | response = new(telegram.Message) 27 | err = b.CallMethod(ctx, "editMessageLiveLocation", r, response) 28 | return 29 | } 30 | 31 | func (r *EditMessageLiveLocation) GetValues() (values map[string]interface{}, err error) { 32 | values = make(map[string]interface{}) 33 | 34 | values["latitude"] = strconv.FormatFloat(r.Latitude, 'f', -1, 64) 35 | 36 | values["longitude"] = strconv.FormatFloat(r.Longitude, 'f', -1, 64) 37 | 38 | if r.BusinessConnectionId != nil { 39 | values["business_connection_id"] = *r.BusinessConnectionId 40 | } 41 | 42 | if r.ChatId != nil { 43 | values["chat_id"] = r.ChatId.String() 44 | } 45 | 46 | if r.Heading != nil { 47 | values["heading"] = strconv.FormatInt(*r.Heading, 10) 48 | } 49 | 50 | if r.HorizontalAccuracy != nil { 51 | values["horizontal_accuracy"] = strconv.FormatFloat(*r.HorizontalAccuracy, 'f', -1, 64) 52 | } 53 | 54 | if r.InlineMessageId != nil { 55 | values["inline_message_id"] = *r.InlineMessageId 56 | } 57 | 58 | if r.LivePeriod != nil { 59 | values["live_period"] = strconv.FormatInt(*r.LivePeriod, 10) 60 | } 61 | 62 | if r.MessageId != nil { 63 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 64 | } 65 | 66 | if r.ProximityAlertRadius != nil { 67 | values["proximity_alert_radius"] = strconv.FormatInt(*r.ProximityAlertRadius, 10) 68 | } 69 | 70 | if r.ReplyMarkup != nil { 71 | var dataReplyMarkup []byte 72 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 73 | return 74 | } 75 | 76 | values["reply_markup"] = string(dataReplyMarkup) 77 | } 78 | 79 | return 80 | } 81 | 82 | func (r *EditMessageLiveLocation) GetFiles() (files map[string]io.Reader) { 83 | return 84 | } 85 | -------------------------------------------------------------------------------- /requests/edit_message_media.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type EditMessageMedia struct { 12 | Media interface{} 13 | BusinessConnectionId *string 14 | ChatId *telegram.ChatId 15 | InlineMessageId *string 16 | MessageId *int64 17 | ReplyMarkup *telegram.InlineKeyboardMarkup 18 | } 19 | 20 | func (r *EditMessageMedia) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new(telegram.Message) 22 | err = b.CallMethod(ctx, "editMessageMedia", r, response) 23 | return 24 | } 25 | 26 | func (r *EditMessageMedia) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | var dataMedia []byte 30 | if dataMedia, err = json.Marshal(r.Media); err != nil { 31 | return 32 | } 33 | 34 | values["media"] = string(dataMedia) 35 | 36 | if r.BusinessConnectionId != nil { 37 | values["business_connection_id"] = *r.BusinessConnectionId 38 | } 39 | 40 | if r.ChatId != nil { 41 | values["chat_id"] = r.ChatId.String() 42 | } 43 | 44 | if r.InlineMessageId != nil { 45 | values["inline_message_id"] = *r.InlineMessageId 46 | } 47 | 48 | if r.MessageId != nil { 49 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 50 | } 51 | 52 | if r.ReplyMarkup != nil { 53 | var dataReplyMarkup []byte 54 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 55 | return 56 | } 57 | 58 | values["reply_markup"] = string(dataReplyMarkup) 59 | } 60 | 61 | return 62 | } 63 | 64 | func (r *EditMessageMedia) GetFiles() (files map[string]io.Reader) { 65 | files = make(map[string]io.Reader) 66 | 67 | switch value := r.Media.(type) { 68 | case telegram.InputMediaAnimation: 69 | if value.Media.HasFile() { 70 | files[value.Media.GetFormFieldName()] = value.Media.GetFile() 71 | } 72 | if value.Thumbnail != nil && value.Thumbnail.HasFile() { 73 | files[value.Thumbnail.GetFormFieldName()] = value.Thumbnail.GetFile() 74 | } 75 | case telegram.InputMediaDocument: 76 | if value.Media.HasFile() { 77 | files[value.Media.GetFormFieldName()] = value.Media.GetFile() 78 | } 79 | if value.Thumbnail != nil && value.Thumbnail.HasFile() { 80 | files[value.Thumbnail.GetFormFieldName()] = value.Thumbnail.GetFile() 81 | } 82 | case telegram.InputMediaAudio: 83 | if value.Media.HasFile() { 84 | files[value.Media.GetFormFieldName()] = value.Media.GetFile() 85 | } 86 | if value.Thumbnail != nil && value.Thumbnail.HasFile() { 87 | files[value.Thumbnail.GetFormFieldName()] = value.Thumbnail.GetFile() 88 | } 89 | case telegram.InputMediaPhoto: 90 | if value.Media.HasFile() { 91 | files[value.Media.GetFormFieldName()] = value.Media.GetFile() 92 | } 93 | case telegram.InputMediaVideo: 94 | if value.Media.HasFile() { 95 | files[value.Media.GetFormFieldName()] = value.Media.GetFile() 96 | } 97 | if value.Thumbnail != nil && value.Thumbnail.HasFile() { 98 | files[value.Thumbnail.GetFormFieldName()] = value.Thumbnail.GetFile() 99 | } 100 | if value.Cover != nil && value.Cover.HasFile() { 101 | files[value.Cover.GetFormFieldName()] = value.Cover.GetFile() 102 | } 103 | } 104 | 105 | return 106 | } 107 | -------------------------------------------------------------------------------- /requests/edit_message_reply_markup.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type EditMessageReplyMarkup struct { 12 | BusinessConnectionId *string 13 | ChatId *telegram.ChatId 14 | InlineMessageId *string 15 | MessageId *int64 16 | ReplyMarkup *telegram.InlineKeyboardMarkup 17 | } 18 | 19 | func (r *EditMessageReplyMarkup) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 20 | response = new(telegram.Message) 21 | err = b.CallMethod(ctx, "editMessageReplyMarkup", r, response) 22 | return 23 | } 24 | 25 | func (r *EditMessageReplyMarkup) GetValues() (values map[string]interface{}, err error) { 26 | values = make(map[string]interface{}) 27 | 28 | if r.BusinessConnectionId != nil { 29 | values["business_connection_id"] = *r.BusinessConnectionId 30 | } 31 | 32 | if r.ChatId != nil { 33 | values["chat_id"] = r.ChatId.String() 34 | } 35 | 36 | if r.InlineMessageId != nil { 37 | values["inline_message_id"] = *r.InlineMessageId 38 | } 39 | 40 | if r.MessageId != nil { 41 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 42 | } 43 | 44 | if r.ReplyMarkup != nil { 45 | var dataReplyMarkup []byte 46 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 47 | return 48 | } 49 | 50 | values["reply_markup"] = string(dataReplyMarkup) 51 | } 52 | 53 | return 54 | } 55 | 56 | func (r *EditMessageReplyMarkup) GetFiles() (files map[string]io.Reader) { 57 | return 58 | } 59 | -------------------------------------------------------------------------------- /requests/edit_message_text.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type EditMessageText struct { 12 | Text string 13 | BusinessConnectionId *string 14 | ChatId *telegram.ChatId 15 | Entities []telegram.MessageEntity 16 | InlineMessageId *string 17 | LinkPreviewOptions *telegram.LinkPreviewOptions 18 | MessageId *int64 19 | ParseMode *string 20 | ReplyMarkup *telegram.InlineKeyboardMarkup 21 | } 22 | 23 | func (r *EditMessageText) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 24 | response = new(telegram.Message) 25 | err = b.CallMethod(ctx, "editMessageText", r, response) 26 | return 27 | } 28 | 29 | func (r *EditMessageText) GetValues() (values map[string]interface{}, err error) { 30 | values = make(map[string]interface{}) 31 | 32 | values["text"] = r.Text 33 | 34 | if r.BusinessConnectionId != nil { 35 | values["business_connection_id"] = *r.BusinessConnectionId 36 | } 37 | 38 | if r.ChatId != nil { 39 | values["chat_id"] = r.ChatId.String() 40 | } 41 | 42 | if r.Entities != nil { 43 | var dataEntities []byte 44 | if dataEntities, err = json.Marshal(r.Entities); err != nil { 45 | return 46 | } 47 | 48 | values["entities"] = string(dataEntities) 49 | } 50 | 51 | if r.InlineMessageId != nil { 52 | values["inline_message_id"] = *r.InlineMessageId 53 | } 54 | 55 | if r.LinkPreviewOptions != nil { 56 | var dataLinkPreviewOptions []byte 57 | if dataLinkPreviewOptions, err = json.Marshal(r.LinkPreviewOptions); err != nil { 58 | return 59 | } 60 | 61 | values["link_preview_options"] = string(dataLinkPreviewOptions) 62 | } 63 | 64 | if r.MessageId != nil { 65 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 66 | } 67 | 68 | if r.ParseMode != nil { 69 | values["parse_mode"] = *r.ParseMode 70 | } 71 | 72 | if r.ReplyMarkup != nil { 73 | var dataReplyMarkup []byte 74 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 75 | return 76 | } 77 | 78 | values["reply_markup"] = string(dataReplyMarkup) 79 | } 80 | 81 | return 82 | } 83 | 84 | func (r *EditMessageText) GetFiles() (files map[string]io.Reader) { 85 | return 86 | } 87 | -------------------------------------------------------------------------------- /requests/edit_story.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type EditStory struct { 12 | BusinessConnectionId string 13 | Content interface{} 14 | StoryId int64 15 | Areas []telegram.StoryArea 16 | Caption *string 17 | CaptionEntities []telegram.MessageEntity 18 | ParseMode *string 19 | } 20 | 21 | func (r *EditStory) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 22 | response = new(telegram.Story) 23 | err = b.CallMethod(ctx, "editStory", r, response) 24 | return 25 | } 26 | 27 | func (r *EditStory) GetValues() (values map[string]interface{}, err error) { 28 | values = make(map[string]interface{}) 29 | 30 | values["business_connection_id"] = r.BusinessConnectionId 31 | 32 | var dataContent []byte 33 | if dataContent, err = json.Marshal(r.Content); err != nil { 34 | return 35 | } 36 | 37 | values["content"] = string(dataContent) 38 | 39 | values["story_id"] = strconv.FormatInt(r.StoryId, 10) 40 | 41 | if r.Areas != nil { 42 | var dataAreas []byte 43 | if dataAreas, err = json.Marshal(r.Areas); err != nil { 44 | return 45 | } 46 | 47 | values["areas"] = string(dataAreas) 48 | } 49 | 50 | if r.Caption != nil { 51 | values["caption"] = *r.Caption 52 | } 53 | 54 | if r.CaptionEntities != nil { 55 | var dataCaptionEntities []byte 56 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 57 | return 58 | } 59 | 60 | values["caption_entities"] = string(dataCaptionEntities) 61 | } 62 | 63 | if r.ParseMode != nil { 64 | values["parse_mode"] = *r.ParseMode 65 | } 66 | 67 | return 68 | } 69 | 70 | func (r *EditStory) GetFiles() (files map[string]io.Reader) { 71 | files = make(map[string]io.Reader) 72 | 73 | switch value := r.Content.(type) { 74 | case telegram.InputStoryContentPhoto: 75 | if value.Photo.HasFile() { 76 | files[value.Photo.GetFormFieldName()] = value.Photo.GetFile() 77 | } 78 | case telegram.InputStoryContentVideo: 79 | if value.Video.HasFile() { 80 | files[value.Video.GetFormFieldName()] = value.Video.GetFile() 81 | } 82 | } 83 | 84 | return 85 | } 86 | -------------------------------------------------------------------------------- /requests/edit_user_star_subscription.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type EditUserStarSubscription struct { 11 | IsCanceled bool 12 | TelegramPaymentChargeId string 13 | UserId int64 14 | } 15 | 16 | func (r *EditUserStarSubscription) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "editUserStarSubscription", r, response) 19 | return 20 | } 21 | 22 | func (r *EditUserStarSubscription) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | if r.IsCanceled { 26 | values["is_canceled"] = "1" 27 | } else { 28 | values["is_canceled"] = "0" 29 | } 30 | 31 | values["telegram_payment_charge_id"] = r.TelegramPaymentChargeId 32 | 33 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 34 | 35 | return 36 | } 37 | 38 | func (r *EditUserStarSubscription) GetFiles() (files map[string]io.Reader) { 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /requests/export_chat_invite_link.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type ExportChatInviteLink struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *ExportChatInviteLink) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(string) 15 | err = b.CallMethod(ctx, "exportChatInviteLink", r, response) 16 | return 17 | } 18 | 19 | func (r *ExportChatInviteLink) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *ExportChatInviteLink) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/forward_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type ForwardMessage struct { 11 | ChatId telegram.ChatId 12 | FromChatId telegram.ChatId 13 | MessageId int64 14 | DisableNotification *bool 15 | MessageThreadId *int64 16 | ProtectContent *bool 17 | VideoStartTimestamp *int64 18 | } 19 | 20 | func (r *ForwardMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new(telegram.Message) 22 | err = b.CallMethod(ctx, "forwardMessage", r, response) 23 | return 24 | } 25 | 26 | func (r *ForwardMessage) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | values["chat_id"] = r.ChatId.String() 30 | 31 | values["from_chat_id"] = r.FromChatId.String() 32 | 33 | values["message_id"] = strconv.FormatInt(r.MessageId, 10) 34 | 35 | if r.DisableNotification != nil { 36 | if *r.DisableNotification { 37 | values["disable_notification"] = "1" 38 | } else { 39 | values["disable_notification"] = "0" 40 | } 41 | } 42 | 43 | if r.MessageThreadId != nil { 44 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 45 | } 46 | 47 | if r.ProtectContent != nil { 48 | if *r.ProtectContent { 49 | values["protect_content"] = "1" 50 | } else { 51 | values["protect_content"] = "0" 52 | } 53 | } 54 | 55 | if r.VideoStartTimestamp != nil { 56 | values["video_start_timestamp"] = strconv.FormatInt(*r.VideoStartTimestamp, 10) 57 | } 58 | 59 | return 60 | } 61 | 62 | func (r *ForwardMessage) GetFiles() (files map[string]io.Reader) { 63 | return 64 | } 65 | -------------------------------------------------------------------------------- /requests/forward_messages.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type ForwardMessages struct { 12 | ChatId telegram.ChatId 13 | FromChatId telegram.ChatId 14 | MessageIds []int64 15 | DisableNotification *bool 16 | MessageThreadId *int64 17 | ProtectContent *bool 18 | } 19 | 20 | func (r *ForwardMessages) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new([]telegram.MessageId) 22 | err = b.CallMethod(ctx, "forwardMessages", r, response) 23 | return 24 | } 25 | 26 | func (r *ForwardMessages) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | values["chat_id"] = r.ChatId.String() 30 | 31 | values["from_chat_id"] = r.FromChatId.String() 32 | 33 | var dataMessageIds []byte 34 | if dataMessageIds, err = json.Marshal(r.MessageIds); err != nil { 35 | return 36 | } 37 | 38 | values["message_ids"] = string(dataMessageIds) 39 | 40 | if r.DisableNotification != nil { 41 | if *r.DisableNotification { 42 | values["disable_notification"] = "1" 43 | } else { 44 | values["disable_notification"] = "0" 45 | } 46 | } 47 | 48 | if r.MessageThreadId != nil { 49 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 50 | } 51 | 52 | if r.ProtectContent != nil { 53 | if *r.ProtectContent { 54 | values["protect_content"] = "1" 55 | } else { 56 | values["protect_content"] = "0" 57 | } 58 | } 59 | 60 | return 61 | } 62 | 63 | func (r *ForwardMessages) GetFiles() (files map[string]io.Reader) { 64 | return 65 | } 66 | -------------------------------------------------------------------------------- /requests/get_available_gifts.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetAvailableGifts struct { 10 | } 11 | 12 | func (r *GetAvailableGifts) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 13 | response = new(telegram.Gifts) 14 | err = b.CallMethod(ctx, "getAvailableGifts", r, response) 15 | return 16 | } 17 | 18 | func (r *GetAvailableGifts) GetValues() (values map[string]interface{}, err error) { 19 | return 20 | } 21 | 22 | func (r *GetAvailableGifts) GetFiles() (files map[string]io.Reader) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /requests/get_business_account_gifts.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type GetBusinessAccountGifts struct { 11 | BusinessConnectionId string 12 | ExcludeLimited *bool 13 | ExcludeSaved *bool 14 | ExcludeUnique *bool 15 | ExcludeUnlimited *bool 16 | ExcludeUnsaved *bool 17 | Limit *int64 18 | Offset *string 19 | SortByPrice *bool 20 | } 21 | 22 | func (r *GetBusinessAccountGifts) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 23 | response = new(telegram.OwnedGifts) 24 | err = b.CallMethod(ctx, "getBusinessAccountGifts", r, response) 25 | return 26 | } 27 | 28 | func (r *GetBusinessAccountGifts) GetValues() (values map[string]interface{}, err error) { 29 | values = make(map[string]interface{}) 30 | 31 | values["business_connection_id"] = r.BusinessConnectionId 32 | 33 | if r.ExcludeLimited != nil { 34 | if *r.ExcludeLimited { 35 | values["exclude_limited"] = "1" 36 | } else { 37 | values["exclude_limited"] = "0" 38 | } 39 | } 40 | 41 | if r.ExcludeSaved != nil { 42 | if *r.ExcludeSaved { 43 | values["exclude_saved"] = "1" 44 | } else { 45 | values["exclude_saved"] = "0" 46 | } 47 | } 48 | 49 | if r.ExcludeUnique != nil { 50 | if *r.ExcludeUnique { 51 | values["exclude_unique"] = "1" 52 | } else { 53 | values["exclude_unique"] = "0" 54 | } 55 | } 56 | 57 | if r.ExcludeUnlimited != nil { 58 | if *r.ExcludeUnlimited { 59 | values["exclude_unlimited"] = "1" 60 | } else { 61 | values["exclude_unlimited"] = "0" 62 | } 63 | } 64 | 65 | if r.ExcludeUnsaved != nil { 66 | if *r.ExcludeUnsaved { 67 | values["exclude_unsaved"] = "1" 68 | } else { 69 | values["exclude_unsaved"] = "0" 70 | } 71 | } 72 | 73 | if r.Limit != nil { 74 | values["limit"] = strconv.FormatInt(*r.Limit, 10) 75 | } 76 | 77 | if r.Offset != nil { 78 | values["offset"] = *r.Offset 79 | } 80 | 81 | if r.SortByPrice != nil { 82 | if *r.SortByPrice { 83 | values["sort_by_price"] = "1" 84 | } else { 85 | values["sort_by_price"] = "0" 86 | } 87 | } 88 | 89 | return 90 | } 91 | 92 | func (r *GetBusinessAccountGifts) GetFiles() (files map[string]io.Reader) { 93 | return 94 | } 95 | -------------------------------------------------------------------------------- /requests/get_business_account_star_balance.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetBusinessAccountStarBalance struct { 10 | BusinessConnectionId string 11 | } 12 | 13 | func (r *GetBusinessAccountStarBalance) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.StarAmount) 15 | err = b.CallMethod(ctx, "getBusinessAccountStarBalance", r, response) 16 | return 17 | } 18 | 19 | func (r *GetBusinessAccountStarBalance) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["business_connection_id"] = r.BusinessConnectionId 23 | 24 | return 25 | } 26 | 27 | func (r *GetBusinessAccountStarBalance) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/get_business_connection.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetBusinessConnection struct { 10 | BusinessConnectionId string 11 | } 12 | 13 | func (r *GetBusinessConnection) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.BusinessConnection) 15 | err = b.CallMethod(ctx, "getBusinessConnection", r, response) 16 | return 17 | } 18 | 19 | func (r *GetBusinessConnection) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["business_connection_id"] = r.BusinessConnectionId 23 | 24 | return 25 | } 26 | 27 | func (r *GetBusinessConnection) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/get_chat.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetChat struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *GetChat) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.ChatFullInfo) 15 | err = b.CallMethod(ctx, "getChat", r, response) 16 | return 17 | } 18 | 19 | func (r *GetChat) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *GetChat) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/get_chat_administrators.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetChatAdministrators struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *GetChatAdministrators) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new([]interface{}) 15 | err = b.CallMethod(ctx, "getChatAdministrators", r, response) 16 | return 17 | } 18 | 19 | func (r *GetChatAdministrators) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *GetChatAdministrators) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/get_chat_member.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type GetChatMember struct { 12 | ChatId telegram.ChatId 13 | UserId int64 14 | } 15 | 16 | func (r *GetChatMember) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(interface{}) 18 | err = b.CallMethod(ctx, "getChatMember", r, response) 19 | return 20 | } 21 | 22 | func (r *GetChatMember) CallWithResponse(ctx context.Context, b *telegram.Bot, response interface{}) (err error) { 23 | switch response.(type) { 24 | case *telegram.ChatMemberOwner, *telegram.ChatMemberAdministrator, *telegram.ChatMemberMember, *telegram.ChatMemberRestricted, *telegram.ChatMemberLeft, *telegram.ChatMemberBanned: 25 | err = b.CallMethod(ctx, "getChatMember", r, response) 26 | default: 27 | err = errors.New("unsupported response type") 28 | } 29 | 30 | return 31 | } 32 | 33 | func (r *GetChatMember) GetValues() (values map[string]interface{}, err error) { 34 | values = make(map[string]interface{}) 35 | 36 | values["chat_id"] = r.ChatId.String() 37 | 38 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 39 | 40 | return 41 | } 42 | 43 | func (r *GetChatMember) GetFiles() (files map[string]io.Reader) { 44 | return 45 | } 46 | -------------------------------------------------------------------------------- /requests/get_chat_member_count.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetChatMemberCount struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *GetChatMemberCount) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(int64) 15 | err = b.CallMethod(ctx, "getChatMemberCount", r, response) 16 | return 17 | } 18 | 19 | func (r *GetChatMemberCount) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *GetChatMemberCount) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/get_chat_menu_button.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type GetChatMenuButton struct { 12 | ChatId *int64 13 | } 14 | 15 | func (r *GetChatMenuButton) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(interface{}) 17 | err = b.CallMethod(ctx, "getChatMenuButton", r, response) 18 | return 19 | } 20 | 21 | func (r *GetChatMenuButton) CallWithResponse(ctx context.Context, b *telegram.Bot, response interface{}) (err error) { 22 | switch response.(type) { 23 | case *telegram.MenuButtonCommands, *telegram.MenuButtonWebApp, *telegram.MenuButtonDefault: 24 | err = b.CallMethod(ctx, "getChatMenuButton", r, response) 25 | default: 26 | err = errors.New("unsupported response type") 27 | } 28 | 29 | return 30 | } 31 | 32 | func (r *GetChatMenuButton) GetValues() (values map[string]interface{}, err error) { 33 | values = make(map[string]interface{}) 34 | 35 | if r.ChatId != nil { 36 | values["chat_id"] = strconv.FormatInt(*r.ChatId, 10) 37 | } 38 | 39 | return 40 | } 41 | 42 | func (r *GetChatMenuButton) GetFiles() (files map[string]io.Reader) { 43 | return 44 | } 45 | -------------------------------------------------------------------------------- /requests/get_custom_emoji_stickers.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type GetCustomEmojiStickers struct { 11 | CustomEmojiIds []string 12 | } 13 | 14 | func (r *GetCustomEmojiStickers) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new([]telegram.Sticker) 16 | err = b.CallMethod(ctx, "getCustomEmojiStickers", r, response) 17 | return 18 | } 19 | 20 | func (r *GetCustomEmojiStickers) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | var dataCustomEmojiIds []byte 24 | if dataCustomEmojiIds, err = json.Marshal(r.CustomEmojiIds); err != nil { 25 | return 26 | } 27 | 28 | values["custom_emoji_ids"] = string(dataCustomEmojiIds) 29 | 30 | return 31 | } 32 | 33 | func (r *GetCustomEmojiStickers) GetFiles() (files map[string]io.Reader) { 34 | return 35 | } 36 | -------------------------------------------------------------------------------- /requests/get_file.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetFile struct { 10 | FileId string 11 | } 12 | 13 | func (r *GetFile) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.File) 15 | err = b.CallMethod(ctx, "getFile", r, response) 16 | return 17 | } 18 | 19 | func (r *GetFile) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["file_id"] = r.FileId 23 | 24 | return 25 | } 26 | 27 | func (r *GetFile) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/get_forum_topic_icon_stickers.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetForumTopicIconStickers struct { 10 | } 11 | 12 | func (r *GetForumTopicIconStickers) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 13 | response = new([]telegram.Sticker) 14 | err = b.CallMethod(ctx, "getForumTopicIconStickers", r, response) 15 | return 16 | } 17 | 18 | func (r *GetForumTopicIconStickers) GetValues() (values map[string]interface{}, err error) { 19 | return 20 | } 21 | 22 | func (r *GetForumTopicIconStickers) GetFiles() (files map[string]io.Reader) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /requests/get_game_high_scores.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type GetGameHighScores struct { 11 | UserId int64 12 | ChatId *int64 13 | InlineMessageId *string 14 | MessageId *int64 15 | } 16 | 17 | func (r *GetGameHighScores) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new([]telegram.GameHighScore) 19 | err = b.CallMethod(ctx, "getGameHighScores", r, response) 20 | return 21 | } 22 | 23 | func (r *GetGameHighScores) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 27 | 28 | if r.ChatId != nil { 29 | values["chat_id"] = strconv.FormatInt(*r.ChatId, 10) 30 | } 31 | 32 | if r.InlineMessageId != nil { 33 | values["inline_message_id"] = *r.InlineMessageId 34 | } 35 | 36 | if r.MessageId != nil { 37 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 38 | } 39 | 40 | return 41 | } 42 | 43 | func (r *GetGameHighScores) GetFiles() (files map[string]io.Reader) { 44 | return 45 | } 46 | -------------------------------------------------------------------------------- /requests/get_me.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetMe struct { 10 | } 11 | 12 | func (r *GetMe) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 13 | response = new(telegram.User) 14 | err = b.CallMethod(ctx, "getMe", r, response) 15 | return 16 | } 17 | 18 | func (r *GetMe) GetValues() (values map[string]interface{}, err error) { 19 | return 20 | } 21 | 22 | func (r *GetMe) GetFiles() (files map[string]io.Reader) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /requests/get_my_commands.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type GetMyCommands struct { 11 | LanguageCode *string 12 | Scope interface{} 13 | } 14 | 15 | func (r *GetMyCommands) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new([]telegram.BotCommand) 17 | err = b.CallMethod(ctx, "getMyCommands", r, response) 18 | return 19 | } 20 | 21 | func (r *GetMyCommands) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | if r.LanguageCode != nil { 25 | values["language_code"] = *r.LanguageCode 26 | } 27 | 28 | if r.Scope != nil { 29 | var dataScope []byte 30 | if dataScope, err = json.Marshal(r.Scope); err != nil { 31 | return 32 | } 33 | 34 | values["scope"] = string(dataScope) 35 | } 36 | 37 | return 38 | } 39 | 40 | func (r *GetMyCommands) GetFiles() (files map[string]io.Reader) { 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /requests/get_my_default_administrator_rights.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetMyDefaultAdministratorRights struct { 10 | ForChannels *bool 11 | } 12 | 13 | func (r *GetMyDefaultAdministratorRights) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.ChatAdministratorRights) 15 | err = b.CallMethod(ctx, "getMyDefaultAdministratorRights", r, response) 16 | return 17 | } 18 | 19 | func (r *GetMyDefaultAdministratorRights) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | if r.ForChannels != nil { 23 | if *r.ForChannels { 24 | values["for_channels"] = "1" 25 | } else { 26 | values["for_channels"] = "0" 27 | } 28 | } 29 | 30 | return 31 | } 32 | 33 | func (r *GetMyDefaultAdministratorRights) GetFiles() (files map[string]io.Reader) { 34 | return 35 | } 36 | -------------------------------------------------------------------------------- /requests/get_my_description.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetMyDescription struct { 10 | LanguageCode *string 11 | } 12 | 13 | func (r *GetMyDescription) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.BotDescription) 15 | err = b.CallMethod(ctx, "getMyDescription", r, response) 16 | return 17 | } 18 | 19 | func (r *GetMyDescription) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | if r.LanguageCode != nil { 23 | values["language_code"] = *r.LanguageCode 24 | } 25 | 26 | return 27 | } 28 | 29 | func (r *GetMyDescription) GetFiles() (files map[string]io.Reader) { 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /requests/get_my_name.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetMyName struct { 10 | LanguageCode *string 11 | } 12 | 13 | func (r *GetMyName) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.BotName) 15 | err = b.CallMethod(ctx, "getMyName", r, response) 16 | return 17 | } 18 | 19 | func (r *GetMyName) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | if r.LanguageCode != nil { 23 | values["language_code"] = *r.LanguageCode 24 | } 25 | 26 | return 27 | } 28 | 29 | func (r *GetMyName) GetFiles() (files map[string]io.Reader) { 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /requests/get_my_short_description.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetMyShortDescription struct { 10 | LanguageCode *string 11 | } 12 | 13 | func (r *GetMyShortDescription) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.BotShortDescription) 15 | err = b.CallMethod(ctx, "getMyShortDescription", r, response) 16 | return 17 | } 18 | 19 | func (r *GetMyShortDescription) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | if r.LanguageCode != nil { 23 | values["language_code"] = *r.LanguageCode 24 | } 25 | 26 | return 27 | } 28 | 29 | func (r *GetMyShortDescription) GetFiles() (files map[string]io.Reader) { 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /requests/get_star_transactions.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type GetStarTransactions struct { 11 | Limit *int64 12 | Offset *int64 13 | } 14 | 15 | func (r *GetStarTransactions) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(telegram.StarTransactions) 17 | err = b.CallMethod(ctx, "getStarTransactions", r, response) 18 | return 19 | } 20 | 21 | func (r *GetStarTransactions) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | if r.Limit != nil { 25 | values["limit"] = strconv.FormatInt(*r.Limit, 10) 26 | } 27 | 28 | if r.Offset != nil { 29 | values["offset"] = strconv.FormatInt(*r.Offset, 10) 30 | } 31 | 32 | return 33 | } 34 | 35 | func (r *GetStarTransactions) GetFiles() (files map[string]io.Reader) { 36 | return 37 | } 38 | -------------------------------------------------------------------------------- /requests/get_sticker_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetStickerSet struct { 10 | Name string 11 | } 12 | 13 | func (r *GetStickerSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(telegram.StickerSet) 15 | err = b.CallMethod(ctx, "getStickerSet", r, response) 16 | return 17 | } 18 | 19 | func (r *GetStickerSet) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["name"] = r.Name 23 | 24 | return 25 | } 26 | 27 | func (r *GetStickerSet) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/get_updates.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type GetUpdates struct { 12 | AllowedUpdates []string 13 | Limit *int64 14 | Offset *int64 15 | Timeout *int64 16 | } 17 | 18 | func (r *GetUpdates) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 19 | response = new([]telegram.Update) 20 | err = b.CallMethod(ctx, "getUpdates", r, response) 21 | return 22 | } 23 | 24 | func (r *GetUpdates) GetValues() (values map[string]interface{}, err error) { 25 | values = make(map[string]interface{}) 26 | 27 | if r.AllowedUpdates != nil { 28 | var dataAllowedUpdates []byte 29 | if dataAllowedUpdates, err = json.Marshal(r.AllowedUpdates); err != nil { 30 | return 31 | } 32 | 33 | values["allowed_updates"] = string(dataAllowedUpdates) 34 | } 35 | 36 | if r.Limit != nil { 37 | values["limit"] = strconv.FormatInt(*r.Limit, 10) 38 | } 39 | 40 | if r.Offset != nil { 41 | values["offset"] = strconv.FormatInt(*r.Offset, 10) 42 | } 43 | 44 | if r.Timeout != nil { 45 | values["timeout"] = strconv.FormatInt(*r.Timeout, 10) 46 | } 47 | 48 | return 49 | } 50 | 51 | func (r *GetUpdates) GetFiles() (files map[string]io.Reader) { 52 | return 53 | } 54 | -------------------------------------------------------------------------------- /requests/get_user_chat_boosts.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type GetUserChatBoosts struct { 11 | ChatId telegram.ChatId 12 | UserId int64 13 | } 14 | 15 | func (r *GetUserChatBoosts) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(telegram.UserChatBoosts) 17 | err = b.CallMethod(ctx, "getUserChatBoosts", r, response) 18 | return 19 | } 20 | 21 | func (r *GetUserChatBoosts) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *GetUserChatBoosts) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/get_user_profile_photos.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type GetUserProfilePhotos struct { 11 | UserId int64 12 | Limit *int64 13 | Offset *int64 14 | } 15 | 16 | func (r *GetUserProfilePhotos) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(telegram.UserProfilePhotos) 18 | err = b.CallMethod(ctx, "getUserProfilePhotos", r, response) 19 | return 20 | } 21 | 22 | func (r *GetUserProfilePhotos) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 26 | 27 | if r.Limit != nil { 28 | values["limit"] = strconv.FormatInt(*r.Limit, 10) 29 | } 30 | 31 | if r.Offset != nil { 32 | values["offset"] = strconv.FormatInt(*r.Offset, 10) 33 | } 34 | 35 | return 36 | } 37 | 38 | func (r *GetUserProfilePhotos) GetFiles() (files map[string]io.Reader) { 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /requests/get_webhook_info.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type GetWebhookInfo struct { 10 | } 11 | 12 | func (r *GetWebhookInfo) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 13 | response = new(telegram.WebhookInfo) 14 | err = b.CallMethod(ctx, "getWebhookInfo", r, response) 15 | return 16 | } 17 | 18 | func (r *GetWebhookInfo) GetValues() (values map[string]interface{}, err error) { 19 | return 20 | } 21 | 22 | func (r *GetWebhookInfo) GetFiles() (files map[string]io.Reader) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /requests/gift_premium_subscription.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type GiftPremiumSubscription struct { 12 | MonthCount int64 13 | StarCount int64 14 | UserId int64 15 | Text *string 16 | TextEntities []telegram.MessageEntity 17 | TextParseMode *string 18 | } 19 | 20 | func (r *GiftPremiumSubscription) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new(bool) 22 | err = b.CallMethod(ctx, "giftPremiumSubscription", r, response) 23 | return 24 | } 25 | 26 | func (r *GiftPremiumSubscription) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | values["month_count"] = strconv.FormatInt(r.MonthCount, 10) 30 | 31 | values["star_count"] = strconv.FormatInt(r.StarCount, 10) 32 | 33 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 34 | 35 | if r.Text != nil { 36 | values["text"] = *r.Text 37 | } 38 | 39 | if r.TextEntities != nil { 40 | var dataTextEntities []byte 41 | if dataTextEntities, err = json.Marshal(r.TextEntities); err != nil { 42 | return 43 | } 44 | 45 | values["text_entities"] = string(dataTextEntities) 46 | } 47 | 48 | if r.TextParseMode != nil { 49 | values["text_parse_mode"] = *r.TextParseMode 50 | } 51 | 52 | return 53 | } 54 | 55 | func (r *GiftPremiumSubscription) GetFiles() (files map[string]io.Reader) { 56 | return 57 | } 58 | -------------------------------------------------------------------------------- /requests/hide_general_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type HideGeneralForumTopic struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *HideGeneralForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "hideGeneralForumTopic", r, response) 16 | return 17 | } 18 | 19 | func (r *HideGeneralForumTopic) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *HideGeneralForumTopic) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/leave_chat.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type LeaveChat struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *LeaveChat) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "leaveChat", r, response) 16 | return 17 | } 18 | 19 | func (r *LeaveChat) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *LeaveChat) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/log_out.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type LogOut struct { 10 | } 11 | 12 | func (r *LogOut) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 13 | response = new(bool) 14 | err = b.CallMethod(ctx, "logOut", r, response) 15 | return 16 | } 17 | 18 | func (r *LogOut) GetValues() (values map[string]interface{}, err error) { 19 | return 20 | } 21 | 22 | func (r *LogOut) GetFiles() (files map[string]io.Reader) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /requests/pin_chat_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type PinChatMessage struct { 11 | ChatId telegram.ChatId 12 | MessageId int64 13 | BusinessConnectionId *string 14 | DisableNotification *bool 15 | } 16 | 17 | func (r *PinChatMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "pinChatMessage", r, response) 20 | return 21 | } 22 | 23 | func (r *PinChatMessage) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["chat_id"] = r.ChatId.String() 27 | 28 | values["message_id"] = strconv.FormatInt(r.MessageId, 10) 29 | 30 | if r.BusinessConnectionId != nil { 31 | values["business_connection_id"] = *r.BusinessConnectionId 32 | } 33 | 34 | if r.DisableNotification != nil { 35 | if *r.DisableNotification { 36 | values["disable_notification"] = "1" 37 | } else { 38 | values["disable_notification"] = "0" 39 | } 40 | } 41 | 42 | return 43 | } 44 | 45 | func (r *PinChatMessage) GetFiles() (files map[string]io.Reader) { 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /requests/post_story.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type PostStory struct { 12 | ActivePeriod int64 13 | BusinessConnectionId string 14 | Content interface{} 15 | Areas []telegram.StoryArea 16 | Caption *string 17 | CaptionEntities []telegram.MessageEntity 18 | ParseMode *string 19 | PostToChatPage *bool 20 | ProtectContent *bool 21 | } 22 | 23 | func (r *PostStory) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 24 | response = new(telegram.Story) 25 | err = b.CallMethod(ctx, "postStory", r, response) 26 | return 27 | } 28 | 29 | func (r *PostStory) GetValues() (values map[string]interface{}, err error) { 30 | values = make(map[string]interface{}) 31 | 32 | values["active_period"] = strconv.FormatInt(r.ActivePeriod, 10) 33 | 34 | values["business_connection_id"] = r.BusinessConnectionId 35 | 36 | var dataContent []byte 37 | if dataContent, err = json.Marshal(r.Content); err != nil { 38 | return 39 | } 40 | 41 | values["content"] = string(dataContent) 42 | 43 | if r.Areas != nil { 44 | var dataAreas []byte 45 | if dataAreas, err = json.Marshal(r.Areas); err != nil { 46 | return 47 | } 48 | 49 | values["areas"] = string(dataAreas) 50 | } 51 | 52 | if r.Caption != nil { 53 | values["caption"] = *r.Caption 54 | } 55 | 56 | if r.CaptionEntities != nil { 57 | var dataCaptionEntities []byte 58 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 59 | return 60 | } 61 | 62 | values["caption_entities"] = string(dataCaptionEntities) 63 | } 64 | 65 | if r.ParseMode != nil { 66 | values["parse_mode"] = *r.ParseMode 67 | } 68 | 69 | if r.PostToChatPage != nil { 70 | if *r.PostToChatPage { 71 | values["post_to_chat_page"] = "1" 72 | } else { 73 | values["post_to_chat_page"] = "0" 74 | } 75 | } 76 | 77 | if r.ProtectContent != nil { 78 | if *r.ProtectContent { 79 | values["protect_content"] = "1" 80 | } else { 81 | values["protect_content"] = "0" 82 | } 83 | } 84 | 85 | return 86 | } 87 | 88 | func (r *PostStory) GetFiles() (files map[string]io.Reader) { 89 | files = make(map[string]io.Reader) 90 | 91 | switch value := r.Content.(type) { 92 | case telegram.InputStoryContentPhoto: 93 | if value.Photo.HasFile() { 94 | files[value.Photo.GetFormFieldName()] = value.Photo.GetFile() 95 | } 96 | case telegram.InputStoryContentVideo: 97 | if value.Video.HasFile() { 98 | files[value.Video.GetFormFieldName()] = value.Video.GetFile() 99 | } 100 | } 101 | 102 | return 103 | } 104 | -------------------------------------------------------------------------------- /requests/promote_chat_member.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type PromoteChatMember struct { 11 | ChatId telegram.ChatId 12 | UserId int64 13 | CanChangeInfo *bool 14 | CanDeleteMessages *bool 15 | CanDeleteStories *bool 16 | CanEditMessages *bool 17 | CanEditStories *bool 18 | CanInviteUsers *bool 19 | CanManageChat *bool 20 | CanManageTopics *bool 21 | CanManageVideoChats *bool 22 | CanPinMessages *bool 23 | CanPostMessages *bool 24 | CanPostStories *bool 25 | CanPromoteMembers *bool 26 | CanRestrictMembers *bool 27 | IsAnonymous *bool 28 | } 29 | 30 | func (r *PromoteChatMember) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 31 | response = new(bool) 32 | err = b.CallMethod(ctx, "promoteChatMember", r, response) 33 | return 34 | } 35 | 36 | func (r *PromoteChatMember) GetValues() (values map[string]interface{}, err error) { 37 | values = make(map[string]interface{}) 38 | 39 | values["chat_id"] = r.ChatId.String() 40 | 41 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 42 | 43 | if r.CanChangeInfo != nil { 44 | if *r.CanChangeInfo { 45 | values["can_change_info"] = "1" 46 | } else { 47 | values["can_change_info"] = "0" 48 | } 49 | } 50 | 51 | if r.CanDeleteMessages != nil { 52 | if *r.CanDeleteMessages { 53 | values["can_delete_messages"] = "1" 54 | } else { 55 | values["can_delete_messages"] = "0" 56 | } 57 | } 58 | 59 | if r.CanDeleteStories != nil { 60 | if *r.CanDeleteStories { 61 | values["can_delete_stories"] = "1" 62 | } else { 63 | values["can_delete_stories"] = "0" 64 | } 65 | } 66 | 67 | if r.CanEditMessages != nil { 68 | if *r.CanEditMessages { 69 | values["can_edit_messages"] = "1" 70 | } else { 71 | values["can_edit_messages"] = "0" 72 | } 73 | } 74 | 75 | if r.CanEditStories != nil { 76 | if *r.CanEditStories { 77 | values["can_edit_stories"] = "1" 78 | } else { 79 | values["can_edit_stories"] = "0" 80 | } 81 | } 82 | 83 | if r.CanInviteUsers != nil { 84 | if *r.CanInviteUsers { 85 | values["can_invite_users"] = "1" 86 | } else { 87 | values["can_invite_users"] = "0" 88 | } 89 | } 90 | 91 | if r.CanManageChat != nil { 92 | if *r.CanManageChat { 93 | values["can_manage_chat"] = "1" 94 | } else { 95 | values["can_manage_chat"] = "0" 96 | } 97 | } 98 | 99 | if r.CanManageTopics != nil { 100 | if *r.CanManageTopics { 101 | values["can_manage_topics"] = "1" 102 | } else { 103 | values["can_manage_topics"] = "0" 104 | } 105 | } 106 | 107 | if r.CanManageVideoChats != nil { 108 | if *r.CanManageVideoChats { 109 | values["can_manage_video_chats"] = "1" 110 | } else { 111 | values["can_manage_video_chats"] = "0" 112 | } 113 | } 114 | 115 | if r.CanPinMessages != nil { 116 | if *r.CanPinMessages { 117 | values["can_pin_messages"] = "1" 118 | } else { 119 | values["can_pin_messages"] = "0" 120 | } 121 | } 122 | 123 | if r.CanPostMessages != nil { 124 | if *r.CanPostMessages { 125 | values["can_post_messages"] = "1" 126 | } else { 127 | values["can_post_messages"] = "0" 128 | } 129 | } 130 | 131 | if r.CanPostStories != nil { 132 | if *r.CanPostStories { 133 | values["can_post_stories"] = "1" 134 | } else { 135 | values["can_post_stories"] = "0" 136 | } 137 | } 138 | 139 | if r.CanPromoteMembers != nil { 140 | if *r.CanPromoteMembers { 141 | values["can_promote_members"] = "1" 142 | } else { 143 | values["can_promote_members"] = "0" 144 | } 145 | } 146 | 147 | if r.CanRestrictMembers != nil { 148 | if *r.CanRestrictMembers { 149 | values["can_restrict_members"] = "1" 150 | } else { 151 | values["can_restrict_members"] = "0" 152 | } 153 | } 154 | 155 | if r.IsAnonymous != nil { 156 | if *r.IsAnonymous { 157 | values["is_anonymous"] = "1" 158 | } else { 159 | values["is_anonymous"] = "0" 160 | } 161 | } 162 | 163 | return 164 | } 165 | 166 | func (r *PromoteChatMember) GetFiles() (files map[string]io.Reader) { 167 | return 168 | } 169 | -------------------------------------------------------------------------------- /requests/read_business_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type ReadBusinessMessage struct { 11 | BusinessConnectionId string 12 | ChatId int64 13 | MessageId int64 14 | } 15 | 16 | func (r *ReadBusinessMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "readBusinessMessage", r, response) 19 | return 20 | } 21 | 22 | func (r *ReadBusinessMessage) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["business_connection_id"] = r.BusinessConnectionId 26 | 27 | values["chat_id"] = strconv.FormatInt(r.ChatId, 10) 28 | 29 | values["message_id"] = strconv.FormatInt(r.MessageId, 10) 30 | 31 | return 32 | } 33 | 34 | func (r *ReadBusinessMessage) GetFiles() (files map[string]io.Reader) { 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /requests/refund_star_payment.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type RefundStarPayment struct { 11 | TelegramPaymentChargeId string 12 | UserId int64 13 | } 14 | 15 | func (r *RefundStarPayment) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "refundStarPayment", r, response) 18 | return 19 | } 20 | 21 | func (r *RefundStarPayment) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["telegram_payment_charge_id"] = r.TelegramPaymentChargeId 25 | 26 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *RefundStarPayment) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/remove_business_account_profile_photo.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type RemoveBusinessAccountProfilePhoto struct { 10 | BusinessConnectionId string 11 | IsPublic *bool 12 | } 13 | 14 | func (r *RemoveBusinessAccountProfilePhoto) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "removeBusinessAccountProfilePhoto", r, response) 17 | return 18 | } 19 | 20 | func (r *RemoveBusinessAccountProfilePhoto) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["business_connection_id"] = r.BusinessConnectionId 24 | 25 | if r.IsPublic != nil { 26 | if *r.IsPublic { 27 | values["is_public"] = "1" 28 | } else { 29 | values["is_public"] = "0" 30 | } 31 | } 32 | 33 | return 34 | } 35 | 36 | func (r *RemoveBusinessAccountProfilePhoto) GetFiles() (files map[string]io.Reader) { 37 | return 38 | } 39 | -------------------------------------------------------------------------------- /requests/remove_chat_verification.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type RemoveChatVerification struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *RemoveChatVerification) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "removeChatVerification", r, response) 16 | return 17 | } 18 | 19 | func (r *RemoveChatVerification) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *RemoveChatVerification) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/remove_user_verification.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type RemoveUserVerification struct { 11 | UserId int64 12 | } 13 | 14 | func (r *RemoveUserVerification) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "removeUserVerification", r, response) 17 | return 18 | } 19 | 20 | func (r *RemoveUserVerification) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 24 | 25 | return 26 | } 27 | 28 | func (r *RemoveUserVerification) GetFiles() (files map[string]io.Reader) { 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /requests/reopen_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type ReopenForumTopic struct { 11 | ChatId telegram.ChatId 12 | MessageThreadId int64 13 | } 14 | 15 | func (r *ReopenForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "reopenForumTopic", r, response) 18 | return 19 | } 20 | 21 | func (r *ReopenForumTopic) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["message_thread_id"] = strconv.FormatInt(r.MessageThreadId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *ReopenForumTopic) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/reopen_general_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type ReopenGeneralForumTopic struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *ReopenGeneralForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "reopenGeneralForumTopic", r, response) 16 | return 17 | } 18 | 19 | func (r *ReopenGeneralForumTopic) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *ReopenGeneralForumTopic) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/replace_sticker_in_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type ReplaceStickerInSet struct { 12 | Name string 13 | OldSticker string 14 | Sticker telegram.InputSticker 15 | UserId int64 16 | } 17 | 18 | func (r *ReplaceStickerInSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 19 | response = new(bool) 20 | err = b.CallMethod(ctx, "replaceStickerInSet", r, response) 21 | return 22 | } 23 | 24 | func (r *ReplaceStickerInSet) GetValues() (values map[string]interface{}, err error) { 25 | values = make(map[string]interface{}) 26 | 27 | values["name"] = r.Name 28 | 29 | values["old_sticker"] = r.OldSticker 30 | 31 | var dataSticker []byte 32 | if dataSticker, err = json.Marshal(r.Sticker); err != nil { 33 | return 34 | } 35 | 36 | values["sticker"] = string(dataSticker) 37 | 38 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 39 | 40 | return 41 | } 42 | 43 | func (r *ReplaceStickerInSet) GetFiles() (files map[string]io.Reader) { 44 | files = make(map[string]io.Reader) 45 | 46 | if r.Sticker.Sticker.HasFile() { 47 | files[r.Sticker.Sticker.GetFormFieldName()] = r.Sticker.Sticker.GetFile() 48 | } 49 | 50 | return 51 | } 52 | -------------------------------------------------------------------------------- /requests/restrict_chat_member.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type RestrictChatMember struct { 12 | ChatId telegram.ChatId 13 | Permissions telegram.ChatPermissions 14 | UserId int64 15 | UntilDate *int64 16 | UseIndependentChatPermissions *bool 17 | } 18 | 19 | func (r *RestrictChatMember) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 20 | response = new(bool) 21 | err = b.CallMethod(ctx, "restrictChatMember", r, response) 22 | return 23 | } 24 | 25 | func (r *RestrictChatMember) GetValues() (values map[string]interface{}, err error) { 26 | values = make(map[string]interface{}) 27 | 28 | values["chat_id"] = r.ChatId.String() 29 | 30 | var dataPermissions []byte 31 | if dataPermissions, err = json.Marshal(r.Permissions); err != nil { 32 | return 33 | } 34 | 35 | values["permissions"] = string(dataPermissions) 36 | 37 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 38 | 39 | if r.UntilDate != nil { 40 | values["until_date"] = strconv.FormatInt(*r.UntilDate, 10) 41 | } 42 | 43 | if r.UseIndependentChatPermissions != nil { 44 | if *r.UseIndependentChatPermissions { 45 | values["use_independent_chat_permissions"] = "1" 46 | } else { 47 | values["use_independent_chat_permissions"] = "0" 48 | } 49 | } 50 | 51 | return 52 | } 53 | 54 | func (r *RestrictChatMember) GetFiles() (files map[string]io.Reader) { 55 | return 56 | } 57 | -------------------------------------------------------------------------------- /requests/revoke_chat_invite_link.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type RevokeChatInviteLink struct { 10 | ChatId telegram.ChatId 11 | InviteLink string 12 | } 13 | 14 | func (r *RevokeChatInviteLink) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(telegram.ChatInviteLink) 16 | err = b.CallMethod(ctx, "revokeChatInviteLink", r, response) 17 | return 18 | } 19 | 20 | func (r *RevokeChatInviteLink) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["chat_id"] = r.ChatId.String() 24 | 25 | values["invite_link"] = r.InviteLink 26 | 27 | return 28 | } 29 | 30 | func (r *RevokeChatInviteLink) GetFiles() (files map[string]io.Reader) { 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /requests/save_prepared_inline_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type SavePreparedInlineMessage struct { 12 | Result interface{} 13 | UserId int64 14 | AllowBotChats *bool 15 | AllowChannelChats *bool 16 | AllowGroupChats *bool 17 | AllowUserChats *bool 18 | } 19 | 20 | func (r *SavePreparedInlineMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new(telegram.PreparedInlineMessage) 22 | err = b.CallMethod(ctx, "savePreparedInlineMessage", r, response) 23 | return 24 | } 25 | 26 | func (r *SavePreparedInlineMessage) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | var dataResult []byte 30 | if dataResult, err = json.Marshal(r.Result); err != nil { 31 | return 32 | } 33 | 34 | values["result"] = string(dataResult) 35 | 36 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 37 | 38 | if r.AllowBotChats != nil { 39 | if *r.AllowBotChats { 40 | values["allow_bot_chats"] = "1" 41 | } else { 42 | values["allow_bot_chats"] = "0" 43 | } 44 | } 45 | 46 | if r.AllowChannelChats != nil { 47 | if *r.AllowChannelChats { 48 | values["allow_channel_chats"] = "1" 49 | } else { 50 | values["allow_channel_chats"] = "0" 51 | } 52 | } 53 | 54 | if r.AllowGroupChats != nil { 55 | if *r.AllowGroupChats { 56 | values["allow_group_chats"] = "1" 57 | } else { 58 | values["allow_group_chats"] = "0" 59 | } 60 | } 61 | 62 | if r.AllowUserChats != nil { 63 | if *r.AllowUserChats { 64 | values["allow_user_chats"] = "1" 65 | } else { 66 | values["allow_user_chats"] = "0" 67 | } 68 | } 69 | 70 | return 71 | } 72 | 73 | func (r *SavePreparedInlineMessage) GetFiles() (files map[string]io.Reader) { 74 | return 75 | } 76 | -------------------------------------------------------------------------------- /requests/send_audio.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendAudio struct { 13 | Audio telegram.InputFile 14 | ChatId telegram.ChatId 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | Caption *string 18 | CaptionEntities []telegram.MessageEntity 19 | DisableNotification *bool 20 | Duration *int64 21 | MessageEffectId *string 22 | MessageThreadId *int64 23 | ParseMode *string 24 | Performer *string 25 | ProtectContent *bool 26 | ReplyMarkup interface{} 27 | ReplyParameters *telegram.ReplyParameters 28 | Thumbnail *telegram.InputFile 29 | Title *string 30 | } 31 | 32 | func (r *SendAudio) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 33 | response = new(telegram.Message) 34 | err = b.CallMethod(ctx, "sendAudio", r, response) 35 | return 36 | } 37 | 38 | func (r *SendAudio) GetValues() (values map[string]interface{}, err error) { 39 | values = make(map[string]interface{}) 40 | 41 | values["audio"] = r.Audio.GetValue() 42 | 43 | values["chat_id"] = r.ChatId.String() 44 | 45 | if r.AllowPaidBroadcast != nil { 46 | if *r.AllowPaidBroadcast { 47 | values["allow_paid_broadcast"] = "1" 48 | } else { 49 | values["allow_paid_broadcast"] = "0" 50 | } 51 | } 52 | 53 | if r.BusinessConnectionId != nil { 54 | values["business_connection_id"] = *r.BusinessConnectionId 55 | } 56 | 57 | if r.Caption != nil { 58 | values["caption"] = *r.Caption 59 | } 60 | 61 | if r.CaptionEntities != nil { 62 | var dataCaptionEntities []byte 63 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 64 | return 65 | } 66 | 67 | values["caption_entities"] = string(dataCaptionEntities) 68 | } 69 | 70 | if r.DisableNotification != nil { 71 | if *r.DisableNotification { 72 | values["disable_notification"] = "1" 73 | } else { 74 | values["disable_notification"] = "0" 75 | } 76 | } 77 | 78 | if r.Duration != nil { 79 | values["duration"] = strconv.FormatInt(*r.Duration, 10) 80 | } 81 | 82 | if r.MessageEffectId != nil { 83 | values["message_effect_id"] = *r.MessageEffectId 84 | } 85 | 86 | if r.MessageThreadId != nil { 87 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 88 | } 89 | 90 | if r.ParseMode != nil { 91 | values["parse_mode"] = *r.ParseMode 92 | } 93 | 94 | if r.Performer != nil { 95 | values["performer"] = *r.Performer 96 | } 97 | 98 | if r.ProtectContent != nil { 99 | if *r.ProtectContent { 100 | values["protect_content"] = "1" 101 | } else { 102 | values["protect_content"] = "0" 103 | } 104 | } 105 | 106 | if r.ReplyMarkup != nil { 107 | switch value := r.ReplyMarkup.(type) { 108 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 109 | var data []byte 110 | if data, err = json.Marshal(value); err != nil { 111 | return 112 | } 113 | 114 | values["reply_markup"] = string(data) 115 | default: 116 | err = errors.New("unsupported reply_markup field type") 117 | return 118 | } 119 | } 120 | 121 | if r.ReplyParameters != nil { 122 | var dataReplyParameters []byte 123 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 124 | return 125 | } 126 | 127 | values["reply_parameters"] = string(dataReplyParameters) 128 | } 129 | 130 | if r.Thumbnail != nil { 131 | values["thumbnail"] = r.Thumbnail.GetValue() 132 | } 133 | 134 | if r.Title != nil { 135 | values["title"] = *r.Title 136 | } 137 | 138 | return 139 | } 140 | 141 | func (r *SendAudio) GetFiles() (files map[string]io.Reader) { 142 | return 143 | } 144 | -------------------------------------------------------------------------------- /requests/send_chat_action.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type SendChatAction struct { 11 | Action string 12 | ChatId telegram.ChatId 13 | BusinessConnectionId *string 14 | MessageThreadId *int64 15 | } 16 | 17 | func (r *SendChatAction) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "sendChatAction", r, response) 20 | return 21 | } 22 | 23 | func (r *SendChatAction) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["action"] = r.Action 27 | 28 | values["chat_id"] = r.ChatId.String() 29 | 30 | if r.BusinessConnectionId != nil { 31 | values["business_connection_id"] = *r.BusinessConnectionId 32 | } 33 | 34 | if r.MessageThreadId != nil { 35 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 36 | } 37 | 38 | return 39 | } 40 | 41 | func (r *SendChatAction) GetFiles() (files map[string]io.Reader) { 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /requests/send_contact.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendContact struct { 13 | ChatId telegram.ChatId 14 | FirstName string 15 | PhoneNumber string 16 | AllowPaidBroadcast *bool 17 | BusinessConnectionId *string 18 | DisableNotification *bool 19 | LastName *string 20 | MessageEffectId *string 21 | MessageThreadId *int64 22 | ProtectContent *bool 23 | ReplyMarkup interface{} 24 | ReplyParameters *telegram.ReplyParameters 25 | Vcard *string 26 | } 27 | 28 | func (r *SendContact) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 29 | response = new(telegram.Message) 30 | err = b.CallMethod(ctx, "sendContact", r, response) 31 | return 32 | } 33 | 34 | func (r *SendContact) GetValues() (values map[string]interface{}, err error) { 35 | values = make(map[string]interface{}) 36 | 37 | values["chat_id"] = r.ChatId.String() 38 | 39 | values["first_name"] = r.FirstName 40 | 41 | values["phone_number"] = r.PhoneNumber 42 | 43 | if r.AllowPaidBroadcast != nil { 44 | if *r.AllowPaidBroadcast { 45 | values["allow_paid_broadcast"] = "1" 46 | } else { 47 | values["allow_paid_broadcast"] = "0" 48 | } 49 | } 50 | 51 | if r.BusinessConnectionId != nil { 52 | values["business_connection_id"] = *r.BusinessConnectionId 53 | } 54 | 55 | if r.DisableNotification != nil { 56 | if *r.DisableNotification { 57 | values["disable_notification"] = "1" 58 | } else { 59 | values["disable_notification"] = "0" 60 | } 61 | } 62 | 63 | if r.LastName != nil { 64 | values["last_name"] = *r.LastName 65 | } 66 | 67 | if r.MessageEffectId != nil { 68 | values["message_effect_id"] = *r.MessageEffectId 69 | } 70 | 71 | if r.MessageThreadId != nil { 72 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 73 | } 74 | 75 | if r.ProtectContent != nil { 76 | if *r.ProtectContent { 77 | values["protect_content"] = "1" 78 | } else { 79 | values["protect_content"] = "0" 80 | } 81 | } 82 | 83 | if r.ReplyMarkup != nil { 84 | switch value := r.ReplyMarkup.(type) { 85 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 86 | var data []byte 87 | if data, err = json.Marshal(value); err != nil { 88 | return 89 | } 90 | 91 | values["reply_markup"] = string(data) 92 | default: 93 | err = errors.New("unsupported reply_markup field type") 94 | return 95 | } 96 | } 97 | 98 | if r.ReplyParameters != nil { 99 | var dataReplyParameters []byte 100 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 101 | return 102 | } 103 | 104 | values["reply_parameters"] = string(dataReplyParameters) 105 | } 106 | 107 | if r.Vcard != nil { 108 | values["vcard"] = *r.Vcard 109 | } 110 | 111 | return 112 | } 113 | 114 | func (r *SendContact) GetFiles() (files map[string]io.Reader) { 115 | return 116 | } 117 | -------------------------------------------------------------------------------- /requests/send_dice.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendDice struct { 13 | ChatId telegram.ChatId 14 | AllowPaidBroadcast *bool 15 | BusinessConnectionId *string 16 | DisableNotification *bool 17 | Emoji *string 18 | MessageEffectId *string 19 | MessageThreadId *int64 20 | ProtectContent *bool 21 | ReplyMarkup interface{} 22 | ReplyParameters *telegram.ReplyParameters 23 | } 24 | 25 | func (r *SendDice) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 26 | response = new(telegram.Message) 27 | err = b.CallMethod(ctx, "sendDice", r, response) 28 | return 29 | } 30 | 31 | func (r *SendDice) GetValues() (values map[string]interface{}, err error) { 32 | values = make(map[string]interface{}) 33 | 34 | values["chat_id"] = r.ChatId.String() 35 | 36 | if r.AllowPaidBroadcast != nil { 37 | if *r.AllowPaidBroadcast { 38 | values["allow_paid_broadcast"] = "1" 39 | } else { 40 | values["allow_paid_broadcast"] = "0" 41 | } 42 | } 43 | 44 | if r.BusinessConnectionId != nil { 45 | values["business_connection_id"] = *r.BusinessConnectionId 46 | } 47 | 48 | if r.DisableNotification != nil { 49 | if *r.DisableNotification { 50 | values["disable_notification"] = "1" 51 | } else { 52 | values["disable_notification"] = "0" 53 | } 54 | } 55 | 56 | if r.Emoji != nil { 57 | values["emoji"] = *r.Emoji 58 | } 59 | 60 | if r.MessageEffectId != nil { 61 | values["message_effect_id"] = *r.MessageEffectId 62 | } 63 | 64 | if r.MessageThreadId != nil { 65 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 66 | } 67 | 68 | if r.ProtectContent != nil { 69 | if *r.ProtectContent { 70 | values["protect_content"] = "1" 71 | } else { 72 | values["protect_content"] = "0" 73 | } 74 | } 75 | 76 | if r.ReplyMarkup != nil { 77 | switch value := r.ReplyMarkup.(type) { 78 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 79 | var data []byte 80 | if data, err = json.Marshal(value); err != nil { 81 | return 82 | } 83 | 84 | values["reply_markup"] = string(data) 85 | default: 86 | err = errors.New("unsupported reply_markup field type") 87 | return 88 | } 89 | } 90 | 91 | if r.ReplyParameters != nil { 92 | var dataReplyParameters []byte 93 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 94 | return 95 | } 96 | 97 | values["reply_parameters"] = string(dataReplyParameters) 98 | } 99 | 100 | return 101 | } 102 | 103 | func (r *SendDice) GetFiles() (files map[string]io.Reader) { 104 | return 105 | } 106 | -------------------------------------------------------------------------------- /requests/send_document.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendDocument struct { 13 | ChatId telegram.ChatId 14 | Document telegram.InputFile 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | Caption *string 18 | CaptionEntities []telegram.MessageEntity 19 | DisableContentTypeDetection *bool 20 | DisableNotification *bool 21 | MessageEffectId *string 22 | MessageThreadId *int64 23 | ParseMode *string 24 | ProtectContent *bool 25 | ReplyMarkup interface{} 26 | ReplyParameters *telegram.ReplyParameters 27 | Thumbnail *telegram.InputFile 28 | } 29 | 30 | func (r *SendDocument) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 31 | response = new(telegram.Message) 32 | err = b.CallMethod(ctx, "sendDocument", r, response) 33 | return 34 | } 35 | 36 | func (r *SendDocument) GetValues() (values map[string]interface{}, err error) { 37 | values = make(map[string]interface{}) 38 | 39 | values["chat_id"] = r.ChatId.String() 40 | 41 | values["document"] = r.Document.GetValue() 42 | 43 | if r.AllowPaidBroadcast != nil { 44 | if *r.AllowPaidBroadcast { 45 | values["allow_paid_broadcast"] = "1" 46 | } else { 47 | values["allow_paid_broadcast"] = "0" 48 | } 49 | } 50 | 51 | if r.BusinessConnectionId != nil { 52 | values["business_connection_id"] = *r.BusinessConnectionId 53 | } 54 | 55 | if r.Caption != nil { 56 | values["caption"] = *r.Caption 57 | } 58 | 59 | if r.CaptionEntities != nil { 60 | var dataCaptionEntities []byte 61 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 62 | return 63 | } 64 | 65 | values["caption_entities"] = string(dataCaptionEntities) 66 | } 67 | 68 | if r.DisableContentTypeDetection != nil { 69 | if *r.DisableContentTypeDetection { 70 | values["disable_content_type_detection"] = "1" 71 | } else { 72 | values["disable_content_type_detection"] = "0" 73 | } 74 | } 75 | 76 | if r.DisableNotification != nil { 77 | if *r.DisableNotification { 78 | values["disable_notification"] = "1" 79 | } else { 80 | values["disable_notification"] = "0" 81 | } 82 | } 83 | 84 | if r.MessageEffectId != nil { 85 | values["message_effect_id"] = *r.MessageEffectId 86 | } 87 | 88 | if r.MessageThreadId != nil { 89 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 90 | } 91 | 92 | if r.ParseMode != nil { 93 | values["parse_mode"] = *r.ParseMode 94 | } 95 | 96 | if r.ProtectContent != nil { 97 | if *r.ProtectContent { 98 | values["protect_content"] = "1" 99 | } else { 100 | values["protect_content"] = "0" 101 | } 102 | } 103 | 104 | if r.ReplyMarkup != nil { 105 | switch value := r.ReplyMarkup.(type) { 106 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 107 | var data []byte 108 | if data, err = json.Marshal(value); err != nil { 109 | return 110 | } 111 | 112 | values["reply_markup"] = string(data) 113 | default: 114 | err = errors.New("unsupported reply_markup field type") 115 | return 116 | } 117 | } 118 | 119 | if r.ReplyParameters != nil { 120 | var dataReplyParameters []byte 121 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 122 | return 123 | } 124 | 125 | values["reply_parameters"] = string(dataReplyParameters) 126 | } 127 | 128 | if r.Thumbnail != nil { 129 | values["thumbnail"] = r.Thumbnail.GetValue() 130 | } 131 | 132 | return 133 | } 134 | 135 | func (r *SendDocument) GetFiles() (files map[string]io.Reader) { 136 | return 137 | } 138 | -------------------------------------------------------------------------------- /requests/send_game.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type SendGame struct { 12 | ChatId int64 13 | GameShortName string 14 | AllowPaidBroadcast *bool 15 | BusinessConnectionId *string 16 | DisableNotification *bool 17 | MessageEffectId *string 18 | MessageThreadId *int64 19 | ProtectContent *bool 20 | ReplyMarkup *telegram.InlineKeyboardMarkup 21 | ReplyParameters *telegram.ReplyParameters 22 | } 23 | 24 | func (r *SendGame) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 25 | response = new(telegram.Message) 26 | err = b.CallMethod(ctx, "sendGame", r, response) 27 | return 28 | } 29 | 30 | func (r *SendGame) GetValues() (values map[string]interface{}, err error) { 31 | values = make(map[string]interface{}) 32 | 33 | values["chat_id"] = strconv.FormatInt(r.ChatId, 10) 34 | 35 | values["game_short_name"] = r.GameShortName 36 | 37 | if r.AllowPaidBroadcast != nil { 38 | if *r.AllowPaidBroadcast { 39 | values["allow_paid_broadcast"] = "1" 40 | } else { 41 | values["allow_paid_broadcast"] = "0" 42 | } 43 | } 44 | 45 | if r.BusinessConnectionId != nil { 46 | values["business_connection_id"] = *r.BusinessConnectionId 47 | } 48 | 49 | if r.DisableNotification != nil { 50 | if *r.DisableNotification { 51 | values["disable_notification"] = "1" 52 | } else { 53 | values["disable_notification"] = "0" 54 | } 55 | } 56 | 57 | if r.MessageEffectId != nil { 58 | values["message_effect_id"] = *r.MessageEffectId 59 | } 60 | 61 | if r.MessageThreadId != nil { 62 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 63 | } 64 | 65 | if r.ProtectContent != nil { 66 | if *r.ProtectContent { 67 | values["protect_content"] = "1" 68 | } else { 69 | values["protect_content"] = "0" 70 | } 71 | } 72 | 73 | if r.ReplyMarkup != nil { 74 | var dataReplyMarkup []byte 75 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 76 | return 77 | } 78 | 79 | values["reply_markup"] = string(dataReplyMarkup) 80 | } 81 | 82 | if r.ReplyParameters != nil { 83 | var dataReplyParameters []byte 84 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 85 | return 86 | } 87 | 88 | values["reply_parameters"] = string(dataReplyParameters) 89 | } 90 | 91 | return 92 | } 93 | 94 | func (r *SendGame) GetFiles() (files map[string]io.Reader) { 95 | return 96 | } 97 | -------------------------------------------------------------------------------- /requests/send_gift.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type SendGift struct { 12 | GiftId string 13 | ChatId *telegram.ChatId 14 | PayForUpgrade *bool 15 | Text *string 16 | TextEntities []telegram.MessageEntity 17 | TextParseMode *string 18 | UserId *int64 19 | } 20 | 21 | func (r *SendGift) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 22 | response = new(bool) 23 | err = b.CallMethod(ctx, "sendGift", r, response) 24 | return 25 | } 26 | 27 | func (r *SendGift) GetValues() (values map[string]interface{}, err error) { 28 | values = make(map[string]interface{}) 29 | 30 | values["gift_id"] = r.GiftId 31 | 32 | if r.ChatId != nil { 33 | values["chat_id"] = r.ChatId.String() 34 | } 35 | 36 | if r.PayForUpgrade != nil { 37 | if *r.PayForUpgrade { 38 | values["pay_for_upgrade"] = "1" 39 | } else { 40 | values["pay_for_upgrade"] = "0" 41 | } 42 | } 43 | 44 | if r.Text != nil { 45 | values["text"] = *r.Text 46 | } 47 | 48 | if r.TextEntities != nil { 49 | var dataTextEntities []byte 50 | if dataTextEntities, err = json.Marshal(r.TextEntities); err != nil { 51 | return 52 | } 53 | 54 | values["text_entities"] = string(dataTextEntities) 55 | } 56 | 57 | if r.TextParseMode != nil { 58 | values["text_parse_mode"] = *r.TextParseMode 59 | } 60 | 61 | if r.UserId != nil { 62 | values["user_id"] = strconv.FormatInt(*r.UserId, 10) 63 | } 64 | 65 | return 66 | } 67 | 68 | func (r *SendGift) GetFiles() (files map[string]io.Reader) { 69 | return 70 | } 71 | -------------------------------------------------------------------------------- /requests/send_location.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendLocation struct { 13 | ChatId telegram.ChatId 14 | Latitude float64 15 | Longitude float64 16 | AllowPaidBroadcast *bool 17 | BusinessConnectionId *string 18 | DisableNotification *bool 19 | Heading *int64 20 | HorizontalAccuracy *float64 21 | LivePeriod *int64 22 | MessageEffectId *string 23 | MessageThreadId *int64 24 | ProtectContent *bool 25 | ProximityAlertRadius *int64 26 | ReplyMarkup interface{} 27 | ReplyParameters *telegram.ReplyParameters 28 | } 29 | 30 | func (r *SendLocation) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 31 | response = new(telegram.Message) 32 | err = b.CallMethod(ctx, "sendLocation", r, response) 33 | return 34 | } 35 | 36 | func (r *SendLocation) GetValues() (values map[string]interface{}, err error) { 37 | values = make(map[string]interface{}) 38 | 39 | values["chat_id"] = r.ChatId.String() 40 | 41 | values["latitude"] = strconv.FormatFloat(r.Latitude, 'f', -1, 64) 42 | 43 | values["longitude"] = strconv.FormatFloat(r.Longitude, 'f', -1, 64) 44 | 45 | if r.AllowPaidBroadcast != nil { 46 | if *r.AllowPaidBroadcast { 47 | values["allow_paid_broadcast"] = "1" 48 | } else { 49 | values["allow_paid_broadcast"] = "0" 50 | } 51 | } 52 | 53 | if r.BusinessConnectionId != nil { 54 | values["business_connection_id"] = *r.BusinessConnectionId 55 | } 56 | 57 | if r.DisableNotification != nil { 58 | if *r.DisableNotification { 59 | values["disable_notification"] = "1" 60 | } else { 61 | values["disable_notification"] = "0" 62 | } 63 | } 64 | 65 | if r.Heading != nil { 66 | values["heading"] = strconv.FormatInt(*r.Heading, 10) 67 | } 68 | 69 | if r.HorizontalAccuracy != nil { 70 | values["horizontal_accuracy"] = strconv.FormatFloat(*r.HorizontalAccuracy, 'f', -1, 64) 71 | } 72 | 73 | if r.LivePeriod != nil { 74 | values["live_period"] = strconv.FormatInt(*r.LivePeriod, 10) 75 | } 76 | 77 | if r.MessageEffectId != nil { 78 | values["message_effect_id"] = *r.MessageEffectId 79 | } 80 | 81 | if r.MessageThreadId != nil { 82 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 83 | } 84 | 85 | if r.ProtectContent != nil { 86 | if *r.ProtectContent { 87 | values["protect_content"] = "1" 88 | } else { 89 | values["protect_content"] = "0" 90 | } 91 | } 92 | 93 | if r.ProximityAlertRadius != nil { 94 | values["proximity_alert_radius"] = strconv.FormatInt(*r.ProximityAlertRadius, 10) 95 | } 96 | 97 | if r.ReplyMarkup != nil { 98 | switch value := r.ReplyMarkup.(type) { 99 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 100 | var data []byte 101 | if data, err = json.Marshal(value); err != nil { 102 | return 103 | } 104 | 105 | values["reply_markup"] = string(data) 106 | default: 107 | err = errors.New("unsupported reply_markup field type") 108 | return 109 | } 110 | } 111 | 112 | if r.ReplyParameters != nil { 113 | var dataReplyParameters []byte 114 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 115 | return 116 | } 117 | 118 | values["reply_parameters"] = string(dataReplyParameters) 119 | } 120 | 121 | return 122 | } 123 | 124 | func (r *SendLocation) GetFiles() (files map[string]io.Reader) { 125 | return 126 | } 127 | -------------------------------------------------------------------------------- /requests/send_media_group.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendMediaGroup struct { 13 | ChatId telegram.ChatId 14 | Media interface{} 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | DisableNotification *bool 18 | MessageEffectId *string 19 | MessageThreadId *int64 20 | ProtectContent *bool 21 | ReplyParameters *telegram.ReplyParameters 22 | } 23 | 24 | func (r *SendMediaGroup) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 25 | response = new([]telegram.Message) 26 | err = b.CallMethod(ctx, "sendMediaGroup", r, response) 27 | return 28 | } 29 | 30 | func (r *SendMediaGroup) GetValues() (values map[string]interface{}, err error) { 31 | values = make(map[string]interface{}) 32 | 33 | values["chat_id"] = r.ChatId.String() 34 | 35 | switch value := r.Media.(type) { 36 | case []telegram.InputMediaAudio, []telegram.InputMediaDocument, []telegram.InputMediaPhoto, []telegram.InputMediaVideo: 37 | var data []byte 38 | if data, err = json.Marshal(value); err != nil { 39 | return 40 | } 41 | 42 | values["media"] = string(data) 43 | default: 44 | err = errors.New("unsupported media field type") 45 | return 46 | } 47 | 48 | if r.AllowPaidBroadcast != nil { 49 | if *r.AllowPaidBroadcast { 50 | values["allow_paid_broadcast"] = "1" 51 | } else { 52 | values["allow_paid_broadcast"] = "0" 53 | } 54 | } 55 | 56 | if r.BusinessConnectionId != nil { 57 | values["business_connection_id"] = *r.BusinessConnectionId 58 | } 59 | 60 | if r.DisableNotification != nil { 61 | if *r.DisableNotification { 62 | values["disable_notification"] = "1" 63 | } else { 64 | values["disable_notification"] = "0" 65 | } 66 | } 67 | 68 | if r.MessageEffectId != nil { 69 | values["message_effect_id"] = *r.MessageEffectId 70 | } 71 | 72 | if r.MessageThreadId != nil { 73 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 74 | } 75 | 76 | if r.ProtectContent != nil { 77 | if *r.ProtectContent { 78 | values["protect_content"] = "1" 79 | } else { 80 | values["protect_content"] = "0" 81 | } 82 | } 83 | 84 | if r.ReplyParameters != nil { 85 | var dataReplyParameters []byte 86 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 87 | return 88 | } 89 | 90 | values["reply_parameters"] = string(dataReplyParameters) 91 | } 92 | 93 | return 94 | } 95 | 96 | func (r *SendMediaGroup) GetFiles() (files map[string]io.Reader) { 97 | files = make(map[string]io.Reader) 98 | 99 | switch value := r.Media.(type) { 100 | case []telegram.InputMediaAudio: 101 | for _, item := range value { 102 | if item.Thumbnail != nil && item.Thumbnail.HasFile() { 103 | files[item.Thumbnail.GetFormFieldName()] = item.Thumbnail.GetFile() 104 | } 105 | if item.Media.HasFile() { 106 | files[item.Media.GetFormFieldName()] = item.Media.GetFile() 107 | } 108 | } 109 | case []telegram.InputMediaDocument: 110 | for _, item := range value { 111 | if item.Media.HasFile() { 112 | files[item.Media.GetFormFieldName()] = item.Media.GetFile() 113 | } 114 | if item.Thumbnail != nil && item.Thumbnail.HasFile() { 115 | files[item.Thumbnail.GetFormFieldName()] = item.Thumbnail.GetFile() 116 | } 117 | } 118 | case []telegram.InputMediaPhoto: 119 | for _, item := range value { 120 | if item.Media.HasFile() { 121 | files[item.Media.GetFormFieldName()] = item.Media.GetFile() 122 | } 123 | } 124 | case []telegram.InputMediaVideo: 125 | for _, item := range value { 126 | if item.Media.HasFile() { 127 | files[item.Media.GetFormFieldName()] = item.Media.GetFile() 128 | } 129 | if item.Thumbnail != nil && item.Thumbnail.HasFile() { 130 | files[item.Thumbnail.GetFormFieldName()] = item.Thumbnail.GetFile() 131 | } 132 | if item.Cover != nil && item.Cover.HasFile() { 133 | files[item.Cover.GetFormFieldName()] = item.Cover.GetFile() 134 | } 135 | } 136 | } 137 | return 138 | } 139 | -------------------------------------------------------------------------------- /requests/send_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendMessage struct { 13 | ChatId telegram.ChatId 14 | Text string 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | DisableNotification *bool 18 | Entities []telegram.MessageEntity 19 | LinkPreviewOptions *telegram.LinkPreviewOptions 20 | MessageEffectId *string 21 | MessageThreadId *int64 22 | ParseMode *string 23 | ProtectContent *bool 24 | ReplyMarkup interface{} 25 | ReplyParameters *telegram.ReplyParameters 26 | } 27 | 28 | func (r *SendMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 29 | response = new(telegram.Message) 30 | err = b.CallMethod(ctx, "sendMessage", r, response) 31 | return 32 | } 33 | 34 | func (r *SendMessage) GetValues() (values map[string]interface{}, err error) { 35 | values = make(map[string]interface{}) 36 | 37 | values["chat_id"] = r.ChatId.String() 38 | 39 | values["text"] = r.Text 40 | 41 | if r.AllowPaidBroadcast != nil { 42 | if *r.AllowPaidBroadcast { 43 | values["allow_paid_broadcast"] = "1" 44 | } else { 45 | values["allow_paid_broadcast"] = "0" 46 | } 47 | } 48 | 49 | if r.BusinessConnectionId != nil { 50 | values["business_connection_id"] = *r.BusinessConnectionId 51 | } 52 | 53 | if r.DisableNotification != nil { 54 | if *r.DisableNotification { 55 | values["disable_notification"] = "1" 56 | } else { 57 | values["disable_notification"] = "0" 58 | } 59 | } 60 | 61 | if r.Entities != nil { 62 | var dataEntities []byte 63 | if dataEntities, err = json.Marshal(r.Entities); err != nil { 64 | return 65 | } 66 | 67 | values["entities"] = string(dataEntities) 68 | } 69 | 70 | if r.LinkPreviewOptions != nil { 71 | var dataLinkPreviewOptions []byte 72 | if dataLinkPreviewOptions, err = json.Marshal(r.LinkPreviewOptions); err != nil { 73 | return 74 | } 75 | 76 | values["link_preview_options"] = string(dataLinkPreviewOptions) 77 | } 78 | 79 | if r.MessageEffectId != nil { 80 | values["message_effect_id"] = *r.MessageEffectId 81 | } 82 | 83 | if r.MessageThreadId != nil { 84 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 85 | } 86 | 87 | if r.ParseMode != nil { 88 | values["parse_mode"] = *r.ParseMode 89 | } 90 | 91 | if r.ProtectContent != nil { 92 | if *r.ProtectContent { 93 | values["protect_content"] = "1" 94 | } else { 95 | values["protect_content"] = "0" 96 | } 97 | } 98 | 99 | if r.ReplyMarkup != nil { 100 | switch value := r.ReplyMarkup.(type) { 101 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 102 | var data []byte 103 | if data, err = json.Marshal(value); err != nil { 104 | return 105 | } 106 | 107 | values["reply_markup"] = string(data) 108 | default: 109 | err = errors.New("unsupported reply_markup field type") 110 | return 111 | } 112 | } 113 | 114 | if r.ReplyParameters != nil { 115 | var dataReplyParameters []byte 116 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 117 | return 118 | } 119 | 120 | values["reply_parameters"] = string(dataReplyParameters) 121 | } 122 | 123 | return 124 | } 125 | 126 | func (r *SendMessage) GetFiles() (files map[string]io.Reader) { 127 | return 128 | } 129 | -------------------------------------------------------------------------------- /requests/send_paid_media.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendPaidMedia struct { 13 | ChatId telegram.ChatId 14 | Media []interface{} 15 | StarCount int64 16 | AllowPaidBroadcast *bool 17 | BusinessConnectionId *string 18 | Caption *string 19 | CaptionEntities []telegram.MessageEntity 20 | DisableNotification *bool 21 | ParseMode *string 22 | Payload *string 23 | ProtectContent *bool 24 | ReplyMarkup interface{} 25 | ReplyParameters *telegram.ReplyParameters 26 | ShowCaptionAboveMedia *bool 27 | } 28 | 29 | func (r *SendPaidMedia) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 30 | response = new(telegram.Message) 31 | err = b.CallMethod(ctx, "sendPaidMedia", r, response) 32 | return 33 | } 34 | 35 | func (r *SendPaidMedia) GetValues() (values map[string]interface{}, err error) { 36 | values = make(map[string]interface{}) 37 | 38 | values["chat_id"] = r.ChatId.String() 39 | 40 | var dataMedia []byte 41 | if dataMedia, err = json.Marshal(r.Media); err != nil { 42 | return 43 | } 44 | 45 | values["media"] = string(dataMedia) 46 | 47 | values["star_count"] = strconv.FormatInt(r.StarCount, 10) 48 | 49 | if r.AllowPaidBroadcast != nil { 50 | if *r.AllowPaidBroadcast { 51 | values["allow_paid_broadcast"] = "1" 52 | } else { 53 | values["allow_paid_broadcast"] = "0" 54 | } 55 | } 56 | 57 | if r.BusinessConnectionId != nil { 58 | values["business_connection_id"] = *r.BusinessConnectionId 59 | } 60 | 61 | if r.Caption != nil { 62 | values["caption"] = *r.Caption 63 | } 64 | 65 | if r.CaptionEntities != nil { 66 | var dataCaptionEntities []byte 67 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 68 | return 69 | } 70 | 71 | values["caption_entities"] = string(dataCaptionEntities) 72 | } 73 | 74 | if r.DisableNotification != nil { 75 | if *r.DisableNotification { 76 | values["disable_notification"] = "1" 77 | } else { 78 | values["disable_notification"] = "0" 79 | } 80 | } 81 | 82 | if r.ParseMode != nil { 83 | values["parse_mode"] = *r.ParseMode 84 | } 85 | 86 | if r.Payload != nil { 87 | values["payload"] = *r.Payload 88 | } 89 | 90 | if r.ProtectContent != nil { 91 | if *r.ProtectContent { 92 | values["protect_content"] = "1" 93 | } else { 94 | values["protect_content"] = "0" 95 | } 96 | } 97 | 98 | if r.ReplyMarkup != nil { 99 | switch value := r.ReplyMarkup.(type) { 100 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 101 | var data []byte 102 | if data, err = json.Marshal(value); err != nil { 103 | return 104 | } 105 | 106 | values["reply_markup"] = string(data) 107 | default: 108 | err = errors.New("unsupported reply_markup field type") 109 | return 110 | } 111 | } 112 | 113 | if r.ReplyParameters != nil { 114 | var dataReplyParameters []byte 115 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 116 | return 117 | } 118 | 119 | values["reply_parameters"] = string(dataReplyParameters) 120 | } 121 | 122 | if r.ShowCaptionAboveMedia != nil { 123 | if *r.ShowCaptionAboveMedia { 124 | values["show_caption_above_media"] = "1" 125 | } else { 126 | values["show_caption_above_media"] = "0" 127 | } 128 | } 129 | 130 | return 131 | } 132 | 133 | func (r *SendPaidMedia) GetFiles() (files map[string]io.Reader) { 134 | return 135 | } 136 | -------------------------------------------------------------------------------- /requests/send_photo.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendPhoto struct { 13 | ChatId telegram.ChatId 14 | Photo telegram.InputFile 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | Caption *string 18 | CaptionEntities []telegram.MessageEntity 19 | DisableNotification *bool 20 | HasSpoiler *bool 21 | MessageEffectId *string 22 | MessageThreadId *int64 23 | ParseMode *string 24 | ProtectContent *bool 25 | ReplyMarkup interface{} 26 | ReplyParameters *telegram.ReplyParameters 27 | ShowCaptionAboveMedia *bool 28 | } 29 | 30 | func (r *SendPhoto) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 31 | response = new(telegram.Message) 32 | err = b.CallMethod(ctx, "sendPhoto", r, response) 33 | return 34 | } 35 | 36 | func (r *SendPhoto) GetValues() (values map[string]interface{}, err error) { 37 | values = make(map[string]interface{}) 38 | 39 | values["chat_id"] = r.ChatId.String() 40 | 41 | values["photo"] = r.Photo.GetValue() 42 | 43 | if r.AllowPaidBroadcast != nil { 44 | if *r.AllowPaidBroadcast { 45 | values["allow_paid_broadcast"] = "1" 46 | } else { 47 | values["allow_paid_broadcast"] = "0" 48 | } 49 | } 50 | 51 | if r.BusinessConnectionId != nil { 52 | values["business_connection_id"] = *r.BusinessConnectionId 53 | } 54 | 55 | if r.Caption != nil { 56 | values["caption"] = *r.Caption 57 | } 58 | 59 | if r.CaptionEntities != nil { 60 | var dataCaptionEntities []byte 61 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 62 | return 63 | } 64 | 65 | values["caption_entities"] = string(dataCaptionEntities) 66 | } 67 | 68 | if r.DisableNotification != nil { 69 | if *r.DisableNotification { 70 | values["disable_notification"] = "1" 71 | } else { 72 | values["disable_notification"] = "0" 73 | } 74 | } 75 | 76 | if r.HasSpoiler != nil { 77 | if *r.HasSpoiler { 78 | values["has_spoiler"] = "1" 79 | } else { 80 | values["has_spoiler"] = "0" 81 | } 82 | } 83 | 84 | if r.MessageEffectId != nil { 85 | values["message_effect_id"] = *r.MessageEffectId 86 | } 87 | 88 | if r.MessageThreadId != nil { 89 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 90 | } 91 | 92 | if r.ParseMode != nil { 93 | values["parse_mode"] = *r.ParseMode 94 | } 95 | 96 | if r.ProtectContent != nil { 97 | if *r.ProtectContent { 98 | values["protect_content"] = "1" 99 | } else { 100 | values["protect_content"] = "0" 101 | } 102 | } 103 | 104 | if r.ReplyMarkup != nil { 105 | switch value := r.ReplyMarkup.(type) { 106 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 107 | var data []byte 108 | if data, err = json.Marshal(value); err != nil { 109 | return 110 | } 111 | 112 | values["reply_markup"] = string(data) 113 | default: 114 | err = errors.New("unsupported reply_markup field type") 115 | return 116 | } 117 | } 118 | 119 | if r.ReplyParameters != nil { 120 | var dataReplyParameters []byte 121 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 122 | return 123 | } 124 | 125 | values["reply_parameters"] = string(dataReplyParameters) 126 | } 127 | 128 | if r.ShowCaptionAboveMedia != nil { 129 | if *r.ShowCaptionAboveMedia { 130 | values["show_caption_above_media"] = "1" 131 | } else { 132 | values["show_caption_above_media"] = "0" 133 | } 134 | } 135 | 136 | return 137 | } 138 | 139 | func (r *SendPhoto) GetFiles() (files map[string]io.Reader) { 140 | return 141 | } 142 | -------------------------------------------------------------------------------- /requests/send_sticker.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendSticker struct { 13 | ChatId telegram.ChatId 14 | Sticker telegram.InputFile 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | DisableNotification *bool 18 | Emoji *string 19 | MessageEffectId *string 20 | MessageThreadId *int64 21 | ProtectContent *bool 22 | ReplyMarkup interface{} 23 | ReplyParameters *telegram.ReplyParameters 24 | } 25 | 26 | func (r *SendSticker) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 27 | response = new(telegram.Message) 28 | err = b.CallMethod(ctx, "sendSticker", r, response) 29 | return 30 | } 31 | 32 | func (r *SendSticker) GetValues() (values map[string]interface{}, err error) { 33 | values = make(map[string]interface{}) 34 | 35 | values["chat_id"] = r.ChatId.String() 36 | 37 | values["sticker"] = r.Sticker.GetValue() 38 | 39 | if r.AllowPaidBroadcast != nil { 40 | if *r.AllowPaidBroadcast { 41 | values["allow_paid_broadcast"] = "1" 42 | } else { 43 | values["allow_paid_broadcast"] = "0" 44 | } 45 | } 46 | 47 | if r.BusinessConnectionId != nil { 48 | values["business_connection_id"] = *r.BusinessConnectionId 49 | } 50 | 51 | if r.DisableNotification != nil { 52 | if *r.DisableNotification { 53 | values["disable_notification"] = "1" 54 | } else { 55 | values["disable_notification"] = "0" 56 | } 57 | } 58 | 59 | if r.Emoji != nil { 60 | values["emoji"] = *r.Emoji 61 | } 62 | 63 | if r.MessageEffectId != nil { 64 | values["message_effect_id"] = *r.MessageEffectId 65 | } 66 | 67 | if r.MessageThreadId != nil { 68 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 69 | } 70 | 71 | if r.ProtectContent != nil { 72 | if *r.ProtectContent { 73 | values["protect_content"] = "1" 74 | } else { 75 | values["protect_content"] = "0" 76 | } 77 | } 78 | 79 | if r.ReplyMarkup != nil { 80 | switch value := r.ReplyMarkup.(type) { 81 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 82 | var data []byte 83 | if data, err = json.Marshal(value); err != nil { 84 | return 85 | } 86 | 87 | values["reply_markup"] = string(data) 88 | default: 89 | err = errors.New("unsupported reply_markup field type") 90 | return 91 | } 92 | } 93 | 94 | if r.ReplyParameters != nil { 95 | var dataReplyParameters []byte 96 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 97 | return 98 | } 99 | 100 | values["reply_parameters"] = string(dataReplyParameters) 101 | } 102 | 103 | return 104 | } 105 | 106 | func (r *SendSticker) GetFiles() (files map[string]io.Reader) { 107 | return 108 | } 109 | -------------------------------------------------------------------------------- /requests/send_venue.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendVenue struct { 13 | Address string 14 | ChatId telegram.ChatId 15 | Latitude float64 16 | Longitude float64 17 | Title string 18 | AllowPaidBroadcast *bool 19 | BusinessConnectionId *string 20 | DisableNotification *bool 21 | FoursquareId *string 22 | FoursquareType *string 23 | GooglePlaceId *string 24 | GooglePlaceType *string 25 | MessageEffectId *string 26 | MessageThreadId *int64 27 | ProtectContent *bool 28 | ReplyMarkup interface{} 29 | ReplyParameters *telegram.ReplyParameters 30 | } 31 | 32 | func (r *SendVenue) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 33 | response = new(telegram.Message) 34 | err = b.CallMethod(ctx, "sendVenue", r, response) 35 | return 36 | } 37 | 38 | func (r *SendVenue) GetValues() (values map[string]interface{}, err error) { 39 | values = make(map[string]interface{}) 40 | 41 | values["address"] = r.Address 42 | 43 | values["chat_id"] = r.ChatId.String() 44 | 45 | values["latitude"] = strconv.FormatFloat(r.Latitude, 'f', -1, 64) 46 | 47 | values["longitude"] = strconv.FormatFloat(r.Longitude, 'f', -1, 64) 48 | 49 | values["title"] = r.Title 50 | 51 | if r.AllowPaidBroadcast != nil { 52 | if *r.AllowPaidBroadcast { 53 | values["allow_paid_broadcast"] = "1" 54 | } else { 55 | values["allow_paid_broadcast"] = "0" 56 | } 57 | } 58 | 59 | if r.BusinessConnectionId != nil { 60 | values["business_connection_id"] = *r.BusinessConnectionId 61 | } 62 | 63 | if r.DisableNotification != nil { 64 | if *r.DisableNotification { 65 | values["disable_notification"] = "1" 66 | } else { 67 | values["disable_notification"] = "0" 68 | } 69 | } 70 | 71 | if r.FoursquareId != nil { 72 | values["foursquare_id"] = *r.FoursquareId 73 | } 74 | 75 | if r.FoursquareType != nil { 76 | values["foursquare_type"] = *r.FoursquareType 77 | } 78 | 79 | if r.GooglePlaceId != nil { 80 | values["google_place_id"] = *r.GooglePlaceId 81 | } 82 | 83 | if r.GooglePlaceType != nil { 84 | values["google_place_type"] = *r.GooglePlaceType 85 | } 86 | 87 | if r.MessageEffectId != nil { 88 | values["message_effect_id"] = *r.MessageEffectId 89 | } 90 | 91 | if r.MessageThreadId != nil { 92 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 93 | } 94 | 95 | if r.ProtectContent != nil { 96 | if *r.ProtectContent { 97 | values["protect_content"] = "1" 98 | } else { 99 | values["protect_content"] = "0" 100 | } 101 | } 102 | 103 | if r.ReplyMarkup != nil { 104 | switch value := r.ReplyMarkup.(type) { 105 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 106 | var data []byte 107 | if data, err = json.Marshal(value); err != nil { 108 | return 109 | } 110 | 111 | values["reply_markup"] = string(data) 112 | default: 113 | err = errors.New("unsupported reply_markup field type") 114 | return 115 | } 116 | } 117 | 118 | if r.ReplyParameters != nil { 119 | var dataReplyParameters []byte 120 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 121 | return 122 | } 123 | 124 | values["reply_parameters"] = string(dataReplyParameters) 125 | } 126 | 127 | return 128 | } 129 | 130 | func (r *SendVenue) GetFiles() (files map[string]io.Reader) { 131 | return 132 | } 133 | -------------------------------------------------------------------------------- /requests/send_video_note.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendVideoNote struct { 13 | ChatId telegram.ChatId 14 | VideoNote telegram.InputFile 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | DisableNotification *bool 18 | Duration *int64 19 | Length *int64 20 | MessageEffectId *string 21 | MessageThreadId *int64 22 | ProtectContent *bool 23 | ReplyMarkup interface{} 24 | ReplyParameters *telegram.ReplyParameters 25 | Thumbnail *telegram.InputFile 26 | } 27 | 28 | func (r *SendVideoNote) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 29 | response = new(telegram.Message) 30 | err = b.CallMethod(ctx, "sendVideoNote", r, response) 31 | return 32 | } 33 | 34 | func (r *SendVideoNote) GetValues() (values map[string]interface{}, err error) { 35 | values = make(map[string]interface{}) 36 | 37 | values["chat_id"] = r.ChatId.String() 38 | 39 | values["video_note"] = r.VideoNote.GetValue() 40 | 41 | if r.AllowPaidBroadcast != nil { 42 | if *r.AllowPaidBroadcast { 43 | values["allow_paid_broadcast"] = "1" 44 | } else { 45 | values["allow_paid_broadcast"] = "0" 46 | } 47 | } 48 | 49 | if r.BusinessConnectionId != nil { 50 | values["business_connection_id"] = *r.BusinessConnectionId 51 | } 52 | 53 | if r.DisableNotification != nil { 54 | if *r.DisableNotification { 55 | values["disable_notification"] = "1" 56 | } else { 57 | values["disable_notification"] = "0" 58 | } 59 | } 60 | 61 | if r.Duration != nil { 62 | values["duration"] = strconv.FormatInt(*r.Duration, 10) 63 | } 64 | 65 | if r.Length != nil { 66 | values["length"] = strconv.FormatInt(*r.Length, 10) 67 | } 68 | 69 | if r.MessageEffectId != nil { 70 | values["message_effect_id"] = *r.MessageEffectId 71 | } 72 | 73 | if r.MessageThreadId != nil { 74 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 75 | } 76 | 77 | if r.ProtectContent != nil { 78 | if *r.ProtectContent { 79 | values["protect_content"] = "1" 80 | } else { 81 | values["protect_content"] = "0" 82 | } 83 | } 84 | 85 | if r.ReplyMarkup != nil { 86 | switch value := r.ReplyMarkup.(type) { 87 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 88 | var data []byte 89 | if data, err = json.Marshal(value); err != nil { 90 | return 91 | } 92 | 93 | values["reply_markup"] = string(data) 94 | default: 95 | err = errors.New("unsupported reply_markup field type") 96 | return 97 | } 98 | } 99 | 100 | if r.ReplyParameters != nil { 101 | var dataReplyParameters []byte 102 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 103 | return 104 | } 105 | 106 | values["reply_parameters"] = string(dataReplyParameters) 107 | } 108 | 109 | if r.Thumbnail != nil { 110 | values["thumbnail"] = r.Thumbnail.GetValue() 111 | } 112 | 113 | return 114 | } 115 | 116 | func (r *SendVideoNote) GetFiles() (files map[string]io.Reader) { 117 | return 118 | } 119 | -------------------------------------------------------------------------------- /requests/send_voice.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "errors" 7 | "github.com/temoon/telegram-bots-api" 8 | "io" 9 | "strconv" 10 | ) 11 | 12 | type SendVoice struct { 13 | ChatId telegram.ChatId 14 | Voice telegram.InputFile 15 | AllowPaidBroadcast *bool 16 | BusinessConnectionId *string 17 | Caption *string 18 | CaptionEntities []telegram.MessageEntity 19 | DisableNotification *bool 20 | Duration *int64 21 | MessageEffectId *string 22 | MessageThreadId *int64 23 | ParseMode *string 24 | ProtectContent *bool 25 | ReplyMarkup interface{} 26 | ReplyParameters *telegram.ReplyParameters 27 | } 28 | 29 | func (r *SendVoice) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 30 | response = new(telegram.Message) 31 | err = b.CallMethod(ctx, "sendVoice", r, response) 32 | return 33 | } 34 | 35 | func (r *SendVoice) GetValues() (values map[string]interface{}, err error) { 36 | values = make(map[string]interface{}) 37 | 38 | values["chat_id"] = r.ChatId.String() 39 | 40 | values["voice"] = r.Voice.GetValue() 41 | 42 | if r.AllowPaidBroadcast != nil { 43 | if *r.AllowPaidBroadcast { 44 | values["allow_paid_broadcast"] = "1" 45 | } else { 46 | values["allow_paid_broadcast"] = "0" 47 | } 48 | } 49 | 50 | if r.BusinessConnectionId != nil { 51 | values["business_connection_id"] = *r.BusinessConnectionId 52 | } 53 | 54 | if r.Caption != nil { 55 | values["caption"] = *r.Caption 56 | } 57 | 58 | if r.CaptionEntities != nil { 59 | var dataCaptionEntities []byte 60 | if dataCaptionEntities, err = json.Marshal(r.CaptionEntities); err != nil { 61 | return 62 | } 63 | 64 | values["caption_entities"] = string(dataCaptionEntities) 65 | } 66 | 67 | if r.DisableNotification != nil { 68 | if *r.DisableNotification { 69 | values["disable_notification"] = "1" 70 | } else { 71 | values["disable_notification"] = "0" 72 | } 73 | } 74 | 75 | if r.Duration != nil { 76 | values["duration"] = strconv.FormatInt(*r.Duration, 10) 77 | } 78 | 79 | if r.MessageEffectId != nil { 80 | values["message_effect_id"] = *r.MessageEffectId 81 | } 82 | 83 | if r.MessageThreadId != nil { 84 | values["message_thread_id"] = strconv.FormatInt(*r.MessageThreadId, 10) 85 | } 86 | 87 | if r.ParseMode != nil { 88 | values["parse_mode"] = *r.ParseMode 89 | } 90 | 91 | if r.ProtectContent != nil { 92 | if *r.ProtectContent { 93 | values["protect_content"] = "1" 94 | } else { 95 | values["protect_content"] = "0" 96 | } 97 | } 98 | 99 | if r.ReplyMarkup != nil { 100 | switch value := r.ReplyMarkup.(type) { 101 | case telegram.InlineKeyboardMarkup, telegram.ReplyKeyboardMarkup, telegram.ReplyKeyboardRemove, telegram.ForceReply: 102 | var data []byte 103 | if data, err = json.Marshal(value); err != nil { 104 | return 105 | } 106 | 107 | values["reply_markup"] = string(data) 108 | default: 109 | err = errors.New("unsupported reply_markup field type") 110 | return 111 | } 112 | } 113 | 114 | if r.ReplyParameters != nil { 115 | var dataReplyParameters []byte 116 | if dataReplyParameters, err = json.Marshal(r.ReplyParameters); err != nil { 117 | return 118 | } 119 | 120 | values["reply_parameters"] = string(dataReplyParameters) 121 | } 122 | 123 | return 124 | } 125 | 126 | func (r *SendVoice) GetFiles() (files map[string]io.Reader) { 127 | return 128 | } 129 | -------------------------------------------------------------------------------- /requests/set_business_account_bio.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetBusinessAccountBio struct { 10 | BusinessConnectionId string 11 | Bio *string 12 | } 13 | 14 | func (r *SetBusinessAccountBio) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setBusinessAccountBio", r, response) 17 | return 18 | } 19 | 20 | func (r *SetBusinessAccountBio) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["business_connection_id"] = r.BusinessConnectionId 24 | 25 | if r.Bio != nil { 26 | values["bio"] = *r.Bio 27 | } 28 | 29 | return 30 | } 31 | 32 | func (r *SetBusinessAccountBio) GetFiles() (files map[string]io.Reader) { 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /requests/set_business_account_gift_settings.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetBusinessAccountGiftSettings struct { 11 | AcceptedGiftTypes telegram.AcceptedGiftTypes 12 | BusinessConnectionId string 13 | ShowGiftButton bool 14 | } 15 | 16 | func (r *SetBusinessAccountGiftSettings) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setBusinessAccountGiftSettings", r, response) 19 | return 20 | } 21 | 22 | func (r *SetBusinessAccountGiftSettings) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | var dataAcceptedGiftTypes []byte 26 | if dataAcceptedGiftTypes, err = json.Marshal(r.AcceptedGiftTypes); err != nil { 27 | return 28 | } 29 | 30 | values["accepted_gift_types"] = string(dataAcceptedGiftTypes) 31 | 32 | values["business_connection_id"] = r.BusinessConnectionId 33 | 34 | if r.ShowGiftButton { 35 | values["show_gift_button"] = "1" 36 | } else { 37 | values["show_gift_button"] = "0" 38 | } 39 | 40 | return 41 | } 42 | 43 | func (r *SetBusinessAccountGiftSettings) GetFiles() (files map[string]io.Reader) { 44 | return 45 | } 46 | -------------------------------------------------------------------------------- /requests/set_business_account_name.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetBusinessAccountName struct { 10 | BusinessConnectionId string 11 | FirstName string 12 | LastName *string 13 | } 14 | 15 | func (r *SetBusinessAccountName) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "setBusinessAccountName", r, response) 18 | return 19 | } 20 | 21 | func (r *SetBusinessAccountName) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["business_connection_id"] = r.BusinessConnectionId 25 | 26 | values["first_name"] = r.FirstName 27 | 28 | if r.LastName != nil { 29 | values["last_name"] = *r.LastName 30 | } 31 | 32 | return 33 | } 34 | 35 | func (r *SetBusinessAccountName) GetFiles() (files map[string]io.Reader) { 36 | return 37 | } 38 | -------------------------------------------------------------------------------- /requests/set_business_account_profile_photo.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetBusinessAccountProfilePhoto struct { 11 | BusinessConnectionId string 12 | Photo interface{} 13 | IsPublic *bool 14 | } 15 | 16 | func (r *SetBusinessAccountProfilePhoto) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setBusinessAccountProfilePhoto", r, response) 19 | return 20 | } 21 | 22 | func (r *SetBusinessAccountProfilePhoto) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["business_connection_id"] = r.BusinessConnectionId 26 | 27 | var dataPhoto []byte 28 | if dataPhoto, err = json.Marshal(r.Photo); err != nil { 29 | return 30 | } 31 | 32 | values["photo"] = string(dataPhoto) 33 | 34 | if r.IsPublic != nil { 35 | if *r.IsPublic { 36 | values["is_public"] = "1" 37 | } else { 38 | values["is_public"] = "0" 39 | } 40 | } 41 | 42 | return 43 | } 44 | 45 | func (r *SetBusinessAccountProfilePhoto) GetFiles() (files map[string]io.Reader) { 46 | files = make(map[string]io.Reader) 47 | 48 | switch value := r.Photo.(type) { 49 | case telegram.InputProfilePhotoStatic: 50 | if value.Photo.HasFile() { 51 | files[value.Photo.GetFormFieldName()] = value.Photo.GetFile() 52 | } 53 | case telegram.InputProfilePhotoAnimated: 54 | if value.Animation.HasFile() { 55 | files[value.Animation.GetFormFieldName()] = value.Animation.GetFile() 56 | } 57 | } 58 | 59 | return 60 | } 61 | -------------------------------------------------------------------------------- /requests/set_business_account_username.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetBusinessAccountUsername struct { 10 | BusinessConnectionId string 11 | Username *string 12 | } 13 | 14 | func (r *SetBusinessAccountUsername) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setBusinessAccountUsername", r, response) 17 | return 18 | } 19 | 20 | func (r *SetBusinessAccountUsername) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["business_connection_id"] = r.BusinessConnectionId 24 | 25 | if r.Username != nil { 26 | values["username"] = *r.Username 27 | } 28 | 29 | return 30 | } 31 | 32 | func (r *SetBusinessAccountUsername) GetFiles() (files map[string]io.Reader) { 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /requests/set_chat_administrator_custom_title.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type SetChatAdministratorCustomTitle struct { 11 | ChatId telegram.ChatId 12 | CustomTitle string 13 | UserId int64 14 | } 15 | 16 | func (r *SetChatAdministratorCustomTitle) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setChatAdministratorCustomTitle", r, response) 19 | return 20 | } 21 | 22 | func (r *SetChatAdministratorCustomTitle) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["chat_id"] = r.ChatId.String() 26 | 27 | values["custom_title"] = r.CustomTitle 28 | 29 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 30 | 31 | return 32 | } 33 | 34 | func (r *SetChatAdministratorCustomTitle) GetFiles() (files map[string]io.Reader) { 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /requests/set_chat_description.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetChatDescription struct { 10 | ChatId telegram.ChatId 11 | Description *string 12 | } 13 | 14 | func (r *SetChatDescription) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setChatDescription", r, response) 17 | return 18 | } 19 | 20 | func (r *SetChatDescription) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["chat_id"] = r.ChatId.String() 24 | 25 | if r.Description != nil { 26 | values["description"] = *r.Description 27 | } 28 | 29 | return 30 | } 31 | 32 | func (r *SetChatDescription) GetFiles() (files map[string]io.Reader) { 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /requests/set_chat_menu_button.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type SetChatMenuButton struct { 12 | ChatId *int64 13 | MenuButton interface{} 14 | } 15 | 16 | func (r *SetChatMenuButton) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setChatMenuButton", r, response) 19 | return 20 | } 21 | 22 | func (r *SetChatMenuButton) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | if r.ChatId != nil { 26 | values["chat_id"] = strconv.FormatInt(*r.ChatId, 10) 27 | } 28 | 29 | if r.MenuButton != nil { 30 | var dataMenuButton []byte 31 | if dataMenuButton, err = json.Marshal(r.MenuButton); err != nil { 32 | return 33 | } 34 | 35 | values["menu_button"] = string(dataMenuButton) 36 | } 37 | 38 | return 39 | } 40 | 41 | func (r *SetChatMenuButton) GetFiles() (files map[string]io.Reader) { 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /requests/set_chat_permissions.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetChatPermissions struct { 11 | ChatId telegram.ChatId 12 | Permissions telegram.ChatPermissions 13 | UseIndependentChatPermissions *bool 14 | } 15 | 16 | func (r *SetChatPermissions) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setChatPermissions", r, response) 19 | return 20 | } 21 | 22 | func (r *SetChatPermissions) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["chat_id"] = r.ChatId.String() 26 | 27 | var dataPermissions []byte 28 | if dataPermissions, err = json.Marshal(r.Permissions); err != nil { 29 | return 30 | } 31 | 32 | values["permissions"] = string(dataPermissions) 33 | 34 | if r.UseIndependentChatPermissions != nil { 35 | if *r.UseIndependentChatPermissions { 36 | values["use_independent_chat_permissions"] = "1" 37 | } else { 38 | values["use_independent_chat_permissions"] = "0" 39 | } 40 | } 41 | 42 | return 43 | } 44 | 45 | func (r *SetChatPermissions) GetFiles() (files map[string]io.Reader) { 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /requests/set_chat_photo.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetChatPhoto struct { 10 | ChatId telegram.ChatId 11 | Photo telegram.InputFile 12 | } 13 | 14 | func (r *SetChatPhoto) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setChatPhoto", r, response) 17 | return 18 | } 19 | 20 | func (r *SetChatPhoto) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["chat_id"] = r.ChatId.String() 24 | 25 | values["photo"] = r.Photo.GetValue() 26 | 27 | return 28 | } 29 | 30 | func (r *SetChatPhoto) GetFiles() (files map[string]io.Reader) { 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /requests/set_chat_sticker_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetChatStickerSet struct { 10 | ChatId telegram.ChatId 11 | StickerSetName string 12 | } 13 | 14 | func (r *SetChatStickerSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setChatStickerSet", r, response) 17 | return 18 | } 19 | 20 | func (r *SetChatStickerSet) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["chat_id"] = r.ChatId.String() 24 | 25 | values["sticker_set_name"] = r.StickerSetName 26 | 27 | return 28 | } 29 | 30 | func (r *SetChatStickerSet) GetFiles() (files map[string]io.Reader) { 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /requests/set_chat_title.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetChatTitle struct { 10 | ChatId telegram.ChatId 11 | Title string 12 | } 13 | 14 | func (r *SetChatTitle) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setChatTitle", r, response) 17 | return 18 | } 19 | 20 | func (r *SetChatTitle) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["chat_id"] = r.ChatId.String() 24 | 25 | values["title"] = r.Title 26 | 27 | return 28 | } 29 | 30 | func (r *SetChatTitle) GetFiles() (files map[string]io.Reader) { 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /requests/set_custom_emoji_sticker_set_thumbnail.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetCustomEmojiStickerSetThumbnail struct { 10 | Name string 11 | CustomEmojiId *string 12 | } 13 | 14 | func (r *SetCustomEmojiStickerSetThumbnail) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setCustomEmojiStickerSetThumbnail", r, response) 17 | return 18 | } 19 | 20 | func (r *SetCustomEmojiStickerSetThumbnail) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["name"] = r.Name 24 | 25 | if r.CustomEmojiId != nil { 26 | values["custom_emoji_id"] = *r.CustomEmojiId 27 | } 28 | 29 | return 30 | } 31 | 32 | func (r *SetCustomEmojiStickerSetThumbnail) GetFiles() (files map[string]io.Reader) { 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /requests/set_game_score.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type SetGameScore struct { 11 | Score int64 12 | UserId int64 13 | ChatId *int64 14 | DisableEditMessage *bool 15 | Force *bool 16 | InlineMessageId *string 17 | MessageId *int64 18 | } 19 | 20 | func (r *SetGameScore) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 21 | response = new(telegram.Message) 22 | err = b.CallMethod(ctx, "setGameScore", r, response) 23 | return 24 | } 25 | 26 | func (r *SetGameScore) GetValues() (values map[string]interface{}, err error) { 27 | values = make(map[string]interface{}) 28 | 29 | values["score"] = strconv.FormatInt(r.Score, 10) 30 | 31 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 32 | 33 | if r.ChatId != nil { 34 | values["chat_id"] = strconv.FormatInt(*r.ChatId, 10) 35 | } 36 | 37 | if r.DisableEditMessage != nil { 38 | if *r.DisableEditMessage { 39 | values["disable_edit_message"] = "1" 40 | } else { 41 | values["disable_edit_message"] = "0" 42 | } 43 | } 44 | 45 | if r.Force != nil { 46 | if *r.Force { 47 | values["force"] = "1" 48 | } else { 49 | values["force"] = "0" 50 | } 51 | } 52 | 53 | if r.InlineMessageId != nil { 54 | values["inline_message_id"] = *r.InlineMessageId 55 | } 56 | 57 | if r.MessageId != nil { 58 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 59 | } 60 | 61 | return 62 | } 63 | 64 | func (r *SetGameScore) GetFiles() (files map[string]io.Reader) { 65 | return 66 | } 67 | -------------------------------------------------------------------------------- /requests/set_message_reaction.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type SetMessageReaction struct { 12 | ChatId telegram.ChatId 13 | MessageId int64 14 | IsBig *bool 15 | Reaction []interface{} 16 | } 17 | 18 | func (r *SetMessageReaction) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 19 | response = new(bool) 20 | err = b.CallMethod(ctx, "setMessageReaction", r, response) 21 | return 22 | } 23 | 24 | func (r *SetMessageReaction) GetValues() (values map[string]interface{}, err error) { 25 | values = make(map[string]interface{}) 26 | 27 | values["chat_id"] = r.ChatId.String() 28 | 29 | values["message_id"] = strconv.FormatInt(r.MessageId, 10) 30 | 31 | if r.IsBig != nil { 32 | if *r.IsBig { 33 | values["is_big"] = "1" 34 | } else { 35 | values["is_big"] = "0" 36 | } 37 | } 38 | 39 | if r.Reaction != nil { 40 | var dataReaction []byte 41 | if dataReaction, err = json.Marshal(r.Reaction); err != nil { 42 | return 43 | } 44 | 45 | values["reaction"] = string(dataReaction) 46 | } 47 | 48 | return 49 | } 50 | 51 | func (r *SetMessageReaction) GetFiles() (files map[string]io.Reader) { 52 | return 53 | } 54 | -------------------------------------------------------------------------------- /requests/set_my_commands.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetMyCommands struct { 11 | Commands []telegram.BotCommand 12 | LanguageCode *string 13 | Scope interface{} 14 | } 15 | 16 | func (r *SetMyCommands) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setMyCommands", r, response) 19 | return 20 | } 21 | 22 | func (r *SetMyCommands) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | var dataCommands []byte 26 | if dataCommands, err = json.Marshal(r.Commands); err != nil { 27 | return 28 | } 29 | 30 | values["commands"] = string(dataCommands) 31 | 32 | if r.LanguageCode != nil { 33 | values["language_code"] = *r.LanguageCode 34 | } 35 | 36 | if r.Scope != nil { 37 | var dataScope []byte 38 | if dataScope, err = json.Marshal(r.Scope); err != nil { 39 | return 40 | } 41 | 42 | values["scope"] = string(dataScope) 43 | } 44 | 45 | return 46 | } 47 | 48 | func (r *SetMyCommands) GetFiles() (files map[string]io.Reader) { 49 | return 50 | } 51 | -------------------------------------------------------------------------------- /requests/set_my_default_administrator_rights.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetMyDefaultAdministratorRights struct { 11 | ForChannels *bool 12 | Rights *telegram.ChatAdministratorRights 13 | } 14 | 15 | func (r *SetMyDefaultAdministratorRights) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "setMyDefaultAdministratorRights", r, response) 18 | return 19 | } 20 | 21 | func (r *SetMyDefaultAdministratorRights) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | if r.ForChannels != nil { 25 | if *r.ForChannels { 26 | values["for_channels"] = "1" 27 | } else { 28 | values["for_channels"] = "0" 29 | } 30 | } 31 | 32 | if r.Rights != nil { 33 | var dataRights []byte 34 | if dataRights, err = json.Marshal(r.Rights); err != nil { 35 | return 36 | } 37 | 38 | values["rights"] = string(dataRights) 39 | } 40 | 41 | return 42 | } 43 | 44 | func (r *SetMyDefaultAdministratorRights) GetFiles() (files map[string]io.Reader) { 45 | return 46 | } 47 | -------------------------------------------------------------------------------- /requests/set_my_description.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetMyDescription struct { 10 | Description *string 11 | LanguageCode *string 12 | } 13 | 14 | func (r *SetMyDescription) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setMyDescription", r, response) 17 | return 18 | } 19 | 20 | func (r *SetMyDescription) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | if r.Description != nil { 24 | values["description"] = *r.Description 25 | } 26 | 27 | if r.LanguageCode != nil { 28 | values["language_code"] = *r.LanguageCode 29 | } 30 | 31 | return 32 | } 33 | 34 | func (r *SetMyDescription) GetFiles() (files map[string]io.Reader) { 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /requests/set_my_name.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetMyName struct { 10 | LanguageCode *string 11 | Name *string 12 | } 13 | 14 | func (r *SetMyName) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setMyName", r, response) 17 | return 18 | } 19 | 20 | func (r *SetMyName) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | if r.LanguageCode != nil { 24 | values["language_code"] = *r.LanguageCode 25 | } 26 | 27 | if r.Name != nil { 28 | values["name"] = *r.Name 29 | } 30 | 31 | return 32 | } 33 | 34 | func (r *SetMyName) GetFiles() (files map[string]io.Reader) { 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /requests/set_my_short_description.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetMyShortDescription struct { 10 | LanguageCode *string 11 | ShortDescription *string 12 | } 13 | 14 | func (r *SetMyShortDescription) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setMyShortDescription", r, response) 17 | return 18 | } 19 | 20 | func (r *SetMyShortDescription) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | if r.LanguageCode != nil { 24 | values["language_code"] = *r.LanguageCode 25 | } 26 | 27 | if r.ShortDescription != nil { 28 | values["short_description"] = *r.ShortDescription 29 | } 30 | 31 | return 32 | } 33 | 34 | func (r *SetMyShortDescription) GetFiles() (files map[string]io.Reader) { 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /requests/set_passport_data_errors.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type SetPassportDataErrors struct { 12 | Errors []interface{} 13 | UserId int64 14 | } 15 | 16 | func (r *SetPassportDataErrors) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setPassportDataErrors", r, response) 19 | return 20 | } 21 | 22 | func (r *SetPassportDataErrors) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | var dataErrors []byte 26 | if dataErrors, err = json.Marshal(r.Errors); err != nil { 27 | return 28 | } 29 | 30 | values["errors"] = string(dataErrors) 31 | 32 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 33 | 34 | return 35 | } 36 | 37 | func (r *SetPassportDataErrors) GetFiles() (files map[string]io.Reader) { 38 | return 39 | } 40 | -------------------------------------------------------------------------------- /requests/set_sticker_emoji_list.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetStickerEmojiList struct { 11 | EmojiList []string 12 | Sticker string 13 | } 14 | 15 | func (r *SetStickerEmojiList) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "setStickerEmojiList", r, response) 18 | return 19 | } 20 | 21 | func (r *SetStickerEmojiList) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | var dataEmojiList []byte 25 | if dataEmojiList, err = json.Marshal(r.EmojiList); err != nil { 26 | return 27 | } 28 | 29 | values["emoji_list"] = string(dataEmojiList) 30 | 31 | values["sticker"] = r.Sticker 32 | 33 | return 34 | } 35 | 36 | func (r *SetStickerEmojiList) GetFiles() (files map[string]io.Reader) { 37 | return 38 | } 39 | -------------------------------------------------------------------------------- /requests/set_sticker_keywords.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetStickerKeywords struct { 11 | Sticker string 12 | Keywords []string 13 | } 14 | 15 | func (r *SetStickerKeywords) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "setStickerKeywords", r, response) 18 | return 19 | } 20 | 21 | func (r *SetStickerKeywords) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["sticker"] = r.Sticker 25 | 26 | if r.Keywords != nil { 27 | var dataKeywords []byte 28 | if dataKeywords, err = json.Marshal(r.Keywords); err != nil { 29 | return 30 | } 31 | 32 | values["keywords"] = string(dataKeywords) 33 | } 34 | 35 | return 36 | } 37 | 38 | func (r *SetStickerKeywords) GetFiles() (files map[string]io.Reader) { 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /requests/set_sticker_mask_position.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | ) 9 | 10 | type SetStickerMaskPosition struct { 11 | Sticker string 12 | MaskPosition *telegram.MaskPosition 13 | } 14 | 15 | func (r *SetStickerMaskPosition) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "setStickerMaskPosition", r, response) 18 | return 19 | } 20 | 21 | func (r *SetStickerMaskPosition) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["sticker"] = r.Sticker 25 | 26 | if r.MaskPosition != nil { 27 | var dataMaskPosition []byte 28 | if dataMaskPosition, err = json.Marshal(r.MaskPosition); err != nil { 29 | return 30 | } 31 | 32 | values["mask_position"] = string(dataMaskPosition) 33 | } 34 | 35 | return 36 | } 37 | 38 | func (r *SetStickerMaskPosition) GetFiles() (files map[string]io.Reader) { 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /requests/set_sticker_position_in_set.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type SetStickerPositionInSet struct { 11 | Position int64 12 | Sticker string 13 | } 14 | 15 | func (r *SetStickerPositionInSet) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "setStickerPositionInSet", r, response) 18 | return 19 | } 20 | 21 | func (r *SetStickerPositionInSet) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["position"] = strconv.FormatInt(r.Position, 10) 25 | 26 | values["sticker"] = r.Sticker 27 | 28 | return 29 | } 30 | 31 | func (r *SetStickerPositionInSet) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/set_sticker_set_thumbnail.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type SetStickerSetThumbnail struct { 11 | Format string 12 | Name string 13 | UserId int64 14 | Thumbnail *telegram.InputFile 15 | } 16 | 17 | func (r *SetStickerSetThumbnail) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "setStickerSetThumbnail", r, response) 20 | return 21 | } 22 | 23 | func (r *SetStickerSetThumbnail) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["format"] = r.Format 27 | 28 | values["name"] = r.Name 29 | 30 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 31 | 32 | if r.Thumbnail != nil { 33 | values["thumbnail"] = r.Thumbnail.GetValue() 34 | } 35 | 36 | return 37 | } 38 | 39 | func (r *SetStickerSetThumbnail) GetFiles() (files map[string]io.Reader) { 40 | return 41 | } 42 | -------------------------------------------------------------------------------- /requests/set_sticker_set_title.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type SetStickerSetTitle struct { 10 | Name string 11 | Title string 12 | } 13 | 14 | func (r *SetStickerSetTitle) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "setStickerSetTitle", r, response) 17 | return 18 | } 19 | 20 | func (r *SetStickerSetTitle) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["name"] = r.Name 24 | 25 | values["title"] = r.Title 26 | 27 | return 28 | } 29 | 30 | func (r *SetStickerSetTitle) GetFiles() (files map[string]io.Reader) { 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /requests/set_user_emoji_status.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type SetUserEmojiStatus struct { 11 | UserId int64 12 | EmojiStatusCustomEmojiId *string 13 | EmojiStatusExpirationDate *int64 14 | } 15 | 16 | func (r *SetUserEmojiStatus) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "setUserEmojiStatus", r, response) 19 | return 20 | } 21 | 22 | func (r *SetUserEmojiStatus) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 26 | 27 | if r.EmojiStatusCustomEmojiId != nil { 28 | values["emoji_status_custom_emoji_id"] = *r.EmojiStatusCustomEmojiId 29 | } 30 | 31 | if r.EmojiStatusExpirationDate != nil { 32 | values["emoji_status_expiration_date"] = strconv.FormatInt(*r.EmojiStatusExpirationDate, 10) 33 | } 34 | 35 | return 36 | } 37 | 38 | func (r *SetUserEmojiStatus) GetFiles() (files map[string]io.Reader) { 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /requests/set_webhook.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type SetWebhook struct { 12 | Url string 13 | AllowedUpdates []string 14 | Certificate *telegram.InputFile 15 | DropPendingUpdates *bool 16 | IpAddress *string 17 | MaxConnections *int64 18 | SecretToken *string 19 | } 20 | 21 | func (r *SetWebhook) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 22 | response = new(bool) 23 | err = b.CallMethod(ctx, "setWebhook", r, response) 24 | return 25 | } 26 | 27 | func (r *SetWebhook) GetValues() (values map[string]interface{}, err error) { 28 | values = make(map[string]interface{}) 29 | 30 | values["url"] = r.Url 31 | 32 | if r.AllowedUpdates != nil { 33 | var dataAllowedUpdates []byte 34 | if dataAllowedUpdates, err = json.Marshal(r.AllowedUpdates); err != nil { 35 | return 36 | } 37 | 38 | values["allowed_updates"] = string(dataAllowedUpdates) 39 | } 40 | 41 | if r.Certificate != nil { 42 | values["certificate"] = r.Certificate.GetValue() 43 | } 44 | 45 | if r.DropPendingUpdates != nil { 46 | if *r.DropPendingUpdates { 47 | values["drop_pending_updates"] = "1" 48 | } else { 49 | values["drop_pending_updates"] = "0" 50 | } 51 | } 52 | 53 | if r.IpAddress != nil { 54 | values["ip_address"] = *r.IpAddress 55 | } 56 | 57 | if r.MaxConnections != nil { 58 | values["max_connections"] = strconv.FormatInt(*r.MaxConnections, 10) 59 | } 60 | 61 | if r.SecretToken != nil { 62 | values["secret_token"] = *r.SecretToken 63 | } 64 | 65 | return 66 | } 67 | 68 | func (r *SetWebhook) GetFiles() (files map[string]io.Reader) { 69 | return 70 | } 71 | -------------------------------------------------------------------------------- /requests/stop_message_live_location.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type StopMessageLiveLocation struct { 12 | BusinessConnectionId *string 13 | ChatId *telegram.ChatId 14 | InlineMessageId *string 15 | MessageId *int64 16 | ReplyMarkup *telegram.InlineKeyboardMarkup 17 | } 18 | 19 | func (r *StopMessageLiveLocation) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 20 | response = new(telegram.Message) 21 | err = b.CallMethod(ctx, "stopMessageLiveLocation", r, response) 22 | return 23 | } 24 | 25 | func (r *StopMessageLiveLocation) GetValues() (values map[string]interface{}, err error) { 26 | values = make(map[string]interface{}) 27 | 28 | if r.BusinessConnectionId != nil { 29 | values["business_connection_id"] = *r.BusinessConnectionId 30 | } 31 | 32 | if r.ChatId != nil { 33 | values["chat_id"] = r.ChatId.String() 34 | } 35 | 36 | if r.InlineMessageId != nil { 37 | values["inline_message_id"] = *r.InlineMessageId 38 | } 39 | 40 | if r.MessageId != nil { 41 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 42 | } 43 | 44 | if r.ReplyMarkup != nil { 45 | var dataReplyMarkup []byte 46 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 47 | return 48 | } 49 | 50 | values["reply_markup"] = string(dataReplyMarkup) 51 | } 52 | 53 | return 54 | } 55 | 56 | func (r *StopMessageLiveLocation) GetFiles() (files map[string]io.Reader) { 57 | return 58 | } 59 | -------------------------------------------------------------------------------- /requests/stop_poll.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "github.com/temoon/telegram-bots-api" 7 | "io" 8 | "strconv" 9 | ) 10 | 11 | type StopPoll struct { 12 | ChatId telegram.ChatId 13 | MessageId int64 14 | BusinessConnectionId *string 15 | ReplyMarkup *telegram.InlineKeyboardMarkup 16 | } 17 | 18 | func (r *StopPoll) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 19 | response = new(telegram.Poll) 20 | err = b.CallMethod(ctx, "stopPoll", r, response) 21 | return 22 | } 23 | 24 | func (r *StopPoll) GetValues() (values map[string]interface{}, err error) { 25 | values = make(map[string]interface{}) 26 | 27 | values["chat_id"] = r.ChatId.String() 28 | 29 | values["message_id"] = strconv.FormatInt(r.MessageId, 10) 30 | 31 | if r.BusinessConnectionId != nil { 32 | values["business_connection_id"] = *r.BusinessConnectionId 33 | } 34 | 35 | if r.ReplyMarkup != nil { 36 | var dataReplyMarkup []byte 37 | if dataReplyMarkup, err = json.Marshal(r.ReplyMarkup); err != nil { 38 | return 39 | } 40 | 41 | values["reply_markup"] = string(dataReplyMarkup) 42 | } 43 | 44 | return 45 | } 46 | 47 | func (r *StopPoll) GetFiles() (files map[string]io.Reader) { 48 | return 49 | } 50 | -------------------------------------------------------------------------------- /requests/transfer_business_account_stars.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type TransferBusinessAccountStars struct { 11 | BusinessConnectionId string 12 | StarCount int64 13 | } 14 | 15 | func (r *TransferBusinessAccountStars) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "transferBusinessAccountStars", r, response) 18 | return 19 | } 20 | 21 | func (r *TransferBusinessAccountStars) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["business_connection_id"] = r.BusinessConnectionId 25 | 26 | values["star_count"] = strconv.FormatInt(r.StarCount, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *TransferBusinessAccountStars) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/transfer_gift.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type TransferGift struct { 11 | BusinessConnectionId string 12 | NewOwnerChatId int64 13 | OwnedGiftId string 14 | StarCount *int64 15 | } 16 | 17 | func (r *TransferGift) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "transferGift", r, response) 20 | return 21 | } 22 | 23 | func (r *TransferGift) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["business_connection_id"] = r.BusinessConnectionId 27 | 28 | values["new_owner_chat_id"] = strconv.FormatInt(r.NewOwnerChatId, 10) 29 | 30 | values["owned_gift_id"] = r.OwnedGiftId 31 | 32 | if r.StarCount != nil { 33 | values["star_count"] = strconv.FormatInt(*r.StarCount, 10) 34 | } 35 | 36 | return 37 | } 38 | 39 | func (r *TransferGift) GetFiles() (files map[string]io.Reader) { 40 | return 41 | } 42 | -------------------------------------------------------------------------------- /requests/unban_chat_member.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type UnbanChatMember struct { 11 | ChatId telegram.ChatId 12 | UserId int64 13 | OnlyIfBanned *bool 14 | } 15 | 16 | func (r *UnbanChatMember) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "unbanChatMember", r, response) 19 | return 20 | } 21 | 22 | func (r *UnbanChatMember) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["chat_id"] = r.ChatId.String() 26 | 27 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 28 | 29 | if r.OnlyIfBanned != nil { 30 | if *r.OnlyIfBanned { 31 | values["only_if_banned"] = "1" 32 | } else { 33 | values["only_if_banned"] = "0" 34 | } 35 | } 36 | 37 | return 38 | } 39 | 40 | func (r *UnbanChatMember) GetFiles() (files map[string]io.Reader) { 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /requests/unban_chat_sender_chat.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type UnbanChatSenderChat struct { 11 | ChatId telegram.ChatId 12 | SenderChatId int64 13 | } 14 | 15 | func (r *UnbanChatSenderChat) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "unbanChatSenderChat", r, response) 18 | return 19 | } 20 | 21 | func (r *UnbanChatSenderChat) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["sender_chat_id"] = strconv.FormatInt(r.SenderChatId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *UnbanChatSenderChat) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/unhide_general_forum_topic.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type UnhideGeneralForumTopic struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *UnhideGeneralForumTopic) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "unhideGeneralForumTopic", r, response) 16 | return 17 | } 18 | 19 | func (r *UnhideGeneralForumTopic) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *UnhideGeneralForumTopic) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/unpin_all_chat_messages.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type UnpinAllChatMessages struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *UnpinAllChatMessages) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "unpinAllChatMessages", r, response) 16 | return 17 | } 18 | 19 | func (r *UnpinAllChatMessages) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *UnpinAllChatMessages) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/unpin_all_forum_topic_messages.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type UnpinAllForumTopicMessages struct { 11 | ChatId telegram.ChatId 12 | MessageThreadId int64 13 | } 14 | 15 | func (r *UnpinAllForumTopicMessages) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "unpinAllForumTopicMessages", r, response) 18 | return 19 | } 20 | 21 | func (r *UnpinAllForumTopicMessages) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["chat_id"] = r.ChatId.String() 25 | 26 | values["message_thread_id"] = strconv.FormatInt(r.MessageThreadId, 10) 27 | 28 | return 29 | } 30 | 31 | func (r *UnpinAllForumTopicMessages) GetFiles() (files map[string]io.Reader) { 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /requests/unpin_all_general_forum_topic_messages.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type UnpinAllGeneralForumTopicMessages struct { 10 | ChatId telegram.ChatId 11 | } 12 | 13 | func (r *UnpinAllGeneralForumTopicMessages) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 14 | response = new(bool) 15 | err = b.CallMethod(ctx, "unpinAllGeneralForumTopicMessages", r, response) 16 | return 17 | } 18 | 19 | func (r *UnpinAllGeneralForumTopicMessages) GetValues() (values map[string]interface{}, err error) { 20 | values = make(map[string]interface{}) 21 | 22 | values["chat_id"] = r.ChatId.String() 23 | 24 | return 25 | } 26 | 27 | func (r *UnpinAllGeneralForumTopicMessages) GetFiles() (files map[string]io.Reader) { 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /requests/unpin_chat_message.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type UnpinChatMessage struct { 11 | ChatId telegram.ChatId 12 | BusinessConnectionId *string 13 | MessageId *int64 14 | } 15 | 16 | func (r *UnpinChatMessage) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(bool) 18 | err = b.CallMethod(ctx, "unpinChatMessage", r, response) 19 | return 20 | } 21 | 22 | func (r *UnpinChatMessage) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["chat_id"] = r.ChatId.String() 26 | 27 | if r.BusinessConnectionId != nil { 28 | values["business_connection_id"] = *r.BusinessConnectionId 29 | } 30 | 31 | if r.MessageId != nil { 32 | values["message_id"] = strconv.FormatInt(*r.MessageId, 10) 33 | } 34 | 35 | return 36 | } 37 | 38 | func (r *UnpinChatMessage) GetFiles() (files map[string]io.Reader) { 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /requests/upgrade_gift.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type UpgradeGift struct { 11 | BusinessConnectionId string 12 | OwnedGiftId string 13 | KeepOriginalDetails *bool 14 | StarCount *int64 15 | } 16 | 17 | func (r *UpgradeGift) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 18 | response = new(bool) 19 | err = b.CallMethod(ctx, "upgradeGift", r, response) 20 | return 21 | } 22 | 23 | func (r *UpgradeGift) GetValues() (values map[string]interface{}, err error) { 24 | values = make(map[string]interface{}) 25 | 26 | values["business_connection_id"] = r.BusinessConnectionId 27 | 28 | values["owned_gift_id"] = r.OwnedGiftId 29 | 30 | if r.KeepOriginalDetails != nil { 31 | if *r.KeepOriginalDetails { 32 | values["keep_original_details"] = "1" 33 | } else { 34 | values["keep_original_details"] = "0" 35 | } 36 | } 37 | 38 | if r.StarCount != nil { 39 | values["star_count"] = strconv.FormatInt(*r.StarCount, 10) 40 | } 41 | 42 | return 43 | } 44 | 45 | func (r *UpgradeGift) GetFiles() (files map[string]io.Reader) { 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /requests/upload_sticker_file.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type UploadStickerFile struct { 11 | Sticker telegram.InputFile 12 | StickerFormat string 13 | UserId int64 14 | } 15 | 16 | func (r *UploadStickerFile) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 17 | response = new(telegram.File) 18 | err = b.CallMethod(ctx, "uploadStickerFile", r, response) 19 | return 20 | } 21 | 22 | func (r *UploadStickerFile) GetValues() (values map[string]interface{}, err error) { 23 | values = make(map[string]interface{}) 24 | 25 | values["sticker"] = r.Sticker.GetValue() 26 | 27 | values["sticker_format"] = r.StickerFormat 28 | 29 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 30 | 31 | return 32 | } 33 | 34 | func (r *UploadStickerFile) GetFiles() (files map[string]io.Reader) { 35 | return 36 | } 37 | -------------------------------------------------------------------------------- /requests/verify_chat.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | ) 8 | 9 | type VerifyChat struct { 10 | ChatId telegram.ChatId 11 | CustomDescription *string 12 | } 13 | 14 | func (r *VerifyChat) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 15 | response = new(bool) 16 | err = b.CallMethod(ctx, "verifyChat", r, response) 17 | return 18 | } 19 | 20 | func (r *VerifyChat) GetValues() (values map[string]interface{}, err error) { 21 | values = make(map[string]interface{}) 22 | 23 | values["chat_id"] = r.ChatId.String() 24 | 25 | if r.CustomDescription != nil { 26 | values["custom_description"] = *r.CustomDescription 27 | } 28 | 29 | return 30 | } 31 | 32 | func (r *VerifyChat) GetFiles() (files map[string]io.Reader) { 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /requests/verify_user.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import ( 4 | "context" 5 | "github.com/temoon/telegram-bots-api" 6 | "io" 7 | "strconv" 8 | ) 9 | 10 | type VerifyUser struct { 11 | UserId int64 12 | CustomDescription *string 13 | } 14 | 15 | func (r *VerifyUser) Call(ctx context.Context, b *telegram.Bot) (response interface{}, err error) { 16 | response = new(bool) 17 | err = b.CallMethod(ctx, "verifyUser", r, response) 18 | return 19 | } 20 | 21 | func (r *VerifyUser) GetValues() (values map[string]interface{}, err error) { 22 | values = make(map[string]interface{}) 23 | 24 | values["user_id"] = strconv.FormatInt(r.UserId, 10) 25 | 26 | if r.CustomDescription != nil { 27 | values["custom_description"] = *r.CustomDescription 28 | } 29 | 30 | return 31 | } 32 | 33 | func (r *VerifyUser) GetFiles() (files map[string]io.Reader) { 34 | return 35 | } 36 | -------------------------------------------------------------------------------- /type_chat_id.go: -------------------------------------------------------------------------------- 1 | package telegram 2 | 3 | import ( 4 | "encoding/json" 5 | "strconv" 6 | ) 7 | 8 | type ChatId struct { 9 | id int64 10 | name string 11 | } 12 | 13 | //goland:noinspection GoUnusedExportedFunction 14 | func NewChatId(id int64, name string) (chatId ChatId) { 15 | if id != 0 { 16 | chatId.id = id 17 | } else if len(name) > 0 { 18 | chatId.name = name 19 | } 20 | 21 | return 22 | } 23 | 24 | //goland:noinspection GoMixedReceiverTypes 25 | func (c *ChatId) GetId() int64 { 26 | return c.id 27 | } 28 | 29 | //goland:noinspection GoMixedReceiverTypes 30 | func (c *ChatId) GetName() string { 31 | return c.name 32 | } 33 | 34 | //goland:noinspection GoMixedReceiverTypes 35 | func (c ChatId) MarshalJSON() (data []byte, err error) { 36 | return json.Marshal(c.String()) 37 | } 38 | 39 | //goland:noinspection GoMixedReceiverTypes 40 | func (c *ChatId) UnmarshalJSON(data []byte) (err error) { 41 | if len(data) >= 2 && data[0] == '"' && data[len(data)-1] == '"' { // len(`""`) == 2 42 | data = data[1 : len(data)-1] 43 | } 44 | 45 | if len(data) > 0 { 46 | if data[0] == '@' { 47 | c.name = string(data) 48 | } else { 49 | c.id, err = strconv.ParseInt(string(data), 10, 64) 50 | } 51 | } 52 | 53 | return 54 | } 55 | 56 | //goland:noinspection GoMixedReceiverTypes 57 | func (c *ChatId) String() string { 58 | if c.id != 0 { 59 | return strconv.FormatInt(c.id, 10) 60 | } else if len(c.name) > 0 { 61 | return c.name 62 | } 63 | 64 | return "" 65 | } 66 | -------------------------------------------------------------------------------- /type_input_file.go: -------------------------------------------------------------------------------- 1 | package telegram 2 | 3 | import ( 4 | "encoding/json" 5 | "io" 6 | ) 7 | 8 | type InputFile struct { 9 | fileId string 10 | file io.Reader 11 | fileName string 12 | } 13 | 14 | //goland:noinspection GoUnusedExportedFunction 15 | func NewInputFile(fileId string, file io.Reader, fileName string) (inputFile InputFile) { 16 | if len(fileId) > 0 { 17 | inputFile.fileId = fileId 18 | } else if file != nil && len(fileName) > 0 { 19 | inputFile.file = file 20 | inputFile.fileName = fileName 21 | } 22 | 23 | return 24 | } 25 | 26 | //goland:noinspection GoMixedReceiverTypes 27 | func (f InputFile) MarshalJSON() (data []byte, err error) { 28 | return json.Marshal(f.String()) 29 | } 30 | 31 | //goland:noinspection GoMixedReceiverTypes 32 | func (f *InputFile) UnmarshalJSON(data []byte) (err error) { 33 | var fileId string 34 | if err = json.Unmarshal(data, &fileId); err != nil { 35 | return 36 | } 37 | 38 | f.fileId = fileId 39 | 40 | return 41 | } 42 | 43 | //goland:noinspection GoMixedReceiverTypes 44 | func (f *InputFile) String() string { 45 | if f.fileId != "" { 46 | return f.fileId 47 | } else if f.HasFile() { 48 | return "attach://" + f.GetFormFieldName() 49 | } 50 | 51 | return "" 52 | } 53 | 54 | //goland:noinspection GoMixedReceiverTypes 55 | func (f *InputFile) GetValue() interface{} { 56 | if len(f.fileId) > 0 { 57 | return f.fileId 58 | } else if f.HasFile() { 59 | return f.file 60 | } 61 | 62 | return "" 63 | } 64 | 65 | //goland:noinspection GoMixedReceiverTypes 66 | func (f *InputFile) HasFile() bool { 67 | return f.file != nil && len(f.fileName) > 0 68 | } 69 | 70 | //goland:noinspection GoMixedReceiverTypes 71 | func (f *InputFile) GetFormFieldName() string { 72 | return "file_" + f.fileName 73 | } 74 | 75 | //goland:noinspection GoMixedReceiverTypes 76 | func (f *InputFile) GetFile() io.Reader { 77 | return f.file 78 | } 79 | --------------------------------------------------------------------------------