Transabot 2.0 — Starting over

So I have a Telegram personal bot that I use in one of my groups. This bot is not meant to be used by any other group since it was designed mainly for our “needs”. And I needed a reason to dive into Telegram BOTs API.

I recently migrated the group to a supergroup — it allows us to have more members, better message moderation and a few other features that we don’t really use. And since the migration changes the group id on the Telegram server and broke one of the main features of the bot: the quotes.

The bot has a command that allows any user to add a message as a quote and assign it to a command. Then, you just send that command on the chat and the bot will forward the message. Since the group id and the messages id changed, the quotes stopped working.

So I need to resend every message to the bot so it can record a new ID to that message and do the proper forwarding.

I decided that, since I have to do that, I’ll take my time to upgrade a few things on how the bot works to prevent issues like this in the future. I’ll also add unit tests and automate the deploy process — today it’s a simple scp to the server, but I want to use CI.

Currently, the bot is written in PHP, using Laravel 5.0 as the main framework. I’ll upgrade the Laravel to the latest version, add a Redis server to optimize searching for quotes and redesign a few database models.

I’ll document my progress here on Medium and I’ll have a public Gitlab repository set-up so you can check the code, if you want.

The progress

  1. Upgrading Laravel
  2. New Quote System


I have a few milestones that I want to achieve on this new Transabot version.

  1. New Quote System
  2. Gitlab CI
  3. Unit Test
  4. Redis Server
  5. Cronjob for reminders

New Quote System

The current quote system works just fine, but there are a few things I want changed. First of all, I don’t record the author of the quote, just the person who actually added the quote on the system. Second of all, I want to add an option to quote someone using the new Inline Query from Telegram, and for that I need to also record the author of the quote. Since I upgraded our group to a Supergroup and we lost all the quotes (quotes are directly linked to the group ID and upgrading to a supergroup changes the group ID, thus, breaking the quotes we had) I’ll take the time to update how quotes are added and also record their author.

GitLab CI

I’ve been using Gitlab for a while now, instead of github, since it allows me have unlimited private repositories and the interface is much better than BitBucket’s. Gitlab also has CI integrated. I could use Travis CI but it is free for open-repositories only. It’s the same reason I won’t be able to add a Scrutinizer-CI to Transabot repository. Tasks like detecting code smells, mess detector and other stuff will all be run under a GitLab CI Task.

Unit Testing

I wrote this bot in a few hours so we could have some fun with it in our group. So, obviously, I wrote no tests whatsoever. Since I’ll be rewriting most of the code, I guess this is a good opportunity to add, at least, unit tests.


Currently, every time a user requests a quote or something, I query a SQLite database for it. Since we don’t have many users and we’re below 100 quotes, it’s not a big deal. But I recently implemented the option to send inline quotes and that’s were the bot struggles, since I need to order the quotes in popularity order and it takes a while to fetch them from the database. Redis should provide a faster response when user queries the inline quotes.

Cronjob for Reminders

Another available command in Transabot is the `/later` command. You can add reminders to check a link or see something later. I want to add an option to be reminded in “30 minutes” or “5 days” and I’ll need to add a cron task for that. I’ll be using Laravel Task Scheduling to achieve this.

These are the ideas I had to improve Transbot both in code quality and funcionality. If anything else comes up, I’ll be updating this post with new ideas and I’ll link everything related to Transabot development.

See you later. :)

Show your support

Clapping shows how much you appreciated Filipe Kiss’s story.