Documentation ¶
Index ¶
- Constants
- type API
- func (tg *API) CheckAuth(data map[string]interface{}) (ok bool)
- func (tg *API) DLFile(filePath string) (file []byte, err error)
- func (tg *API) GetFile(fileID string) (ans APIResponse)
- func (tg *API) GetMe() (ans APIResponse)
- func (tg *API) SendAudio(msg SendAudio) (ans APIResponse)
- func (tg *API) SendMessage(msg SendMessageData) (ans APIResponse)
- func (tg *API) SendMessageBig(msg SendMessageData) (ans []APIResponse)
- func (tg *API) SetWebhook(url string) (ans APIResponse)
- type APIResponse
- type APIResponseParameters
- type Audio
- type CallbackQuery
- type Chat
- type File
- type InlineQuery
- type Message
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type SendAudio
- type SendGetFile
- type SendMessageData
- type Update
- type User
Constants ¶
const ( // APIEndpoint is the endpoint for all API methods, with formatting for Sprintf APIEndpoint = "https://tg.3ng.ru/bot%s/%s" // FileEndpoint is the endpoint for downloading a file from Telegram FileEndpoint = "https://tg.3ng.ru/file/bot%s/%s" // Максимальный размер текста для сообщения TextMaxSize = 4000 // Максимальный размер описания CaptionMaxSize = 200 )
Telegram constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { AccessToken string RetryDontWait bool sync.Mutex // contains filtered or unexported fields }
API - Базовый объект
func (*API) GetFile ¶ added in v0.1.2
func (tg *API) GetFile(fileID string) (ans APIResponse)
GetFile -
func (*API) SendAudio ¶
func (tg *API) SendAudio(msg SendAudio) (ans APIResponse)
SendMessage - Отправка сообщения
func (*API) SendMessage ¶
func (tg *API) SendMessage(msg SendMessageData) (ans APIResponse)
SendMessage - Отправка сообщения
func (*API) SendMessageBig ¶
func (tg *API) SendMessageBig(msg SendMessageData) (ans []APIResponse)
SendMessageBig - Отправка сообщения с проверкой на длину
func (*API) SetWebhook ¶
func (tg *API) SetWebhook(url string) (ans APIResponse)
SetWebhook - Установка Webhook
type APIResponse ¶
type APIResponse struct { Ok bool `json:"ok"` Result json.RawMessage `json:"result"` ErrorCode int `json:"error_code"` Description string `json:"description"` Parameters APIResponseParameters `json:"parameters"` }
APIResponse is a response from the Telegram API with the result stored raw.
type APIResponseParameters ¶
type APIResponseParameters struct { RetryAfter int `json:"retry_after"` MigrateToChatID int64 `json:"migrate_to_chat_id"` }
APIResponseParameters - параметры ответа
type Audio ¶ added in v0.1.1
type Audio struct { FileID string `json:"file_id"` Duration int `json:"duration"` Performer string `json:"performer"` Title string `json:"title"` MimeType string `json:"mime_type"` FileSize int64 `json:"file_size"` }
Audio audio type
type CallbackQuery ¶
type CallbackQuery struct { ID string `json:"id"` From User `json:"from"` Message Message `json:"message"` InlineMessageID string `json:"inline_message_id"` Data string `json:"data"` }
CallbackQuery запрос
type Chat ¶
type Chat struct { ID int64 `json:"id"` Type string `json:"type"` Title string `json:"title"` UserName string `json:"username"` FirstName string `json:"first_name"` LastName string `json:"last_name"` }
Chat is returned in Message, because it's not clear which it is.
type InlineQuery ¶
type InlineQuery struct { ID string `json:"id"` From User `json:"user"` Query string `json:"query"` Offset string `json:"offset"` }
InlineQuery - Inline запрос
type Message ¶
type Message struct { MessageID int64 `json:"message_id"` From User `json:"from"` Date int64 `json:"date"` Chat Chat `json:"chat"` Text string `json:"text"` Audio Audio `json:"audio"` }
Message is returned by almost every request, and contains data about almost anything.
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct { Keyboard [][]string `json:"keyboard"` ResizeKeyboard bool `json:"resize_keyboard"` OneTimeKeyboard bool `json:"one_time_keyboard"` Selective bool `json:"selective"` }
ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
type ReplyKeyboardRemove ¶
type ReplyKeyboardRemove struct { RemoveKeyboard bool `json:"remove_keyboard"` Selective bool `json:"selective"` }
ReplyKeyboardRemove - удаление клавиатуры
type SendAudio ¶
type SendAudio struct { ChatID int64 `json:"chat_id,omitempty"` Audio []byte `json:"audio,omitempty"` Duration int `json:"duration,omitempty"` Performer string `json:"performer,omitempty"` Title string `json:"title,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` FileName string `json:"filename,omitempty"` }
SendAudio - Аудио для отправки
type SendGetFile ¶ added in v0.1.2
type SendGetFile struct {
FileID string `json:"file_id"`
}
SendGetFile - инфа о файле
type SendMessageData ¶
type SendMessageData struct { ChatID interface{} `json:"chat_id"` Text string `json:"text"` ParseMode string `json:"parse_mode"` DisableWebPagePreview bool `json:"disable_web_page_preview"` ReplyToMessageID int64 `json:"reply_to_message_id"` ReplyMarkup interface{} `json:"reply_markup"` DisableNotification bool `json:"disable_notification"` }
SendMessageData - Сообщение
type Update ¶
type Update struct { UpdateID int64 `json:"update_id"` Message Message `json:"message"` InlineQuery InlineQuery `json:"inline_query"` CallbackQuery CallbackQuery `json:"callback_query"` }
Update - Обновление от телеграма