YaoiBot
- 3 Devlogs
- 3 Total hours
A Mastodon bot that posts Yaoi (boyslove), because the old one is dead.
A Mastodon bot that posts Yaoi (boyslove), because the old one is dead.
Over some time, I made a few improvements. The service now no longer runs as root, but as a dynamic user, which allocates a UID and GID at random. I had a few issues in the meantime, because this also automatically enables a lot of hardening functionality, preventing Deno from downloading its dependencies. I overrode the DENO_DIR environment variable and had systemd create a cache directory, and now it works.
Also, the access token is now no longer provided as a string, but inside an encrypted .env file. The dotenv file, however, is not loaded by Deno, but by systemd, which then passes it to the Deno process as usual.
Thanks to @jak2k for a lot of pointers to these systemd features!
It turns out the library hiccups when using a RAM buffer. I now save the files to /tmp, and create a ReadStream, and now it works! The rest of the time was spent writing a Nix flake, which both wraps the package (currently using a shell script, until I figure out how to run deno compile in the offline sandbox), and contains a NixOS module, which creates a systemd timer to run the bot as a oneshot service.
I wrote code that should work™. But for some reason, I get an HTTP error 400, and the stacktrace is of no use, since it is somewhere within the event loop. Also, some time is missing from Hackatime, since it only tracks git repositories.