From 79397e2eb6d27dde112cf48efe9ff5f56fef3a2b Mon Sep 17 00:00:00 2001 From: Julien Riou Date: Tue, 26 Jan 2021 07:46:04 +0100 Subject: [PATCH] Add link to etherscan in block notifications Signed-off-by: Julien Riou --- flexpool.py | 1 + main.py | 4 ++-- templates/block.md.j2 | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/flexpool.py b/flexpool.py index 9e3ea0d..6465866 100644 --- a/flexpool.py +++ b/flexpool.py @@ -16,6 +16,7 @@ class LastBlock: self._exchange_rate = exchange_rate self._currency = currency block = self.get_last_block() + self.hash = block.hash self.number = block.number self.time = block.time self.raw_reward = block.total_rewards diff --git a/main.py b/main.py index 10cb56d..41394e1 100644 --- a/main.py +++ b/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'): 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} payload = telegram.create_block_payload(chat_id=config['telegram']['chat_id'], message_variables=variables) try: @@ -56,7 +56,7 @@ def watch_block(config, disable_notifications, last_block=None, exchange_rate=No logger.info('block notification sent to telegram') except HTTPError as err: logger.error('failed to send notification to telegram') - logger.debug(str(err)) + logger.exception(err) return block diff --git a/templates/block.md.j2 b/templates/block.md.j2 index 0af6e15..1be4ec6 100644 --- a/templates/block.md.j2 +++ b/templates/block.md.j2 @@ -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 %} +*Date/Time*: {{time}} *Round time*: {{round_time}} *Luck*: {{luck}}