fixing hook, iambuttbot

This commit is contained in:
Ryan Hitchman 2009-03-16 12:56:26 -06:00
parent 5213276d6f
commit 4b749762cd
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,4 @@
syntax: glob
.*.swp
*.pyc
iambuttbot_password

View File

@ -18,7 +18,7 @@ def sieve(func):
_hook_add(func, ['sieve', (_make_sig(func), func)])
return func
def command(func, hook=None, **kwargs):
def command(func=None, hook=None, **kwargs):
args = {}
def command_wrapper(func):
if func.func_code.co_argcount not in (1, 2):

View File

@ -6,11 +6,13 @@ posts everything buttbot says to the iambuttbot twitter account
import urllib
import hook
@hook.command(hook=r'(.*)')
@hook.command(hook=r'(.*)', prefix=False)
def iambuttbot(bot, input):
if input.nick.lower() != 'buttbot': return
buttbot_pass = open('iambuttbot_passwd').readlines()[0].strip()
if input.nick.lower() != 'buttbot':
return
password = open('iambuttbot_password').readlines()[0].strip()
status = input.inp if len(input.inp) <= 140 else input.inp[:137] + "..."
data = urllib.urlencode({"status": status})
response = urllib.urlopen("http://iambuttbot:%s@twitter.com/statuses/update.xml" % (buttbot_pass,), data)
url = 'http://iambuttbot:%s@twitter.com/statuses/update.xml' % password
response = urllib.urlopen(url, data)