telegram

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoToken = errors.New("token is empty")

Functions

This section is empty.

Types

type Chat

type Chat struct {
	ID        int    `json:"id"`
	Title     string `json:"title"`
	Type      string `json:"type"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

type File

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

type Handler

type Handler interface {
	RobotToken(ctx context.Context) string
	MessageHandle(ctx context.Context, message Message, blobs map[string][]byte) error
}

type Message

type Message struct {
	MessageID    int         `json:"message_id"`
	From         User        `json:"from"`
	Date         int         `json:"date"`
	Text         *string     `json:"text"`
	Chat         *Chat       `json:"chat"`
	MediaGroupID *string     `json:"media_group_id"`
	Photo        []PhotoSize `json:"photo"`
	Caption      *string     `json:"caption"`
}

func (Message) GetMaxPhotoFileID

func (m Message) GetMaxPhotoFileID() string

type PhotoSize

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

type Robot

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

func NewRobotWithHandler

func NewRobotWithHandler(h Handler) *Robot

NewRobotWithHandler create a telegram robot with specified handler.

func (*Robot) EditMessage

func (r *Robot) EditMessage(ctx context.Context, chatID, messageID int, text string) (*Message, error)

EditMessage make an editMessageText api request.

func (*Robot) GetFile

func (r *Robot) GetFile(ctx context.Context, fileID string) (*File, error)

GetFile get download info of File by fileID from Telegram.

func (*Robot) GetUpdates

func (r *Robot) GetUpdates(ctx context.Context, offset int) ([]Update, error)

GetUpdates make a getUpdates api request.

func (*Robot) SendReplyMessage

func (r *Robot) SendReplyMessage(ctx context.Context, chatID, replyID int, text string) (*Message, error)

SendReplyMessage make a sendMessage api request.

func (*Robot) Start

func (r *Robot) Start(ctx context.Context)

Start start an infinity call of getUpdates from Telegram, call r.MessageHandle while get new message updates.

type Update

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

type User

type User struct {
	ID int `json:"id"`
}

Jump to

Keyboard shortcuts

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