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 syntax: glob
.*.swp .*.swp
*.pyc *.pyc
iambuttbot_password

View File

@ -18,7 +18,7 @@ def sieve(func):
_hook_add(func, ['sieve', (_make_sig(func), func)]) _hook_add(func, ['sieve', (_make_sig(func), func)])
return func return func
def command(func, hook=None, **kwargs): def command(func=None, hook=None, **kwargs):
args = {} args = {}
def command_wrapper(func): def command_wrapper(func):
if func.func_code.co_argcount not in (1, 2): 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 urllib
import hook import hook
@hook.command(hook=r'(.*)') @hook.command(hook=r'(.*)', prefix=False)
def iambuttbot(bot, input): def iambuttbot(bot, input):
if input.nick.lower() != 'buttbot': return if input.nick.lower() != 'buttbot':
return
buttbot_pass = open('iambuttbot_passwd').readlines()[0].strip() password = open('iambuttbot_password').readlines()[0].strip()
status = input.inp if len(input.inp) <= 140 else input.inp[:137] + "..." status = input.inp if len(input.inp) <= 140 else input.inp[:137] + "..."
data = urllib.urlencode({"status": status}) 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)