bot
A Go zero-dependencies telegram bot framework.
Simple
GitHub
#library #telegram
@golang_tips
A Go zero-dependencies telegram bot framework.
Simple
echo
example:package main
import (
"context"
"os"
"os/signal"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
)
// Send any text message to the bot after the bot has been started
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
opts := []bot.Option{
bot.WithDefaultHandler(handler),
}
b, err := bot.New("YOUR_BOT_TOKEN_FROM_BOTFATHER", opts...)
if err != nil {
panic(err)
}
b.Start(ctx)
}
func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: update.Message.Text,
})
}
GitHub
#library #telegram
@golang_tips
GitHub
GitHub - go-telegram/bot: Telegram Bot API Go framework
Telegram Bot API Go framework. Contribute to go-telegram/bot development by creating an account on GitHub.