🎨 Move NewBot method to separate file
This commit is contained in:
parent
acbcc9f64e
commit
583880f568
13
new_bot.go
Normal file
13
new_bot.go
Normal 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
|
||||||
|
}
|
14
telegram.go
14
telegram.go
|
@ -14,22 +14,8 @@ const (
|
||||||
|
|
||||||
StyleMarkdown = "markdown"
|
StyleMarkdown = "markdown"
|
||||||
StyleHTML = "html"
|
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) {
|
func (bot *Bot) request(dst []byte, method string, args *http.Args) (*Response, error) {
|
||||||
method = fmt.Sprintf(APIEndpoint, bot.AccessToken, method)
|
method = fmt.Sprintf(APIEndpoint, bot.AccessToken, method)
|
||||||
_, body, err := http.Post(dst, method, args)
|
_, body, err := http.Post(dst, method, args)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user