GoTTBot is an asynchronous wrapper for the TamTam Bot API written in Golang. It provides all the methods and types that are available on the official TamTam Bot API and aims to keep everything type-safe and rid of generics.
You can use this package to create bots easily in golang, for any futher help you can check out the documentations or reach us through the following:
- Easy to use: Heavily inspired by the python-telegram-bot and gotgbot, GoTTBot is designed in such a way that even a beginner can make a bot with it easily.
- Asynchronous: GoTTBot processes each update in a separate goroutine to keep it asynchronous.
- Easy Migration: Bots source codes can be easily migrated from Telegram Bot API to TamTam Bot API using the GoTTBot as it has intercept with the GoTGBot library.
- Filters: GoTTBot provides filters to make it easy for you to sort different type of updates in a managed way.
You can download the library with the help of standard go get
command.
go get github.com/anonyindian/gottbot
You can find various examples in the examples directory, a simple echo example is as follows:
package main
import (
"fmt"
"log"
"os"
"github.com/anonyindian/gottbot"
"github.com/anonyindian/gottbot/ext"
"github.com/anonyindian/gottbot/filters"
"github.com/anonyindian/gottbot/handlers"
)
func main() {
bot, err := gottbot.NewBot(os.Getenv("TAMTAM_BOT_TOKEN"), nil)
if err != nil {
panic(err)
}
updater := ext.NewUpdater(nil)
updater.StartPolling(bot, nil)
dispatcher := updater.Dispatcher
dispatcher.AddHandler(handlers.MessageHandler(filters.Message.All, echo))
fmt.Println("Started example bot with long polling...")
updater.Idle()
}
func echo(bot *gottbot.Bot, ctx *ext.Context) error {
msg := ctx.EffectiveMessage
_, err := msg.Reply(bot, msg.Body.Text, nil)
if err != nil {
log.Println("failed to send message:", err.Error())
}
return ext.EndGroups
}
This section includes some bots written with the GoTTBot library:
- evalbot: A bot to eval codes of various programming languages.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update examples as appropriate.
Licensed Under GNU General Public License v3