tg

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tg implements some of the Telegram API methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Ok          bool        `json:"ok"`
	ErrorCode   int         `json:"error_code"`
	Description string      `json:"description"`
	Result      interface{} `json:"result"`
}

APIResponse is a response to a request to the Telegram API.

type Bot

type Bot struct {
	Token string
}

Bot is an instance of a Telegram bot.

func (*Bot) AnswerCallbackQuery

func (b *Bot) AnswerCallbackQuery(callbackID, text string) error

AnswerCallbackQuery implements Telegram's answerCallbackQuery method.

func (*Bot) DeleteMessage

func (b *Bot) DeleteMessage(chatID, messageID int64) error

DeleteMessage implements Telegram's deleteMessage method.

func (*Bot) DownloadFile

func (b *Bot) DownloadFile(fileID string) ([]byte, error)

DownloadFile downloads file from the Telegram server.

func (*Bot) EditMessageText

func (b *Bot) EditMessageText(chatID, messageID int64, text string, keyboard ...InlineKeyboardMarkup) error

EditMessageText implements Telegram's editMessageText method.

func (*Bot) GetFile

func (b *Bot) GetFile(fileID string) (File, error)

GetFile implements Telegram's getFile method.

func (*Bot) GetUpdates

func (b *Bot) GetUpdates(offset int64, limit, timeout int, allowedUpdates []string) ([]Update, error)

GetUpdates implements Telegram's getUpdates method.

func (*Bot) SendDocument

func (b *Bot) SendDocument(chatID int64, documentPath string) error

SendDocument implements Telegram's sendDocument method.

func (*Bot) SendMessage

func (b *Bot) SendMessage(chatID int64, message string, keyboard ...InlineKeyboardMarkup) (Message, error)

SendMessage implements Telegram's sendMessage method.

type CallbackQuery

type CallbackQuery struct {
	ID      string  `json:"id"`
	From    User    `json:"from"`
	Message Message `json:"message"`
	Data    string  `json:"data"`
}

CallbackQuery object represents an incoming callback query from a callback button in an inline keyboard.

type Chat

type Chat struct {
	ID int64 `json:"id"`
}

Chat object represents a chat.

type Document

type Document struct {
	FileID   string `json:"file_id"`
	UniqueID string `json:"file_unique_id"`
	FileName string `json:"file_name"`
	MimeType string `json:"mime_type"`
	FileSize int    `json:"file_size"`
}

Document object represents a general file (as opposed to photos, voice messages and audio files).

type File

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

File object represents a file ready to be downloaded.

type InlineKeyboardButton

type InlineKeyboardButton struct {
	Text         string `json:"text"`
	CallbackData string `json:"callback_data"`
}

InlineKeyboardButton object represents one button of an inline keyboard.

type InlineKeyboardMarkup

type InlineKeyboardMarkup struct {
	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}

InlineKeyboardMarkup object represents an inline keyboard that appears right next to the message it belongs to.

type Message

type Message struct {
	MessageID int64       `json:"message_id"`
	From      User        `json:"from"`
	Chat      Chat        `json:"chat"`
	Date      int64       `json:"date"`
	Text      string      `json:"text"`
	Photo     []PhotoSize `json:"photo"`
	Document  Document    `json:"document"`
}

Message object represents a message.

type PhotoSize

type PhotoSize struct {
	FileID       string `json:"file_id"`
	FileUniqueID string `json:"file_unique_id"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
	FileSize     int    `json:"file_size"`
}

PhotoSize object represents one size of a photo or a file / sticker thumbnail.

type Update

type Update struct {
	UpdateID      int64         `json:"update_id"`
	Message       Message       `json:"message"`
	CallbackQuery CallbackQuery `json:"callback_query"`
}

Update object represents an incoming 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 object represents a Telegram user or bot.

Jump to

Keyboard shortcuts

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