put input.inp.strip() in sieve, remove repetitive stripping in plugins
This commit is contained in:
parent
92c6d798b5
commit
33585f3190
|
@ -33,7 +33,7 @@ def nrolls(count, n):
|
|||
def dice(inp):
|
||||
".dice <diceroll> -- simulates dicerolls, e.g. .dice 2d20-d5+4 roll 2 " \
|
||||
"D20s, subtract 1D5, add 4"
|
||||
if not inp.strip():
|
||||
if not inp:
|
||||
return dice.__doc__
|
||||
|
||||
spec = whitespace_re.sub('', inp)
|
||||
|
|
|
@ -6,7 +6,6 @@ from util import hook
|
|||
@hook.command
|
||||
def down(inp):
|
||||
'''.down <url> -- checks to see if the site is down'''
|
||||
inp = inp.strip()
|
||||
|
||||
if not inp:
|
||||
return down.__doc__
|
||||
|
|
|
@ -10,6 +10,6 @@ def explain(inp):
|
|||
inp = inp.encode('utf8', 'ignore')
|
||||
|
||||
try:
|
||||
return explain_c_declaration(inp.rstrip())
|
||||
return explain_c_declaration(inp)
|
||||
except Exception, e:
|
||||
return 'error: %s' % e
|
||||
|
|
|
@ -10,7 +10,7 @@ def help(bot, input):
|
|||
if func.__doc__ is not None:
|
||||
funcs[csig[1]] = func
|
||||
|
||||
if not input.inp.strip():
|
||||
if not input.inp:
|
||||
input.pm('available commands: ' + ' '.join(sorted(funcs)))
|
||||
else:
|
||||
if input.inp in funcs:
|
||||
|
|
|
@ -15,7 +15,7 @@ def py(inp):
|
|||
return py.__doc__
|
||||
|
||||
res = urllib.urlopen("http://eval.appspot.com/eval?statement=%s" %
|
||||
urllib.quote(inp.strip(), safe='')).readlines()
|
||||
urllib.quote(inp, safe='')).readlines()
|
||||
if len(res) == 0:
|
||||
return
|
||||
res[0] = re_lineends.split(res[0])[0]
|
||||
|
|
|
@ -46,14 +46,13 @@ def remember(bot, input):
|
|||
except ValueError:
|
||||
return remember.__doc__
|
||||
|
||||
tail = tail.strip()
|
||||
low = head.lower()
|
||||
if low not in memory[filename]:
|
||||
input.reply("done.")
|
||||
else:
|
||||
input.reply('forgetting that "%s", remembering this instead.' %
|
||||
memory[filename][low])
|
||||
memory[filename][low] = input.inp.strip()
|
||||
memory[filename][low] = input.inp
|
||||
save_memory(filename, memory[filename])
|
||||
|
||||
|
||||
|
@ -64,10 +63,10 @@ def forget(bot, input):
|
|||
filename = make_filename(bot.persist_dir, input.chan)
|
||||
memory.setdefault(filename, load_memory(filename))
|
||||
|
||||
if not input.inp.strip():
|
||||
if not input.inp:
|
||||
return forget.__doc__
|
||||
|
||||
low = input.inp.strip().lower()
|
||||
low = input.inp.lower()
|
||||
if low not in memory[filename]:
|
||||
return "I don't know about that."
|
||||
if not hasattr(input, 'chan'):
|
||||
|
|
|
@ -40,7 +40,7 @@ def seen(bot, input):
|
|||
if len(input.msg) < 6:
|
||||
return seen.__doc__
|
||||
|
||||
query = input.inp.strip()
|
||||
query = input.inp
|
||||
|
||||
if query.lower() == input.nick.lower():
|
||||
return "Have you looked in a mirror lately?"
|
||||
|
|
|
@ -24,6 +24,7 @@ def sieve_suite(bot, input, func, args):
|
|||
if input.re is None:
|
||||
return None
|
||||
|
||||
input.inp = ' '.join(input.re.groups())
|
||||
input.inp_unstripped = ' '.join(input.re.groups())
|
||||
input.inp = input.inp_unstripped.strip()
|
||||
|
||||
return input
|
||||
|
|
|
@ -7,11 +7,12 @@ import json
|
|||
from util import hook
|
||||
|
||||
@hook.command
|
||||
def suggest(inp):
|
||||
def suggest(bot, input):
|
||||
".suggest [#n] <phrase> -- gets a random/the nth suggested google search"
|
||||
if not inp.strip():
|
||||
if not input.inp:
|
||||
return suggest.__doc__
|
||||
|
||||
inp = input.inp_unstripped
|
||||
m = re.match('^#(\d+) (.+)$', inp)
|
||||
if m:
|
||||
num, inp = m.groups()
|
||||
|
|
|
@ -81,7 +81,7 @@ def tell(bot, input):
|
|||
if len(input.msg) < 6:
|
||||
return tell.__doc__
|
||||
|
||||
query = input.msg[6:].strip().partition(" ")
|
||||
query = input.inp.partition(" ")
|
||||
|
||||
if query[0] == input.nick:
|
||||
return "No."
|
||||
|
|
|
@ -31,7 +31,6 @@ def twitter(inp):
|
|||
".twitter <user>/<user> <n>/<id>/#<hashtag>/@<user> -- gets last/<n>th tweet from"\
|
||||
"<user>/gets tweet <id>/gets random tweet with #<hashtag>/gets replied tweet from @<user>"
|
||||
|
||||
inp = inp.strip()
|
||||
if not inp:
|
||||
return twitter.__doc__
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ from util import hook
|
|||
@hook.command
|
||||
def urban(inp):
|
||||
'''.u/.urban <phrase> -- looks up <phrase> on urbandictionary.com'''
|
||||
if not inp.strip():
|
||||
if not inp:
|
||||
return urban.__doc__
|
||||
|
||||
url = 'http://www.urbandictionary.com/define.php?term=' + \
|
||||
urllib.quote(inp.strip(), safe='')
|
||||
urllib.quote(inp, safe='')
|
||||
page = html.parse(url)
|
||||
words = page.xpath("//td[@class='word']")
|
||||
defs = page.xpath("//div[@class='definition']")
|
||||
|
|
|
@ -41,7 +41,7 @@ def weather(bot, input):
|
|||
stalk = load_stalk(filename)
|
||||
|
||||
nick = input.nick.lower()
|
||||
loc = input.inp.strip()
|
||||
loc = input.inp
|
||||
dontsave = loc.endswith(" dontsave")
|
||||
if dontsave:
|
||||
loc = loc[:-9].strip().lower()
|
||||
|
|
|
@ -16,14 +16,14 @@ paren_re = re.compile('\s*\(.*\)$')
|
|||
|
||||
@hook.command(hook='w(\s+.*|$)')
|
||||
@hook.command
|
||||
def wiki(query):
|
||||
def wiki(inp):
|
||||
'''.w/.wiki <phrase> -- gets first sentence of wikipedia ''' \
|
||||
'''article on <phrase>'''
|
||||
|
||||
if not query.strip():
|
||||
if not inp:
|
||||
return wiki.__doc__
|
||||
|
||||
q = search_url % (urllib.quote(query.strip(), safe=''))
|
||||
q = search_url % (urllib.quote(inp, safe=''))
|
||||
x = etree.parse(q)
|
||||
|
||||
ns = '{http://opensearch.org/searchsuggest2}'
|
||||
|
|
Loading…
Reference in New Issue