load self when created

pull/1/head
Syfaro 10 years ago
parent 9cf4f13772
commit d789456a8e
  1. 14
      bot.go

@ -3,11 +3,21 @@ package tgbotapi
type BotApi struct {
Token string `json:"token"`
Debug bool `json:"debug"`
Self User `json:"-"`
Updates chan Update `json:"-"`
}
func NewBotApi(token string) *BotApi {
return &BotApi{
func NewBotApi(token string) (*BotApi, error) {
bot := &BotApi{
Token: token,
}
self, err := bot.GetMe()
if err != nil {
return BotApi{}, err
}
bot.Self = self
return bot
}