alias .btc to '.coin btc'
This commit is contained in:
parent
1e4e919910
commit
6256a2dc78
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user