telegrambot

package
v1.0.23 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BadTelegramBot = errors.New("Bad TelegramBot parameters")

Functions

This section is empty.

Types

type TbResponseMessageStruct

type TbResponseMessageStruct struct {
	Ok          bool   `json:"ok"`
	ErrorCode   int    `json:"error_code"`
	Description string `json:"description"`
	Result      struct {
		MessageId int `json:"message_id"`
		Chat      struct {
			Id       int64  `json:"id"`
			Title    string `json:"title"`
			Username string `json:"username"`
			Type     string `json:"type"`
		} `json:"chat"`
		Date int64  `json:"date"`
		Text string `json:"text"`
	} `json:"result"`
}

json struct to parse response

type TelegramBot

type TelegramBot struct {
	Token          string `yaml:"BotToken"`
	ChatID         string `yaml:"ChatID"`
	RequestURL     string
	Request        *fasthttp.Request
	Response       *fasthttp.Response
	FastHTTPClient *fasthttp.Client
	// contains filtered or unexported fields
}

TelegramBot struct with token and one chatid

func NewTelegramBot

func NewTelegramBot(confPath string) (tb *TelegramBot, err error)

NewTelegramBot reads a config file for bot token and chatID and creates new TelegramBot struct

func NewTelegramBotFromEnv

func NewTelegramBotFromEnv() (tb *TelegramBot, err error)

NewTelegramBot is a constructor from ENV

func (*TelegramBot) FastRequest

func (tbot *TelegramBot) FastRequest(action string, params map[string]string) (error, *TbResponseMessageStruct)

FastRequest make fasthttp request

func (*TelegramBot) GetChat

func (tbot *TelegramBot) GetChat(name string) error

SendMessage is used for sending messages

func (*TelegramBot) GetChatMember

func (tbot *TelegramBot) GetChatMember(name string, user string) error

SendMessage is used for sending messages

func (*TelegramBot) GetChatMemberCount

func (tbot *TelegramBot) GetChatMemberCount(name string) error

SendMessage is used for sending messages

func (*TelegramBot) GetResult

func (tbot *TelegramBot) GetResult() interface{}

GetResult

func (*TelegramBot) GetUpdates

func (tbot *TelegramBot) GetUpdates() error

SendMessage is used for sending messages

func (*TelegramBot) InviteUser

func (tbot *TelegramBot) InviteUser(name string) error

SendMessage is used for sending messages

func (*TelegramBot) SendMessage

func (tbot *TelegramBot) SendMessage(message string, markdown bool, keys ...interface{}) (error, *TbResponseMessageStruct)

SendMessage is used for sending messages. Arguments keys must contain TelegramKeyboard{} to add keys to your message

func (*TelegramBot) Write

func (tbot *TelegramBot) Write(message []byte) (int, error)

TelegramBotHandler reads bot params from configPath and accepts some log struct to find if its needed to print some mess to telegram bot

type TelegramKeyboard

type TelegramKeyboard struct {
	Keyboard        [][]string `json:"keyboard"`
	OneTimeKeyboard bool       `json:"one_time_keyboard"`
	ResizeKeyboard  bool       `json:"resize_keyboard"`
}

struct for telegram reply_markup keyboard

Jump to

Keyboard shortcuts

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