Skip to content

Commit ca47ae4

Browse files
committed
Optionally disable telegram notifications
1 parent cd96e28 commit ca47ae4

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ where `settings.txt` is an environment file with [Settings](#settings).
9191
| NOTIFIERS_TELEGRAM_TOKEN | Telegram chat token where notifications about low balance or errors will be sent. | No | - |
9292
| NOTIFIERS_TELEGRAM_CHAT_ID | Telegram chat ID where notifications about low balance or errors will be sent. | No | - |
9393
| PROCESS_INTERVAL | How long to wait before processing again. | Yes | - |
94+
| SEND_TELEGRAM_NOTIFICATIONS | Defines whether to send telegram notifications about oracle balance and errors. | No | True |
9495

9596
## Example settings
9697

main.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
LOG_LEVEL,
2323
PROCESS_INTERVAL,
2424
BEACON_CHAIN_RPC_ENDPOINT,
25+
SEND_TELEGRAM_NOTIFICATIONS,
2526
)
2627
from src.utils import (
2728
get_web3_client,
@@ -66,15 +67,16 @@ def main() -> None:
6667
# wait for interrupt
6768
interrupt_handler = InterruptHandler()
6869

69-
# Notify Telegram the oracle is warming up, so that
70-
# oracle maintainers know the service has restarted
71-
telegram.notify(
72-
message=f"Oracle starting with account [{web3_client.eth.defaultAccount}]"
73-
f"(https://etherscan.io/address/{web3_client.eth.defaultAccount})",
74-
parse_mode="markdown",
75-
raise_on_errors=True,
76-
disable_web_page_preview=True,
77-
)
70+
if SEND_TELEGRAM_NOTIFICATIONS:
71+
# Notify Telegram the oracle is warming up, so that
72+
# oracle maintainers know the service has restarted
73+
telegram.notify(
74+
message=f"Oracle starting with account [{web3_client.eth.defaultAccount}]"
75+
f"(https://etherscan.io/address/{web3_client.eth.defaultAccount})",
76+
parse_mode="markdown",
77+
raise_on_errors=True,
78+
disable_web_page_preview=True,
79+
)
7880

7981
# wait that node is synced before trying to do anything
8082
wait_prysm_ready(interrupt_handler, BEACON_CHAIN_RPC_ENDPOINT, PROCESS_INTERVAL)
@@ -83,9 +85,10 @@ def main() -> None:
8385
w3=web3_client, interrupt_handler=interrupt_handler
8486
)
8587
# check oracle balance
86-
check_default_account_balance(
87-
web3_client, BALANCE_WARNING_THRESHOLD, BALANCE_ERROR_THRESHOLD
88-
)
88+
if SEND_TELEGRAM_NOTIFICATIONS:
89+
check_default_account_balance(
90+
web3_client, BALANCE_WARNING_THRESHOLD, BALANCE_ERROR_THRESHOLD
91+
)
8992

9093
while not interrupt_handler.exit:
9194
# update Reward Token total rewards

src/reward_token.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
ORACLES_CONTRACT_ADDRESS,
2525
BALANCE_WARNING_THRESHOLD,
2626
BALANCE_ERROR_THRESHOLD,
27+
SEND_TELEGRAM_NOTIFICATIONS,
2728
)
2829
from src.utils import (
2930
InterruptHandler,
@@ -307,6 +308,7 @@ def process(self) -> None:
307308
logger.info(f"Re-scheduling rewards update: next at={self.next_update_at}")
308309

309310
# check oracle balance
310-
check_default_account_balance(
311-
self.w3, BALANCE_WARNING_THRESHOLD, BALANCE_ERROR_THRESHOLD
312-
)
311+
if SEND_TELEGRAM_NOTIFICATIONS:
312+
check_default_account_balance(
313+
self.w3, BALANCE_WARNING_THRESHOLD, BALANCE_ERROR_THRESHOLD
314+
)

src/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
environ["STALE_CHECK_MIDDLEWARE_ALLOWABLE_DELAY"]
3232
)
3333

34+
# defines whether to enable sending telegram notifications
35+
SEND_TELEGRAM_NOTIFICATIONS: bool = environ.get(
36+
"SEND_TELEGRAM_NOTIFICATIONS", "True"
37+
) in ("True", "true")
38+
3439
# whether to retry http or ws requests
3540
INJECT_RETRY_REQUEST_MIDDLEWARE: bool = environ.get(
3641
"INJECT_RETRY_REQUEST_MIDDLEWARE", "False"

0 commit comments

Comments
 (0)