This commit is contained in:
Ryan Hitchman 2010-04-22 21:50:56 -06:00
parent e55774b770
commit f61895fdc3
5 changed files with 14 additions and 15 deletions

View File

@ -24,14 +24,14 @@ class Input(dict):
def pm(msg): def pm(msg):
conn.msg(nick, msg) conn.msg(nick, msg)
def notice(msg): def notice(msg):
conn.cmd('NOTICE', [nick, msg]) conn.cmd('NOTICE', [nick, msg])
dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command, dict.__init__(self, conn=conn, raw=raw, prefix=prefix, command=command,
params=params, nick=nick, user=user, host=host, params=params, nick=nick, user=user, host=host,
paraml=paraml, msg=msg, server=conn.server, chan=chan, paraml=paraml, msg=msg, server=conn.server, chan=chan,
notice=notice, say=say, reply=reply, pm=pm, bot=bot, notice=notice, say=say, reply=reply, pm=pm, bot=bot,
lastparam=paraml[-1]) lastparam=paraml[-1])
# make dict keys accessible as attributes # make dict keys accessible as attributes

View File

@ -25,11 +25,10 @@ def bible(inp):
return text return text
## Koran look-up plugin by Ghetto Wizard
@hook.command('allah') @hook.command('allah')
@hook.command @hook.command
def koran(inp): def koran(inp): # Koran look-up plugin by Ghetto Wizard
".koran <chapter.verse> -- gets <chapter.verse> from the Koran" ".koran <chapter.verse> -- gets <chapter.verse> from the Koran"
if not inp: if not inp:
@ -38,7 +37,7 @@ def koran(inp):
url = 'http://quod.lib.umich.edu/cgi/k/koran/koran-idx?type=simple' url = 'http://quod.lib.umich.edu/cgi/k/koran/koran-idx?type=simple'
results = http.get_html(url, q1=inp).xpath('//li') results = http.get_html(url, q1=inp).xpath('//li')
if not results: if not results:
return 'No results for ' + inp return 'No results for ' + inp

View File

@ -36,7 +36,7 @@ def tellinput(paraml, input=None, db=None, bot=None):
user_from, message, time, chan = tells[0] user_from, message, time, chan = tells[0]
reltime = timesince.timesince(time) reltime = timesince.timesince(time)
reply = "%s said %s ago in %s: %s" % (user_from, reltime, chan, reply = "%s said %s ago in %s: %s" % (user_from, reltime, chan,
message) message)
if len(tells) > 1: if len(tells) > 1:
reply += " (+%d more, .showtells to view)" % (len(tells) - 1) reply += " (+%d more, .showtells to view)" % (len(tells) - 1)
@ -61,8 +61,8 @@ def showtells(inp, nick='', chan='', notice=None, db=None):
for tell in tells: for tell in tells:
user_from, message, time, chan = tell user_from, message, time, chan = tell
reltime = timesince.timesince(time) past = timesince.timesince(time)
notice("%s said %s ago in %s: %s" % (user_from, reltime, chan, message)) notice("%s said %s ago in %s: %s" % (user_from, past, chan, message))
db.execute("delete from tell where user_to=lower(?)", db.execute("delete from tell where user_to=lower(?)",
(nick,)) (nick,))

View File

@ -1,6 +1,6 @@
# tf.py: written by ipsum # tf.py: written by ipsum
# #
# This skybot plugin retreives the number of items # This skybot plugin retreives the number of items
# a given user has waiting from idling in Team Fortress 2. # a given user has waiting from idling in Team Fortress 2.
from util import hook, http from util import hook, http
@ -13,10 +13,10 @@ def tf(inp):
if not inp: if not inp:
return tf.__doc__ return tf.__doc__
if inp.isdigit(): if inp.isdigit():
link = 'profiles' link = 'profiles'
else: else:
link = 'id' link = 'id'
url = 'http://steamcommunity.com/%s/%s/tfitems?json=1' % \ url = 'http://steamcommunity.com/%s/%s/tfitems?json=1' % \
@ -27,7 +27,7 @@ def tf(inp):
except ValueError: except ValueError:
return '%s is not a valid profile' % inp return '%s is not a valid profile' % inp
dropped,dhats,hats = 0,0,0 dropped, dhats, hats = 0, 0, 0
for item, data in inv.iteritems(): for item, data in inv.iteritems():
ind = int(data['defindex']) ind = int(data['defindex'])
if data['inventory'] == 0: if data['inventory'] == 0:

View File

@ -33,7 +33,7 @@ def get_json(*args, **kwargs):
return json.loads(get(*args, **kwargs)) return json.loads(get(*args, **kwargs))
def open(url, query_params={}, user_agent=user_agent, post_data=None, def open(url, query_params={}, user_agent=user_agent, post_data=None,
get_method=None, **kwargs): get_method=None, **kwargs):
query_params.update(kwargs) query_params.update(kwargs)
@ -47,7 +47,7 @@ def open(url, query_params={}, user_agent=user_agent, post_data=None,
request.add_header('User-Agent', user_agent) request.add_header('User-Agent', user_agent)
return urllib2.build_opener().open(request) return urllib2.build_opener().open(request)
def prepare_url(url, queries): def prepare_url(url, queries):
if queries: if queries:
scheme, netloc, path, query, fragment = urlparse.urlsplit(url) scheme, netloc, path, query, fragment = urlparse.urlsplit(url)