MattBot
A bot to “dent” the poetry of Matthew Arnold, line by line, to mattarnold@status.farcebork.com (a status.net account).
This “bot” consists of three files, and a cronjob.
Files:
- a plain text file containing all of the poetry of Matthew Arnold.
- a config file bearing only the current line number
- the bash script that reads the line and sends the “dent” (update) to status.net
cronjob
I just have this in my crontab
0 * * * * /path/to/mattUP
This runs the script every hour.
code
Here's the script (which I have named “mattUP”):
#!/bin/bash # dent the entire poetic works of Matthew Arnold # by tony baldwin | www.tonybaldwin.me # what line are we on? read from the config file source mattline.cfg # grab the line from the text file myline="$line"p ud=$(sed -n $myline mattarnoldpoems.txt) # send the update curl -u mattarnold:********* -d "status=$ud&source=mattBot" \ http://status.farcebork.com/api/statuses/update.xml # rewrite the config file, incrementing the line number by 1 # the poetry file has 14222 lines, so, when we reach 14222 # we will start all over, resetting to line 1. if [[ $myline = 14222 ]]; then newline=1 else newline=$((line + 1)) fi echo line=$newline > mattline.cfg #done exit
config
The mattline.cfg file is very simple. It looks like this:
line=1
initially, and then each time the script is run, it increments the value by 1, and rewrites the file.
poetry
And the poetry file, mattarnoldpoems.txt, is just a simple, plain text file, with all of Matthew Arnold's poetic works, line by line, with no empty lines.
download
Download mattbot: http://tonybaldwin.me/downloads/mattbot.tar.gz
Why would you want to download mattbot?
Well, you could use it as an example to set up a bot to post the poetry of, say, William Butler Yeats, or T.S. Eliot.
O, si quieres, se puede hacer el mismo con la poesia de Pablo Neruda.
Or, maybe you'd like to dent or tweet The Constitution of the United States of America.
If you set up any of these, or something else cool, be sure to comment below and let me know all about it.
in action
See the mattbot in action at mattarnold@status.farcebork.com.
shortlink to this page: http://tonyb.us/mattbot
— tonybaldwin 2012.05.05.13.40
