Releases: protoncr/tourmaline
Quick patch
v0.19.1 v0.19.1 update
So many good things!
This is a pretty massive update, and there's way too much to go into here. Basically though, if I were to break this update down into a couple achievements this is what we have:
Connection Pooling
I, and others, were having some issues earlier on using the client in a concurrent environment. This is because the client was using a single HTTP::Client
which was being shared between threads/fibers. When one fiber would finish it would close the connection, causing a very confusing stack trace that said nothing about what the root of the problem was.
After much testing and debugging I decided to add a connection pool, which is basically like a library of HTTP::Client
instances. The pool has a finite number of instances it can spawn, and starts with a limited number. When a request is made the client checks out a client, uses it, and then checks it back in to the pool. It's thread safe and works perfectly, at a very small cost to performance.
Proxies
Another requested feature was proxy support. Unfortunately Crystal's HTTP::Client
doesn't support proxies itself, but thanks to mamantoha/http_proxy I was able to implement proxy support pretty easily. The Client
initializer now accepts several parameters for configuring the proxy as well.
PagedInlineKeyboard
I added a convenience class for creating paginated inline keyboards called PagedInlineKeyboard
. You can see it in action in the pagination bot example.
Stage
Last, but certainly not least, I have finally managed to implement some form of state management in the form of a Stage
. It's not perfect, but you can now have "conversations" with your bot in which you collect information and do something with it.
You can see an example of a Stage
in action in the stage bot example, which I've tried to document very well.
Major performance boost!
This update mainly focuses on the removal of Halite in favor of the built in HTTP::Client. It resulted in a major speed boost.
Bot API 4.8 Update
Updated to bot API 4.8, including the support for the new darts animation
Improved keyboards and persistence
This update includes a lot of good stuff. First and foremost are the improvements to building inline and reply keyboards. The old method was based heavily off of TelegrafJS and it worked, but the new way is much more "Crystally". Here's an example of it in action:
keyboard = Tourmaline::ReplyKeyboardMarkup.build do
button "Info"
button "Visit Us"
end
also included in this update are changes to how persistence works. I wasn't a fan of how I was handling things before, but now I think things are much better. Prior to this update, Persistence
was a module which was included in each persistence type which would then be included in the final client. Nothing wrong with this approach, but it did make it so that information could not be easily passed to the Persistence
object.
Now Persistence
is a class and Client
will always have one. The default persistence is NilPersistence
which does nothing. This can be easily swapped out for one of the other persistence types by passing the desired persistence object to the Client
initializer.
I've also added DBPersistence
which allows you to persist Users and Chats using a database rather than just a Hash or a JSON file. It uses the db shard on the backend and can be used with any of the supported adapters.
Filters!
- Add CHANGELOG
- Add support for Filters.
- Add
users
methods toUpdate
andMessage
to return all users included in the same. - Replaced usage of the
strange
logger with the new CrystalLog
class. - Log all updates with
Debug
severity ifVERBOSE
environment variable is set totrue
. - (breaking change) Renamed
File
toTFile
to avoid conflicting with the builtinFile
class. - (breaking change) removed the
Handler
class and all subclasses. Update handling is now done exclusively with theEventHandler
class andFilter
s.
Bug fix for EventHandler
So I made a small mistake in an earlier revision which was causing On
events to be fired by every event type, which was obviously a problem. This release fixes that.
Update to Bot API 4.7
This update adds support for the few new goodies included in the new version of the bot api. This includes:
- Support for the new
Dice
object as well as thesend_dice
method and a newUpdateAction
. get_my_commands
andset_my_commands
methods for programmatically getting and setting your bots recognized commands.- The new
tgs_sticker
parameter forcreate_new_sticker_set
andadd_to_sticker_set
. - New
thumb
field for theStickerSet
object, as well as the methodset_sticker_set_thumb
.
Many changes
The biggest change here is that Tourmaline::Bot
has been renamed to Tourmaline::Client
. Client
now includes Tourmaline
by default as well.
More context
This release introduces a couple of major changes to the way events are handled. Previously, only Command
events had access to a Context
; other events, such as On
only had access to the Update
object.
Now Command
, On
, and the new Action
events all have their own contexts, specific to that event type. Check out the docs for more info.
We now have access to the Action
event, allowing much easier use of inline callback buttons. See the media_bot for an example.