Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.
/ wikipediastats Public archive

A Haskell-powered Twitter bot that posts milestones and statistics of various Wikipedias.

License

Notifications You must be signed in to change notification settings

doersino/wikipediastats

Repository files navigation

wikipediastats

As it turns out, the otherwise-excellent shared hosting plan I'm running all of my Twitter bots on limits RAM use to 1.5 GB per user, which is insufficient for building some of the dependencies of this bot. As a result, I've decided to reimplement it in JavaScript – another language that I wanted to get up to speed on (in a server context, anyway, i.e. with Node.js). Long story short: This repository will remain unmaintained.


A Haskell-powered Twitter bot that posts milestones and statistics of various Wikipedias.

While the main purpose of building this Twitter bot was to get myself reacquainted with Haskell, it's actually doing semi-interesting stuff. Whenever you run this program, it

  1. downloads and parses a list of all the different-language Wikipedias,
  2. scrapes some of the more interesting statistics for each of them,
  3. compares these stats to previously scraped and cached values (unless the cache doesn't exist, in which case goto 5),
  4. fires off a tweet if a milestone has been reached, i.e. the first digit of a stat has changed (e.g. 49894 → 50002), and
  5. refreshes the now-stale cache with the newly scraped values.

Now witness the firepowerresults of this fully armed and operational battle stationTwitter bot and check out @wikipediastats!

Setup

Fairly typical for a modern Haskell thing, I believe. First, install a reasonably recent release of Stack. Then:

$ git clone https://github.com/doersino/wikipediastats
$ cd wikipediastats
$ stack build

If that's been successful, make a copy of config.sample.ini, name it config.ini and fill in your Twitter API credentials as described in the helpful comment you'll find in there.

Run the bot at least once during setup to build the initial cache:

$ stack run

Optionally, you can play around a bit:

$ stack repl

Or verify that everything's working just swell:

$ stack test

If you're actually intending to use this as a Twitter bot, set up a cronjob to execute stack run every hour or so, roughly like this:

0 * * * * cd PATH_TO_WIKIPEDIASTATS && stack run

Notes

  • This three-afternoon project was my first foray into Haskell after not touching it for a couple of years (and back then, I was firmly lodged in the beginner-to-intermediate gap). Don't expect elegance, custom monads or adherence to best practices.
  • I haven't bothered listing version ranges for the dependencies of this tool in package.yaml because I don't know which past or future versions will invariably break things, but I think the fixed Stackage resolver version makes this less problematic than it used to be before Stack was around? Not sure. If you, a future software historian, can't seem to get the dependencies to play along nicely, I'm quite sorry.
  • An improvement I didn't care to implement: Store the largest tweeted value (for each stat, for each Wikipedia) in the cache in order to avoid duplicate tweets when the stat reaches a milestone, falls below it again due to article deletions or similar, then reaches the milestone again.

About

A Haskell-powered Twitter bot that posts milestones and statistics of various Wikipedias.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published