https://github.com/go-telegram-bot-api/telegram-bot-api

Golang bindings for the Telegram Bot API

https://github.com/go-telegram-bot-api/telegram-bot-api

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.4%) to scientific vocabulary

Keywords

golang hacktoberfest telegram
Last synced: 5 months ago · JSON representation

Repository

Golang bindings for the Telegram Bot API

Basic Info
Statistics
  • Stars: 6,247
  • Watchers: 89
  • Forks: 967
  • Open Issues: 172
  • Releases: 19
Topics
golang hacktoberfest telegram
Created over 10 years ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md

Golang bindings for the Telegram Bot API

Go Reference Test

All methods are fairly self-explanatory, and reading the godoc page should explain everything. If something isn't clear, open an issue or submit a pull request.

There are more tutorials and high-level information on the website, go-telegram-bot-api.dev.

The scope of this project is just to provide a wrapper around the API without any additional features. There are other projects for creating something with plugins and command handlers without having to design all that yourself.

Join the development group if you want to ask questions or discuss development.

Example

First, ensure the library is installed and up to date by running go get -u github.com/go-telegram-bot-api/telegram-bot-api/v5.

This is a very simple bot that just displays any gotten updates, then replies it to that chat.

```go package main

import ( "log"

tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"

)

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

bot.Debug = true

log.Printf("Authorized on account %s", bot.Self.UserName)

u := tgbotapi.NewUpdate(0)
u.Timeout = 60

updates := bot.GetUpdatesChan(u)

for update := range updates {
    if update.Message != nil { // If we got a message
        log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)

        msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
        msg.ReplyToMessageID = update.Message.MessageID

        bot.Send(msg)
    }
}

} ```

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/v5"

)

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)

wh, _ := tgbotapi.NewWebhookWithCert("https://www.example.com:8443/"+bot.Token, "cert.pem")

_, err = bot.Request(wh)
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 certificate, 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 is available, you may wish to generate your free TLS certificate there.

Owner

  • Name: go-telegram-bot-api
  • Login: go-telegram-bot-api
  • Kind: organization

Golang library for the Telegram Bot API

GitHub Events

Total
  • Issues event: 16
  • Watch event: 544
  • Issue comment event: 50
  • Pull request review comment event: 1
  • Pull request review event: 4
  • Pull request event: 19
  • Fork event: 101
Last Year
  • Issues event: 16
  • Watch event: 544
  • Issue comment event: 50
  • Pull request review comment event: 1
  • Pull request review event: 4
  • Pull request event: 19
  • Fork event: 101

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 451
  • Total Committers: 99
  • Avg Commits per committer: 4.556
  • Development Distribution Score (DDS): 0.758
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Syfaro s****o@f****n 109
Syfaro s****o@h****m 88
Gleb Sinyavsky z****b@g****m 38
Ilya Kaznacheev i****a@k****e 31
Jqs7 7@j****m 9
zhuharev k****l@z****u 8
Jiayu Yi y****u@g****m 7
MrYadro y****v@g****m 7
Amir Khazaie 7****r@g****m 5
Oleksandr Savchuk m****h@g****m 5
Raul Santos r****s@g****m 5
TJ Horner me@t****m 5
pr0head p****d@g****m 4
bcmk 4****k 4
Oleksandr Redko o****b@g****m 4
Daniel Leining d****l@l****g 4
Denis Orlikhin q****k@y****u 4
Erik Pellizzon e****1@g****m 3
Henner k****n@w****t 3
Lord-Protector s****y@k****e 3
sirlandalf l****7@g****m 3
NemoD503 1****s@g****m 3
Maxim Martyanov me@l****g 3
temamagic a****5@g****m 2
rozha i****v@g****m 2
ros-tel v****w@y****u 2
quenbyako r****j@p****m 2
nightghost m****n@g****m 2
lupoDharkael i****e@h****s 2
gropher g****n@g****m 2
and 69 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 139
  • Total pull requests: 98
  • Average time to close issues: 19 days
  • Average time to close pull requests: 2 months
  • Total issue authors: 127
  • Total pull request authors: 60
  • Average comments per issue: 1.65
  • Average comments per pull request: 0.47
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 14
  • Pull requests: 23
  • Average time to close issues: 2 days
  • Average time to close pull requests: 3 days
  • Issue authors: 11
  • Pull request authors: 14
  • Average comments per issue: 0.86
  • Average comments per pull request: 0.3
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • AdamRussak (3)
  • gay1958 (3)
  • pyed (2)
  • LazarenkoA (2)
  • mazanur (2)
  • Akhilesh53 (2)
  • appleGun22 (2)
  • TGsystem (2)
  • duyledat197 (2)
  • cryptodogge (2)
  • PaulAnnekov (1)
  • yms2772 (1)
  • greenhell1337 (1)
  • fffilimonov (1)
  • hyahm (1)
Pull Request Authors
  • lambrightn17 (18)
  • Pharmaceutical0 (8)
  • OvyFlash (8)
  • iamwavecut (6)
  • JavadZahedi (4)
  • huantt (4)
  • toby127 (4)
  • rusanov8 (4)
  • alexandear (3)
  • aminsato (3)
  • crayonwow (2)
  • maxwelbm (2)
  • sphantix (2)
  • fgazat (2)
  • kotyurgini (2)
Top Labels
Issue Labels
help wanted (2) documentation (1) question (1)
Pull Request Labels

Dependencies

.github/workflows/test.yml actions
  • actions/checkout v2 composite
  • actions/setup-go v2 composite
  • codecov/codecov-action v1 composite
go.mod go
go.sum go