Make <url> a Factoid post-processor. This allows us to use text-web-api-things that are sightly more dynamic
This commit is contained in:
parent
2089a53c50
commit
0e6e744605
1 changed files with 6 additions and 6 deletions
|
@ -136,12 +136,6 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
||||||
variables = 'input="""%s"""; nick="%s"; chan="%s"; bot_nick="%s";' % (arguments.replace('"', '\\"'),
|
variables = 'input="""%s"""; nick="%s"; chan="%s"; bot_nick="%s";' % (arguments.replace('"', '\\"'),
|
||||||
input.nick, input.chan, input.conn.nick)
|
input.nick, input.chan, input.conn.nick)
|
||||||
result = execute.eval_py(variables + code)
|
result = execute.eval_py(variables + code)
|
||||||
elif data.startswith("<url>"):
|
|
||||||
url = data[5:].strip()
|
|
||||||
try:
|
|
||||||
result = http.get(url)
|
|
||||||
except http.HttpError:
|
|
||||||
result = "Could not fetch URL."
|
|
||||||
else:
|
else:
|
||||||
result = data
|
result = data
|
||||||
|
|
||||||
|
@ -151,6 +145,12 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
|
||||||
if result.startswith("<act>"):
|
if result.startswith("<act>"):
|
||||||
result = result[5:].strip()
|
result = result[5:].strip()
|
||||||
me(result)
|
me(result)
|
||||||
|
elif result.startswith("<url>"):
|
||||||
|
url = result[5:].strip()
|
||||||
|
try:
|
||||||
|
say(http.get(url))
|
||||||
|
except http.HttpError:
|
||||||
|
say("Could not fetch URL.")
|
||||||
else:
|
else:
|
||||||
if prefix_on:
|
if prefix_on:
|
||||||
say("\x02[%s]:\x02 %s" % (factoid_id, result))
|
say("\x02[%s]:\x02 %s" % (factoid_id, result))
|
||||||
|
|
Reference in a new issue