Skip to content

Commit c125d78

Browse files
authored
feat: format telegram message (#66)
* format telegram message * bump * fix
1 parent 2a6dc76 commit c125d78

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ignore_missing_imports = true
44

55
[tool.poetry]
66
name = "pyth-observer"
7-
version = "0.2.3"
7+
version = "0.2.4"
88
description = "Alerts and stuff"
99
authors = []
1010
readme = "README.md"

pyth_observer/event.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,17 @@ async def send(self):
128128
telegram_api_url = (
129129
f"https://api.telegram.org/bot{self.telegram_bot_token}/sendMessage"
130130
)
131+
132+
formatted_message = ""
133+
for key, value in text.items():
134+
value_str = f"{value:.2f}%" if key == "deviation" else f"{value}"
135+
formatted_message += (
136+
f"*{key.capitalize().replace('_', ' ')}:* {value_str}\n"
137+
)
138+
131139
message_data = {
132140
"chat_id": chat_id,
133-
"text": text,
141+
"text": formatted_message,
134142
"parse_mode": "Markdown",
135143
}
136144

0 commit comments

Comments
 (0)