Matthew's Website

I created my first Telegram bot

1st of May 2022


I was mindlessly browsing Hackernews when I stumbled upon a post about a guy who put his whole into a single database and it allowed him to generate interesting statistics about himself; stuff like his sleep patterns, location history, etc. You can check Felix's project over here: https://howisfelix.today

In order to input various data points to his database, Felix uses a Telegram bot. When I read about that, the dots in my mind had not connected yet. But then I went back to Hackernews to read the discussion on the project and someone mentioned a website which displays information about how many times its author has sneezed. That was my eureka moment. I can create a Telegram bot which will count my sneezes. What an amazing idea!

I immediately began reading about Telegram bots and looking up tutorials about creating them. It turned out to be a piece of cake, there is a Python library made exclusively for communication the API. Since I had never built a Docker image before, the only problem I had was putting everything together and running it on my VPS. Luckily, after making a couple a newbie mistakes, everything started working and my bot was up and running.

So what does my bot do? Every time I send a message it increases the number of times I sneezed by one. It also keeps track of the date and time for future statistics purposes. It can distinguish between users so if someone finds my bot, they will get their own sneeze count.
I also added an /undo function which removes the most recent sneeze from the database (just in case I send too many messages) and there is a /delete_all command which resets your sneeze count back to zero. Now I'm working on implementing a /stats command which will show some kind of a weekly (or maybe monthly?) sneeze summary.

Despite being fully functioning, I still consider the bot to be under development, which means I will not be sharing it here. Though feel free to use it if you somehow manage to find it!