1
0
Fork 0

Make fiat currency optional

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-01-25 13:08:01 +01:00
parent bd204d6b7a
commit 792a068792
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
4 changed files with 11 additions and 11 deletions

View file

@ -22,7 +22,7 @@ bot. You'll need the `chat_id` and `auth_key` for the next section.
Configuration file use the JSON format with the following keys:
* `miner`: wallet address of the miner
* `currency`: symbol of the currency to convert (default: USD)
* `currency`: symbol of the currency to convert (optional)
* `telegram`: send notifications with Telegram (optional)
* `auth_key`: Telegram authentication key for the bot API
* `chat_id`: Telegram chat room id (where to send the message)

16
main.py
View file

@ -13,7 +13,6 @@ logger = logging.getLogger(__name__)
DEFAULT_STATE_FILE = 'state.json'
DEFAULT_CURRENCY = 'USD'
def parse_arguments():
@ -104,14 +103,15 @@ def main():
state = read_state(state_file)
exchange_rate = None
currency = config.get('currency', DEFAULT_CURRENCY)
currency = config.get('currency')
logger.debug('fetching current rate')
try:
exchange_rate = get_rate(ids='ethereum', vs_currencies=currency)
except HTTPError as err:
logger.warning(f'failed to get ETH/{currency} rate')
logger.debug(str(err))
if currency:
logger.debug('fetching current rate')
try:
exchange_rate = get_rate(ids='ethereum', vs_currencies=currency)
except HTTPError as err:
logger.warning(f'failed to get ETH/{currency} rate')
logger.debug(str(err))
block = watch_block(last_block=state.get('block'), config=config, disable_notifications=args.disable_notifications,
exchange_rate=exchange_rate, currency=currency)

View file

@ -1,5 +1,5 @@
*💰 New balance*
*Address*: {{address}}
*Unpaid balance*: {{balance}} {% if balance_fiat %}\({{balance_fiat}}\){% endif %}
*Unpaid balance*: {{balance}} {% if balance_fiat != 'None' %}\({{balance_fiat}}\){% endif %}
*Unpaid percentage*: {{balance_percentage}}

View file

@ -1,6 +1,6 @@
*⛏️ New block {{number}}*
*Date/Time*: {{time}}
*Reward*: {{reward}} {% if reward_fiat %}\({{reward_fiat}}\){% endif %}
*Reward*: {{reward}} {% if reward_fiat != 'None' %}\({{reward_fiat}}\){% endif %}
*Round time*: {{round_time}}
*Luck*: {{luck}}