Skip to content

penguinpowernz/mastocritters

Repository files navigation

Mastocritters

A toolchain for creating mastodon bots that masquerade as US Politicians disclosing their stock trades.

Level1Techs Devember 2022

level1techslogo

This was done as part of the Level1Techs Devember competition. Check them out at https://level1techs.com/ or https://www.youtube.com/c/level1techs

This is running on a Linode server at https://indoors.trade using the Level1Techs coupon: https://linode.com/level1techs

The version of the software that was submitted for the competition is tagged v1.0.0.

image

Method of Operation

I didn't want to patch Mastodons API to allow certain extra required features like modifying a posts publish time. I opted instead for using the Mastodon evironment and models directly to insert data parsed from the JSON output of other tools.

#!/usr/bin/env ruby

require '/path/to/mastodon/config/environment.rb'

a = Account.create(username: "nancy_pelosi", note: "Mock account of Representative for California")
Status.new(account: a , text: "Hello world")
# ...etc...

Also having avatars is nice, so https://bioguides.congress.gov and https://github.com/unitedstates/images are used to create avatar images file structure.

I use the lstrades binary from https://github.com/penguinpowernz/stonkcritter

The steps look something like this:

  1. download BioGuides and images
  2. rename the images to the congress critters name based on the BioGuides
  3. download the trade disclosure data using lstrades
  4. generate a JSON doc of congress critters in that disclosure data, including some aggregate metadata using lstrades
  5. convert the BioGuides to a single JSON doc with just the info we need
  6. create any missing accounts, update existing accounts with the latest metadata
  7. add avatars to any accounts that were created
  8. convert trade disclosures from the JSON doc to status posts using lstrades

Problems

There are some problems that need to be solved at some point:

  • the names in the trade disclosure data don't always match whats in the bioguide, better matching is needed
  • this also affects the avatar generation/naming
  • unauthenticated Mastodon is not really that user friendly
  • there is no way to uniquely identify any particular trade disclosure, so it is hard to protect against double ups
  • updating is fragile for this reason

About

Track US politician stock trades in Mastodon

Resources

Stars

Watchers

Forks

Packages

No packages published