Code Monkey home page Code Monkey logo

everympbot's Introduction

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.

everympbot's People

Contributors

generalist avatar

Stargazers

Magnus Sälgö avatar Lucas Werkmeister avatar

Watchers

 avatar

everympbot's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.