load self when created

bot-api-6.1
Syfaro 2015-06-25 23:44:14 -05:00
parent 9cf4f13772
commit d789456a8e
1 changed files with 12 additions and 2 deletions

14
bot.go
View File

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