Skip to content

Commit a258a39

Browse files
committed
Switch color formating to using colors.parse
1 parent ad08280 commit a258a39

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

plugins/cryptocurrency.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import requests
1616

1717
from cloudbot import hook
18+
from cloudbot.util import colors
1819

1920
API_URL = "https://api.coinmarketcap.com/v1/ticker/{}"
2021

@@ -96,9 +97,9 @@ def crypto_command(text):
9697

9798
change = float(data['percent_change_24h'])
9899
if change > 0:
99-
change_str = "\x033 {}%\x0f".format(change)
100+
change_str = "$(dark_green) {}%$(clear)".format(change)
100101
elif change < 0:
101-
change_str = "\x035 {}%\x0f".format(change)
102+
change_str = "$(dark_red) {}%$(clear)".format(change)
102103
else:
103104
change_str = "{}%".format(change)
104105

@@ -109,9 +110,7 @@ def crypto_command(text):
109110
except LookupError:
110111
return "Unable to convert to currency '{}'".format(currency)
111112

112-
return "{} // \x0307{}{:,.2f}\x0f {} - {:,.7f} BTC // {} change".format(data['symbol'],
113-
currency_sign,
114-
float(converted_value),
115-
currency.upper(),
116-
float(data['price_btc']),
117-
change_str)
113+
return colors.parse("{} // $(orange){}{:,.2f}$(clear) {} - {:,.7f} BTC // {} change".format(
114+
data['symbol'], currency_sign, float(converted_value), currency.upper(),
115+
float(data['price_btc']), change_str
116+
))

0 commit comments

Comments
 (0)