Skip to content

Commit

Permalink
Merge pull request #202 from go-telegram-bot-api/develop
Browse files Browse the repository at this point in the history
Deduplicate code, improve response accuracy.
  • Loading branch information
Syfaro authored Nov 8, 2021
2 parents 54104a0 + 7c82078 commit 6b71d4d
Show file tree
Hide file tree
Showing 30 changed files with 5,566 additions and 2,776 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test

on:
push:
branches:
- master
- develop
pull_request:

jobs:
build:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build
run: go build -v .

- name: Test
run: go test -coverprofile=coverage.out -covermode=atomic -v .

- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
file: ./coverage.out
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
coverage.out
tmp/
book/
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

55 changes: 1 addition & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,60 +62,7 @@ func main() {
}
```

There are more examples on the [wiki](https://github.com/go-telegram-bot-api/telegram-bot-api/wiki)
There are more examples on the [site](https://go-telegram-bot-api.github.io/)
with detailed information on how to do many different kinds of things.
It's a great place to get started on using keyboards, commands, or other
kinds of reply markup.

If you need to use webhooks (if you wish to run on Google App Engine),
you may use a slightly different method.

```go
package main

import (
"log"
"net/http"

"github.com/go-telegram-bot-api/telegram-bot-api"
)

func main() {
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken")
if err != nil {
log.Fatal(err)
}

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"))
if err != nil {
log.Fatal(err)
}
info, err := bot.GetWebhookInfo()
if err != nil {
log.Fatal(err)
}
if info.LastErrorDate != 0 {
log.Printf("Telegram callback failed: %s", info.LastErrorMessage)
}
updates := bot.ListenForWebhook("/" + bot.Token)
go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)

for update := range updates {
log.Printf("%+v\n", update)
}
}
```

If you need, you may generate a self signed certficate, as this requires
HTTPS / TLS. The above example tells Telegram that this is your
certificate and that it should be trusted, even though it is not
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) is available,
you may wish to generate your free TLS certificate there.
9 changes: 9 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[book]
authors = ["Syfaro"]
language = "en"
multilingual = false
src = "docs"
title = "Go Telegram Bot API"

[output.html]
git-repository-url = "https://github.com/go-telegram-bot-api/telegram-bot-api"
Loading

0 comments on commit 6b71d4d

Please sign in to comment.