bot.go (view raw)
1// Methods for interacting with the Telegram Bot API.
2package tgbotapi
3
4type BotApi struct {
5 Token string `json:"token"`
6 Debug bool `json:"debug"`
7 Self User `json:"-"`
8 Updates chan Update `json:"-"`
9}
10
11// Creates a new BotApi instance.
12// Requires a token, provided by @BotFather on Telegram
13func NewBotApi(token string) (*BotApi, error) {
14 bot := &BotApi{
15 Token: token,
16 }
17
18 self, err := bot.GetMe()
19 if err != nil {
20 return &BotApi{}, err
21 }
22
23 bot.Self = self
24
25 return bot, nil
26}