docstring snopes, don't respond to "<botnick> <command>" (can still do "<botnick>: <command>", PEP8
This commit is contained in:
parent
98709ab40c
commit
bc05053d8a
|
@ -156,7 +156,7 @@ def main(conn, out):
|
||||||
prefix = r'^(?:[.]|'
|
prefix = r'^(?:[.]|'
|
||||||
|
|
||||||
command_re = prefix + inp.conn.nick
|
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)
|
m = re.match(command_re, inp.lastparam)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ def seeninput(paraml, input=None, db=None, bot=None):
|
||||||
def seen(inp, nick='', chan='', db=None, input=None):
|
def seen(inp, nick='', chan='', db=None, input=None):
|
||||||
".seen <nick> -- Tell when a nickname was last in active in irc"
|
".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."
|
return "You need to get your eyes checked."
|
||||||
|
|
||||||
if inp.lower() == nick.lower():
|
if inp.lower() == nick.lower():
|
||||||
|
|
|
@ -8,6 +8,8 @@ search_url = "http://search.atomz.com/search/?sp_a=00062d45-sp00000000"
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def snopes(inp):
|
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")
|
search_page = http.get_html(search_url, sp_q=inp, sp_c="1")
|
||||||
result_urls = search_page.xpath("//a[@target='_self']/@href")
|
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
|
claim = re.sub(r"[\s\xa0]+", " ", claim) # compress whitespace
|
||||||
status = re.sub(r"[\s\xa0]+", " ", status)
|
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])
|
||||||
|
|
|
@ -39,10 +39,10 @@ def get_json(*args, **kwargs):
|
||||||
|
|
||||||
def open(url, query_params=None, user_agent=user_agent, post_data=None,
|
def open(url, query_params=None, user_agent=user_agent, post_data=None,
|
||||||
get_method=None, cookies=False, **kwargs):
|
get_method=None, cookies=False, **kwargs):
|
||||||
|
|
||||||
if query_params is None:
|
if query_params is None:
|
||||||
query_params = {}
|
query_params = {}
|
||||||
|
|
||||||
query_params.update(kwargs)
|
query_params.update(kwargs)
|
||||||
|
|
||||||
url = prepare_url(url, query_params)
|
url = prepare_url(url, query_params)
|
||||||
|
@ -77,10 +77,10 @@ def prepare_url(url, queries):
|
||||||
|
|
||||||
|
|
||||||
def to_utf8(s):
|
def to_utf8(s):
|
||||||
if isinstance(s, str):
|
if isinstance(s, unicode):
|
||||||
return s
|
|
||||||
else:
|
|
||||||
return s.encode('utf8', 'ignore')
|
return s.encode('utf8', 'ignore')
|
||||||
|
else:
|
||||||
|
return str(s)
|
||||||
|
|
||||||
|
|
||||||
def quote_plus(s):
|
def quote_plus(s):
|
||||||
|
|
Loading…
Reference in New Issue