Created
April 22, 2010 02:14
-
-
Save avelino/374726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Thiago Avelino <[email protected]> | |
import twitter | |
import jabberbot | |
import yql | |
import urllib,urllib2 | |
botcmd = jabberbot.botcmd | |
_jabber_user = '[email protected]' | |
_jabber_pass = 'pass' | |
class twettbot(jabberbot.JabberBot): | |
_user = _jabber_user | |
_pass = _jabber_pass | |
def __init__(self): | |
jabberbot.JabberBot.__init__(self, self._user, self._pass) | |
def callback_message(self, conn, mess): | |
return jabberbot.JabberBot.callback_message(self, conn, mess) | |
@botcmd (hidden=True) | |
def post(self, mess, args): | |
"""Post a message to twitter""" | |
query = "https://query.yahooapis.com/v1/public/yql?q=use%20'http%3A%2F%2Fwww.yqlblog.net%2Fsamples%2Ftwitter.status.xml'%3B%20insert%20into%20twitter.status%20(status%2Cusername%2Cpassword)%20values%20('"+ str(args) + "'%2C'"+ TWITTER_USERNAME +"'%2C'"+ TWITTER_PASSWORD +"')%3B&format=json&callback=" | |
urllib2.urlopen(query).read() | |
return query | |
if __name__ == '__main__': | |
bot = twettbot() | |
bot.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment