2009-03-16 18:33:59 +00:00
|
|
|
"""
|
|
|
|
iambuttbot.py: avidal 2009
|
|
|
|
posts everything buttbot says to the iambuttbot twitter account
|
|
|
|
"""
|
|
|
|
|
|
|
|
import urllib
|
|
|
|
import hook
|
|
|
|
|
2009-04-18 00:57:18 +00:00
|
|
|
|
2009-03-30 23:58:19 +00:00
|
|
|
@hook.command(hook=r'(.*)', prefix=False, ignorebots=False)
|
2009-03-16 18:42:00 +00:00
|
|
|
def iambuttbot(bot, input):
|
2009-04-18 00:57:18 +00:00
|
|
|
if input.nick.lower() != 'buttbot':
|
2009-03-16 18:56:26 +00:00
|
|
|
return
|
|
|
|
|
2009-04-17 03:52:47 +00:00
|
|
|
if '@' in input or '#' in input:
|
|
|
|
return #prevent abuse
|
|
|
|
|
2009-03-16 18:56:26 +00:00
|
|
|
password = open('iambuttbot_password').readlines()[0].strip()
|
2009-03-16 18:33:59 +00:00
|
|
|
status = input.inp if len(input.inp) <= 140 else input.inp[:137] + "..."
|
2009-03-28 03:42:19 +00:00
|
|
|
data = urllib.urlencode({"status": status.encode('utf8')})
|
2009-03-16 18:56:26 +00:00
|
|
|
url = 'http://iambuttbot:%s@twitter.com/statuses/update.xml' % password
|
|
|
|
response = urllib.urlopen(url, data)
|