diff --git a/announce.py b/announce.py index ae99aec944..d724179f8c 100644 --- a/announce.py +++ b/announce.py @@ -7,6 +7,7 @@ """ from willie.module import command, example + @command('announce') @example('.announce Some important message here') def announce(bot, trigger): diff --git a/github.py b/github.py index 124a54173a..d2e1b63a33 100644 --- a/github.py +++ b/github.py @@ -13,6 +13,7 @@ from willie import web from willie.module import commands + def checkConfig(bot): if not bot.config.has_option('github', 'oauth_token') or not bot.config.has_option('github', 'repo'): return False diff --git a/help.py b/help.py index 9d88303d81..baee7e93d4 100644 --- a/help.py +++ b/help.py @@ -8,6 +8,7 @@ """ from willie.module import command, rule, example, priority + @rule('$nick' '(?i)(help|doc) +([A-Za-z]+)(?:\?+)?$') @example('.help tell') @command('help') @@ -20,11 +21,12 @@ def help(bot, trigger): name = trigger.group(2) name = name.lower() - if bot.doc.has_key(name): + if name in bot.doc: bot.reply(bot.doc[name][0]) if bot.doc[name][1]: bot.say('e.g. ' + bot.doc[name][1]) + @command('commands') @priority('low') def commands(bot, trigger): @@ -35,6 +37,7 @@ def commands(bot, trigger): bot.msg(trigger.nick, ("For help, do '%s: help example' where example is the " + "name of the command you want help for.") % bot.nick) + @rule('$nick' r'(?i)help(?:[?!]+)?$') @priority('low') def help2(bot, trigger): diff --git a/lmgtfy.py b/lmgtfy.py index cb9475d3c9..21cba7cc15 100644 --- a/lmgtfy.py +++ b/lmgtfy.py @@ -7,6 +7,7 @@ """ from willie.module import commands + @commands('lmgtfy', 'lmgify', 'gify', 'gtfy') def googleit(bot, trigger): """Let me just... google that for you.""" diff --git a/search.py b/search.py index e28743a1d0..b7f7321228 100644 --- a/search.py +++ b/search.py @@ -121,6 +121,7 @@ def bing_search(query, lang='en-GB'): r_duck = re.compile(r'nofollow" class="[^"]+" href="(.*?)">') + def duck_search(query): query = query.replace('!', '') query = web.quote(query) diff --git a/units.py b/units.py index f02f4d216a..18f0633ec2 100644 --- a/units.py +++ b/units.py @@ -9,17 +9,21 @@ from willie.module import command, commands, example, NOLIMIT import re -find_temp = re.compile('(-?[0-9]*\.?[0-9]*)[ °]*(K|C|F)', re.IGNORECASE) -find_length = re.compile('([0-9]*\.?[0-9]*)[ ]*(mile[s]?|mi|inch|in|foot|feet|ft|yard[s]?|yd|(?:centi|kilo|)meter[s]?|[kc]?m)', re.IGNORECASE) +find_temp = re.compile('(-?[0-9]*\.?[0-9]*)[ °]*(K|C|F)', re.IGNORECASE) +find_length = re.compile('([0-9]*\.?[0-9]*)[ ]*(mile[s]?|mi|inch|in|foot|feet|ft|yard[s]?|yd|(?:centi|kilo|)meter[s]?|[kc]?m)', re.IGNORECASE) + def f_to_c(temp): - return (float(temp) - 32) * 5/9 + return (float(temp) - 32) * 5 / 9 + def c_to_k(temp): return temp + 273.15 + def c_to_f(temp): - return (9.0/5.0 * temp + 32) + return (9.0 / 5.0 * temp + 32) + def k_to_c(temp): return temp - 273.15 @@ -50,6 +54,7 @@ def temperature(bot, trigger): fahrenheit = c_to_f(celsius) bot.reply("%s°C = %s°F = %sK" % (celsius, fahrenheit, kelvin)) + @commands('length', 'distance') @example('.distance 3km') def distance(bot, trigger): @@ -64,7 +69,7 @@ def distance(bot, trigger): unit = source[1].lower() numeric = float(source[0]) meter = 0 - if unit in ("meters","meter", "m"): + if unit in ("meters", "meter", "m"): meter = numeric elif unit in ("kilometers", "kilometer", "km"): meter = numeric * 1000 @@ -72,9 +77,9 @@ def distance(bot, trigger): meter = numeric / 0.00062137 elif unit in ("inch", "in"): meter = numeric / 39.370 - elif unit in ("centimeters","centimeter","cm"): + elif unit in ("centimeters", "centimeter", "cm"): meter = numeric / 100 - elif unit in ("feet","foot","ft"): + elif unit in ("feet", "foot", "ft"): meter = numeric / 3.2808 elif unit in ("yards", "yard", "yd"): meter = numeric / (3.2808 * 3) @@ -86,7 +91,6 @@ def distance(bot, trigger): else: metric_part = '%sm' % meter - # Shit like this makes me hate being an American. inch = meter * 39.37 foot = int(inch) / 12 @@ -118,4 +122,3 @@ def distance(bot, trigger): stupid_part = ', '.join(parts) bot.reply('%s = %s' % (metric_part, stupid_part)) -