From d789456a8ee117671b042f623cf2dc3e8823b9b9 Mon Sep 17 00:00:00 2001 From: Syfaro Date: Thu, 25 Jun 2015 23:44:14 -0500 Subject: [PATCH] load self when created --- bot.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bot.go b/bot.go index b037aed..3ec2197 100644 --- a/bot.go +++ b/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 }