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