mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-15 06:55:48 +00:00
change telegram default index to telegram-index
This commit is contained in:
@ -38,6 +38,7 @@ class Telegram(Report, JinjaTemplate):
|
||||
:ivar api_key: bot api key
|
||||
:ivar chat_id: chat id to post message, either string with @ or integer
|
||||
:ivar template_path: path to template for built packages
|
||||
:ivar template_type: template message type to be used in parse mode, one of MarkdownV2, HTML, Markdown
|
||||
"""
|
||||
|
||||
TELEGRAM_API_URL = "https://api.telegram.org"
|
||||
@ -56,6 +57,7 @@ class Telegram(Report, JinjaTemplate):
|
||||
self.api_key = configuration.get(section, "api_key")
|
||||
self.chat_id = configuration.get(section, "chat_id")
|
||||
self.template_path = configuration.getpath(section, "template_path")
|
||||
self.template_type = configuration.get(section, "template_type", fallback="HTML")
|
||||
|
||||
def _send(self, text: str) -> None:
|
||||
"""
|
||||
@ -65,7 +67,7 @@ class Telegram(Report, JinjaTemplate):
|
||||
try:
|
||||
response = requests.post(
|
||||
f"{self.TELEGRAM_API_URL}/bot{self.api_key}/sendMessage",
|
||||
data={"chat_id": self.chat_id, "text": text})
|
||||
data={"chat_id": self.chat_id, "text": text, "parse_mode": self.template_type})
|
||||
response.raise_for_status()
|
||||
except requests.HTTPError as e:
|
||||
self.logger.exception("could not perform request: %s", exception_response_text(e))
|
||||
|
Reference in New Issue
Block a user