diff --git a/modules/crypto.py b/modules/crypto.py index 98a7019..4ee73e4 100755 --- a/modules/crypto.py +++ b/modules/crypto.py @@ -53,3 +53,12 @@ def crypto(bot, trigger): msg += f"\x0310Total Market Cap\x03: \x0308" msg += re.sub(r'(^.+\.\d\d).*', r'\1', data['total_market_cap']) + "\x03" bot.msg(msg) + + +@commands('btc', 'bitcoin') +def bitcoin(bot, trigger): + """ + An alias for ".coin btc". + """ + trigger.args = ".coin btc".split() + crypto(bot, trigger) diff --git a/modules/currency.py b/modules/currency.py index 75ea0d7..f96715a 100755 --- a/modules/currency.py +++ b/modules/currency.py @@ -49,26 +49,29 @@ def exchange(bot, trigger): bot.msg(msg) -@commands('btc', 'bitcoin') -@example('.btc EUR') -def bitcoin(bot, trigger): - """ - Show the current bitcoin value in USD. Optional parameter allows non-USD - conversion. - """ - if len(trigger.args) < 2: - cur_to = "USD" - else: - cur_to = trigger.args[1] - cur_to = cur_to.upper() +# coindesk changed their api and now i don't understand it, so this function +# is deprecated. - url = BTC_URI.format(**{"CUR_TO": cur_to}) - res = requests.get(url, verify=True) - - if res.text.startswith("Sorry"): - return bot.reply("Invalid currency type. Must be ISO 4217 compliant.") - data = res.json() - - rate = data["bpi"][cur_to]["rate_float"] - msg = f"\x03101 BTC\x03 = \x0312{rate} {cur_to}" - bot.msg(msg) +#@commands('btc', 'bitcoin') +#@example('.btc EUR') +#def bitcoin(bot, trigger): +# """ +# Show the current bitcoin value in USD. Optional parameter allows non-USD +# conversion. +# """ +# if len(trigger.args) < 2: +# cur_to = "USD" +# else: +# cur_to = trigger.args[1] +# cur_to = cur_to.upper() +# +# url = BTC_URI.format(**{"CUR_TO": cur_to}) +# res = requests.get(url, verify=True) +# +# if res.text.startswith("Sorry"): +# return bot.reply("Invalid currency type. Must be ISO 4217 compliant.") +# data = res.json() +# +# rate = data["bpi"][cur_to]["rate_float"] +# msg = f"\x03101 BTC\x03 = \x0312{rate} {cur_to}" +# bot.msg(msg)