bot

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const HelpText = `` /* 693-byte string literal not displayed */

HelpText to be returned on /help call.

Variables

View Source
var BuildDate = "today"

BuildDate to be returned in response with version

View Source
var Version = "latest"

Version to be returned in response when asked for

Functions

func NoResponse

func NoResponse(writer http.ResponseWriter)

NoResponse function is the HandleFunc for sending no response.

func Run

func Run()

Run method for starting the server.

func SendTgPhotoFormData

func SendTgPhotoFormData(chatID int64, fileID string, scale, blurFactor float64, returnSameSize bool)

SendTgPhotoFormData method to send Photo in multipart/form-data type.

func UpdateHandler

func UpdateHandler(writer http.ResponseWriter, request *http.Request)

UpdateHandler function is the HandleFunc for all requests

Types

type Animation

type Animation struct {
	FileID   string      `json:"file_id"`
	Thumb    []PhotoSize `json:"thumb"`
	FileName string      `json:"file_name"`
	MimeType string      `json:"mime_type"`
	FileSize int         `json:"file_size"`
}

Animation struct for decoding Animation Object from Telegram API

type Audio

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  int    `json:"file_size"`
}

Audio struct for decoding Audio Object from Telegram API

type BaseMethod

type BaseMethod interface {
	// contains filtered or unexported methods
}

BaseMethod method type is base for all other methods

func ProcessMessage

func ProcessMessage(update Update) (BaseMethod, error)

ProcessMessage method

type ByResolution

type ByResolution []PhotoSize

ByResolution for sorting photos by its Resolution

func (ByResolution) Len

func (a ByResolution) Len() int

func (ByResolution) Less

func (a ByResolution) Less(i, j int) bool

func (ByResolution) Swap

func (a ByResolution) Swap(i, j int)

type CallbackQuery

type CallbackQuery struct {
	CallbackQueryID int64
}

CallbackQuery struct for decoding CallbackQuery Object from Telegram API

type Chat

type Chat struct {
	ID                          int64      `json:"id"`
	Type                        string     `json:"type"` // Type of chat, can be either “private”, “group”, “supergroup” or “channel”
	Title                       string     `json:"title"`
	Username                    string     `json:"username"`
	FirstName                   string     `json:"first_name"`
	LastName                    string     `json:"last_name"`
	AllMembersAreAdministrators bool       `json:"all_members_are_administrators"`
	Photo                       *ChatPhoto `json:"photo"`
	Description                 string     `json:"description"`
	InviteLink                  string     `json:"invite_link"`
	PinnedMessage               *Message   `json:"pinned_message"`
}

Chat struct for decoding Chat Object from Telegram API

type ChatPhoto

type ChatPhoto struct {
	SmallFileID string `json:"small_file_id"`
	BigFileID   string `json:"big_file_id"`
}

ChatPhoto struct for decoding ChatPhoto Object from Telegram API

type ChosenInlineResult

type ChosenInlineResult struct {
	ChosenInlineResultID int64
}

ChosenInlineResult struct for decoding ChosenInlineResult Object from Telegram API

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 struct for decoding Contact Object from Telegram API

type Document

type Document struct {
	FileID   string      `json:"file_id"`
	Thumb    []PhotoSize `json:"thumb"`
	FileName string      `json:"file_name"`
	MimeType string      `json:"mime_type"`
	FileSize int         `json:"file_size"`
}

Document struct for decoding Document Object from Telegram API

type File

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

File struct for decoding File Object from Telegram API

type FileResult

type FileResult struct {
	Ok     bool  `json:"ok"`
	Result *File `json:"result"`
}

FileResult struct for decoding FileResult Object from Telegram API

type Game

type Game struct {
	Title        string          `json:"title"`
	Description  string          `json:"description"`
	Photo        []PhotoSize     `json:"photo"`
	Text         string          `json:"text"`
	TextEntities []MessageEntity `json:"text_entities"`
	Animation    Animation       `json:"animation"`
}

Game struct for decoding Game Object from Telegram API

type InlineKeyboardButton

type InlineKeyboardButton struct {
	Text                         string `json:"text,omitempty"`
	URL                          string `json:"url,omitempty"`
	CallbackData                 string `json:"callback_data,omitempty"`
	SwitchInlineQuery            string `json:"switch_inline_query,omitempty"`
	SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"`
}

InlineKeyboardButton struct for decoding InlineKeyboardButton Object from Telegram API

type InlineKeyboardMarkup

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

InlineKeyboardMarkup struct for decoding InlineKeyboardMarkup Object from Telegram API

type InlineQuery

type InlineQuery struct {
	InlineQueryID int64
}

InlineQuery struct for decoding InlineQuery Object from Telegram API

type Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

Location struct for decoding Location Object from Telegram API

type Message

type Message struct {
	MessageID             int64            `json:"message_id"`
	FromUser              *User            `json:"from"`
	Date                  int64            `json:"date"`
	Chat                  *Chat            `json:"chat"`
	ForwardFrom           *User            `json:"forward_from"`
	ForwardFromChat       *Chat            `json:"forward_from_chat"`
	ForwardFromMessageID  int64            `json:"forward_from_message_id"`
	ForwardSignature      string           `json:"forward_signature"`
	ForwardDate           int64            `json:"forward_date"`
	ReplyToMessage        *Message         `json:"reply_to_message"`
	EditDate              int64            `json:"edit_date"`
	AuthorSignature       string           `json:"author_signature"`
	Text                  string           `json:"text"`
	Entities              *[]MessageEntity `json:"entities"`
	Audio                 *Audio           `json:"audio"`
	Document              *Document        `json:"document"`
	Game                  *Game            `json:"game"`
	Photo                 *[]PhotoSize     `json:"photo"`
	Sticker               *Sticker         `json:"sticker"`
	Video                 *Video           `json:"video"`
	Voice                 *Voice           `json:"voice"`
	VideoNote             *VideoNote       `json:"video_note"`
	NewChatMembers        *[]User          `json:"new_chat_members"`
	Caption               string           `json:"caption"`
	Contact               *Contact         `json:"contact"`
	Location              *Location        `json:"location"`
	Venue                 *Venue           `json:"venue"`
	NewChatMember         *User            `json:"new_chat_member"`
	LeftChatMember        *User            `json:"left_chat_member"`
	NewChatTitle          bool             `json:"new_chat_title"`
	NewChatPhoto          bool             `json:"new_chat_photo"`
	DeleteChatPhoto       bool             `json:"delete_chat_photo"`
	GroupChatCreated      bool             `json:"group_chat_created"`
	SupergroupChatCreated bool             `json:"supergroup_chat_created"`
	ChannelChatCreated    bool             `json:"channel_chat_created"`
	MigrateToChatID       int64            `json:"migrate_to_chat_id"`
	MigrateFromChatID     int64            `json:"migrate_from_chat_id"`
}

Message struct for decoding Message Object from Telegram API

type MessageEntity

type MessageEntity struct {
	Type   string `json:"type"` //Type of the entity. Can be mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), text_mention (for users without usernames)
	Offset int    `json:"offset"`
	Length int    `json:"length"`
	URL    string `json:"url"`
	User   User   `json:"user"`
}

MessageEntity struct for decoding MessageEntity Object from Telegram API

type PhotoSize

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

PhotoSize struct for decoding PhotoSize Object from Telegram API

type SendChatAction

type SendChatAction struct {
	BaseMethod `json:"-"`
	Method     string `json:"method"`
	ChatID     int64  `json:"chat_id"`
	Action     string `json:"action"`
}

SendChatAction method type to be extended from BaseMethod

type SendDocument

type SendDocument struct {
	BaseMethod          `json:"-"`
	Method              string                `json:"method"`
	ChatID              int64                 `json:"chat_id"`
	Document            string                `json:"photo,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	DisableNotification bool                  `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64                 `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

SendDocument method type to be extended from BaseMethod

type SendMessage

type SendMessage struct {
	BaseMethod            `json:"-"`
	Method                string                `json:"method"`
	ChatID                int64                 `json:"chat_id"`
	Text                  string                `json:"text"`
	ParseMode             string                `json:"parse_mode,omitempty"`
	DisableWebPagePreview bool                  `json:"disable_web_page_preview,omitempty"`
	DisableNotification   bool                  `json:"disable_notification,omitempty"`
	ReplyToMessageID      int64                 `json:"reply_to_message_id,omitempty"`
	ReplyMarkup           *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

SendMessage method type to be extended from BaseMethod

type SendPhoto

type SendPhoto struct {
	BaseMethod          `json:"-"`
	Method              string                `json:"method"`
	ChatID              int64                 `json:"chat_id"`
	Photo               string                `json:"photo,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	DisableNotification bool                  `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64                 `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

SendPhoto method type to be extended from BaseMethod

type Sticker

type Sticker struct {
	FileID  string      `json:"file_id"`
	Width   int         `json:"width"`
	Height  int         `json:"height"`
	Thumb   []PhotoSize `json:"thumb"`
	Emoji   string      `json:"emoji"`
	SetName string      `json:"set_name"`
	// MaskPosition MaskPosition `json:"mask_position"`
	FileSize int `json:"file_size"`
}

Sticker struct for decoding Sticker Object from Telegram API

type Update

type Update struct {
	UpdateID           int64               `json:"update_id"`
	Message            *Message            `json:"message,omitempty"`
	EditedMessage      *Message            `json:"edited_message,omitempty"`
	ChannelPost        *Message            `json:"channel_post,omitempty"`
	EditChannelPost    *Message            `json:"edit_channel_post,omitempty"`
	InlineQuery        *InlineQuery        `json:"inline_query,omitempty"`
	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
	CallbackQuery      *CallbackQuery      `json:"callback_query,omitempty"`
}

Update struct for decoding Update Object from Telegram API

type User

type User struct {
	ID           int64  `json:"id"`
	IsBot        bool   `json:"is_bot"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	Username     string `json:"username"`
	LanguageCode string `json:"language_code"`
}

User struct for decoding User Object from Telegram API

type UserProfilePhotos

type UserProfilePhotos struct {
	TotalCount int           `json:"total_count"`
	Photos     [][]PhotoSize `json:"photos"`
}

UserProfilePhotos struct for decoding UserProfilePhotos Object from Telegram API

type Venue

type Venue struct {
	Location     Location `json:"location"`
	Title        string   `json:"title"`
	Address      string   `json:"address"`
	FoursquareID string   `json:"foursquare_id"`
}

Venue struct for decoding Venue Object from Telegram API

type Video

type Video struct {
	FileID   string      `json:"file_id"`
	Width    int         `json:"width"`
	Height   int         `json:"height"`
	Duration int         `json:"duration"`
	Thumb    []PhotoSize `json:"thumb"`
	MimeType string      `json:"mime_type"`
	FileSize int         `json:"file_size"`
}

Video struct for decoding Video Object from Telegram API

type VideoNote

type VideoNote struct {
	FileID   string      `json:"file_id"`
	Length   int         `json:"length"`
	Duration int         `json:"duration"`
	Thumb    []PhotoSize `json:"thumb"`
	FileSize int         `json:"file_size"`
}

VideoNote struct for decoding VideoNote Object from Telegram API

type Voice

type Voice struct {
	FileID   string `json:"file_id"`
	Duration int    `json:"duration"`
	MimeType string `json:"mime_type"`
	FileSize int    `json:"file_size"`
}

Voice struct for decoding Voice Object from Telegram API

Jump to

Keyboard shortcuts

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