polyrhythms

polyrhythms

Peter Sobot  //  Musician and software engineering student. I make things. Check out some of my work at petersobot.com.

Dec 1 / 12:10am

"The Street Preacher" - A Hyper-Local Twitter Bot

I walk through Yonge & Dundas Square in Toronto every day.

Yonge_dundas_toronto

That intersection, which some call Toronto's equivalent of Times Square, has a large number of street preachers. Loud, startling, obnoxious people that yell warnings of doom or urge repentance. Silly people.

I decided to use Twitter's real-time streaming API to make an extremely specific location-based Twitter bot. The purpose? To respond to you if you tweet near the street preachers at Yonge & Dundas, with similar messages. Call it art, or a statement about society, or making fun of those preachers, whatever - I call it a fun technical and social experiment.

Using an excellent ArsTechnica article as a guide, I created a quick Python script that watches the Twitter stream for a given area, and replies to tweets in a very specific location. (±10 meters or so, by my guess.) If you're one of the lucky few to tweet within those bounds, you'll get a reply from @yonge_dundas:

Godalmighty

A day later, I decided to clean up the script (rewrite it in Ruby, too) and open-source it. Well, here it is, in a quick Github gist:

The only trouble I had with the resulting script was that it doesn't have proper daemonization - the Ruby Daemons gem that comes packaged with TweetStream doesn't play nice with Ruby Logging. (And it could use some rate limiting.)

Feel free to fork it, repurpose it, and do whatever! (Just keep my name at the top, if you please.)