Documentation
¶
Index ¶
- Constants
- Variables
- func ParseRequest(r *http.Request, opt *ParseOptions) (ans *types.Message, err error)
- func SendMessage(req *types.Message, botans *types.Message, opt *MessageOptions) (err error)
- func SetEndpoint(domain string)
- type API
- type APIResponse
- type APIResponseParameters
- type CallbackQuery
- type Chat
- type Contact
- type File
- type InlineQuery
- type Message
- type MessageOptions
- type ParseOptions
- type PhotoSize
- type ReplyKeyboardButton
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type SendGetFile
- type SendMessageData
- type Update
- type User
Constants ¶
const ( // Максимальный размер текста для сообщения TextMaxSize = 4000 // Максимальный размер описания CaptionMaxSize = 200 )
Telegram constants
Variables ¶
var ( // APIEndpoint is the endpoint for all API methods, with formatting for Sprintf APIEndpoint = "https://api.telegram.org/bot%s/%s" // FileEndpoint is the endpoint for downloading a file from Telegram FileEndpoint = "https://api.telegram.org/file/bot%s/%s" )
Functions ¶
func ParseRequest ¶
ParseRequest - Разбираем запрос, проверяем его корректность и приводим к стандартному виду
func SendMessage ¶
SendMessage - Отправляем сообщение
func SetEndpoint ¶
func SetEndpoint(domain string)
SetEndpoint - Устанавливаем какой endpoint использовать
Types ¶
type API ¶
type API struct {
AccessToken string
RetryDontWait bool
sync.Mutex
// contains filtered or unexported fields
}
API - Базовый объект
func (*API) GetFile ¶
func (tg *API) GetFile(sgf SendGetFile) (ans APIResponse)
GetFile - Отправка сообщения
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 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 Contact ¶
type Contact struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
UserID int64 `json:"user_id"`
}
Contact - объект контакта
type File ¶
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"`
Contact Contact `json:"contact"`
Photo []PhotoSize `json:"photo"`
}
Message is returned by almost every request, and contains data about almost anything.
func (*Message) GetBestPhoto ¶
type MessageOptions ¶
type MessageOptions struct {
Token string
}
MessageOptions - Опции отправки сообщения
type ParseOptions ¶
type ParseOptions struct {
Token string
}
ParseOptions - Опции парсинга сообщения
type PhotoSize ¶
type PhotoSize struct {
FileID string `json:"file_id"`
Width int64 `json:"width"`
Height int64 `json:"height"`
FileSize int64 `json:"file_size"`
}
PhotoSize - объект фото
type ReplyKeyboardButton ¶
type ReplyKeyboardButton struct {
Text string `json:"text"`
RequestContact bool `json:"request_contact"`
RequestLocation bool `json:"request_location"`
}
ReplyKeyboardButton - структура кнопки клавиатуры
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct {
Keyboard interface{} `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 SendGetFile ¶
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"`
HideReplyMarkup bool
}
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 - Обновление от телеграма