Skip to content

generalist/everympbot

Repository files navigation

everympbot

This is a Python script to assemble tweets for the @everympbot account on Twitter. It pulls data from the Wikidata British Politicians dataset to generate a short summary for a given MP.

The main script is twitterbot.sh. This calls assembly.py, which randomly selects an entry from a pre-selected list of candidate items in sourceids.txt. It then runs two queries to get data about the entry, and assembles a tweet, plus optionally an image if one is present on Wikidata. It logs the generated tweet and some metadata in generatedlog.txt.

The second script,tweeting.py, pulls credentials from config.txt and then uses the twython framework to post the tweet plus, if it exists, an image. It then logs this in tweetedlog.txt.

The shell script can be run manually or set to run on a regular basis.

A second pair of scripts, twitterbot-1386.sh and assembly-1386.py, generate a simplified tweet for early MPs, using a seperate candidates file (sourceids-1386.txt)

reportscripts.py refreshes the two candidate files automatically, and generates a tweet with overall statistics.

Version log

  • 0.1 - minimal one-line tweet using everywordbot
  • 0.2 - adds Wikidata link
  • 0.3 - adds Wikipedia or Wikidata link, plus optional ODNB, Hansard, Rush links.
  • 0.4 - adds a check to make sure that there was continuous service (otherwise it would only tweet one half of it)
  • 0.5 - rewritten to cope with multiple distinct periods of office, seats, or parties.
  • 0.6 - tweaked to add a number of parties or seats where appropriate
  • 1.0 - changed to a multi-line tweet posted with twython
  • 1.1 - adds support for images
  • 1.2 - logs image correctly
  • 1.3 - adds Who's Who
  • 1.4 - fixes user-agent issues

Generating sourceids.txt:

Candidate lists are a plain text file of Wikidata QIDs, of the form Q123456 - no prefixes or suffixes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors