all repos — telegram-bot-api @ 8b7b15afc2157f54f6c0ae05351f3a8ddfcd42be

Golang bindings for the Telegram Bot API

Update README.md.
Syfaro syfaro@huefox.com
Fri, 29 Dec 2017 01:26:54 -0600
commit

8b7b15afc2157f54f6c0ae05351f3a8ddfcd42be

parent

ef374648bffe645f2b07f968f6d56636f7057a51

3 files changed, 24 insertions(+), 26 deletions(-)

jump to
M README.mdREADME.md

@@ -16,9 +16,6 @@ without any additional features. There are other projects for creating

something with plugins and command handlers without having to design all that yourself. -Use `github.com/go-telegram-bot-api/telegram-bot-api` for the latest -version, or use `gopkg.in/telegram-bot-api.v4` for the stable build. - Join [the development group](https://telegram.me/go_telegram_bot_api) if you want to ask questions or discuss development.

@@ -32,7 +29,8 @@ package main

import ( "log" - "gopkg.in/telegram-bot-api.v4" + + "github.com/go-telegram-bot-api/telegram-bot-api" ) func main() {

@@ -72,9 +70,10 @@ ```go

package main import ( - "gopkg.in/telegram-bot-api.v4" "log" "net/http" + + "github.com/go-telegram-bot-api/telegram-bot-api" ) func main() {

@@ -87,7 +86,7 @@ bot.Debug = true

log.Printf("Authorized on account %s", bot.Self.UserName) - _, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem")) + _, err = bot.Request(tgbotapi.NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem")) if err != nil { log.Fatal(err) }

@@ -108,5 +107,5 @@ properly signed.

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj "//O=Org\CN=Test" -nodes -Now that [Let's Encrypt](https://letsencrypt.org) has entered public beta, -you may wish to generate your free TLS certificate there. +Now that [Let's Encrypt](https://letsencrypt.org) is available, you may +wish to generate your free TLS certificate there.
M bot.gobot.go

@@ -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:

@@ -286,6 +270,20 @@ }

return bot.MakeRequest(c.method(), v) } +} + +// 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
M helpers_test.gohelpers_test.go

@@ -1,8 +1,9 @@

package tgbotapi_test import ( + "testing" + "github.com/go-telegram-bot-api/telegram-bot-api" - "testing" ) func TestNewInlineQueryResultArticle(t *testing.T) {