repositorypackage
0.0.0-20250222141335-102dc0d80628
Repository: https://github.com/kittenbark/tg.git
Documentation: pkg.go.dev
# README
kittenbark/tg
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. (From Golang README.md)
This package should be as trivial and straightforward as Golang is to me.
- Consistent simple api.
- Trivial declarative updates flow, filtering and branches.
- Compile-time safety: zero
interface{}
exposed to user-space. - Zero dependencies.
Inspired by teloxide and its declarative nature.
Example: echo bot with commands and filtering
package main
import (
"context"
"github.com/kittenbark/tg"
)
func main() {
tg.NewFromEnv().
Filter(tg.OnPrivateMessage).
HandleCommand("/start", tg.CommonTextReply("hello this echo bot is made with @kittenbark_tg")).
HandleCommand("/help", tg.CommonTextReply("just send a message")).
Branch(tg.OnMessage, func(ctx context.Context, upd *tg.Update) error {
msg := upd.Message
_, err := tg.CopyMessage(ctx, msg.Chat.Id, msg.Chat.Id, msg.MessageId)
return err
}).
Start()
}
TODO
- handle album
- generic sugar with bot.send & bot.edit (?)
- support generic pollers & webhooks
- write more examples and docs