bemyak
1 supporter
Devlog №000

Devlog №000

Mar 23, 2021

I thought that this is a suitable place to post changelogs, so I'll start doing that. This post will summarize the latest changes, but later on I'll make a new post for each update.

Telegram API interaction got fixed

You might have noticed that the bot wasn't responding for a few days. The reason for that is overlapping of several events:

  • A rust telegram library that I use is maintained quite poorly, so some merge requests are hanging there for a while without any attention

  • The Telegram rolled out a major update that changed the way some events are handled

This resulted in a situation when while fetching the updates, the bot got a message of type the it wasn't aware of and so it crashed. It then got automatically started only to get the same message and crash again.

The fix for this was already submitted, but not merged. All of this pushed me to create my own fork, so now the bot both uses the correct API and runs on the latest tokio (async runtime for rust).

Commands in groups are handled correctly (again)

Few days ago (2021-03-19) I found out that the bot doesn't work well in groups because a command there usually comes with "@roll_bot" suffix. I was pretty sure that I already saw that and implemented trimming, but apparently either it was removed during a refactoring or I'm just daydreaming.

Anyway, this got fixed and now the bot can be used in group chats.

New roll parser

This is a really major change. When I was estimating work needed for different commands, I thought that /roll should be the easiest one! Right? Hell, no

The problem here is that dice notation is somewhat crappy and I don't want to force users to strictly follow it as other bots do. I also wanted to implement some nice "shortcuts" like "/roll +" to roll with advantage. And this was all done using this regexp:

(?P<num>\+|\-|\d+)?(?:(?:d|к|д)(?P<face>\d+))?\s*(?:(?P<bonus_sign>\+|\-|\*|/)\s*(?P<bonus_value>\d+))?(?:[\s]|$)

Pretty tough, right?

It ended up in some weird bugs, lack of support for adding dice values and so on. My friend joked that I'm over-engineering it and soon I'll implement the whole parser... Well, he was right. Now we have a whole damn parser for dice notation (okay, reasonable subset of it) and full support for mathematical expressions. Now you can have a really long and complex formulas there if you need.

Did you know?

To quickly roll d20 with some bonus (5, for example) you can just type "/r +5"

Enjoy this post?

Buy bemyak a coffee

More from bemyak