telegram-bot-api/bot.go

27 lines
515 B
Go
Raw Normal View History

2015-06-26 08:19:29 +02:00
// Methods for interacting with the Telegram Bot API.
package tgbotapi
type BotApi struct {
Token string `json:"token"`
Debug bool `json:"debug"`
2015-06-26 06:44:14 +02:00
Self User `json:"-"`
Updates chan Update `json:"-"`
}
2015-06-26 08:19:29 +02:00
// Creates a new BotApi instance.
// Requires a token, provided by @BotFather on Telegram
2015-06-26 06:44:14 +02:00
func NewBotApi(token string) (*BotApi, error) {
bot := &BotApi{
Token: token,
}
2015-06-26 06:44:14 +02:00
self, err := bot.GetMe()
if err != nil {
2015-06-26 06:45:56 +02:00
return &BotApi{}, err
2015-06-26 06:44:14 +02:00
}
bot.Self = self
2015-06-26 06:45:56 +02:00
return bot, nil
}