Add link to etherscan in block notifications
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
1f621be8be
commit
79397e2eb6
3 changed files with 6 additions and 4 deletions
|
@ -16,6 +16,7 @@ class LastBlock:
|
||||||
self._exchange_rate = exchange_rate
|
self._exchange_rate = exchange_rate
|
||||||
self._currency = currency
|
self._currency = currency
|
||||||
block = self.get_last_block()
|
block = self.get_last_block()
|
||||||
|
self.hash = block.hash
|
||||||
self.number = block.number
|
self.number = block.number
|
||||||
self.time = block.time
|
self.time = block.time
|
||||||
self.raw_reward = block.total_rewards
|
self.raw_reward = block.total_rewards
|
||||||
|
|
4
main.py
4
main.py
|
@ -48,7 +48,7 @@ def watch_block(config, disable_notifications, last_block=None, exchange_rate=No
|
||||||
|
|
||||||
if not disable_notifications and config.get('telegram'):
|
if not disable_notifications and config.get('telegram'):
|
||||||
logger.debug('sending block notification to telegram')
|
logger.debug('sending block notification to telegram')
|
||||||
variables = {'number': block.number, 'time': block.time, 'reward': block.reward,
|
variables = {'hash': block.hash, 'number': block.number, 'time': block.time, 'reward': block.reward,
|
||||||
'reward_fiat': block.reward_fiat, 'round_time': block.round_time, 'luck': block.luck}
|
'reward_fiat': block.reward_fiat, 'round_time': block.round_time, 'luck': block.luck}
|
||||||
payload = telegram.create_block_payload(chat_id=config['telegram']['chat_id'], message_variables=variables)
|
payload = telegram.create_block_payload(chat_id=config['telegram']['chat_id'], message_variables=variables)
|
||||||
try:
|
try:
|
||||||
|
@ -56,7 +56,7 @@ def watch_block(config, disable_notifications, last_block=None, exchange_rate=No
|
||||||
logger.info('block notification sent to telegram')
|
logger.info('block notification sent to telegram')
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
logger.error('failed to send notification to telegram')
|
logger.error('failed to send notification to telegram')
|
||||||
logger.debug(str(err))
|
logger.exception(err)
|
||||||
|
|
||||||
return block
|
return block
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
*⛏️ New block {{number}}*
|
*⛏️ New block*
|
||||||
|
|
||||||
*Date/Time*: {{time}}
|
*Number*: [{{number}}](https://etherscan.io/block/{{hash}})
|
||||||
*Reward*: {{reward}} {% if reward_fiat != 'None' %}\({{reward_fiat}}\){% endif %}
|
*Reward*: {{reward}} {% if reward_fiat != 'None' %}\({{reward_fiat}}\){% endif %}
|
||||||
|
*Date/Time*: {{time}}
|
||||||
*Round time*: {{round_time}}
|
*Round time*: {{round_time}}
|
||||||
*Luck*: {{luck}}
|
*Luck*: {{luck}}
|
||||||
|
|
Reference in a new issue