1
0

🎨 Move NewBot method to separate file

This commit is contained in:
Maxim Lebedev 2017-10-05 18:22:16 +05:00
parent acbcc9f64e
commit 583880f568
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
2 changed files with 13 additions and 14 deletions

13
new_bot.go Normal file
View File

@ -0,0 +1,13 @@
package telegram
type Bot struct {
AccessToken string
Self *User
}
func NewBot(accessToken string) (*Bot, error) {
var err error
bot := &Bot{AccessToken: accessToken}
bot.Self, err = bot.GetMe()
return bot, err
}

View File

@ -14,22 +14,8 @@ const (
StyleMarkdown = "markdown"
StyleHTML = "html"
errorInt64OrString = "use only int64 or string"
)
type Bot struct {
AccessToken string
Self *User
}
func NewBot(accessToken string) (*Bot, error) {
var err error
bot := &Bot{AccessToken: accessToken}
bot.Self, err = bot.GetMe()
return bot, err
}
func (bot *Bot) request(dst []byte, method string, args *http.Args) (*Response, error) {
method = fmt.Sprintf(APIEndpoint, bot.AccessToken, method)
_, body, err := http.Post(dst, method, args)