Skip to content

Commit

Permalink
feat: format telegram message (#66)
Browse files Browse the repository at this point in the history
* format telegram message

* bump

* fix
  • Loading branch information
cctdaniel authored May 16, 2024
1 parent 2a6dc76 commit c125d78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ignore_missing_imports = true

[tool.poetry]
name = "pyth-observer"
version = "0.2.3"
version = "0.2.4"
description = "Alerts and stuff"
authors = []
readme = "README.md"
Expand Down
10 changes: 9 additions & 1 deletion pyth_observer/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,17 @@ async def send(self):
telegram_api_url = (
f"https://api.telegram.org/bot{self.telegram_bot_token}/sendMessage"
)

formatted_message = ""
for key, value in text.items():
value_str = f"{value:.2f}%" if key == "deviation" else f"{value}"
formatted_message += (
f"*{key.capitalize().replace('_', ' ')}:* {value_str}\n"
)

message_data = {
"chat_id": chat_id,
"text": text,
"text": formatted_message,
"parse_mode": "Markdown",
}

Expand Down

0 comments on commit c125d78

Please sign in to comment.