Updated Project: I’ve added a lot of new commands and features to my bot, including statuspage integration, a private channel joiner and docker support, alongside bug fixes for my existing commands and modules.
Updated Project: I’ve added a lot of new commands and features to my bot, including statuspage integration, a private channel joiner and docker support, alongside bug fixes for my existing commands and modules.
I created a lot more features and commands for my bot, which will be very helpful for my channels management on slack, and future development of this bot, such as switching to Docker and implementing machine ids.
During this devlog, I added 2 main features, a private joiner command, similar to Neon’s bot that allows you request to join other people’s private channels, and an integration to a statuspage, so I can track the uptime and receive notifications when my bot inevitably goes down.
Basically, for this feature, I used the command boilerplate that I created at the start of this project, and then created a new function that would be the entry point to any commands run. My main function runs when the command is run, and basically checks if the user is on the blacklist (which is stored as a txt file), and if they have already requested access, all using helper functions that I made. Then I post a block kit message to the op user (me) with the user and 3 buttons, accept, decline and blacklist. The first two do exactly what they suggest, and the blacklist button opens a text file and writes the user id of the requester to the end of it to prevent them from requesting again.
Recently, on my Raspberry Pi, I setup a Uptime Kuma instance, which is an open source version of services like Atlassian Startpage, which you may have seen in places like claude and cloudflare. Aside from all of the server-side config I needed to setup this up for myself (which isn’t included in this devlog), I needed a way to be able to check the status of my Slack bot. For the rest of my monitors, I could just make a HTTP request to them, but since my bot runs on socket mode, I have to use an alternate method, where the bot has to make a request to the statuspage server, instead of the usual other way around. To do this, I used python’s requests library, along with the subprocess library to accomplish this. Since the statuspage server isn’t the one making the request, I have to first use the system’s built in ping command to get the ping of 1.1.1.1, a popular DNS server, and save that for use in the query to the statuspage, which is a simple GET method, with the ping and status in the URL parameters.
You have a look at my statuspage here, and try my private joiner command out by running /join-obobs-duck in Slack.
Log in to leave a comment
in this devlog, I moved my whole project to Docker, which allows me to deploy it much more easily and is just cleaner overall.
I started off with a basic dockerfile, and then iterated on it to fix some issues. One of the major issues I had was with pip, since I was running it as root and my actual program couldn’t access/find the modules at all, and I fixed this by chowning the /app directory and then switching to the user straight away before running pip.
Basically, I added a Docker file and docker-compose that uses my existing .env system and makes deployment much cleaner
Log in to leave a comment
I created a /ping command for my bot! The reason why there’s like 4 hours on this is because I had 3 or 4 revisions of this 😭.
Originally, I tried a method where my bot would post a message, then get the message timestamp from slack (basically a unix epoch, seconds since Jan 1, 1970), but this wasn’t accurate (results of like 1000ms, which is definitely not true) since, my system clock will never be perfectly synced with slack’s server.
Next, I tried to use python’s subprocesses module to run a ping command (like ping slack.com), like something you would do in the terminal and then use that result. However, Slack blocks ICMP (which is what ping uses), so this didn’t work either.
Finally, I tried a method where I created and closed a TCP port, and measured the time it took, which is surprisingly accurate. On top of this, I also added an API “ping” measurement, where I measured the time it took for a request to the Slack API to finish, which is wildly inaccurate lol (like 500ms of “ping”)
Log in to leave a comment