From 4b749762cd0d276355ce1ea1532a2bd0728c2f07 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Mon, 16 Mar 2009 12:56:26 -0600 Subject: [PATCH] fixing hook, iambuttbot --- .hgignore | 1 + plugins/hook.py | 2 +- plugins/iambuttbot.py | 12 +++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.hgignore b/.hgignore index 09079fe..283715b 100644 --- a/.hgignore +++ b/.hgignore @@ -1,3 +1,4 @@ syntax: glob .*.swp *.pyc +iambuttbot_password diff --git a/plugins/hook.py b/plugins/hook.py index c99f045..7574bf8 100644 --- a/plugins/hook.py +++ b/plugins/hook.py @@ -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): diff --git a/plugins/iambuttbot.py b/plugins/iambuttbot.py index 812d148..51d4606 100644 --- a/plugins/iambuttbot.py +++ b/plugins/iambuttbot.py @@ -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)