botapi

package
v0.0.0-...-45605f7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileIDFromMessage

func GetFileIDFromMessage(msg Message) (string, bool)

GetFileIDFromMessage finds file_id in message attachments.

Types

type Animation

type Animation struct {
	FileID       string    `json:"file_id"`
	FileUniqueID string    `json:"file_unique_id"`
	Width        int       `json:"width"`
	Height       int       `json:"height"`
	Duration     int       `json:"duration"`
	Thumb        PhotoSize `json:"thumb"`
	FileName     string    `json:"file_name"`
	MimeType     string    `json:"mime_type"`
	FileSize     int       `json:"file_size"`
}

type Audio

type Audio struct {
	FileID       string    `json:"file_id"`
	FileUniqueID string    `json:"file_unique_id"`
	Duration     int       `json:"duration"`
	Performer    string    `json:"performer"`
	Title        string    `json:"title"`
	Thumb        PhotoSize `json:"thumb"`
	FileName     string    `json:"file_name"`
	MimeType     string    `json:"mime_type"`
	FileSize     int       `json:"file_size"`
}

type Chat

type Chat struct {
	ID            int      `json:"id"`
	Type          string   `json:"type"`
	Title         string   `json:"title"`
	Username      string   `json:"username"`
	FirstName     string   `json:"first_name"`
	LastName      string   `json:"last_name"`
	Bio           string   `json:"bio"`
	Description   string   `json:"description"`
	InviteLink    string   `json:"invite_link"`
	PinnedMessage *Message `json:"pinned_message"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is simplified Telegram BotAPI client.

func NewClient

func NewClient(token string, opts Options) *Client

NewClient creates new Client.

func (*Client) GetBotAPIMessage

func (m *Client) GetBotAPIMessage(ctx context.Context, msgID int) (Message, error)

GetBotAPIMessage sends getUpdates request to BotAPI and finds message by msg_id.

NB: it can find only recently received messages.

func (*Client) GetFile

func (m *Client) GetFile(ctx context.Context, id string) (rErr error)

GetFile sends getFile request to BotAPI.

type Document

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

type MaskPosition

type MaskPosition struct {
	Point  string  `json:"point"`
	XShift float64 `json:"x_shift"`
	YShift float64 `json:"y_shift"`
	Scale  float64 `json:"scale"`
}

type Message

type Message struct {
	MessageID int         `json:"message_id"`
	Chat      Chat        `json:"chat"`
	Animation Animation   `json:"animation"`
	Audio     Audio       `json:"audio"`
	Document  Document    `json:"document"`
	Photo     []PhotoSize `json:"photo"`
	Sticker   Sticker     `json:"sticker"`
	Video     Video       `json:"video"`
	VideoNote VideoNote   `json:"video_note"`
	Voice     Voice       `json:"voice"`
}

type Options

type Options struct {
	HTTPClient *http.Client
}

Options is Client options.

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"`
}

type Sticker

type Sticker struct {
	FileID       string       `json:"file_id"`
	FileUniqueID string       `json:"file_unique_id"`
	Width        int          `json:"width"`
	Height       int          `json:"height"`
	IsAnimated   bool         `json:"is_animated"`
	Thumb        PhotoSize    `json:"thumb"`
	Emoji        string       `json:"emoji"`
	SetName      string       `json:"set_name"`
	MaskPosition MaskPosition `json:"mask_position"`
	FileSize     int          `json:"file_size"`
}

type Update

type Update struct {
	UpdateID int     `json:"update_id"`
	Message  Message `json:"message"`
}

type Video

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

type VideoNote

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

type Voice

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

Jump to

Keyboard shortcuts

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