Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eternnoir/gotelebot
https://github.com/eternnoir/gotelebot
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eternnoir/gotelebot
- Owner: eternnoir
- License: gpl-2.0
- Created: 2015-08-25T09:21:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-04-12T07:47:58.000Z (over 3 years ago)
- Last Synced: 2024-07-31T12:07:25.356Z (5 months ago)
- Language: Go
- Homepage: http://godoc.org/github.com/eternnoir/gotelebot
- Size: 634 KB
- Stars: 23
- Watchers: 5
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-telegram-bots - gotelebot
- awesome-telegram - gotelebot
README
# gotelebot
[![GoDoc](https://godoc.org/github.com/eternnoir/gotelebot?status.svg)](https://godoc.org/github.com/eternnoir/gotelebot)
Golang (Go) implementation for the Telegram Bot API.
This project provide a wrapper around the Telegram Bot API with golang. You can easy to ues telegram bot api
in golang way by use this project. And gotelebot provided polling method let developer easy to get new messages.Almost all method in Telegram bot api have been implement.
While official telegram bot api update, this project will update as soon as possible.## Installation
```
go get github.com/eternnoir/gotelebot
```## Document
Full godoc document [http://godoc.org/github.com/eternnoir/gotelebot](http://godoc.org/github.com/eternnoir/gotelebot)
### Echo Bot Example
```go
package mainimport (
"fmt"
"github.com/eternnoir/gotelebot"
)func main() {
// Echo Bot example.// Create gotelebot instance
bot := gotelebot.InitTeleBot("TOKEN")
// Start get new message whit goroutine and 60s timeout.
go bot.StartPolling(true, 60)
go processNewMessage(bot)
processNewInlineQuery(bot)
}func processNewMessage(bot *gotelebot.TeleBot) {
newMsgChan := bot.Messages
for {
m := <-newMsgChan // Get new messaage, when new message arrive.
fmt.Printf("Get Message:%#v \n", m)
if m.Text != "" { // Check message is text message.
bot.SendMessage(int(m.Chat.Id), m.Text, nil)
}
}
}func processNewInlineQuery(bot *gotelebot.TeleBot) {
newQuery := bot.InlineQuerys
for {
q := <-newQuery
fmt.Printf("Get NewInlineQuery:%#v \n", q)
if q.Query != "" { // Only return result when query string not empty.
result1 := types.NewInlineQueryResultArticl()
result1.Id = "1"
result1.Title = "Example"
result1.MessageText = "Hi" + q.Query
_, err := bot.AnswerInlineQuery(q.Id, []interface{}{result1}, nil)
if err != nil {
fmt.Println(err)
}
}
}
}```
## Telegram Bot API Support
## Methods
| Telegram Bot API Method | gotelebot Method | Status |
|-------------------------|----------------------|-------------|
| getMe | GetMe | Supported |
| sendMessage | SendMessage | Supported |
| forwardMessage | ForwardMessage | Supported |
| sendPhoto | SendPhoto | Supported |
| sendAudio | SendAudio | Supported |
| sendDocument | SendDocument | Supported |
| sendSticker | SendSticker | Supported |
| sendVideo | SendVideo | Supported |
| sendVoice | SendVoice | Supported |
| sendLocation | SendLocation | Supported |
| sendChatAction | SendChatAction | Supported |
| getUserProfilePhotos | GetUserProfilePhotos | Supported |
| getUpdates | GetUpdates | Supported |
| getFile | GetFile | Supported |
| inline mode | inline mode | Supported |# Change Log
## 2015-10-12
* New type ```Chat``` support. More information : https://core.telegram.org/bots/api#recent-changes