project project-management-only / Scraper Snitch Bot avatar

project-management-only/scraper-snitch-bot#6: Move Bot Config To YAML

Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.14
Created: 29-Jan-23 15:58


We now have two wrapper scripts for the bot - one to toot, and another to regenerate the receipt files.

It's inevitable that, at some point, config between the two is going to accidentally diverge, so we should look at moving the bot's (limited) config to a YAML file

Toggle State Changes


assigned to @btasker

This is a larger job than it sounds, config within the bot is currently an absolute fucking mess, with quite a lot of it relying on globals.

If we're touching config anyway, we need to look at tidying that up.


mentioned in commit misc/python-mastodon-snitch-bot@877cd27a9b17ee8aece1fbe7722a35b2167e24de

Commit: misc/python-mastodon-snitch-bot@877cd27a9b17ee8aece1fbe7722a35b2167e24de 
Author: B Tasker                            
Date: 2023-01-29T16:28:05.000+00:00 


Start moving things to YAML config (project-management-only/scraper-snitch-bot#6)

This is currently properly nasty.

We now load the config from YAML, but currently just the assign the relevant parts to the hodge-podge of globals that are in use.

The next step is to start factoring those out, one by one

+61 -18 (79 lines changed)

Some 12 commits, and a whole bunch of line changes, later, this is done.

Config looks like this


# InfluxDB config
  host: localhost
  port: 443
  bucket: "logs"
  measurement: "snitched"
  forever_filter: "time < now() + interval '1 minute'"

query_period: 12 hour
receipt_dir: /receipts
notes_dir: /notes
state_dir: /state
robots_disallow_all: Y

  visibility: private
  toot_at: 'cc'
  tags: []


And the much simplified commandline looks like

docker run --rm --name="bot_snitch" -v /home/ben/tmp/snitch/state:/state -v /home/ben/tmp/snitch/receipts:/receipts -v /home/ben/tmp/snitch/notes:/notes -v /home/ben/tmp/snitch/config.yaml:/config.yaml -e DRY_RUN=Y <image>

Although the bot version in prod won't currently consume it, I've deployed a config file so things won't go pete tong when the update is deployed (the env vars should be removed from the command line at that point, but nothing will break if they aren't)

changed title from Move Config To YAML to Move {+Bot +}Config To YAML