docstring snopes, don't respond to "<botnick> <command>" (can still do "<botnick>: <command>", PEP8

This commit is contained in:
Ryan Hitchman 2010-11-11 23:18:32 -06:00
parent 98709ab40c
commit bc05053d8a
4 changed files with 11 additions and 8 deletions

View File

@ -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)

View File

@ -26,7 +26,8 @@ def seeninput(paraml, input=None, db=None, bot=None):
def seen(inp, nick='', chan='', db=None, input=None):
".seen <nick> -- 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():

View File

@ -8,6 +8,8 @@ search_url = "http://search.atomz.com/search/?sp_a=00062d45-sp00000000"
@hook.command
def snopes(inp):
".snopes <topic> -- searches snopes for an urban legend about <topic>"
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])

View File

@ -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):