all repos — telegram-bot-api @ d789456a8ee117671b042f623cf2dc3e8823b9b9

Golang bindings for the Telegram Bot API

load self when created
Syfaro syfaro@foxpaw.in
Thu, 25 Jun 2015 23:44:14 -0500
commit

d789456a8ee117671b042f623cf2dc3e8823b9b9

parent

9cf4f13772aae8db75fe2b03f45e578a38eec965

1 files changed, 12 insertions(+), 2 deletions(-)

jump to
M bot.gobot.go

@@ -3,11 +3,21 @@

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 }