The tweeting bot’s actions cause it to wander the world and sporadically report on it’s progress, who is in the same location (bots, players or objects) and snippets of conversations it hears, from players or bots talking to each other. I’m using tweepy, a python twitter library, so I had to do a bit of a cheap hack for the racket->python process communication using the filesystem. The python daemon simply waits for a file to be created by the main bot AI thread and sends the contents of it to the twitter stream. In order to do the authentication with OAuth I needed to set up a Twitter application to get a pair of keys to sign the single user the app will have.
Here is the code for the tweepy daemon:
#!/usr/bin/env python import tweepy import os.path import time auth = tweepy.OAuthHandler("your consumer key", "your consumer secret") print(auth.get_authorization_url()) # you need to visit this site, logged in as the twitter user verifier = raw_input('Verifier:') # then input the verifier code here before continuing auth.get_access_token(verifier) api = tweepy.API(auth) # this api allows us to read or write from the user's account while True: if os.path.isfile("msg"): # look for a file called "msg" f = open("msg", "r") api.update_status(f.read()) # dump the contents into the twitter stream f.close() os.remove("msg") time.sleep(10)