Documentation ¶
Overview ¶
A Telegram Bot API wrapper.
Current supports Bot API version is 4.2.
Example:
import "github.com/deadblue/telegroid" import "github.com/deadblue/telegroid/arguments" // Create a bot instance bot := telegroid.New("your_bot_token") // Get bot information me, err := bot.GetMe() if err != nil { panic(err) } // Send markdown text message with an inline keyboard args := new(arguments.SendMessageArgs) args.ChatId(1234) args.Text("Hello, *world*!").Markdown() args.InlineKeyboard(). AddUrlButton("Github", "https://github.com/deadblue/telegroid"). AddUrlButton("Author", "tg://resolve?domain=deadbluex"). AddCallbackButton("Foo", "Bar"). Layout(2, 1). Finish() msg, err := bot.SendMessage(args) if err != nil { panic(err) }
Index ¶
- Constants
- type Animation
- type Audio
- type Bot
- type CallbackGame
- type CallbackQuery
- type Chat
- type ChatMember
- type ChatPhoto
- type ChatType
- type ChosenInlineResult
- type Contact
- type Document
- type EncryptedCredentials
- type EncryptedPassportElement
- type EntityType
- func (t EntityType) IsBold() bool
- func (t EntityType) IsBotCommand() bool
- func (t EntityType) IsCashtag() bool
- func (t EntityType) IsCode() bool
- func (t EntityType) IsEmail() bool
- func (t EntityType) IsHashtag() bool
- func (t EntityType) IsItalic() bool
- func (t EntityType) IsPhoneNumber() bool
- func (t EntityType) IsPre() bool
- func (t EntityType) IsTextLink() bool
- func (t EntityType) IsTextMention() bool
- func (t EntityType) IsUrl() bool
- type File
- type Game
- type GameHighScore
- type InlineQuery
- type Invoice
- type Location
- type MaskPosition
- type MemberStatus
- type Message
- type MessageEntity
- type OrderInfo
- type PassportData
- type PassportFile
- type PassportType
- func (t PassportType) IsAddress() bool
- func (t PassportType) IsBankStatement() bool
- func (t PassportType) IsDriverLicense() bool
- func (t PassportType) IsEmail() bool
- func (t PassportType) IsIdentityCard() bool
- func (t PassportType) IsInternalPassport() bool
- func (t PassportType) IsPassport() bool
- func (t PassportType) IsPassportRegistration() bool
- func (t PassportType) IsPersonalDetails() bool
- func (t PassportType) IsPhoneNumber() bool
- func (t PassportType) IsRentalAgreement() bool
- func (t PassportType) IsTemporaryRegistration() bool
- func (t PassportType) IsUtilityBill() bool
- type PhotoSize
- type Poll
- type PollOption
- type PreCheckoutQuery
- type ShippingAddress
- type ShippingQuery
- type Sticker
- type StickerSet
- type SuccessfulPayment
- type Update
- type User
- type UserProfilePhotos
- type Venue
- type Video
- type VideoNote
- type Voice
- type WebhookInfo
Constants ¶
View Source
const ( Version = "1.0" BotApiVersion = "4.2" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { // Get me GetMe func() (*User, error) // Get updates GetUpdates func(args *arguments.GetUpdatesArgs) ([]*Update, error) // Webhook management SetWebhook func(args *arguments.SetWebhookArgs) (bool, error) DeleteWebhook func() (bool, error) GetWebhookInfo func() (*WebhookInfo, error) // Send message ForwardMessage func(args *arguments.ForwardMessageArgs) (*Message, error) SendMessage func(args *arguments.SendMessageArgs) (*Message, error) SendPhoto func(args *arguments.SendPhotoArgs) (*Message, error) SendAudio func(args *arguments.SendAudioArgs) (*Message, error) SendDocument func(args *arguments.SendDocumentArgs) (*Message, error) SendVideo func(args *arguments.SendVideoArgs) (*Message, error) SendAnimation func(args *arguments.SendAnimationArgs) (*Message, error) SendVoice func(args *arguments.SendVoiceArgs) (*Message, error) SendVideoNote func(args *arguments.SendVideoNoteArgs) (*Message, error) SendMediaGroup func(args *arguments.SendMediaGroupArgs) ([]*Message, error) SendLocation func(args *arguments.SendLocationArgs) (*Message, error) SendVenue func(args *arguments.SendVenueArgs) (*Message, error) SendContact func(args *arguments.SendContactArgs) (*Message, error) SendPoll func(args *arguments.SendPollArgs) (*Message, error) SendChatAction func(args *arguments.SendChatActionArgs) (bool, error) // Inline keyboard callback AnswerCallbackQuery func(args *arguments.AnswerCallbackQueryArgs) (bool, error) // Delete message DeleteMessage func(args *arguments.ChatMessageArgs) (bool, error) // Edit own message EditMessageText func(args *arguments.EditMessageTextArgs) (*Message, error) EditMessageCaption func(args *arguments.EditMessageCaptionArgs) (*Message, error) EditMessageMedia func(args *arguments.EditMessageMediaArgs) (*Message, error) EditMessageReplyMarkup func(args *arguments.EditMessageReplyMarkupArgs) (*Message, error) EditMessageLiveLocation func(args *arguments.EditMessageLiveLocationArgs) (*Message, error) StopMessageLiveLocation func(args *arguments.EditMessageReplyMarkupArgs) (*Message, error) StopPoll func(args *arguments.StopPollArgs) (*Poll, error) // Edit other's message EditOthersMessageText func(args *arguments.EditMessageTextArgs) (bool, error) `method:"editMessageText"` EditOthersMessageCaption func(args *arguments.EditMessageCaptionArgs) (bool, error) `method:"editMessageCaption"` EditOthersMessageMedia func(args *arguments.EditMessageMediaArgs) (bool, error) `method:"editMessageMedia"` EditOthersMessageReplyMarkup func(args *arguments.EditMessageReplyMarkupArgs) (bool, error) `method:"editMessageReplyMarkup"` EditOthersMessageLiveLocation func(args *arguments.EditMessageLiveLocationArgs) (bool, error) `method:"editMessageLiveLocation"` StopOthersMessageLiveLocation func(args *arguments.EditMessageReplyMarkupArgs) (bool, error) `method:"stopMessageLiveLocation"` // User information GetUserProfilePhotos func(args *arguments.GetUserProfilePhotosArgs) (*UserProfilePhotos, error) // Chat information GetChat func(args *arguments.ChatArgs) (*Chat, error) GetChatAdministrators func(args *arguments.ChatArgs) ([]*ChatMember, error) GetChatMembersCount func(args *arguments.ChatArgs) (int, error) GetChatMember func(args *arguments.ChatMemberArgs) (*ChatMember, error) // Chat management KickChatMember func(args *arguments.KickChatMemberArgs) (bool, error) UnbanChatMember func(args *arguments.ChatMemberArgs) (bool, error) RestrictChatMember func(args *arguments.RestrictChatMemberArgs) (bool, error) PromoteChatMember func(args *arguments.PromoteChatMemberArgs) (bool, error) ExportChatInviteLink func(args *arguments.ChatArgs) (string, error) SetChatPhoto func(args *arguments.SetChatPhotoArgs) (bool, error) DeleteChatPhoto func(args *arguments.ChatArgs) (bool, error) SetChatTitle func(args *arguments.SetChatTitleArgs) (bool, error) SetChatDescription func(args *arguments.SetChatDescriptionArgs) (bool, error) PinChatMessage func(args *arguments.PinChatMessageArgs) (bool, error) UnpinChatMessage func(args *arguments.ChatArgs) (bool, error) SetChatStickerSet func(args *arguments.SetChatStickerSetArgs) (bool, error) DeleteChatStickerSet func(args *arguments.ChatArgs) (bool, error) LeaveChat func(args *arguments.ChatArgs) (bool, error) // Misc GetFile func(args *arguments.GetFileArgs) (*File, error) // Sticker SendSticker func(args *arguments.SendStickerArgs) (*Message, error) GetStickerSet func(args *arguments.GetStickerSetArgs) (*StickerSet, error) UploadStickerFile func(args *arguments.UploadStickerFileArgs) (*File, error) CreateNewStickerSet func(args *arguments.CreateNewStickerSetArgs) (bool, error) AddStickerToSet func(args *arguments.AddStickerToSetArgs) (bool, error) SetStickerPositionInSet func(args *arguments.SetStickerPositionInSetArgs) (bool, error) DeleteStickerFromSet func(args *arguments.DeleteStickerFromSetArgs) (bool, error) // Game SendGame func(args *arguments.SendGameArgs) (*Message, error) SetGameScore func(args *arguments.SetGameScoreArgs) (bool, error) GetGameHighScores func(args *arguments.GetGameHighScoresArgs) (*GameHighScore, error) // Inline mode //AnswerInlineQuery func(args *arguments.AnswerInlineQueryArgs) (bool, error) // Payment SendInvoice func(args *arguments.SendInvoiceArgs) (*Message, error) AnswerShippingQuery func(args *arguments.AnswerShippingQueryArgs) (bool, error) AnswerPreCheckoutQuery func(args *arguments.AnswerPreCheckoutQueryArgs) (bool, error) // Passport SetPassportDataErrors func(args *arguments.SetPassportDataErrorsArgs) (bool, error) // contains filtered or unexported fields }
Telegram Bot API wrapper
type CallbackGame ¶
type CallbackGame struct{}
type CallbackQuery ¶
type Chat ¶
type Chat struct { Id int `json:"id"` Type ChatType `json:"type"` Title string `json:"title"` Username string `json:"username"` FirstName string `json:"first_name"` LastName string `json:"last_name"` AllMembersAreAdministrators bool `json:"all_members_are_administrators"` Photo *ChatPhoto `json:"photo"` Description string `json:"description"` InviteLink string `json:"invite_link"` PinnedMessage *Message `json:"pinned_message"` StickerSetName string `json:"sticker_set_name"` CanSetStickerName bool `json:"can_set_sticker_name"` }
type ChatMember ¶
type ChatMember struct { User *User `json:"user"` Status MemberStatus `json:"status"` UntilDate int `json:"until_date"` IsMember bool `json:"is_member"` CanBeEdited bool `json:"can_be_edited"` CanChangeInfo bool `json:"can_change_info"` CanPostMessages bool `json:"can_post_messages"` CanEditMessages bool `json:"can_edit_messages"` CanDeleteMessages bool `json:"can_delete_messages"` CanPinMessages bool `json:"can_pin_messages"` CanInviteUsers bool `json:"can_invite_users"` CanRestrictMembers bool `json:"can_restrict_members"` CanPromoteMembers bool `json:"can_promote_members"` CanSendMessages bool `json:"can_send_messages"` CanSendMediaMessages bool `json:"can_send_media_messages"` CanSendOtherMessages bool `json:"can_send_other_messages"` CanAddWebPagePreviews bool `json:"can_add_web_page_previews"` }
type ChatType ¶
type ChatType string
The enum type for "Chat.Type". Developer can simply call "IsXXX" method to judge its value.
func (ChatType) IsSuperGroup ¶
type ChosenInlineResult ¶
type EncryptedCredentials ¶
type EncryptedPassportElement ¶
type EncryptedPassportElement struct { Type PassportType `json:"type"` Data string `json:"data"` PhoneNumber string `json:"phone_number"` Email string `json:"email"` Files []*PassportFile `json:"files"` FrontSide *PassportFile `json:"front_side"` ReverseSide *PassportFile `json:"reverse_side"` Selfie *PassportFile `json:"selfie"` Translation []*PassportFile `json:"translation"` Hash string `json:"hash"` }
type EntityType ¶
type EntityType string
The enum type for "MessageEntity.Type". Developer can simply call "IsXXX" method to judge its value.
func (EntityType) IsBold ¶
func (t EntityType) IsBold() bool
func (EntityType) IsBotCommand ¶
func (t EntityType) IsBotCommand() bool
func (EntityType) IsCashtag ¶
func (t EntityType) IsCashtag() bool
func (EntityType) IsCode ¶
func (t EntityType) IsCode() bool
func (EntityType) IsEmail ¶
func (t EntityType) IsEmail() bool
func (EntityType) IsHashtag ¶
func (t EntityType) IsHashtag() bool
func (EntityType) IsItalic ¶
func (t EntityType) IsItalic() bool
func (EntityType) IsPhoneNumber ¶
func (t EntityType) IsPhoneNumber() bool
func (EntityType) IsPre ¶
func (t EntityType) IsPre() bool
func (EntityType) IsTextLink ¶
func (t EntityType) IsTextLink() bool
func (EntityType) IsTextMention ¶
func (t EntityType) IsTextMention() bool
func (EntityType) IsUrl ¶
func (t EntityType) IsUrl() bool
type GameHighScore ¶
type InlineQuery ¶
type MaskPosition ¶
type MemberStatus ¶
type MemberStatus string
The enum type for "ChangeMember.Status". Developer can simply call "IsXXX" method to judge its value.
func (MemberStatus) IsAdministrator ¶
func (s MemberStatus) IsAdministrator() bool
func (MemberStatus) IsCreator ¶
func (s MemberStatus) IsCreator() bool
func (MemberStatus) IsKicked ¶
func (s MemberStatus) IsKicked() bool
func (MemberStatus) IsLeft ¶
func (s MemberStatus) IsLeft() bool
func (MemberStatus) IsMember ¶
func (s MemberStatus) IsMember() bool
func (MemberStatus) IsRestricted ¶
func (s MemberStatus) IsRestricted() bool
type Message ¶
type Message struct { MessageId int `json:"message_id"` From *User `json:"from"` Date int `json:"date"` Chat *Chat `json:"chat"` ForwardFrom *User `json:"forward_from"` ForwardFromChat *Chat `json:"forward_from_chat"` ForwardFromMessageId int `json:"forward_from_message_id"` ForwardSignature string `json:"forward_signature"` ForwardSenderName string `json:"forward_sender_name"` ForwardDate int `json:"forward_date"` ReplyToMessage *Message `json:"reply_to_message"` EditDate int `json:"edit_date"` MediaGroupId string `json:"media_group_id"` AuthorSignature string `json:"author_signature"` Text string `json:"text"` Entities []*MessageEntity `json:"entities"` CaptionEntities []*MessageEntity `json:"caption_entities"` Audio *Audio `json:"audio"` Document *Document `json:"document"` Animation *Animation `json:"animation"` Game *Game `json:"game"` Photo []*PhotoSize `json:"photo"` Sticker *Sticker `json:"sticker"` Video *Video `json:"video"` Voice *Voice `json:"voice"` VideoNote *VideoNote `json:"video_note"` Caption string `json:"caption"` Location *Location `json:"location"` Venue *Venue `json:"venue"` Poll *Poll `json:"poll"` NewChatMembers []*User `json:"new_chat_members"` LeftChatMember *User `json:"left_chat_member"` NewChatTitle string `json:"new_chat_title"` NewChatPhoto []*PhotoSize `json:"new_chat_photo"` DeleteChatPhoto bool `json:"delete_chat_photo"` GroupChatCreated bool `json:"group_chat_created"` SupergroupChatCreated bool `json:"supergroup_chat_created"` ChannelChatCreated bool `json:"channel_chat_created"` MigrateToChatId int `json:"migrate_to_chat_id"` MigrateFromChatId int `json:"migrate_from_chat_id"` PinnedMessage *Message `json:"pinned_message"` Invoice *Invoice `json:"invoice"` SuccessfulPayment *SuccessfulPayment `json:"successful_payment"` ConnectedWebsite string `json:"connected_website"` PassportData *PassportData `json:"passport_data"` }
type MessageEntity ¶
type MessageEntity struct { Type EntityType `json:"type"` Offset int `json:"offset"` Length int `json:"length"` Url string `json:"url"` User *User `json:"user"` }
type OrderInfo ¶
type OrderInfo struct { Name string `json:"name"` PhoneNumber string `json:"phone_number"` Email string `json:"email"` ShippingAddress *ShippingAddress `json:"shipping_address"` }
type PassportData ¶
type PassportData struct { Data []*EncryptedPassportElement `json:"data"` Credentials *EncryptedCredentials `json:"credentials"` }
type PassportFile ¶
type PassportType ¶
type PassportType string
The enum type for "PassportData.Type". Developer can simply call "IsXXX" method to judge its value.
func (PassportType) IsAddress ¶
func (t PassportType) IsAddress() bool
func (PassportType) IsBankStatement ¶
func (t PassportType) IsBankStatement() bool
func (PassportType) IsDriverLicense ¶
func (t PassportType) IsDriverLicense() bool
func (PassportType) IsEmail ¶
func (t PassportType) IsEmail() bool
func (PassportType) IsIdentityCard ¶
func (t PassportType) IsIdentityCard() bool
func (PassportType) IsInternalPassport ¶
func (t PassportType) IsInternalPassport() bool
func (PassportType) IsPassport ¶
func (t PassportType) IsPassport() bool
func (PassportType) IsPassportRegistration ¶
func (t PassportType) IsPassportRegistration() bool
func (PassportType) IsPersonalDetails ¶
func (t PassportType) IsPersonalDetails() bool
func (PassportType) IsPhoneNumber ¶
func (t PassportType) IsPhoneNumber() bool
func (PassportType) IsRentalAgreement ¶
func (t PassportType) IsRentalAgreement() bool
func (PassportType) IsTemporaryRegistration ¶
func (t PassportType) IsTemporaryRegistration() bool
func (PassportType) IsUtilityBill ¶
func (t PassportType) IsUtilityBill() bool
type Poll ¶
type Poll struct { Id string `json:"id"` Question string `json:"question"` Options []*PollOption `json:"options"` IsClosed bool `json:"is_closed"` }
type PollOption ¶
type PreCheckoutQuery ¶
type ShippingAddress ¶
type ShippingQuery ¶
type ShippingQuery struct { Id string `json:"id"` From *User `json:"from"` InvoicePayload string `json:"invoice_payload"` ShippingAddress *ShippingAddress `json:"shipping_address"` }
type StickerSet ¶
type SuccessfulPayment ¶
type SuccessfulPayment struct { Currency string `json:"currency"` TotalAmount int `json:"total_amount"` InvoicePayload string `json:"invoice_payload"` ShippingOptionId string `json:"shipping_option_id"` OrderInfo *OrderInfo `json:"order_info"` TelegramPaymentChargeId string `json:"telegram_payment_charge_id"` ProviderPaymentChargeId string `json:"provider_payment_charge_id"` }
type Update ¶
type Update struct { UpdateId int `json:"update_id"` Message *Message `json:"message"` EditedMessage *Message `json:"edited_message"` ChannelPost *Message `json:"channel_post"` EditedChannelPost *Message `json:"edited_channel_post"` InlineQuery *InlineQuery `json:"inline_query"` ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"` CallbackQuery *CallbackQuery `json:"callback_query"` ShippingQuery *ShippingQuery `json:"shipping_query"` PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"` Poll *Poll `json:"poll"` }
type UserProfilePhotos ¶
type WebhookInfo ¶
type WebhookInfo struct { Url string `json:"url"` HasCustomCertificate bool `json:"has_custom_certificate"` PendingUpdateCount int `json:"pending_update_count"` LastErrorDate int `json:"last_error_date"` LastErrorMessage string `json:"last_error_message"` MaxConnections int `json:"max_connections"` AllowedUpdates []string `json:"allowed_updates"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.