From 8c33af02aeed539ff463ccac28c5d1ec2f8b451b Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 10 Sep 2012 12:12:45 +1200 Subject: [PATCH] Update plugins/factoids.py --- plugins/factoids.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/factoids.py b/plugins/factoids.py index 06a185c..cdd0a15 100755 --- a/plugins/factoids.py +++ b/plugins/factoids.py @@ -132,16 +132,22 @@ def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None): data = get_memory(db, factoid_id) if data: - # if the factoid starts with , its a dynamic one + # factoid preprocessors if data.startswith(""): - data = data[4:].strip() + code = data[4:].strip() variables = 'input="""%s"""; nick="%s"; chan="%s"; bot_nick="%s";' % (arguments.replace('"', '\\"'), input.nick, input.chan, input.conn.nick) - result = eval_py(variables + data) - + result = eval_py(variables + code) + elif data.startswith(""): + url = data[5:].strip() + try: + result = http.get(url) + except http.HttpError: + result = "Could not fetch URL." else: result = data + # factoid postprocessors result = multiword_replace(result, shortcodes) if result.startswith(""):