For this release, aside from Bot API implementation, we've prepared many new useful features.
Changelog
- Completed Webhook, Games, Stickers and Payments APIs
- Synchronous mode and serverless support (#219)
- Keyboard constructors (#290)
- Special
ChatID
recipient type (#263)
Serverless
Now it's possible to use telebot
together with serverless providers like AWS, Azure, etc... Thanks to one of the package's contributors, you can check out the exhaustive example in examples/awslambdaechobot.
pref := tb.Settings{
Token: "",
Synchronous: true,
}
b, err := tb.NewBot(pref)
// ...
Keyboard constructors
Use special helper functions and types to decrease boilerplate across the code. The new keyboards builder make their definition easier. Look into updated README Keyboards
section for details.
menu := &ReplyMarkup{ResizeReplyKeyboard: true}
var (
// Reply buttons.
btnHelp = menu.Text("ℹ Help")
btnSettings = menu.Text("⚙ Settings")
)
menu.Reply(
menu.Row(btnHelp),
menu.Row(btnSettings),
)
b.Handle(&btnHelp, func(m *tb.Message) {...})
b.Handle(&btnSettings, func(m *tb.Message) {...})
ChatID
type
It was a bit confusing to work with specific chat IDs. You had to wrap integer into &tb.Chat{}
every time you wanted to send a message. Imagine you have a config file with a bunch of defined group or channel IDs. Now you can use your int64
values directly with functions which accept Recipient
interface.
type Config struct {
AdminGroup tb.ChatID `yaml:"admin_group_id"`
AdsChannel tb.ChatID `yaml:"ads_channel_id"`
}
b.Send(conf.AdminGroup, "message")
b.Send(conf.AdsChannel, "message")
Fixes
- Added
OnAnimation
endpoint - Fixed regular expression for errors handling
Action
fields were removed from Buttonsb.Forward()
changed to takeEditable
instead of*Message