Skip to content

Commit

Permalink
📝 chore: the telegram alarm message now is inside of pre & code tags
Browse files Browse the repository at this point in the history
  • Loading branch information
metalpoch committed Nov 11, 2024
1 parent 3fe3c8b commit e007c03
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions smart/src/libs/tracking.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
from datetime import datetime

import requests


class Telegram:
def __init__(self, bot_id: str, chat_id: str) -> None:
def __init__(
self, bot_id: str, chat_id: str, disable_notification: bool = True
) -> None:
self.chat_id = chat_id
self.bot_id = bot_id
self.disable_notification = disable_notification

def __send_message_payload(
self, module: str, category: str, event: str, msg: str
) -> dict[str, str | bool]:
text = f"""<b>Tracker Error</b>
text = f"""<pre><code class="language-Tracker Error">
📅 Date: {datetime.now().strftime("%d/%m/%Y %H:%M:%S")}
<b>🧩 Module:</b> {module}
🧩 Module: {module}
<b>🗃 Category:</b> {category}
🗃 Category: {category}
<b>⚠ Event:</b> {event}
💬 Message: {msg}
<b>💬 Message:</b> {msg}"""
⚠ Event: {event}</code></pre>"""

return {
"text": text,
"parse_mode": "HTML",
"chat_id": self.chat_id,
"disable_web_page_preview": True,
"disable_notification": self.disable_notification,
}

def send_message(self, module: str, category: str, event: str, msg: str) -> dict:
Expand Down

0 comments on commit e007c03

Please sign in to comment.