forked from coccoinomane/web3cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_controller.py
More file actions
30 lines (25 loc) · 975 Bytes
/
Copy pathdebug_controller.py
File metadata and controls
30 lines (25 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from cement import ex
from web3cli.framework.controller import Controller
from web3cli.helpers.render import render
from web3cli.helpers.telegram import send_tg_message
class DebugController(Controller):
"""Handler for commands used for debugging purposes"""
class Meta:
label = "debug"
help = "Commands used for debugging purposes"
stacked_type = "nested"
stacked_on = "base"
hide = True
@ex(
help="Send a Telegram message to the configured chat. Useful for testing notifications.",
arguments=[
(["--message"], {"default": "Hello world 🤗"}),
(["--chat"], {"action": "store"}),
],
)
def telegram(self) -> None:
chat_id = self.app.pargs.chat or self.app.get_option("telegram_chat_id")
if send_tg_message(self.app, self.app.pargs.message, chat_id):
render(self.app, "Ok ✅")
else:
render(self.app, "Error ❌")