fixed currency.py

This commit is contained in:
iou1name 2018-05-17 23:06:45 -04:00
parent ff4c71253c
commit 1a50e1e444
3 changed files with 6 additions and 11 deletions

View File

@ -29,17 +29,17 @@ def exchange(bot, trigger):
cur_to = cur_to.upper() cur_to = cur_to.upper()
cur_from = cur_from.upper() cur_from = cur_from.upper()
api_key = bot.config["currency"].get("api_key") api_key = bot.config.currency.api_key
url = URI.format(**{"API_KEY": api_key, "CUR_FROM": cur_from}) url = CUR_URI.format(**{"API_KEY": api_key, "CUR_FROM": cur_from})
res = requests.get(url, verify=True) res = requests.get(url, verify=True)
res.raise_for_status() res.raise_for_status()
data = res.json() data = res.json()
if data["result"] == "failed": if data["result"] == "error":
return bot.reply("Invalid input currency. Must be ISO 4217 compliant.") return bot.msg("Error: " + data["error"])
rate = data["rates"].get(cur_to) rate = data["rates"].get(cur_to)
if not rate: 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) new_amount = round(rate*amount, 2)
msg = f"\x0310{amount} {cur_from}\x03 = \x0312{new_amount} {cur_to}" msg = f"\x0310{amount} {cur_from}\x03 = \x0312{new_amount} {cur_to}"

View File

@ -2,8 +2,6 @@
""" """
Long live the Internet of Things! Long live the Internet of Things!
""" """
import time
import requests import requests
import module import module
@ -35,9 +33,6 @@ def roomTemp(bot, trigger):
""" """
try: try:
res = requests.get("http://192.168.1.25/", timeout=10) 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: except requests.exceptions.ReadTimeout:
return bot.say("Connection error. Timeout reached.") return bot.say("Connection error. Timeout reached.")
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:

View File

@ -155,7 +155,7 @@ def pickMovie(bot, trigger):
movieInfo(bot, trigger) movieInfo(bot, trigger)
# @require_admin @require_admin
@commands('addmovie') @commands('addmovie')
@example('.addmovie Gay Niggers From Outer Space') @example('.addmovie Gay Niggers From Outer Space')
def addMovie(bot, trigger): def addMovie(bot, trigger):