h/plugins/iambuttbot.py

30 lines
869 B
Python
Raw Normal View History

"""
iambuttbot.py: avidal 2009
posts everything buttbot says to the iambuttbot twitter account
"""
import urllib
from util import hook
@hook.command(hook=r'(.*)', prefix=False, ignorebots=False)
def iambuttbot(bot, input):
2009-05-15 03:07:31 +00:00
if input.nick.lower() not in ('buttbot', 'buttsbot'):
2009-03-16 18:56:26 +00:00
return
2009-04-25 19:33:49 +00:00
if '@' in input.inp or '#' in input.inp:
return #prevent abuse
2009-03-16 18:56:26 +00:00
password = open('iambuttbot_password').readlines()[0].strip()
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)
2009-04-23 02:50:51 +00:00
try:
open('iambuttbot_password')
except IOError:
print 'iambuttbot twitter password not found: module disabled'
del iambuttbot