Documentation ¶
Index ¶
- Variables
- type TbResponseMessageStruct
- type TelegramBot
- func (tbot *TelegramBot) FastRequest(action string, params map[string]string) (error, *TbResponseMessageStruct)
- func (tbot *TelegramBot) GetChat(name string) error
- func (tbot *TelegramBot) GetChatMember(name string, user string) error
- func (tbot *TelegramBot) GetChatMemberCount(name string) error
- func (tbot *TelegramBot) GetResult() interface{}
- func (tbot *TelegramBot) GetUpdates() error
- func (tbot *TelegramBot) InviteUser(name string) error
- func (tbot *TelegramBot) SendMessage(message string, markdown bool, keys ...interface{}) (error, *TbResponseMessageStruct)
- func (tbot *TelegramBot) Write(message []byte) (int, error)
- type TelegramKeyboard
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBadTelegramBot = errors.New("Bad TelegramBot parameters") ErrTelegramBotMultiple500 = errors.New("Telegram does not response, multiple 500") )
Functions ¶
This section is empty.
Types ¶
type TbResponseMessageStruct ¶ added in v1.0.18
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
func (*TbResponseMessageStruct) String ¶ added in v1.0.26
func (tbResp *TbResponseMessageStruct) String() string
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) 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
type TelegramKeyboard ¶ added in v1.0.11
type TelegramKeyboard struct { Keyboard [][]string `json:"keyboard"` OneTimeKeyboard bool `json:"one_time_keyboard"` ResizeKeyboard bool `json:"resize_keyboard"` }
struct for telegram reply_markup keyboard
Click to show internal directories.
Click to hide internal directories.