Tourmaline Versions Save

Simple Telegram bot library for Crystal

v0.19.1

3 years ago

v0.19.0

3 years ago

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.

0.18.1

4 years ago

This update mainly focuses on the removal of Halite in favor of the built in HTTP::Client. It resulted in a major speed boost.

v0.18.0

4 years ago

Updated to bot API 4.8, including the support for the new darts animation

v0.17.0

4 years ago

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.

v0.16.0

4 years ago
  • Add CHANGELOG
  • Add support for Filters.
  • Add users methods to Update and Message to return all users included in the same.
  • Replaced usage of the strange logger with the new Crystal Log class.
  • Log all updates with Debug severity if VERBOSE environment variable is set to true.
  • (breaking change) Renamed File to TFile to avoid conflicting with the builtin File class.
  • (breaking change) removed the Handler class and all subclasses. Update handling is now done exclusively with the EventHandler class and Filters.

v0.15.1

4 years ago

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.

v0.15.0

4 years ago

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 the send_dice method and a new UpdateAction.
  • get_my_commands and set_my_commands methods for programmatically getting and setting your bots recognized commands.
  • The new tgs_sticker parameter for create_new_sticker_set and add_to_sticker_set.
  • New thumb field for the StickerSet object, as well as the method set_sticker_set_thumb.

v0.14.0

4 years ago

The biggest change here is that Tourmaline::Bot has been renamed to Tourmaline::Client. Client now includes Tourmaline by default as well.

v0.13.0

4 years ago

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.