From bc05053d8a5d72bfa2c9e21528f896c6c29a3998 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Thu, 11 Nov 2010 23:18:32 -0600 Subject: [PATCH] docstring snopes, don't respond to " " (can still do ": ", PEP8 --- core/main.py | 2 +- plugins/seen.py | 3 ++- plugins/snopes.py | 4 +++- plugins/util/http.py | 10 +++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/main.py b/core/main.py index 883effd..6dc35b3 100644 --- a/core/main.py +++ b/core/main.py @@ -156,7 +156,7 @@ def main(conn, out): prefix = r'^(?:[.]|' command_re = prefix + inp.conn.nick - command_re += r'[:,]*\s+)(\w+)(?:$|\s+)(.*)' + command_re += r'[:,]+\s+)(\w+)(?:$|\s+)(.*)' m = re.match(command_re, inp.lastparam) diff --git a/plugins/seen.py b/plugins/seen.py index ca7a98a..3fdbf9d 100644 --- a/plugins/seen.py +++ b/plugins/seen.py @@ -26,7 +26,8 @@ def seeninput(paraml, input=None, db=None, bot=None): def seen(inp, nick='', chan='', db=None, input=None): ".seen -- Tell when a nickname was last in active in irc" - if input.conn.nick.lower() == inp.lower(): # user is looking for us, being a smartass + if input.conn.nick.lower() == inp.lower(): + # user is looking for us, being a smartass return "You need to get your eyes checked." if inp.lower() == nick.lower(): diff --git a/plugins/snopes.py b/plugins/snopes.py index a3caff1..abfa10c 100644 --- a/plugins/snopes.py +++ b/plugins/snopes.py @@ -8,6 +8,8 @@ search_url = "http://search.atomz.com/search/?sp_a=00062d45-sp00000000" @hook.command def snopes(inp): + ".snopes -- searches snopes for an urban legend about " + search_page = http.get_html(search_url, sp_q=inp, sp_c="1") result_urls = search_page.xpath("//a[@target='_self']/@href") @@ -23,4 +25,4 @@ def snopes(inp): claim = re.sub(r"[\s\xa0]+", " ", claim) # compress whitespace status = re.sub(r"[\s\xa0]+", " ", status) - return "%s %s %s" % (claim, status, result_urls[0]) + return "%s %s %s" % (claim, status, result_urls[0]) diff --git a/plugins/util/http.py b/plugins/util/http.py index cca70a8..4f8181d 100644 --- a/plugins/util/http.py +++ b/plugins/util/http.py @@ -39,10 +39,10 @@ def get_json(*args, **kwargs): def open(url, query_params=None, user_agent=user_agent, post_data=None, get_method=None, cookies=False, **kwargs): - + if query_params is None: query_params = {} - + query_params.update(kwargs) url = prepare_url(url, query_params) @@ -77,10 +77,10 @@ def prepare_url(url, queries): def to_utf8(s): - if isinstance(s, str): - return s - else: + if isinstance(s, unicode): return s.encode('utf8', 'ignore') + else: + return str(s) def quote_plus(s):