From 256592b79f12cc5b19bf6cc82ea644204cb3ce41 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sat, 5 Oct 2013 16:20:37 -0700 Subject: [PATCH] add help for a bunch of modules --- modules/bitcoin.py | 3 +++ modules/botfun.py | 4 ++++ modules/botsnack.py | 1 + modules/catfacts.py | 4 +++- modules/imdb.py | 39 +++++++++++++++++++++------------------ modules/mylife.py | 2 +- modules/nsfw.py | 1 + modules/slogan.py | 2 ++ modules/vtluugwiki.py | 3 ++- modules/wikipedia.py | 2 ++ modules/wiktionary.py | 2 ++ modules/wuvt.py | 4 +++- 12 files changed, 45 insertions(+), 22 deletions(-) diff --git a/modules/bitcoin.py b/modules/bitcoin.py index 51cd5da..524965c 100644 --- a/modules/bitcoin.py +++ b/modules/bitcoin.py @@ -9,6 +9,9 @@ import web def bitcoin(phenny, input): + """.bitcoin [ - Convert an + arbitrary amount of some currency to or from Bitcoin.""" + amount = input.group(2) currency = input.group(3) diff --git a/modules/botfun.py b/modules/botfun.py index 64700be..a06c1f7 100644 --- a/modules/botfun.py +++ b/modules/botfun.py @@ -9,6 +9,8 @@ import random otherbot = "truncatedcone" def botfight(phenny, input): + """.botfight - Fight the other bot in the channel.""" + messages = ["hits %s", "punches %s", "kicks %s", "hits %s with a rubber hose", "stabs %s with a clean kitchen knife"] response = random.choice(messages) @@ -17,6 +19,8 @@ botfight.commands = ['botfight'] botfight.priority = 'low' def bothug(phenny, input): + """.bothug - Hug the other bot in the channel.""" + phenny.do("hugs %s" % otherbot) bothug.commands = ['bothug'] bothug.priority = 'low' diff --git a/modules/botsnack.py b/modules/botsnack.py index d953f2d..485eabe 100644 --- a/modules/botsnack.py +++ b/modules/botsnack.py @@ -36,6 +36,7 @@ def decrease_hunger(current_hunger, food_value): return current_hunger + food_value def botsnack(phenny, input): + """.botsnack - Feed me a bot snack.""" now = time.time() diff --git a/modules/catfacts.py b/modules/catfacts.py index baea709..71bc695 100644 --- a/modules/catfacts.py +++ b/modules/catfacts.py @@ -18,7 +18,9 @@ def catfacts_get(): return False def catfacts(phenny, input): + """.catfact - Receive a cat fact.""" + fact = catfacts_get() if fact: phenny.reply(fact) -catfacts.commands = ['catfacts'] +catfacts.commands = ['catfact', 'catfacts'] diff --git a/modules/imdb.py b/modules/imdb.py index cdba5f4..e49dfa7 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -12,26 +12,29 @@ import web def imdb_search(query): - query = query.replace('!', '') - query = query.encode('utf-8') - query = web.quote(query) - uri = 'http://www.omdbapi.com/?i=&t=%s' % query - bytes = web.get(uri) - m = json.loads(bytes) - return m + query = query.replace('!', '') + query = query.encode('utf-8') + query = web.quote(query) + uri = 'http://www.omdbapi.com/?i=&t=%s' % query + bytes = web.get(uri) + m = json.loads(bytes) + return m + def imdb(phenny, input): - query = input.group(2) - if not query: - return phenny.say('.imdb what?') + """.imdb - Use the OMDB API to find a link to a movie on IMDb.""" - m = imdb_search(query) - try: - phenny.say('{0} ({1}): {2} http://imdb.com/title/{3}'.format( - m['Title'], - m['Year'], - m['Plot'], - m['imdbID'])) - except: + query = input.group(2) + if not query: + return phenny.say('.imdb what?') + + m = imdb_search(query) + try: + phenny.say('{0} ({1}): {2} http://imdb.com/title/{3}'.format( + m['Title'], + m['Year'], + m['Plot'], + m['imdbID'])) + except: phenny.reply("No results found for '%s'." % query) imdb.commands = ['imdb'] diff --git a/modules/mylife.py b/modules/mylife.py index d1c5653..3fbbdb3 100644 --- a/modules/mylife.py +++ b/modules/mylife.py @@ -11,7 +11,7 @@ import lxml.html def fml(phenny, input): - """.fml""" + """.fml - Grab something from fmylife.com.""" try: req = web.get("http://www.fmylife.com/random") except: diff --git a/modules/nsfw.py b/modules/nsfw.py index 021086e..914beb1 100644 --- a/modules/nsfw.py +++ b/modules/nsfw.py @@ -5,6 +5,7 @@ author: Casey Link - Mark a link (or some text) as being not safe for work.""" link = input.group(2) if not link: phenny.say(".nsfw - for when a link isn't safe for work") diff --git a/modules/slogan.py b/modules/slogan.py index 37768fb..ac421b9 100644 --- a/modules/slogan.py +++ b/modules/slogan.py @@ -17,6 +17,8 @@ def sloganize(word): return bytes def slogan(phenny, input): + """.slogan - Come up with a slogan for a term.""" + word = input.group(2) if word is None: phenny.say("You need to specify a word; try .slogan Granola") diff --git a/modules/vtluugwiki.py b/modules/vtluugwiki.py index d9705a7..12a3d36 100644 --- a/modules/vtluugwiki.py +++ b/modules/vtluugwiki.py @@ -20,6 +20,8 @@ wikisearch = 'https://vtluug.org/wiki/Special:Search?' \ + 'search={0}&fulltext=Search' def vtluug(phenny, input): + """.vtluug - Look up something on the VTLUUG wiki.""" + origterm = input.groups()[1] if not origterm: return phenny.say('Perhaps you meant ".vtluug VT-Wireless"?') @@ -40,7 +42,6 @@ def vtluug(phenny, input): phenny.say(result) else: phenny.say('Can\'t find anything in the VTLUUG Wiki for "{0}".'.format(origterm)) - vtluug.commands = ['vtluug'] vtluug.priority = 'high' diff --git a/modules/wikipedia.py b/modules/wikipedia.py index aa45c8f..8dbe6f4 100644 --- a/modules/wikipedia.py +++ b/modules/wikipedia.py @@ -17,6 +17,8 @@ wikisearch = 'https://en.wikipedia.org/wiki/Special:Search?' \ + 'search={0}&fulltext=Search' def wik(phenny, input): + """.wik - Look up something on Wikipedia.""" + origterm = input.groups()[1] if not origterm: return phenny.say('Perhaps you meant ".wik Zen"?') diff --git a/modules/wiktionary.py b/modules/wiktionary.py index 6f08bae..8770d1d 100644 --- a/modules/wiktionary.py +++ b/modules/wiktionary.py @@ -90,6 +90,8 @@ def format(word, definitions, number=2): return result.strip(' .,') def w(phenny, input): + """.w - Get the definition of a word from wiktionary.""" + if not input.group(2): return phenny.reply("Nothing to define.") word = input.group(2) diff --git a/modules/wuvt.py b/modules/wuvt.py index c18675f..58b4f8c 100644 --- a/modules/wuvt.py +++ b/modules/wuvt.py @@ -14,7 +14,9 @@ re.MULTILINE r_play = re.compile(r'^(.*?) - (.*?)$') r_dj = re.compile(r'Current DJ: \n(.+?)<') -def wuvt(phenny, input) : +def wuvt(phenny, input): + """.wuvt - Find out what is currently playing on the radio station WUVT.""" + try: playing = web.get('http://www.wuvt.vt.edu/playlists/latest_track.php') djpage = web.get('http://www.wuvt.vt.edu/playlists/current_dj.php')