From 1a50e1e4449c844e19a94968a6cbbfb24958fcb9 Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 17 May 2018 23:06:45 -0400 Subject: [PATCH] fixed currency.py --- modules/currency.py | 10 +++++----- modules/iot.py | 5 ----- modules/movie.py | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/currency.py b/modules/currency.py index a6e5db1..b0f41ff 100755 --- a/modules/currency.py +++ b/modules/currency.py @@ -29,17 +29,17 @@ def exchange(bot, trigger): cur_to = cur_to.upper() cur_from = cur_from.upper() - api_key = bot.config["currency"].get("api_key") - url = URI.format(**{"API_KEY": api_key, "CUR_FROM": cur_from}) + api_key = bot.config.currency.api_key + url = CUR_URI.format(**{"API_KEY": api_key, "CUR_FROM": cur_from}) res = requests.get(url, verify=True) res.raise_for_status() data = res.json() - if data["result"] == "failed": - return bot.reply("Invalid input currency. Must be ISO 4217 compliant.") + if data["result"] == "error": + return bot.msg("Error: " + data["error"]) rate = data["rates"].get(cur_to) if not rate: - return bot.reply("Invalid output currency. Must be ISO 4217 compliant.") + return bot.msg("Invalid output currency. Must be ISO 4217 compliant.") new_amount = round(rate*amount, 2) msg = f"\x0310{amount} {cur_from}\x03 = \x0312{new_amount} {cur_to}" diff --git a/modules/iot.py b/modules/iot.py index fb8354f..ca4aaef 100755 --- a/modules/iot.py +++ b/modules/iot.py @@ -2,8 +2,6 @@ """ Long live the Internet of Things! """ -import time - import requests import module @@ -35,9 +33,6 @@ def roomTemp(bot, trigger): """ try: res = requests.get("http://192.168.1.25/", timeout=10) - del res - time.sleep(1.5) - res = requests.get("http://192.168.1.25/", timeout=10) except requests.exceptions.ReadTimeout: return bot.say("Connection error. Timeout reached.") except requests.exceptions.ConnectionError: diff --git a/modules/movie.py b/modules/movie.py index 1395c84..2dbfdce 100755 --- a/modules/movie.py +++ b/modules/movie.py @@ -155,7 +155,7 @@ def pickMovie(bot, trigger): movieInfo(bot, trigger) -# @require_admin +@require_admin @commands('addmovie') @example('.addmovie Gay Niggers From Outer Space') def addMovie(bot, trigger):