Skip to content
Trolling the ancient Yuletide carol
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
README.md
build.js
config.json
deck-the-halls.sublime-project
deck-the-halls.sublime-workspace
dictionary.js
done.json
index.js
package-lock.json
package.json
tweet-to-words.js

README.md

deck-the-halls

Trolling the ancient Yuletide carol

This bot watched the public Twitter timeline and checks for tweets which fit the metre of Deck The Halls With Boughs Of Holly. That is, four metrical feet consisting of a stressed and an unstressed syllable.

To do this, we use a list of words mapped to their stress patterns. I use the CMU Pronouncing Dictionary, which is a wonderful resource but does mean technically the bot has a slight US accent. It also can't tell what sense a tweet means a word in which can change the stress pattern.

There are a couple of other things it filters for, including tweets that are just the same word four or eight times, or tweets where it isn't fairly clear which parts are content and which are hashtags and the like.

The gist of the code is that it turns a tweet into a string of numbers: a 0 for an unstressed beat, and a 1 (or a 2 but we don't care about the difference here) for a stressed beat. Deck the Halls is 10101010, so we test it against the regex /^([1-9]0){4}$/ to test for Deck the Hallsiness. You can configure the code to sing other songs by changing that regex.

The bot runs at @falalala_la during Christmastime.

To run, this code needs:

You can’t perform that action at this time.