tgapi

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
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) CheckAuth

func (tg *API) CheckAuth(data map[string]interface{}) (ok bool)

CheckAuth - Проверка авторизации

func (*API) DLFile added in v0.1.3

func (tg *API) DLFile(filePath string) (file []byte, err error)

DLFile -

func (*API) GetFile added in v0.1.2

func (tg *API) GetFile(fileID string) (ans APIResponse)

GetFile -

func (*API) GetMe

func (tg *API) GetMe() (ans APIResponse)

GetMe - Получаем инфу о боте

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 File added in v0.1.2

type File struct {
	FileID   string `json:"file_id"`
	FileSize int64  `json:"file_size"`
	FilePath string `json:"file_path"`
}

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 - Обновление от телеграма

type User

type User struct {
	ID        int64  `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	UserName  string `json:"username"`
}

User is a user, contained in Message and returned by GetSelf.

Jump to

Keyboard shortcuts

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