https://github.com/nickname76/telegrambot
Telegram Bot API library in Go, but with more clean code
https://github.com/nickname76/telegrambot
api bot go go-telegram-api go-telegram-bot-api golang library telegram telegram-bot telegram-bot-api wrapper
Last synced: 10 months ago
JSON representation
Telegram Bot API library in Go, but with more clean code
- Host: GitHub
- URL: https://github.com/nickname76/telegrambot
- Owner: nickname76
- License: mit
- Created: 2022-06-28T03:34:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-13T23:13:42.000Z (almost 2 years ago)
- Last Synced: 2024-11-05T10:45:03.676Z (about 1 year ago)
- Topics: api, bot, go, go-telegram-api, go-telegram-bot-api, golang, library, telegram, telegram-bot, telegram-bot-api, wrapper
- Language: Go
- Homepage: https://discord.gg/golang
- Size: 104 KB
- Stars: 29
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ccamel - nickname76/telegrambot - Telegram Bot API library in Go, but with more clean code (Go)
README
# [
Telegrambot](https://github.com/nickname76/telegrambot#example-usage) [
](https://goreportcard.com/report/github.com/nickname76/telegrambot)
[
](https://discord.gg/rX4EhxsW6X)
The most clean and strongly typed Telegram Bot API library in Go
Completely covers Bot API version - **6.2**
Telegram Bot API documentaion: https://core.telegram.org/bots/api
Telegram deep links list: https://core.telegram.org/api/links
More Telegram deep links: https://t.me/DeepLink
**DISCORD**: [https://discord.gg/golang](https://discord.gg/rX4EhxsW6X) (#telegrambot channel)
**Documentation on this library:**
- API https://pkg.go.dev/github.com/nickname76/telegrambot
- Tools https://pkg.go.dev/github.com/nickname76/telegrambot/tools
_Please, **star** this repository, if you found this library useful!_
## Example usage
```Go
package main
import (
"fmt"
"log"
"os"
"os/signal"
"github.com/nickname76/telegrambot"
)
func main() {
api, me, err := telegrambot.NewAPI("YOUR_TELEGRAM_BOT_API_TOKEN")
if err != nil {
log.Fatalf("Error: %v", err)
}
stop := telegrambot.StartReceivingUpdates(api, func(update *telegrambot.Update, err error) {
if err != nil {
log.Printf("Error: %v", err)
return
}
msg := update.Message
if msg == nil {
return
}
_, err = api.SendMessage(&telegrambot.SendMessageParams{
ChatID: msg.Chat.ID,
Text: fmt.Sprintf("Hello %v, I am %v", msg.From.FirstName, me.FirstName),
ReplyMarkup: &telegrambot.ReplyKeyboardMarkup{
Keyboard: [][]*telegrambot.KeyboardButton{{
{
Text: "Hello",
},
}},
ResizeKeyboard: true,
OneTimeKeyboard: true,
},
})
if err != nil {
log.Printf("Error: %v", err)
return
}
})
log.Printf("Started on %v", me.Username)
exitCh := make(chan os.Signal, 1)
signal.Notify(exitCh, os.Interrupt)
<-exitCh
// Waits for all updates handling to complete
stop()
}
```
## See also
If you want to develop Telegram bot, you should also see these libraries, which might be useful for you
- [Repeater](https://github.com/nickname76/repeater) - Go library for creating repeating function calls
- [QiwiP2P](https://github.com/nickname76/qiwip2p) - Go library for Qiwi P2P API