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 (#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!
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()
}
If you want to develop Telegram bot, you should also see these libraries, which might be useful for you