The beginning

I’ve been working on a project called Pystodon . Pystodon is a Mastodon bot that I started working on in August of 2023, nearly a year before writing this post. While developing it, I noticed that I had the opportunity to build it like a framework by focusing on customizability through code. This was my first time building a library-like program and I tried to focus on usability not just for people interacting with the bot but also anyone who wanted to customize it.

A pause in development

I revisited the project in October of 2023 before taking a hiatus from this project for nearly six months. Even though I had stopped working on this program, I was still proud of it. I would say that the code was good from a style perspective. I continued to use Mastodon and found that there was one feature that noticed I wished I had, the ability to be reminded of posts.

A learning opportunity

I’ve known that learning databases, Postgres specifically, would be beneficial. I love self-hosting software but I avoided some self-hosting some services because I didn’t want to have to manage a database if the need arose. I’m aware I should have just learned it, but I didn’t. Either way, I knew that if I wanted to add reminders to Pystodon, I would need to use some sort of persistent storage. A couple days ago, I was working on adding phidata to LLMail . I realized that if I wanted to allow the LLM to use knowledge bases, I would need to use a database. I decided to use this as an opportunity to learn Postgres since I could then use it in Pystodon, in addition to just having a better understanding of this critical technology.

Adding reminders

Whilst working on Pystodon initially, I wanted to implement some asynchronous code that would allow tasks to run in the background while the stream of mentions was being processed. I wrote some code that used Trio and just slept forever. I then had a test function run in the background. I had this implemented thinking that I would need it in the future. I was partially correct. The trio code was unnecessary and I didn’t even use asyncio. However, I did end up writing a while True loop to check for reminders while mentions were being processed. Because I still wanted to make Pystodon a framework, I implemented a class I called CheckThis that allowed for functions to be added that would be ran every n seconds. Along with this, I implemented support for reading and writing reminders to a Postgres database, while learning about databases in the process. I used dateparser to allow for human-readable dates. This allowed for syntax like in 3d2h to be used to set a reminder for three days and two hours in the future. After some testing, I was able to get reminders working. Below is a screenshot of the bot replying to a reminder command. screenshot of the bot replying to a reminder command

General improvements

After adding reminder support, I made some general improvements to the bot including improving Docker support, custom command prefixes, command-line arguments, and having command-specific help messages instead of argument-specific help messages. I merged these changes into the main branch and released version 0.1.0. As part of making these improvements, I changed the regex to be much more reliable. My favorite change was allowing the help command to take arguments. By first running the help command (@bot@instance help), you can get a list of all commands. By running @bot@instance help <command>, you can get a more detailed description of that command. I love how reminiscent this is of using command line tools. The custom command prefixes are also nice since now hashtags don’t have to be used for every command. For example, I added /test that can be run with @bot@instance test. The project is in a pretty usable state now and I might keep it running so people can actually use it. Due to its customizable nature, I think it would be rather cool to see PRs get made adding new features. I’m excited to see where this project goes in the future.