A few weeks ago, I posted about how to build a twitter bot. I wish it stopped there. Unfortunately, all code has bugs (ahem, I mean, features). There are two bugs in my code. The first one I understand, and could probably fix if I tried, but I haven’t because it’s probably more trouble than it’s worth. The second one I don’t understand, but I do know how to fix it.
The first bug has to do with the messy regular expression I used to find the information on the Ethnologue webpages. I probably should have used something like the JavaScript DOM, but at the time I wrote this bot I didn’t know about the DOM. So a good tweet looks like this:
It says the language name, it’s status (dormant), and where it’s from (Bolivia), followed by a link to Ethnologue. But the regular expression sometimes catches the name of the researcher working on the language and the year of the last census, instead of the endangerment status, like this:
This is unfortunate, but it doesn’t seem to happen too often (maybe once every 100 tweets or so). So I’m not to bothered by it.
The second bug happens because… well I don’t know why or when it happens. Sometimes the bot just stops tweeting. It happens every few weeks, but it’s not regular. It’s not after a certain number of days or tweets or anything. It might be because Amazon Web Services, where my bot is hosted, is getting an update to their server, which causes the bot to stop. The last time this happened was around the announcement of the bash shellshock vulnerability, so maybe that has something to do with it?
Anyway, the fix for this bug is simply logging in to my virtual server and restarting the bot at the point where it left off.
So that’s it! If you want a twitter bot, just know you have to maintain it, just like any pet. :)
Pingback: Word Clouds |