Update README.md.

This commit is contained in:
Syfaro 2017-12-29 01:26:54 -06:00
parent ef374648bf
commit 8b7b15afc2
3 changed files with 24 additions and 26 deletions

32
bot.go
View file

@ -243,23 +243,7 @@ func (bot *BotAPI) IsMessageToMe(message Message) bool {
return strings.Contains(message.Text, "@"+bot.Self.UserName)
}
// Send will send a Chattable item to Telegram.
//
// It requires the Chattable to send.
func (bot *BotAPI) Send(c Chattable) (Message, error) {
resp, err := bot.Request(c)
if err != nil {
return Message{}, err
}
var message Message
err = json.Unmarshal(resp.Result, &message)
return message, err
}
// Request makes a request to Telegram that returns an APIResponse, rather than
// a Message.
// Request sends a Chattable to Telegram, and returns the APIResponse.
func (bot *BotAPI) Request(c Chattable) (APIResponse, error) {
switch t := c.(type) {
case Fileable:
@ -288,6 +272,20 @@ func (bot *BotAPI) Request(c Chattable) (APIResponse, error) {
}
}
// Send will send a Chattable item to Telegram and provides the
// returned Message.
func (bot *BotAPI) Send(c Chattable) (Message, error) {
resp, err := bot.Request(c)
if err != nil {
return Message{}, err
}
var message Message
err = json.Unmarshal(resp.Result, &message)
return message, err
}
// debugLog checks if the bot is currently running in debug mode, and if
// so will display information about the request and response in the
// debug log.