At work, we use a chat system for internal communications called Slack. One of the many features of the platform is the ability to integrate other apps, or allow external applications post messages for you. One of the earliest integrations someone integrated was the ability to receive the latest Dilbert comic in the #random channel by simply typing !dilbert as your message. This was known as “Dilbot”.
Unfortunately, there were a few people in the company who
didn’t like absolutely despised Dilbert (with a passion in some cases), which was only exacerbated when I wrote a script that would make Slackbot automatically trigger the !dilbert message between 09:00-11:59 daily.
Clearly something had to be done. So I decided to rewrite a replacement Dilbot from the ground up (mostly) who will send a direct message to users who wanted to see comics. I had written a bot in PHP in the past, but it was very unreliable. A bit of research lead me to find a bare bones bot written by Slack themselves called python-rtmbot. As you can guess, this is written in Python – a language I hadn’t really looked into before, but hey ho, everyday’s a school day.
It wasn’t long before I had a basic bot running and hooked up to a local MariaDB database.
I decided this bot would need to be a little smarter than the old Dilbot one, and provide a wider range of comics (I didn’t want this to be merely a Dilbot 2.0), so I started looking into the best way to implement this. Originally, I chose to utilise ComicSyndicate’s vast list of RSS feeds to provide the comics. Unfortunately, the service proved to be unreliable and only maintained by one person in their spare time.
. @ianhawdon *grr* yes, service down. Who could have guessed that a cheap-ish server is also unreliable 😉 Already working on it.
— ComicSyndicate.org (@ComSynDotOrg) April 4, 2016
So, rather than overwhelming his “cheap-ish server”, I updated Toonbot to start scraping the sites directly, and less aggressively, utilising each comic’s RSS feed if it was available. I’ve also implemented the following features in Toonbot:
- Work Hours – Toonbot only sends messages during typical working hours, though users can adjust this if they’d prefer different times. This respects each user’s timezone. A big feature for us, as we have offices overseas.
- A feedback function – Users can send their Toonbot administrator feedback on the service.
- Announcements – Administrators can send a public announcement to all users who are subscribed to a comic.
- Links to the original comic on the comic’s site – This allows comics to be easily shared.
As well as a few others that aren’t really worth talking about here.
I’ve already received positive feedback from users of the service as well as suggestions for improvements.
The bot is still a work in progress, but it is open source (GPLv3) and is available on GitHub:
So please feel free to fork it, contribute to it, open pull requests, or simply report issues.