Copilot commented on code in PR #44040:
URL: https://github.com/apache/airflow/pull/44040#discussion_r1845243816
##########
providers/src/airflow/providers/telegram/hooks/telegram.py:
##########
@@ -158,3 +158,31 @@ def send_message(self, api_params: dict) -> None:
response = asyncio.run(self.connection.send_message(**kwargs))
self.log.debug(response)
+
+ @tenacity.retry(
+ retry=tenacity.retry_if_exception_type(telegram.error.TelegramError),
+ stop=tenacity.stop_after_attempt(5),
+ wait=tenacity.wait_fixed(1),
+ )
+ def send_file(self, api_params: dict) -> None:
+ """
+ Send the file to a telegram channel or chat.
+
+ :param api_params: params for telegram_instance.send_document. It can
also be used to override chat_id
+ """
+ kwargs: dict[str, Any] = {}
+
+ if self.chat_id is not None:
+ kwargs["chat_id"] = self.chat_id
+ kwargs.update(api_params)
+
+ if "file" not in kwargs or kwargs["file"] is None:
+ raise AirflowException("'file' must be provided for telegram
document message")
Review Comment:
'file' parameter must be provided for sending a Telegram document message
```suggestion
raise AirflowException("'file' parameter must be provided for
sending a Telegram document message")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]