tamtam

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2019 License: MIT Imports: 13 Imported by: 0

README

TamTam Go

Простая реализация клиента к TamTam Bot API на Go.

На данном этапе представляет собой 1 в 1 реализованные методы API + HTTPHandler для веб-хуков + сгенерированные модели.

Документация

Её пока нет :)

Но http://godoc.org/github.com/neonxp/tamtam/ может вам помочь.

Статус

API пока крайне неставбильное и обязательно будет меняться в будущем. Учитывайте это!

Пример

Простые примеры использования находятся в директории examples.

Автор

Александр NeonXP Кирюхин a.kiryukhin@mail.ru

Documentation

Overview

* TamTam Bot API

* TamTam Bot API

Index

Constants

View Source
const (
	AttachmentImage    AttachmentType = "image"
	AttachmentVideo                   = "video"
	AttachmentAudio                   = "audio"
	AttachmentFile                    = "file"
	AttachmentContact                 = "contact"
	AttachmentSticker                 = "sticker"
	AttachmentShare                   = "share"
	AttachmentLocation                = "location"
	AttachmentKeyboard                = "inline_keyboard"
)
View Source
const (
	UpdateTypeMessageCallback  UpdateType = "message_callback"
	UpdateTypeMessageCreated              = "message_created"
	UpdateTypeMessageRemoved              = "message_removed"
	UpdateTypeMessageEdited               = "message_edited"
	UpdateTypeMessageRestored             = "message_restored"
	UpdateTypeBotAdded                    = "bot_added"
	UpdateTypeBotRemoved                  = "bot_removed"
	UpdateTypeUserAdded                   = "user_added"
	UpdateTypeUserRemoved                 = "user_removed"
	UpdateTypeBotStarted                  = "bot_started"
	UpdateTypeChatTitleChanged            = "chat_title_changed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionRequestBody

type ActionRequestBody struct {
	Action SenderAction `json:"action"`
}

type Api

type Api struct {
	// contains filtered or unexported fields
}

func New

func New(key string) *Api

New TamTam Api object

func (*Api) AddMember

func (a *Api) AddMember(chatID int64, users UserIdsList) (*SimpleQueryResult, error)

func (*Api) AnswerOnCallback

func (a *Api) AnswerOnCallback(callbackID int64, callback *CallbackAnswer) (*SimpleQueryResult, error)

func (*Api) DeleteMessage

func (a *Api) DeleteMessage(messageID int64) (*SimpleQueryResult, error)

func (*Api) EditChat

func (a *Api) EditChat(chatID int64, update *ChatPatch) (*Chat, error)

func (*Api) EditMessage

func (a *Api) EditMessage(messageID int64, message *NewMessageBody) (*SimpleQueryResult, error)

func (*Api) EnableLogging

func (a *Api) EnableLogging()

func (*Api) GetChat

func (a *Api) GetChat(chatID int64) (*Chat, error)

func (*Api) GetChatMembers

func (a *Api) GetChatMembers(chatID, count, marker int64) (*ChatMembersList, error)

func (*Api) GetChatMembership

func (a *Api) GetChatMembership(chatID int64) (*ChatMember, error)

func (*Api) GetChats

func (a *Api) GetChats(count, marker int64) (*ChatList, error)

region Chat methods

func (*Api) GetHandler

func (a *Api) GetHandler(updates chan interface{}) http.HandlerFunc

func (*Api) GetMe

func (a *Api) GetMe() (*UserWithPhoto, error)

func (*Api) GetMessages

func (a *Api) GetMessages(chatID int64, messageIDs []string, from int64, to int64, count int64) (*MessageList, error)

func (*Api) GetSubscriptions

func (a *Api) GetSubscriptions() (*GetSubscriptionsResult, error)

func (*Api) GetUpdatesLoop

func (a *Api) GetUpdatesLoop(ctx context.Context, updates chan interface{}) error

func (*Api) GetUploadURL

func (a *Api) GetUploadURL(uploadType UploadType) (*UploadEndpoint, error)

func (*Api) LeaveChat

func (a *Api) LeaveChat(chatID int64) (*SimpleQueryResult, error)

func (*Api) RemoveMember

func (a *Api) RemoveMember(chatID int64, userID int64) (*SimpleQueryResult, error)

func (*Api) SendAction

func (a *Api) SendAction(chatID int64, action SenderAction) (*SimpleQueryResult, error)

func (*Api) SendMessage

func (a *Api) SendMessage(chatID int64, userID int64, message *NewMessageBody) (*Message, error)

func (*Api) Subscribe

func (a *Api) Subscribe(subscribeURL string, updateTypes []string) (*SimpleQueryResult, error)

func (*Api) Unsubscribe

func (a *Api) Unsubscribe(subscriptionURL string) (*SimpleQueryResult, error)

func (*Api) UploadMedia added in v0.1.1

func (a *Api) UploadMedia(uploadType UploadType, filename string) (*UploadedInfo, error)

type Attachment

type Attachment struct {
	Type AttachmentType `json:"type,omitempty"`
}

Generic schema representing message attachment

type AttachmentPayload

type AttachmentPayload struct {
	// Media attachment URL
	Token string `json:"token"`
}

type AttachmentRequest

type AttachmentRequest struct {
	Type string `json:"type,omitempty"`
}

Request to attach some data to message

type AttachmentType

type AttachmentType string

type AudioAttachment

type AudioAttachment struct {
	Type    string            `json:"type,omitempty"`
	Payload AttachmentPayload `json:"payload"`
}

type AudioAttachmentRequest

type AudioAttachmentRequest struct {
	Type    string       `json:"type,omitempty"`
	Payload UploadedInfo `json:"payload"`
}

Request to attach audio to message. MUST be the only attachment in message

type BotAddedToChatUpdate

type BotAddedToChatUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Chat id where bot was added
	ChatId int64 `json:"chat_id"`
	// User id who added bot to chat
	UserId int64 `json:"user_id"`
}

You will receive this update when bot has been added to chat

type BotRemovedFromChatUpdate

type BotRemovedFromChatUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Chat identifier bot removed from
	ChatId int64 `json:"chat_id"`
	// User id who removed bot from chat
	UserId int64 `json:"user_id"`
}

You will receive this update when bot has been removed from chat

type BotStartedUpdate

type BotStartedUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Dialog identifier where event has occurred
	ChatId int64 `json:"chat_id"`
	// User pressed the 'Start' button
	UserId int64 `json:"user_id"`
}

Bot gets this type of update as soon as user pressed `Start` button

type Button

type Button struct {
	Type string `json:"type,omitempty"`
	// Visible text of button
	Text string `json:"text"`
	// Intent of button. Affects clients representation.
	Intent Intent `json:"intent"`
}

type ButtonType

type ButtonType string
const (
	LINK        ButtonType = "link"
	CALLBACK    ButtonType = "callback"
	CONTACT     ButtonType = "request_contact"
	GEOLOCATION ButtonType = "request_geo_location"
)

type Callback

type Callback struct {
	// Unix-time when user pressed the button
	Timestamp int64 `json:"timestamp"`
	// Current keyboard identifier
	CallbackId string `json:"callback_id"`
	// Button payload
	Payload string `json:"payload"`
	// User pressed the button
	User User `json:"user"`
}

Object sent to bot when user presses button

type CallbackAnswer

type CallbackAnswer struct {
	UserId int64 `json:"user_id,omitempty"`
	// Fill this if you want to modify current message
	Message NewMessageBody `json:"message,omitempty"`
	// Fill this if you just want to send one-time notification to user
	Notification string `json:"notification,omitempty"`
}

Send this object when your bot wants to react to when a button is pressed

type CallbackButton

type CallbackButton struct {
	Type ButtonType `json:"type,omitempty"`
	// Visible text of button
	Text string `json:"text"`
	// Intent of button. Affects clients representation.
	Intent Intent `json:"intent"`
	// Button payload
	Payload string `json:"payload"`
}

After pressing this type of button client sends to server payload it contains

type Chat

type Chat struct {
	// Chats identifier
	ChatId int64 `json:"chat_id"`
	// Type of chat. One of: dialog, chat, channel
	Type ChatType `json:"type"`
	// Chat status. One of:  - active: bot is active member of chat  - removed: bot was kicked  - left: bot intentionally left chat  - closed: chat was closed
	Status ChatStatus `json:"status"`
	// Visible title of chat
	Title string `json:"title"`
	// Icon of chat
	Icon Image `json:"icon"`
	// Time of last event occured in chat
	LastEventTime int64 `json:"last_event_time"`
	// Number of people in chat. Always 2 for `dialog` chat type
	ParticipantsCount int32 `json:"participants_count"`
	// Identifier of chat owner. Visible only for chat admins
	OwnerId int64 `json:"owner_id,omitempty"`
	// 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,omitempty"`
	// Is current chat publicly available. Always `false` for dialogs
	IsPublic bool `json:"is_public"`
	// Link on chat if it is public
	Link string `json:"link,omitempty"`
	// Chat description
	Description map[string]interface{} `json:"description"`
}

type ChatAdminPermission

type ChatAdminPermission string

ChatAdminPermission : Chat admin permissions

const (
	READ_ALL_MESSAGES  ChatAdminPermission = "read_all_messages"
	ADD_REMOVE_MEMBERS ChatAdminPermission = "add_remove_members"
	ADD_ADMINS         ChatAdminPermission = "add_admins"
	CHANGE_CHAT_INFO   ChatAdminPermission = "change_chat_info"
	PIN_MESSAGE        ChatAdminPermission = "pin_message"
	WRITE              ChatAdminPermission = "write"
)

List of ChatAdminPermission

type ChatList

type ChatList struct {
	// List of requested chats
	Chats []Chat `json:"chats"`
	// Reference to the next page of requested chats
	Marker int64 `json:"marker"`
}

type ChatMember

type ChatMember struct {
	// Users identifier
	UserId int64 `json:"user_id"`
	// Users visible name
	Name string `json:"name"`
	// Unique public user name. Can be `null` if user is not accessible or it is not set
	Username string `json:"username"`
	// URL of avatar
	AvatarUrl string `json:"avatar_url"`
	// URL of avatar of a bigger size
	FullAvatarUrl  string `json:"full_avatar_url"`
	LastAccessTime int64  `json:"last_access_time"`
	IsOwner        bool   `json:"is_owner"`
	IsAdmin        bool   `json:"is_admin"`
	JoinTime       int64  `json:"join_time"`
	// Permissions in chat if member is admin. `null` otherwise
	Permissions []ChatAdminPermission `json:"permissions"`
}

type ChatMembersList

type ChatMembersList struct {
	// Participants in chat with time of last activity. Visible only for chat admins
	Members []ChatMember `json:"members"`
	// Pointer to the next data page
	Marker int64 `json:"marker"`
}

type ChatPatch

type ChatPatch struct {
	Icon  PhotoAttachmentRequestPayload `json:"icon,omitempty"`
	Title string                        `json:"title,omitempty"`
}

type ChatStatus

type ChatStatus string

ChatStatus : Chat status for current bot

const (
	ACTIVE    ChatStatus = "active"
	REMOVED   ChatStatus = "removed"
	LEFT      ChatStatus = "left"
	CLOSED    ChatStatus = "closed"
	SUSPENDED ChatStatus = "suspended"
)

List of ChatStatus

type ChatTitleChangedUpdate

type ChatTitleChangedUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Chat identifier where event has occurred
	ChatId int64 `json:"chat_id"`
	// User who changed title
	UserId int64 `json:"user_id"`
	// New title
	Title string `json:"title"`
}

Bot gets this type of update as soon as title has been changed in chat

type ChatType

type ChatType string

ChatType : Type of chat. Dialog (one-on-one), chat or channel

const (
	DIALOG  ChatType = "dialog"
	CHAT    ChatType = "chat"
	CHANNEL ChatType = "channel"
)

List of ChatType

type ContactAttachment

type ContactAttachment struct {
	Type    string                   `json:"type,omitempty"`
	Payload ContactAttachmentPayload `json:"payload"`
}

type ContactAttachmentPayload

type ContactAttachmentPayload struct {
	// User info in VCF format
	VcfInfo string `json:"vcfInfo"`
	// User info
	TamInfo User `json:"tamInfo"`
}

type ContactAttachmentRequest

type ContactAttachmentRequest struct {
	Type    string                          `json:"type,omitempty"`
	Payload ContactAttachmentRequestPayload `json:"payload"`
}

Request to attach contact card to message. MUST be the only attachment in message

type ContactAttachmentRequestPayload

type ContactAttachmentRequestPayload struct {
	// Contact name
	Name string `json:"name"`
	// Contact identifier
	ContactId int64 `json:"contactId"`
	// Full information about contact in VCF format
	VcfInfo string `json:"vcfInfo"`
	// Contact phone in VCF format
	VcfPhone string `json:"vcfPhone"`
}

type Error

type Error struct {
	// Error
	Error string `json:"error,omitempty"`
	// Error code
	Code string `json:"code"`
	// Human-readable description
	Message string `json:"message"`
}

Server returns this if there was an exception to your request

type FileAttachment

type FileAttachment struct {
	Type     string            `json:"type,omitempty"`
	Payload  AttachmentPayload `json:"payload"`
	Filename string            `json:"filename"`
	Size     int64             `json:"size"`
}

type FileAttachmentRequest

type FileAttachmentRequest struct {
	Type    string           `json:"type,omitempty"`
	Payload UploadedFileInfo `json:"payload"`
}

Request to attach file to message. MUST be the only attachment in message

type GetSubscriptionsResult

type GetSubscriptionsResult struct {
	// Current suscriptions
	Subscriptions []Subscription `json:"subscriptions"`
}

List of all WebHook subscriptions

type Image

type Image struct {
	// URL of image
	Url string `json:"url"`
}

Generic schema describing image object

type InlineKeyboardAttachment

type InlineKeyboardAttachment struct {
	Type string `json:"type,omitempty"`
	// Unique identifier of keyboard
	//CallbackId string   `json:"callback_id"`
	Payload Keyboard `json:"payload"`
}

Buttons in messages

type InlineKeyboardAttachmentRequest

type InlineKeyboardAttachmentRequest struct {
	Type    string                                 `json:"type,omitempty"`
	Payload InlineKeyboardAttachmentRequestPayload `json:"payload"`
}

Request to attach keyboard to message

type InlineKeyboardAttachmentRequestPayload

type InlineKeyboardAttachmentRequestPayload struct {
	// Two-dimensional array of buttons
	Buttons [][]Button `json:"buttons"`
}

type Intent

type Intent string

Intent : Intent of button

const (
	POSITIVE Intent = "positive"
	NEGATIVE Intent = "negative"
	DEFAULT  Intent = "default"
)

List of Intent

type Keyboard

type Keyboard struct {
	Buttons interface{} `json:"buttons"`
}

Keyboard is two-dimension array of buttons

type KeyboardBuilder

type KeyboardBuilder struct {
	// contains filtered or unexported fields
}

func NewKeyboardBuilder

func NewKeyboardBuilder() *KeyboardBuilder

func (*KeyboardBuilder) AddRow

func (k *KeyboardBuilder) AddRow() *KeyboardRow

func (*KeyboardBuilder) Build

func (k *KeyboardBuilder) Build() Keyboard

type KeyboardRow

type KeyboardRow struct {
	// contains filtered or unexported fields
}

func (*KeyboardRow) AddCallback

func (k *KeyboardRow) AddCallback(text string, intent Intent, payload string) *KeyboardRow

func (*KeyboardRow) AddContact

func (k *KeyboardRow) AddContact(text string, intent Intent, url string) *KeyboardRow

func (*KeyboardRow) AddGeolocation

func (k *KeyboardRow) AddGeolocation(text string, intent Intent, quick bool) *KeyboardRow
func (k *KeyboardRow) AddLink(text string, intent Intent, url string) *KeyboardRow

func (*KeyboardRow) Build

func (k *KeyboardRow) Build() []interface{}

type LinkButton

type LinkButton struct {
	Type ButtonType `json:"type,omitempty"`
	// Visible text of button
	Text string `json:"text"`
	// Intent of button. Affects clients representation.
	Intent Intent `json:"intent"`
	Url    string `json:"url"`
}

After pressing this type of button user follows the link it contains

type LinkedMessage

type LinkedMessage struct {
	// Type of linked message
	Type MessageLinkType `json:"type"`
	// User sent this message
	Sender *User `json:"sender,omitempty"`
	// Chat where message was originally posted
	ChatId  *int64      `json:"chat_id,omitempty"`
	Message MessageBody `json:"message"`
}

type LocationAttachment

type LocationAttachment struct {
	Type      string  `json:"type,omitempty"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type LocationAttachmentRequest

type LocationAttachmentRequest struct {
	Type      string  `json:"type,omitempty"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

Request to attach keyboard to message

type Message

type Message struct {
	// User that sent this message
	Sender *User `json:"sender,omitempty"`
	// Message recipient. Could be user or chat
	Recipient Recipient `json:"recipient"`
	// Unix-time when message was created
	Timestamp int64 `json:"timestamp"`
	// Forwarder or replied message
	Link LinkedMessage `json:"link,omitempty"`
	// Body of created message. Text + attachments. Could be null if message contains only forwarded message.
	Body MessageBody `json:"body"`
}

Message in chat

type MessageBody

type MessageBody struct {
	// Unique identifier of message
	Mid string `json:"mid"`
	// Sequence identifier of message in chat
	Seq int64 `json:"seq"`
	// Message text
	Text string `json:"text"`
	// Message attachments. Could be one of `Attachment` type. See description of this schema
	RawAttachments []json.RawMessage `json:"attachments"`

	Attachments []interface{}
	// In case this message is repled to, it is the unique identifier of the replied message
	ReplyTo string `json:"reply_to,omitempty"`
}

Schema representing body of message

type MessageCallbackUpdate

type MessageCallbackUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64    `json:"timestamp"`
	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"`
}

You will get this `update` as soon as user presses button

type MessageCreatedUpdate

type MessageCreatedUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Newly created message
	Message Message `json:"message"`
}

You will get this `update` as soon as message is created

type MessageEditedUpdate

type MessageEditedUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Edited message
	Message Message `json:"message"`
}

You will get this `update` as soon as message is edited

type MessageLinkType

type MessageLinkType string

MessageLinkType : Type of linked message

const (
	FORWARD MessageLinkType = "forward"
	REPLY   MessageLinkType = "reply"
)

List of MessageLinkType

type MessageList

type MessageList struct {
	// List of messages
	Messages []Message `json:"messages"`
}

Paginated list of messages

type MessageRemovedUpdate

type MessageRemovedUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Identifier of removed message
	MessageId string `json:"message_id"`
}

You will get this `update` as soon as message is removed

type MessageRestoredUpdate

type MessageRestoredUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Restored message identifier
	MessageId string `json:"message_id"`
}

You will get this `update` as soon as message is restored

type NewMessageBody

type NewMessageBody struct {
	// Message text
	Text string `json:"text"`
	// Message attachments. See `AttachmentRequest` and it's inheritors for full information.
	Attachments []interface{} `json:"attachments,omitempty"`
	// If false, chat participants wouldn't be notified
	Notify bool `json:"notify,omitempty"`
}

type PhotoAttachment

type PhotoAttachment struct {
	Type    string                 `json:"type,omitempty"`
	Payload PhotoAttachmentPayload `json:"payload"`
}

Image attachment

type PhotoAttachmentPayload

type PhotoAttachmentPayload struct {
	// Unique identifier of this image
	PhotoId *int64  `json:"photo_id,omitempty"`
	Token   *string `json:"token,omitempty"`
	// Image URL
	Url *string `json:"url,omitempty"`
}

type PhotoAttachmentRequest

type PhotoAttachmentRequest struct {
	Type    string                        `json:"type,omitempty"`
	Payload PhotoAttachmentRequestPayload `json:"payload"`
}

type PhotoAttachmentRequestPayload

type PhotoAttachmentRequestPayload struct {
	// If specified, given URL will be attached to message as image
	Url string `json:"url,omitempty"`
	// Token of any existing attachment
	Token string `json:"token,omitempty"`
	// Tokens were obtained after uploading images
	Photos map[string]PhotoToken `json:"photos,omitempty"`
}

Request to attach image. All fields are mutually exclusive.

type PhotoToken

type PhotoToken struct {
	// Encoded information of uploaded image
	Token string `json:"token"`
}

type PhotoTokens

type PhotoTokens struct {
	Photos map[string]PhotoToken `json:"photos"`
}

This is information you will recieve as soon as an image uploaded

type Recipient

type Recipient struct {
	// Chat identifier
	ChatId int64 `json:"chat_id"`
	// Chat type
	ChatType ChatType `json:"chat_type"`
	// User identifier, if message was sent to user
	UserId int64 `json:"user_id"`
}

New message recepient. Could be user or chat

type RequestContactButton

type RequestContactButton struct {
	Type ButtonType `json:"type,omitempty"`
	// Visible text of button
	Text string `json:"text"`
	// Intent of button. Affects clients representation.
	Intent Intent `json:"intent"`
}

After pressing this type of button client sends new message with attachment of curent user contact

type RequestGeoLocationButton

type RequestGeoLocationButton struct {
	Type ButtonType `json:"type,omitempty"`
	// Visible text of button
	Text string `json:"text"`
	// Intent of button. Affects clients representation.
	Intent Intent `json:"intent"`
	// If *true*, sends location without asking user's confirmation
	Quick bool `json:"quick,omitempty"`
}

After pressing this type of button client sends new message with attachment of current user geo location

type SendMessageResult

type SendMessageResult struct {
	Message Message `json:"message"`
}

type SenderAction

type SenderAction string

SenderAction : Different actions to send to chat members

const (
	TYPING_ON     SenderAction = "typing_on"
	TYPING_OFF    SenderAction = "typing_off"
	SENDING_PHOTO SenderAction = "sending_photo"
	SENDING_VIDEO SenderAction = "sending_video"
	SENDING_AUDIO SenderAction = "sending_audio"
	MARK_SEEN     SenderAction = "mark_seen"
)

List of SenderAction

type ShareAttachment

type ShareAttachment struct {
	Type    string            `json:"type,omitempty"`
	Payload AttachmentPayload `json:"payload"`
}

type SimpleQueryResult

type SimpleQueryResult struct {
	// `true` if request was successful. `false` otherwise
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
}

Simple response to request

type StickerAttachment

type StickerAttachment struct {
	Type    string            `json:"type,omitempty"`
	Payload AttachmentPayload `json:"payload"`
	Width   int               `json:"width"`
	Height  int               `json:"height"`
}

type StickerAttachmentRequest

type StickerAttachmentRequest struct {
	Type    string                          `json:"type,omitempty"`
	Payload StickerAttachmentRequestPayload `json:"payload"`
}

Request to attach sticker. MUST be the only attachment request in message

type StickerAttachmentRequestPayload

type StickerAttachmentRequestPayload struct {
	// Sticker code
	Code string `json:"code"`
}

type Subscription

type Subscription struct {
	// WebHook URL
	Url string `json:"url"`
	// Unix-time when subscription was created
	Time int64 `json:"time"`
	// Update types bot subscribed for
	UpdateTypes []string `json:"update_types"`
	Version     string   `json:"version"`
}

Schema to describe WebHook subscription

type SubscriptionRequestBody

type SubscriptionRequestBody struct {
	// URL of HTTP(S)-endpoint of your bot
	Url string `json:"url"`
	// List of update types your bot want to receive. See `Update` object for a complete list of types
	UpdateTypes []string `json:"update_types,omitempty"`
	// Version of API. Affects model representation
	Version string `json:"version,omitempty"`
}

Request to set up WebHook subscription

type Update

type Update struct {
	UpdateType UpdateType `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
}

`Update` object repsesents different types of events that happened in chat. See its inheritors

type UpdateBotAdded

type UpdateBotAdded struct {
	Update
	ChatID int64 `json:"chat_id"`
	User   User  `json:"user"`
}

type UpdateBotRemoved

type UpdateBotRemoved struct {
	Update
	ChatID int64 `json:"chat_id"`
	User   User  `json:"user"`
}

type UpdateBotStarted

type UpdateBotStarted struct {
	Update
	ChatID int64 `json:"chat_id"`
	User   User  `json:"user"`
}

type UpdateChatTitleChanged

type UpdateChatTitleChanged struct {
	Update
	ChatID int64  `json:"chat_id"`
	User   User   `json:"user"`
	Title  string `json:"title"`
}

type UpdateList

type UpdateList struct {
	// Page of updates
	Updates []json.RawMessage `json:"updates"`
	// Pointer to the next data page
	Marker int64 `json:"marker"`
}

List of all updates in chats your bot participated in

type UpdateMessageCallback

type UpdateMessageCallback struct {
	Update
	Callback Callback `json:"callback"`
	Message  Message  `json:"message"`
}

type UpdateMessageCreated

type UpdateMessageCreated struct {
	Update
	Message Message `json:"message"`
}

type UpdateMessageEdited

type UpdateMessageEdited struct {
	Update
	Message Message `json:"message"`
}

type UpdateMessageRemoved

type UpdateMessageRemoved struct {
	Update
	MessageID string `json:"message_id"`
}

type UpdateMessageRestored

type UpdateMessageRestored struct {
	Update
	MessageID string `json:"message_id"`
}

type UpdateType

type UpdateType string

type UpdateUserAdded

type UpdateUserAdded struct {
	Update
	ChatID    int64 `json:"chat_id"`
	User      User  `json:"user"`
	InviterID int64 `json:"inviter_id"`
}

type UpdateUserRemoved

type UpdateUserRemoved struct {
	Update
	ChatID  int64 `json:"chat_id"`
	User    User  `json:"user"`
	AdminID int64 `json:"admin_id"`
}

type UploadEndpoint

type UploadEndpoint struct {
	// URL to upload
	Url string `json:"url"`
}

Endpoint you should upload to your binaries

type UploadType

type UploadType string

UploadType : Type of file uploading

const (
	PHOTO UploadType = "photo"
	VIDEO UploadType = "video"
	AUDIO UploadType = "audio"
	FILE  UploadType = "file"
)

List of UploadType

type UploadedFileInfo

type UploadedFileInfo struct {
	// Unique file identifier
	FileId int64 `json:"fileId"`
}

This is information you will recieve as soon as a file is uploaded

type UploadedInfo

type UploadedInfo struct {
	Id int64 `json:"id"`
}

This is information you will recieve as soon as audio/video is uploaded

type User

type User struct {
	// Users identifier
	UserId int64 `json:"user_id"`
	// Users visible name
	Name string `json:"name"`
	// Unique public user name. Can be `null` if user is not accessible or it is not set
	Username string `json:"username"`
}

type UserAddedToChatUpdate

type UserAddedToChatUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Chat identifier where event has occured
	ChatId int64 `json:"chat_id"`
	// User added to chat
	UserId int64 `json:"user_id"`
	// User who added user to chat
	InviterId int64 `json:"inviter_id"`
}

You will receive this update when user has been added to chat where bot is administrator

type UserIdsList

type UserIdsList struct {
	UserIds []int64 `json:"user_ids"`
}

type UserRemovedFromChatUpdate

type UserRemovedFromChatUpdate struct {
	UpdateType string `json:"update_type,omitempty"`
	// Unix-time when event has occured
	Timestamp int64 `json:"timestamp"`
	// Chat identifier where event has occured
	ChatId int64 `json:"chat_id"`
	// User removed from chat
	UserId int64 `json:"user_id"`
	// Administrator who removed user from chat
	AdminId int64 `json:"admin_id"`
}

You will receive this update when user has been removed from chat where bot is administrator

type UserWithPhoto

type UserWithPhoto struct {
	// Users identifier
	UserId int64 `json:"user_id"`
	// Users visible name
	Name string `json:"name"`
	// Unique public user name. Can be `null` if user is not accessible or it is not set
	Username string `json:"username"`
	// URL of avatar
	AvatarUrl *string `json:"avatar_url,omitempty"`
	// URL of avatar of a bigger size
	FullAvatarUrl *string `json:"full_avatar_url,omitempty"`
}

type VideoAttachment

type VideoAttachment struct {
	Type    string            `json:"type,omitempty"`
	Payload AttachmentPayload `json:"payload"`
}

type VideoAttachmentRequest

type VideoAttachmentRequest struct {
	Type    string       `json:"type,omitempty"`
	Payload UploadedInfo `json:"payload"`
}

Request to attach video to message

Directories

Path Synopsis
* * Webhook example
* * Webhook example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL