goTelegram

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 13 Imported by: 0

README

Go Report Card

TGBot

Very Small Telegram Library Written In Golang

yoruba-codigy/tgbot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Me     user `json:"result"`
	APIURL string
	// contains filtered or unexported fields
}

Bot : Main Bot Struct

func NewBot

func NewBot(s string) (Bot, error)

NewBot : Create A New Bot

func (*Bot) AddButtons

func (b *Bot) AddButtons(chatID int, buttonData ...string) error

AddButtons : Add Buttons For InlineKeyboard

func (*Bot) AnswerCallback

func (b *Bot) AnswerCallback(callbackID, text string, showAlert bool) error

AnswerCallback : Answer Call Back Query From InlineKeyboard

func (*Bot) CreateKeyboard

func (b *Bot) CreateKeyboard(chatId int, maxColumns ...int)

func (*Bot) DeleteKeyboard

func (b *Bot) DeleteKeyboard(chatID int)

DeleteKeyboard : Delete Current Keyboard

func (*Bot) DeleteMessage

func (b *Bot) DeleteMessage(message Message) error

DeleteMessage : Delete The Specified Message

func (*Bot) DownloadFile added in v1.0.1

func (b *Bot) DownloadFile(fileId, filename string) error

func (*Bot) DownloadFileToMemory added in v1.0.1

func (b *Bot) DownloadFileToMemory(fileId string) ([]byte, error)

func (*Bot) EditMessage

func (b *Bot) EditMessage(m Message, text string) (Message, error)

EditMessage : Edit An Existing Message

func (*Bot) ReplyMessage

func (b *Bot) ReplyMessage(s string, m Message) error

func (*Bot) SendMediaGroup added in v1.0.1

func (b *Bot) SendMediaGroup(files []InputMedia, c Chat, options MediaOptions) error

SendMediaGroup : Send A Group Of Media Files It Only Works With Local Files For Now

func (*Bot) SendMessage

func (b *Bot) SendMessage(s string, c Chat) (Message, error)

SendMessage : Send A Message To A User

func (*Bot) SendPhoto

func (b *Bot) SendPhoto(file string, caption string, c Chat, options MediaOptions) error

func (*Bot) SendPhotoFromMemory added in v1.0.1

func (b *Bot) SendPhotoFromMemory(data []byte, caption string, c Chat, options MediaOptions) error

func (*Bot) SendVideo

func (b *Bot) SendVideo(file string, caption string, c Chat, options MediaOptions) error

func (*Bot) SendVideoFromMemory added in v1.0.1

func (b *Bot) SendVideoFromMemory(data []byte, caption string, c Chat, options MediaOptions) error

func (*Bot) SetHandler

func (b *Bot) SetHandler(fn func(Update)) bool

SetHandler : Set Function To Be Run When New Updates Are Received

func (*Bot) UpdateHandler

func (b *Bot) UpdateHandler(_ http.ResponseWriter, r *http.Request)

UpdateHandler : Handles New Updates From Telegram

type Chat

type Chat struct {
	ID   int    `json:"id"`
	Type string `json:"type"`
}

type InlineKeyboard

type InlineKeyboard struct {
	Text string `json:"text"`
	Data string `json:"callback_data"`
}

InlineKeyboard : Structure To Hold The Keyboard To Be Sent

type InputMedia added in v1.0.1

type InputMedia struct {
	Type              string `json:"type"`
	Media             string `json:"media"`
	Caption           string `json:"caption,omitempty"`
	HasSpoiler        bool   `json:"has_spoiler,omitempty"`
	Width             int    `json:"width,omitempty"`
	Height            int    `json:"height,omitempty"`
	Duration          int    `json:"duration,omitempty"`
	SupportsStreaming bool   `json:"supports_streaming,omitempty"`
}

type MediaOptions added in v1.0.1

type MediaOptions struct {
	UseSpoiler       bool
	SendNotification bool `json:"disable_notification,omitempty"`
	ProtectContent   bool `json:"disable_content_type_detection,omitempty"`
}

type Message

type Message struct {
	MessageID int         `json:"message_id"`
	Text      string      `json:"Text"`
	Chat      Chat        `json:"chat"`
	From      user        `json:"from"`
	File      document    `json:"document"`
	Photo     []photoSize `json:"photo"`
	Video     video       `json:"video"`
}

type Result

type Result struct {
	MessageId int  `json:"message_id"`
	From      user `json:"from"`
	Chat      Chat `json:"chat"`
}

type TResponse

type TResponse struct {
	Ok     bool   `json:"ok"`
	Result Result `json:"result"`
}

type Update

type Update struct {
	UpdateID      int           `json:"update_id"`
	EditedMessage Message       `json:"edited_message"`
	Message       Message       `json:"message"`
	CallbackQuery callbackQuery `json:"callback_query"`
	Command       string
	Type          string
}

Update : Stores Data From Request

Jump to

Keyboard shortcuts

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