Documentation ¶
Index ¶
- Constants
- Variables
- func EqErrors(err error, target *Error) bool
- type ActionRequestBody
- type AttachmentRequest
- type AudioPayload
- type Bigint
- type Bot
- func (b *Bot) AddMembers(chatId int64, userIds []int64) (*SimpleQueryResult, error)
- func (b *Bot) AnswerOnCallback(callbackId string, body CallbackAnswer) (*SimpleQueryResult, error)
- func (b *Bot) ConstructMessage(sessionId string, body ConstructorAnswer) (*SimpleQueryResult, error)
- func (b *Bot) DeleteMessage(messageId string) (*SimpleQueryResult, error)
- func (b *Bot) EditChat(chatId int64, patch ChatPatch) (*Chat, error)
- func (b *Bot) EditMessage(messageId string, body NewMessageBody) (*SimpleQueryResult, error)
- func (b *Bot) GetChat(chatId int64) (*Chat, error)
- func (b *Bot) GetChatAdmins(chatId int64) (*ChatMembersList, error)
- func (b *Bot) GetChatByLink(link string) (*Chat, error)
- func (b *Bot) GetChatMembers(chatId int64, opts *GetChatMembersOpts) (*ChatMembersList, error)
- func (b *Bot) GetChatMembership(chatId int64) (*ChatMember, error)
- func (b *Bot) GetChats(opts *GetChatsOpts) (*ChatList, error)
- func (b *Bot) GetInfo() (*BotInfo, error)
- func (b *Bot) GetMessage(messageId string) (*Message, error)
- func (b *Bot) GetMessages(opts *GetMessagesOpts) (*MessageList, error)
- func (b *Bot) GetPinnedMessage(chatId int64) (*GetPinnedMessageResult, error)
- func (b *Bot) GetSubscriptions() (*GetSubscriptionsResult, error)
- func (b *Bot) GetUpdates(opts *GetUpdatesOpts) (*UpdateList, error)
- func (b *Bot) LeaveChat(chatId int64) (*SimpleQueryResult, error)
- func (b *Bot) MakeRequest(httpMethod string, method string, params url.Values, body []byte) (io.ReadCloser, error)
- func (b *Bot) PatchInfo(patch BotPatch) (*BotInfo, error)
- func (b *Bot) PinMessage(chatId int64, body PinMessageBody) (*SimpleQueryResult, error)
- func (b *Bot) RemoveMember(chatId int64, userId int64, block bool) (*SimpleQueryResult, error)
- func (b *Bot) SendAction(chatId int64, action SenderAction) (*SimpleQueryResult, error)
- func (b *Bot) SendMessage(chatId int64, text string, opts *SendMessageOpts) (*SendMessageResult, error)
- func (b *Bot) Subscribe(body SubscriptionRequestBody) (*SimpleQueryResult, error)
- func (b *Bot) UnpinMessage(chatId int64) (*SimpleQueryResult, error)
- func (b *Bot) Unsubscribe(webhookUrl string) (*SimpleQueryResult, error)
- func (b *Bot) Upload(uploadType UploadType, fileInfo *FileInfo) (Payload, error)
- type BotAdded
- type BotCommand
- type BotInfo
- type BotOpts
- type BotPatch
- type BotRemoved
- type BotStarted
- type Button
- type ButtonsPayload
- type Callback
- type CallbackAnswer
- type CallbackButton
- type Chat
- type ChatAdminPermission
- type ChatButton
- type ChatList
- type ChatMember
- type ChatMembersList
- type ChatPatch
- type ChatStatus
- type ChatTitleChanged
- type ChatType
- type ConstructedMessageBody
- type ConstructorAnswer
- type ContactPayload
- type DeleteMessageParams
- type EditMessageParams
- type Error
- type FileInfo
- type FilePayload
- type GetChatMembersOpts
- type GetChatsOpts
- type GetMessagesOpts
- type GetPinnedMessageResult
- type GetSubscriptionsResult
- type GetUpdatesOpts
- type GetUploadUrlParams
- type Image
- type ImagePayload
- type Input
- type Keyboard
- type LinkButton
- type LinkedMessage
- type LocationPayload
- type MarkupElement
- type Message
- type MessageBody
- type MessageCallback
- type MessageChatCreated
- type MessageConstructed
- type MessageConstructionRequest
- type MessageCreated
- type MessageEdited
- type MessageLink
- type MessageLinkType
- type MessageList
- type MessageRemoved
- type MessageStat
- type NewMessageBody
- type NewMessageLink
- type Payload
- type PhotoToken
- type PinMessageBody
- type Recipient
- type RequestContactButton
- type RequestGeoLocationButton
- type SendMessageBody
- type SendMessageOpts
- type SendMessageResult
- type SenderAction
- type SharePayload
- type SimpleQueryResult
- type StickerPayload
- type Subscription
- type SubscriptionRequestBody
- type TextFormat
- type UnsubscribeParams
- type Update
- type UpdateList
- type UpdateType
- type UploadEndpoint
- type UploadType
- type User
- type UserAdded
- type UserIdsList
- type UserRemoved
- type UserWithPhoto
- type VideoPayload
Constants ¶
const ( API_URL = "https://botapi.tamtam.chat" GET_TIMEOUT = time.Second * 3 )
Variables ¶
var ( AttachmentNotReadyError = &Error{ Code: "attachment.not.ready", Message: "Key: errors.process.attachment.file.not.processed", } InvalidPhotoPayloadError = &Error{ Code: "proto.payload", Message: "No `photos`, `url` or `token` provided. Check payload.", } )
var AllUpdates = []UpdateType{ UpdateTypeBotAdded, UpdateTypeBotRemoved, UpdateTypeBotStarted, UpdateTypeChatTitleChanged, UpdateTypeMessageCallback, UpdateTypeMessageChatCreated, UpdateTypeMessageConstructed, UpdateTypeMessageConstructionRequest, UpdateTypeMessageCreated, UpdateTypeMessageEdited, UpdateTypeMessageRemoved, UpdateTypeUserAdded, UpdateTypeUserRemoved, }
Functions ¶
Types ¶
type ActionRequestBody ¶
type ActionRequestBody struct { // Action Different actions to send to chat members Action SenderAction `json:"action"` }
ActionRequestBody defines model for ActionRequestBody.
type AttachmentRequest ¶
type AttachmentRequest struct {
Payload Payload `json:"payload"`
}
AttachmentRequest Request to attach some data to message
func (AttachmentRequest) MarshalJSON ¶
func (a AttachmentRequest) MarshalJSON() ([]byte, error)
func (*AttachmentRequest) UnmarshalJSON ¶
func (a *AttachmentRequest) UnmarshalJSON(b []byte) error
type AudioPayload ¶
type AudioPayload struct { // Url of the video Url string `json:"url,omitempty"` // Token of any existing attachment Token string `json:"token,omitempty"` // Audio Id AudioId int64 `json:"id,omitempty"` }
AudioPayload Request to attach audio.
func (*AudioPayload) GetPayloadType ¶
func (*AudioPayload) GetPayloadType() string
type Bot ¶
type Bot struct { *BotInfo // contains filtered or unexported fields }
func (*Bot) AddMembers ¶
func (b *Bot) AddMembers(chatId int64, userIds []int64) (*SimpleQueryResult, error)
Adds members to chat. Additional permissions may require.
func (*Bot) AnswerOnCallback ¶
func (b *Bot) AnswerOnCallback(callbackId string, body CallbackAnswer) (*SimpleQueryResult, error)
This method should be called to send an answer after a user has clicked the button. The answer may be an updated message or/and a one-time user notification.
func (*Bot) ConstructMessage ¶
func (b *Bot) ConstructMessage(sessionId string, body ConstructorAnswer) (*SimpleQueryResult, error)
Sends answer on construction request. Answer can contain any prepared message and/or keyboard to help user interact with bot.
func (*Bot) DeleteMessage ¶
func (b *Bot) DeleteMessage(messageId string) (*SimpleQueryResult, error)
Deletes message in a dialog or in a chat if bot has permission to delete messages.
func (*Bot) EditMessage ¶
func (b *Bot) EditMessage(messageId string, body NewMessageBody) (*SimpleQueryResult, error)
Updated message should be sent as NewMessageBody in a request body. In case attachments field is null, the current message attachments won’t be changed. In case of sending an empty list in this field, all attachments will be deleted.
func (*Bot) GetChatAdmins ¶
func (b *Bot) GetChatAdmins(chatId int64) (*ChatMembersList, error)
Returns all chat administrators. Bot must be administrator in requested chat.
func (*Bot) GetChatByLink ¶
Returns chat/channel information by its public link or dialog with user by username
func (*Bot) GetChatMembers ¶
func (b *Bot) GetChatMembers(chatId int64, opts *GetChatMembersOpts) (*ChatMembersList, error)
Returns users participated in chat.
func (*Bot) GetChatMembership ¶
func (b *Bot) GetChatMembership(chatId int64) (*ChatMember, error)
Returns chat membership info for current bot
func (*Bot) GetChats ¶
func (b *Bot) GetChats(opts *GetChatsOpts) (*ChatList, error)
Returns information about chats that bot participated in: a result list and marker points to the next page
func (*Bot) GetInfo ¶
Returns info about current bot. Current bot can be identified by access token. Method returns bot identifier, name and avatar (if any)
func (*Bot) GetMessage ¶
Returns single message by its identifier.
func (*Bot) GetMessages ¶
func (b *Bot) GetMessages(opts *GetMessagesOpts) (*MessageList, error)
Returns messages in chat: result page and marker referencing to the next page.
Messages traversed in reverse direction so the latest message in chat will be first in result array. Therefore if you use from and to parameters, to must be less than from
func (*Bot) GetPinnedMessage ¶
func (b *Bot) GetPinnedMessage(chatId int64) (*GetPinnedMessageResult, error)
Get pinned message in chat or channel.
func (*Bot) GetSubscriptions ¶
func (b *Bot) GetSubscriptions() (*GetSubscriptionsResult, error)
In case your bot gets data via WebHook, the method returns list of all subscriptions
func (*Bot) GetUpdates ¶
func (b *Bot) GetUpdates(opts *GetUpdatesOpts) (*UpdateList, error)
You can use this method for getting updates in case your bot is not subscribed to WebHook. The method is based on long polling.
Every update has its own sequence number. marker property in response points to the next upcoming update.
All previous updates are considered as committed after passing marker parameter. If marker parameter is not passed, your bot will get all updates happened after the last commitment.
func (*Bot) LeaveChat ¶
func (b *Bot) LeaveChat(chatId int64) (*SimpleQueryResult, error)
Removes bot from chat members.
func (*Bot) MakeRequest ¶
func (*Bot) PatchInfo ¶
Edits current bot info. Fill only the fields you want to update. All remaining fields will stay untouched
func (*Bot) PinMessage ¶
func (b *Bot) PinMessage(chatId int64, body PinMessageBody) (*SimpleQueryResult, error)
Pins message in chat or channel.
func (*Bot) RemoveMember ¶
Removes member from chat. Additional permissions may require.
func (*Bot) SendAction ¶
func (b *Bot) SendAction(chatId int64, action SenderAction) (*SimpleQueryResult, error)
Send bot action to chat.
func (*Bot) SendMessage ¶
func (b *Bot) SendMessage(chatId int64, text string, opts *SendMessageOpts) (*SendMessageResult, error)
Sends a message to a chat. As a result for this method new message identifier returns.
Important notice: It may take time for the server to process your file (audio/video or any binary). While a file is not processed you can't attach it. It means the last step will fail with 400 error. Try to send a message again until you'll get a successful result.
func (*Bot) Subscribe ¶
func (b *Bot) Subscribe(body SubscriptionRequestBody) (*SimpleQueryResult, error)
Subscribes bot to receive updates via WebHook. After calling this method, the bot will receive notifications about new events in chat rooms at the specified URL.
Your server must be listening on one of the following ports: 80, 8080, 443, 8443, 16384-32383
func (*Bot) UnpinMessage ¶
func (b *Bot) UnpinMessage(chatId int64) (*SimpleQueryResult, error)
Unpins message in chat or channel.
func (*Bot) Unsubscribe ¶
func (b *Bot) Unsubscribe(webhookUrl string) (*SimpleQueryResult, error)
Unsubscribes bot from receiving updates via WebHook. After calling the method, the bot stops receiving notifications about new events. Notification via the long-poll API becomes available for the bot
type BotAdded ¶
type BotAdded struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Chat identifier where bot is added ChatId int64 `json:"chat_id"` // User who added bot to chat User *User `json:"user"` // Indicates whether bot has been added to channel or not IsChannel bool `json:"is_channel"` }
func (*BotAdded) GetUpdateType ¶
func (*BotAdded) GetUpdateType() UpdateType
type BotCommand ¶
type BotCommand struct { // Description Optional command description Description *string `json:"description"` // Name Command name Name string `json:"name"` }
BotCommand defines model for BotCommand.
type BotInfo ¶
type BotInfo struct { // AvatarUrl URL of avatar AvatarUrl *string `json:"avatar_url,omitempty"` // Commands Commands supported by bot Commands *[]BotCommand `json:"commands"` // Description User description. Can be `null` if user did not fill it out Description *string `json:"description"` // FullAvatarUrl URL of avatar of a bigger size FullAvatarUrl *string `json:"full_avatar_url,omitempty"` // IsBot `true` if user is bot IsBot bool `json:"is_bot"` // LastActivityTime Time of last user activity in TamTam (Unix timestamp in milliseconds). Can be outdated if user disabled its "online" status in settings LastActivityTime int64 `json:"last_activity_time"` // Name Users visible name Name string `json:"name"` // UserId Users identifier UserId int64 `json:"user_id"` // Username Unique public user name. Can be `null` if user is not accessible or it is not set Username *string `json:"username"` }
BotInfo defines model for BotInfo.
type BotPatch ¶
type BotPatch struct { // Commands Commands supported by bot. Pass empty list if you want to remove commands Commands []BotCommand `json:"commands,omitempty"` // Description Bot description up to 16k characters long Description string `json:"description,omitempty"` // Name Visible name of bot Name string `json:"name,omitempty"` // Photo Request to set bot photo Photo *ImagePayload `json:"photo,omitempty"` // Username Bot unique identifier. It can be any string 4-64 characters long containing any digit, letter or special symbols: "-" or "_". It **must** starts with a letter Username string `json:"username,omitempty"` }
BotPatch defines model for BotPatch.
type BotRemoved ¶
type BotRemoved struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Chat identifier where bot is removed ChatId int64 `json:"chat_id"` // User who removed bot to chat User *User `json:"user"` // Indicates whether bot has been removed to channel or not IsChannel bool `json:"is_channel"` }
func (*BotRemoved) GetUpdateType ¶
func (*BotRemoved) GetUpdateType() UpdateType
type BotStarted ¶
type BotStarted struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Dialog identifier where event has occurred ChatId int64 `json:"chat_id"` // User pressed the 'Start' button User *User `json:"user"` // Additional data from deep-link passed on bot startup Payload string `json:"payload,omitempty"` // Current user locale in IETF BCP 47 format UserLocale string `json:"user_locale,omitempty"` }
func (*BotStarted) GetUpdateType ¶
func (*BotStarted) GetUpdateType() UpdateType
type ButtonsPayload ¶
type ButtonsPayload struct {
Buttons [][]Button `json:"buttons"`
}
ButtonsPayload Request to attach buttons.
func (*ButtonsPayload) GetPayloadType ¶
func (*ButtonsPayload) GetPayloadType() string
func (*ButtonsPayload) UnmarshalJSON ¶
func (p *ButtonsPayload) UnmarshalJSON(b []byte) error
type CallbackAnswer ¶
type CallbackAnswer struct { // Message Fill this if you want to modify current message Message *NewMessageBody `json:"message,omitempty"` // Notification Fill this if you just want to send one-time notification to user Notification string `json:"notification,omitempty"` }
CallbackAnswer Send this object when your bot wants to react to when a button is pressed
type CallbackButton ¶
type CallbackButton struct { // Visible text of button Text string `json:"text"` // Button payload Payload string `json:"payload"` // Default: "default" // Enum: "positive" "negative" "default" // Intent of button. Affects clients representation Intent string `json:"intent,omitempty"` }
func (*CallbackButton) GetButtonText ¶
func (b *CallbackButton) GetButtonText() string
func (*CallbackButton) GetButtonType ¶
func (b *CallbackButton) GetButtonType() string
func (CallbackButton) MarshalJSON ¶
func (b CallbackButton) MarshalJSON() ([]byte, error)
type Chat ¶
type Chat struct { // ChatId Chats identifier ChatId int64 `json:"chat_id"` // ChatMessageId Identifier of message that contains `chat` button initialized chat ChatMessageId *string `json:"chat_message_id"` // Description Chat description Description *string `json:"description"` // DialogWithUser Another user in conversation. For `dialog` type chats only DialogWithUser *UserWithPhoto `json:"dialog_with_user"` // Icon Icon of chat Icon *Image `json:"icon"` // IsPublic Is current chat publicly available. Always `false` for dialogs IsPublic bool `json:"is_public"` // LastEventTime Time of last event occurred in chat LastEventTime int64 `json:"last_event_time"` // Link Link on chat Link *string `json:"link"` // MessagesCount Messages count in chat. Only for group chats and channels. **Not available** for dialogs MessagesCount *int `json:"messages_count"` // OwnerId Identifier of chat owner. Visible only for chat admins OwnerId *int64 `json:"owner_id"` // Participants Participants in chat with time of last activity. Can be *null* when you request list of chats. Visible for chat admins only Participants *map[string]int64 `json:"participants"` // ParticipantsCount Number of people in chat. Always 2 for `dialog` chat type ParticipantsCount int32 `json:"participants_count"` // PinnedMessage Pinned message in chat or channel. Returned only when single chat is requested PinnedMessage *Message `json:"pinned_message"` // Status Chat status. One of: // - active: bot is active member of chat // - removed: bot was kicked // - left: bot intentionally left chat // - closed: chat was closed // - suspended: bot was stopped by user. *Only for dialogs* Status ChatStatus `json:"status"` // Title Visible title of chat. Can be null for dialogs Title *string `json:"title"` // Type Type of chat. One of: dialog, chat, channel Type ChatType `json:"type"` }
Chat defines model for Chat.
type ChatAdminPermission ¶
type ChatAdminPermission string
ChatAdminPermission Chat admin permissions
const ( AddAdmins ChatAdminPermission = "add_admins" AddRemoveMembers ChatAdminPermission = "add_remove_members" ChangeChatInfo ChatAdminPermission = "change_chat_info" PinMessage ChatAdminPermission = "pin_message" ReadAllMessages ChatAdminPermission = "read_all_messages" Write ChatAdminPermission = "write" )
Defines values for ChatAdminPermission.
type ChatButton ¶
type ChatButton struct { // Visible text of button Text string `json:"text"` // Title of chat to be created ChatTitle string `json:"chat_title"` // Chat description ChatDescription string `json:"chat_description,omitempty"` // Start payload will be sent to bot as soon as chat created StartPayload string `json:"start_payload,omitempty"` // Unique button identifier across all chat buttons in keyboard. // If uuid changed, new chat will be created on the next click. // Server will generate it at the time when button initially posted. // Reuse it when you edit the message.' UUID string `json:"uuid,omitempty"` }
func (*ChatButton) GetButtonText ¶
func (b *ChatButton) GetButtonText() string
func (*ChatButton) GetButtonType ¶
func (b *ChatButton) GetButtonType() string
func (ChatButton) MarshalJSON ¶
func (b ChatButton) MarshalJSON() ([]byte, error)
type ChatList ¶
type ChatList struct { // Chats List of requested chats Chats []Chat `json:"chats"` // Marker Reference to the next page of requested chats Marker *int64 `json:"marker"` }
ChatList defines model for ChatList.
type ChatMember ¶
type ChatMember struct { // AvatarUrl URL of avatar AvatarUrl *string `json:"avatar_url,omitempty"` // Description User description. Can be `null` if user did not fill it out Description *string `json:"description"` // FullAvatarUrl URL of avatar of a bigger size FullAvatarUrl *string `json:"full_avatar_url,omitempty"` IsAdmin bool `json:"is_admin"` // IsBot `true` if user is bot IsBot bool `json:"is_bot"` IsOwner bool `json:"is_owner"` JoinTime int64 `json:"join_time"` // LastAccessTime User last activity time in chat. Can be outdated for super chats and channels (equals to `join_time`) LastAccessTime int64 `json:"last_access_time"` // LastActivityTime Time of last user activity in TamTam (Unix timestamp in milliseconds). Can be outdated if user disabled its "online" status in settings LastActivityTime int64 `json:"last_activity_time"` // Name Users visible name Name string `json:"name"` // Permissions Permissions in chat if member is admin. `null` otherwise Permissions *[]ChatAdminPermission `json:"permissions"` // UserId Users identifier UserId int64 `json:"user_id"` // Username Unique public user name. Can be `null` if user is not accessible or it is not set Username *string `json:"username"` }
ChatMember defines model for ChatMember.
type ChatMembersList ¶
type ChatMembersList struct { // Marker Pointer to the next data page Marker *int64 `json:"marker"` // Members Participants in chat with time of last activity. Visible only for chat admins Members []ChatMember `json:"members"` }
ChatMembersList defines model for ChatMembersList.
type ChatPatch ¶
type ChatPatch struct { Icon *ImagePayload `json:"icon"` // Notify By default, participants will be notified about change with system message in chat/channel Notify *bool `json:"notify"` // Pin Identifier of message to be pinned in chat. In case you want to remove pin, use [unpin](#operation/unpinMessage) method Pin *string `json:"pin"` Title *string `json:"title"` }
ChatPatch defines model for ChatPatch.
type ChatTitleChanged ¶
type ChatTitleChanged struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Dialog identifier where event has occurred ChatId int64 `json:"chat_id"` // User pressed the 'Start' button User *User `json:"user"` // New Title Title string `json:"title"` }
func (*ChatTitleChanged) GetUpdateType ¶
func (*ChatTitleChanged) GetUpdateType() UpdateType
type ConstructedMessageBody ¶
type ConstructedMessageBody struct { // Attachments Message attachments. See `AttachmentRequest` and it's inheritors for full information Attachments []AttachmentRequest `json:"attachments,omitempty"` // Format Message text format. If set, Format *TextFormat `json:"format"` // Markup Text markup Markup []MarkupElement `json:"markup,omitempty"` // Text Message text Text string `json:"text,omitempty"` }
ConstructedMessageBody defines model for ConstructedMessageBody.
type ConstructorAnswer ¶
type ConstructorAnswer struct { // AllowUserInput If `true` user can send any input manually. Otherwise, only keyboard will be shown AllowUserInput bool `json:"allow_user_input,omitempty"` // Data In this property you can store any additional data up to 8KB. We send this data back to bot within the // next construction request. It is handy to store here any state of construction session Data string `json:"data,omitempty"` // Hint Hint to user. Will be shown on top of keyboard Hint string `json:"hint,omitempty"` // Keyboard Keyboard to show to user in constructor mode Keyboard *Keyboard `json:"keyboard"` // Messages Array of prepared messages. This messages will be sent as user taps on "Send" button Messages []ConstructedMessageBody `json:"messages,omitempty"` // Placeholder Text to show over the text field Placeholder string `json:"placeholder,omitempty"` }
ConstructorAnswer Bot's answer on construction request
type ContactPayload ¶
type ContactPayload struct { // TamTam user info of the contact TamInfo *User `json:"tam_info,omitempty"` // Full information about contact in VCF format VCFInfo string `json:"vcf_info,omitempty"` // Contact Name Name string `json:"name,omitempty"` // Contact identifier if it is registered TamTam user ContactId int64 `json:"contact_id,omitempty"` // Contact phone in VCF format VCFPhone string `json:"vcf_phone,omitempty"` }
ContactPayload Request to attach contact.
func (*ContactPayload) GetPayloadType ¶
func (*ContactPayload) GetPayloadType() string
type DeleteMessageParams ¶
type DeleteMessageParams struct { // MessageId Deleting message identifier MessageId string `form:"message_id" json:"message_id"` }
DeleteMessageParams defines parameters for DeleteMessage.
type EditMessageParams ¶
type EditMessageParams struct { // MessageId Editing message identifier MessageId string `form:"message_id" json:"message_id"` }
EditMessageParams defines parameters for EditMessage.
type Error ¶
type Error struct { // Code Error code Code string `json:"code"` // Message Human-readable description Message string `json:"message"` }
Error Server returns this if there was an exception to your request
type FilePayload ¶
type FilePayload struct { // Url of file Url string `json:"url,omitempty"` // Token of any existing attachment Token string `json:"token,omitempty"` // File id FileId int64 `json:"fileId,omitempty"` // File name Filename string `json:"filename,omitempty"` // File size in bytes Size int64 `json:"size,omitempty"` }
FilePayload Request to attach file.
func (*FilePayload) GetPayloadType ¶
func (*FilePayload) GetPayloadType() string
type GetChatMembersOpts ¶
type GetChatMembersOpts struct { // UserIds *Since* version [0.1.4](#section/About/Changelog). // // Comma-separated list of users identifiers to get their membership. When this parameter is passed, both `count` and `marker` are ignored UserIds []int64 `json:"user_ids,omitempty"` // Marker Marker Marker int64 `form:"marker,omitempty" json:"marker,omitempty"` // Count Count Count int `form:"count,omitempty" json:"count,omitempty"` }
GetChatMembersOpts defines optional parameters for GetMembers.
type GetChatsOpts ¶
type GetChatsOpts struct { // Count Number of chats requested Count int32 `form:"count,omitempty" json:"count,omitempty"` // Marker Points to next data page. `null` for the first page Marker Bigint `form:"marker,omitempty" json:"marker,omitempty"` }
GetChatsOpts defines optional parameters for GetChats.
type GetMessagesOpts ¶
type GetMessagesOpts struct { // ChatId Chat identifier to get messages in chat ChatId Bigint `form:"chat_id,omitempty" json:"chat_id,omitempty"` // MessageIds Comma-separated list of message ids to get MessageIds []string `json:"message_ids,omitempty"` // From Start time for requested messages From Bigint `form:"from,omitempty" json:"from,omitempty"` // To End time for requested messages To Bigint `form:"to,omitempty" json:"to,omitempty"` // Count Maximum amount of messages in response Count int32 `form:"count,omitempty" json:"count,omitempty"` }
GetMessagesOpts defines parameters for GetMessages.
type GetPinnedMessageResult ¶
type GetPinnedMessageResult struct { // Message Pinned message. Can be `null` if no message pinned in chat Message *Message `json:"message"` }
GetPinnedMessageResult defines model for GetPinnedMessageResult.
type GetSubscriptionsResult ¶
type GetSubscriptionsResult struct { // Subscriptions Current subscriptions Subscriptions []Subscription `json:"subscriptions"` }
GetSubscriptionsResult List of all WebHook subscriptions
type GetUpdatesOpts ¶
type GetUpdatesOpts struct { // Limit Maximum number of updates to be retrieved Limit int `form:"limit,omitempty" json:"limit,omitempty"` // Timeout Timeout in seconds for long polling Timeout int `form:"timeout,omitempty" json:"timeout,omitempty"` // Marker Pass `null` to get updates you didn't get yet Marker int64 `form:"marker,omitempty" json:"marker,omitempty"` // Types Comma separated list of update types your bot want to receive Types []string `json:"types,omitempty"` }
GetUpdatesOpts defines parameters for GetUpdates.
type GetUploadUrlParams ¶
type GetUploadUrlParams struct { // Type Uploaded file type: photo, audio, video, file Type UploadType `form:"type" json:"type"` }
GetUploadUrlParams defines parameters for GetUploadUrl.
type Image ¶
type Image struct { // Url URL of image Url string `json:"url"` }
Image Generic schema describing image object
type ImagePayload ¶
type ImagePayload struct { // Photo ID PhotoId int64 `json:"photo_id,omitempty"` // Photos Tokens were obtained after uploading images Photos map[string]PhotoToken `json:"photos,omitempty"` // Token of any existing attachment Token string `json:"token,omitempty"` // Url Any external image URL you want to attach Url string `json:"url,omitempty"` }
ImagePayload Request to attach image. All fields are mutually exclusive
func (*ImagePayload) GetPayloadType ¶
func (*ImagePayload) GetPayloadType() string
type Input ¶
type Input struct { InputType string `json:"input"` // Pressed button payload Payload string `json:"payload,omitempty"` // Messages sent by user during construction process. // Typically it is single element array but sometimes it can contains multiple messages. // Can be empty on initial request when user just opened constructor Messages []ConstructedMessageBody `json:"messages,omitempty"` }
type Keyboard ¶
type Keyboard struct {
Buttons [][]Button `json:"buttons"`
}
Keyboard Keyboard is two-dimension array of buttons
type LinkButton ¶
type LinkButton struct { // Visible text of button Text string `json:"text"` // Button url Url string `json:"url"` }
func (*LinkButton) GetButtonText ¶
func (b *LinkButton) GetButtonText() string
func (*LinkButton) GetButtonType ¶
func (b *LinkButton) GetButtonType() string
func (LinkButton) MarshalJSON ¶
func (b LinkButton) MarshalJSON() ([]byte, error)
type LinkedMessage ¶
type LinkedMessage struct { // ChatId Chat where message has been originally posted. For forwarded messages only ChatId *int64 `json:"chat_id,omitempty"` Message MessageBody `json:"message"` // Sender User sent this message. Can be `null` if message has been posted on behalf of a channel Sender *User `json:"sender,omitempty"` // Type Type of linked message Type MessageLinkType `json:"type"` }
LinkedMessage defines model for LinkedMessage.
type LocationPayload ¶
type LocationPayload struct { // latitude Latitude float64 `json:"latitude,omitempty"` // longitude Longitude float64 `json:"longitude,omitempty"` }
LocationPayload Request to attach location.
func (*LocationPayload) GetPayloadType ¶
func (*LocationPayload) GetPayloadType() string
type MarkupElement ¶
type MarkupElement struct { // From Element start index (zero-based) in text From int32 `json:"from"` // Length Length of the markup element Length int32 `json:"length"` // Type Type of the markup element. Can be **strong**, *emphasized*, ~strikethrough~, ++underline++, `monospaced`, link or user_mention Type string `json:"type"` }
MarkupElement defines model for MarkupElement.
type Message ¶
type Message struct { // Body Body of created message. Text + attachments. Could be null if message contains only forwarded message Body MessageBody `json:"body"` // Constructor Bot-constructor created this message Constructor *User `json:"constructor"` // Link Forwarded or replied message Link *LinkedMessage `json:"link"` // Recipient Message recipient. Could be user or chat Recipient Recipient `json:"recipient"` // Sender User who sent this message. Can be `null` if message has been posted on behalf of a channel Sender *User `json:"sender,omitempty"` // Stat Message statistics. Available only for channels in [GET:/messages](#operation/getMessages) context Stat *MessageStat `json:"stat"` // Timestamp Unix-time when message was created Timestamp int64 `json:"timestamp"` // Url Message public URL. Can be `null` for dialogs or non-public chats/channels Url string `json:"url,omitempty"` }
Message Message in chat
func (*Message) Edit ¶
func (m *Message) Edit(bot *Bot, body NewMessageBody) (*SimpleQueryResult, error)
Edit is a message helper to bot.EditMessage
func (*Message) Forward ¶
func (m *Message) Forward(bot *Bot, chatId int64, text string, opts *SendMessageOpts) (*SendMessageResult, error)
Forward is a message helper to bot.SendMessage with forward message added
func (*Message) Reply ¶
func (m *Message) Reply(bot *Bot, text string, opts *SendMessageOpts) (*SendMessageResult, error)
Reply is a message helper to bot.SendMessage with reply message added
type MessageBody ¶
type MessageBody struct { // Attachments Message attachments. Could be one of `Attachment` type. See description of this schema Attachments []AttachmentRequest `json:"attachments,omitempty"` // Markup Message text markup. See [Formatting](#section/About/Text-formatting) section for more info Markup []MarkupElement `json:"markup,omitempty"` // Mid Unique identifier of message Mid string `json:"mid"` // Seq Sequence identifier of message in chat Seq int64 `json:"seq"` // Text Message text Text string `json:"text,omitempty"` }
MessageBody Schema representing body of message
type MessageCallback ¶
type MessageCallback struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` Callback *Callback `json:"callback"` // Original message containing inline keyboard. Can be null in case it had been deleted by the moment a bot got this update Message *Message `json:"message,omitempty"` // Current user locale in IETF BCP 47 format UserLocale string `json:"user_locale,omitempty"` }
func (*MessageCallback) GetUpdateType ¶
func (*MessageCallback) GetUpdateType() UpdateType
type MessageChatCreated ¶
type MessageChatCreated struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Created chat Chat *Chat `json:"chat"` // Message identifier where the button has been clicked MessageId string `json:"message_id"` // Payload from chat button StartPayload string `json:"start_payload,omitempty"` }
func (*MessageChatCreated) GetUpdateType ¶
func (*MessageChatCreated) GetUpdateType() UpdateType
type MessageConstructed ¶
type MessageConstructed struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // User message Message *Message `json:"message"` // Constructor session identifier SessionId string `json:"session_id"` }
func (*MessageConstructed) GetUpdateType ¶
func (*MessageConstructed) GetUpdateType() UpdateType
type MessageConstructionRequest ¶
type MessageConstructionRequest struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // User pressed the 'Start' button User *User `json:"user"` // Constructor session identifier SessionId string `json:"session_id"` // data received from previous ConstructorAnswer Data string `json:"data,omitempty"` // User's input. It can be message (text/attachments) or simple button's callback Input *Input `json:"input"` // Current user locale in IETF BCP 47 format UserLocale string `json:"user_locale,omitempty"` }
func (*MessageConstructionRequest) GetUpdateType ¶
func (*MessageConstructionRequest) GetUpdateType() UpdateType
type MessageCreated ¶
type MessageCreated struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Original message containing inline keyboard. Can be null in case it had been deleted by the moment a bot got this update Message *Message `json:"message,omitempty"` // Current user locale in IETF BCP 47 format UserLocale string `json:"user_locale,omitempty"` }
func (*MessageCreated) GetUpdateType ¶
func (*MessageCreated) GetUpdateType() UpdateType
type MessageEdited ¶
type MessageEdited struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Message edited Message *Message `json:"message,omitempty"` }
func (*MessageEdited) GetUpdateType ¶
func (*MessageEdited) GetUpdateType() UpdateType
type MessageLink ¶
type MessageLink struct { // Message identifier of original message Mid string `json:"mid"` // Type of message link Type MessageLinkType `json:"type"` }
Link to Message
type MessageLinkType ¶
type MessageLinkType string
MessageLinkType Type of linked message
const ( Forward MessageLinkType = "forward" Reply MessageLinkType = "reply" )
Defines values for MessageLinkType.
type MessageList ¶
type MessageList struct { // Messages List of messages Messages []Message `json:"messages"` }
MessageList Paginated list of messages
type MessageRemoved ¶
type MessageRemoved struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Identifier of removed message MessageId string `json:"message_id"` // Chat identifier where message has been deleted ChatId int64 `json:"chat_id"` // User who deleted this message UserId int64 `json:"user_id"` }
func (*MessageRemoved) GetUpdateType ¶
func (*MessageRemoved) GetUpdateType() UpdateType
type MessageStat ¶
type MessageStat struct {
Views int `json:"views"`
}
MessageStat Message statistics
type NewMessageBody ¶
type NewMessageBody struct { // Attachments Message attachments. See `AttachmentRequest` and it's inheritors for full information Attachments []AttachmentRequest `json:"attachments,omitempty"` // Format If set, message text will be formated according to given markup Format *TextFormat `json:"format"` // Link Link to Message Link *NewMessageLink `json:"link"` // Notify If false, chat participants would not be notified Notify bool `json:"notify,omitempty"` // Text Message text Text string `json:"text,omitempty"` }
NewMessageBody defines model for NewMessageBody.
type NewMessageLink ¶
type NewMessageLink struct { // Mid Message identifier of original message Mid string `json:"mid"` // Type Type of message link Type MessageLinkType `json:"type"` }
NewMessageLink defines model for NewMessageLink.
type PhotoToken ¶
type PhotoToken struct { // Token Encoded information of uploaded image Token string `json:"token"` }
PhotoToken defines model for PhotoToken.
type PinMessageBody ¶
type PinMessageBody struct { // MessageId Identifier of message to be pinned in chat MessageId string `json:"message_id"` // Notify If `true`, participants will be notified with system message in chat/channel Notify bool `json:"notify,omitempty"` }
PinMessageBody defines model for PinMessageBody.
type Recipient ¶
type Recipient struct { // ChatId Chat identifier ChatId int64 `json:"chat_id,omitempty"` // ChatType Chat type ChatType ChatType `json:"chat_type"` // UserId User identifier, if message was sent to user UserId int64 `json:"user_id,omitempty"` }
Recipient New message recipient. Could be user or chat
type RequestContactButton ¶
type RequestContactButton struct { // Visible text of button Text string `json:"text"` }
func (*RequestContactButton) GetButtonText ¶
func (b *RequestContactButton) GetButtonText() string
func (*RequestContactButton) GetButtonType ¶
func (b *RequestContactButton) GetButtonType() string
func (RequestContactButton) MarshalJSON ¶
func (b RequestContactButton) MarshalJSON() ([]byte, error)
type RequestGeoLocationButton ¶
type RequestGeoLocationButton struct { // Visible text of button Text string `json:"text"` // If true, sends location without asking user's confirmation Quick bool `json:"quick,omitempty"` }
func (*RequestGeoLocationButton) GetButtonText ¶
func (b *RequestGeoLocationButton) GetButtonText() string
func (*RequestGeoLocationButton) GetButtonType ¶
func (b *RequestGeoLocationButton) GetButtonType() string
func (RequestGeoLocationButton) MarshalJSON ¶
func (b RequestGeoLocationButton) MarshalJSON() ([]byte, error)
type SendMessageBody ¶
type SendMessageBody struct { // Message text Text string `json:"text,omitempty"` // Attachments Message attachments. Could be one of `Attachment` type. See description of this schema Attachments []AttachmentRequest `json:"attachments,omitempty"` // Link to Message Link *MessageLink `json:"link,omitempty"` // If set, message text will be formated according to given markup Format TextFormat `json:"format,omitempty"` // If false, chat participants would not be notified Notify bool `json:"notify,omitempty"` }
type SendMessageOpts ¶
type SendMessageOpts struct { // DisableLinkPreview If `false`, server will not generate media preview for links in text DisableLinkPreview bool `form:"disable_link_preview,omitempty" json:"disable_link_preview,omitempty"` // Attachments Message attachments. Could be one of `Attachment` type. See description of this schema Attachments []AttachmentRequest `json:"attachments"` // Link to Message Link *MessageLink `json:"link,omitempty"` // If set, message text will be formated according to given markup Format TextFormat `json:"format"` // If false, chat participants would not be notified Notify bool `json:"notify,omitempty"` }
SendMessageOpts defines optional parameters for SendMessage.
type SendMessageResult ¶
type SendMessageResult struct { // Message Message in chat Message Message `json:"message"` }
SendMessageResult defines model for SendMessageResult.
type SenderAction ¶
type SenderAction string
SenderAction Different actions to send to chat members
const ( TypingOn SenderAction = "typing_on" SendingPhoto SenderAction = "sending_photo" SendingVideo SenderAction = "sending_video" SendingAudio SenderAction = "sending_audio" SendingFile SenderAction = "sending_file" MarkSeen SenderAction = "mark_seen" )
func (SenderAction) GetSenderAction ¶
func (s SenderAction) GetSenderAction() string
type SharePayload ¶
type SharePayload struct { string `json:"token,omitempty"` Url string `json:"url,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` ImageUrl string `json:"image_url,omitempty"` }Token
SharePayload Request to attach share.
func (*SharePayload) GetPayloadType ¶
func (*SharePayload) GetPayloadType() string
type SimpleQueryResult ¶
type SimpleQueryResult struct { // Message Explanatory message if the result is not successful Message *string `json:"message,omitempty"` // Success `true` if request was successful. `false` otherwise Success bool `json:"success"` }
SimpleQueryResult Simple response to request
type StickerPayload ¶
type StickerPayload struct { // Sticker code Code string `json:"code,omitempty"` // Url Any external sticker URL you want to attach Url string `json:"url,omitempty"` // Sticker width Width int `json:"width,omitempty"` // Sticker height Height int `json:"height,omitempty"` }
StickerPayload Request to attach sticker.
func (*StickerPayload) GetPayloadType ¶
func (*StickerPayload) GetPayloadType() string
type Subscription ¶
type Subscription struct { // Time Unix-time when subscription was created Time int64 `json:"time"` // UpdateTypes Update types bot subscribed for UpdateTypes []string `json:"update_types,omitempty"` // Url Webhook URL Url string `json:"url"` Version string `json:"version,omitempty"` }
Subscription Schema to describe WebHook subscription
type SubscriptionRequestBody ¶
type SubscriptionRequestBody struct { // UpdateTypes List of update types your bot want to receive. See `Update` object for a complete list of types UpdateTypes []UpdateType `json:"update_types,omitempty"` // Url URL of HTTP(S)-endpoint of your bot. Must starts with http(s):// Url string `json:"url"` // Version Version of API. Affects model representation Version string `json:"version,omitempty"` }
SubscriptionRequestBody Request to set up WebHook subscription
type TextFormat ¶
type TextFormat string
TextFormat Message text format
const ( Html TextFormat = "html" Markdown TextFormat = "markdown" )
Defines values for TextFormat.
type UnsubscribeParams ¶
type UnsubscribeParams struct { // Url URL to remove from WebHook subscriptions Url string `form:"url" json:"url"` }
UnsubscribeParams defines parameters for Unsubscribe.
type Update ¶
type Update struct { Type UpdateType MessageCreated *MessageCreated MessageEdited *MessageEdited MessageRemoved *MessageRemoved MessageCallback *MessageCallback BotAdded *BotAdded BotRemoved *BotRemoved BotStarted *BotStarted UserAdded *UserAdded UserRemoved *UserRemoved ChatTitleChanged *ChatTitleChanged MessageChatCreated *MessageChatCreated MessageConstructed *MessageConstructed MessageConstructionRequest *MessageConstructionRequest }
Update `Update` object represents different types of events that happened in chat.
func (*Update) GetUpdateType ¶
func (u *Update) GetUpdateType() UpdateType
type UpdateList ¶
type UpdateList struct { // Marker Pointer to the next data page Marker int64 `json:"marker,omitempty"` // Updates Page of updates Updates []Update `json:"updates"` }
UpdateList List of all updates in chats your bot participated in
func (*UpdateList) UnmarshalJSON ¶
func (p *UpdateList) UnmarshalJSON(b []byte) error
type UpdateType ¶
type UpdateType string
const ( UpdateTypeMessageCreated UpdateType = "message_created" UpdateTypeMessageRemoved UpdateType = "message_removed" UpdateTypeMessageCallback UpdateType = "message_callback" UpdateTypeMessageEdited UpdateType = "message_edited" UpdateTypeBotAdded UpdateType = "bot_added" UpdateTypeBotRemoved UpdateType = "bot_removed" UpdateTypeBotStarted UpdateType = "bot_started" UpdateTypeUserAdded UpdateType = "user_added" UpdateTypeUserRemoved UpdateType = "user_removed" UpdateTypeChatTitleChanged UpdateType = "chat_title_changed" UpdateTypeMessageConstructionRequest UpdateType = "message_construction_request" UpdateTypeMessageConstructed UpdateType = "message_constructed" UpdateTypeMessageChatCreated UpdateType = "message_chat_created" )
type UploadEndpoint ¶
type UploadEndpoint struct { // Url URL to upload Url string `json:"url"` }
UploadEndpoint Endpoint you should upload to your binaries
type UploadType ¶
type UploadType string
UploadType Type of file uploading
const ( UploadTypeImage UploadType = "image" UploadTypeVideo UploadType = "video" UploadTypeAudio UploadType = "audio" UploadTypeFile UploadType = "file" )
type User ¶
type User struct { // IsBot `true` if user is bot IsBot bool `json:"is_bot"` // LastActivityTime Time of last user activity in TamTam (Unix timestamp in milliseconds). Can be outdated if user disabled its "online" status in settings LastActivityTime int64 `json:"last_activity_time"` // Name Users visible name Name string `json:"name"` // UserId Users identifier UserId int64 `json:"user_id"` // Username Unique public user name. Can be `null` if user is not accessible or it is not set Username string `json:"username,omitempty"` }
User defines model for User.
type UserAdded ¶
type UserAdded struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Chat identifier where event has occurred ChatId int64 `json:"chat_id"` // User added to chat User *User `json:"user"` // User who added user to chat. Can be null in case when user joined chat by link InviderId int64 `json:"inviter_id,omitempty"` // Indicates whether user has been added to channel or not IsChannel bool `json:"is_channel"` }
func (*UserAdded) GetUpdateType ¶
func (*UserAdded) GetUpdateType() UpdateType
type UserIdsList ¶
type UserIdsList struct {
UserIds interface{} `json:"user_ids"`
}
UserIdsList defines model for UserIdsList.
type UserRemoved ¶
type UserRemoved struct { // Timestamp Unix-time when event has occurred Timestamp int64 `json:"timestamp"` UpdateType UpdateType `json:"update_type"` // Chat identifier where event has occurred ChatId int64 `json:"chat_id"` // User removed from chat User *User `json:"user"` // Administrator who removed user from chat. Can be null in case when user left chat AdminId int64 `json:"admin_id,omitempty"` // Indicates whether user has been removed from a channel or not IsChannel bool `json:"is_channel"` }
func (*UserRemoved) GetUpdateType ¶
func (*UserRemoved) GetUpdateType() UpdateType
type UserWithPhoto ¶
type UserWithPhoto struct { // AvatarUrl URL of avatar AvatarUrl *string `json:"avatar_url,omitempty"` // Description User description. Can be `null` if user did not fill it out Description *string `json:"description"` // FullAvatarUrl URL of avatar of a bigger size FullAvatarUrl *string `json:"full_avatar_url,omitempty"` // IsBot `true` if user is bot IsBot bool `json:"is_bot"` // LastActivityTime Time of last user activity in TamTam (Unix timestamp in milliseconds). Can be outdated if user disabled its "online" status in settings LastActivityTime int64 `json:"last_activity_time"` // Name Users visible name Name string `json:"name"` // UserId Users identifier UserId int64 `json:"user_id"` // Username Unique public user name. Can be `null` if user is not accessible or it is not set Username *string `json:"username"` }
UserWithPhoto defines model for UserWithPhoto.
type VideoPayload ¶
type VideoPayload struct { // Url of the video Url string `json:"url,omitempty"` // Token of any existing attachment Token string `json:"token,omitempty"` // Video Id VideoId int64 `json:"id,omitempty"` // Thumbnail of the video Thumbnail *Image `json:"thumbnail,omitempty"` // Duration of the video Duration int64 `json:"duration,omitempty"` // Sticker width Width int `json:"width,omitempty"` // Sticker height Height int `json:"height,omitempty"` }
VideoPayload Request to attach video.
func (*VideoPayload) GetPayloadType ¶
func (*VideoPayload) GetPayloadType() string