airflow.providers.telegram.hooks.telegram¶
Telegram Hook。
类¶
此 Hook 允许您使用 telegram python-telegram-bot 库向 Telegram 发布消息。 |
模块内容¶
- class airflow.providers.telegram.hooks.telegram.TelegramHook(telegram_conn_id=default_conn_name, token=None, chat_id=None)[source]¶
基类:
airflow.hooks.base.BaseHook
此 Hook 允许您使用 telegram python-telegram-bot 库向 Telegram 发布消息。
此库可以在这里找到: https://github.com/python-telegram-bot/python-telegram-bot 它既接受 Telegram 机器人 API 令牌,也接受包含 Telegram 机器人 API 令牌的连接。如果两者都提供,token 参数将优先使用,否则将使用来自 telegram_conn_id 连接中的 'password' 字段。chat_id 也可以通过连接中的 'host' 字段提供。以下是 telegram_connection 的详细信息: name: 'telegram-connection-name' conn_type: 'telegram' password: 'TELEGRAM_TOKEN' (可选) host: 'chat_id' (可选) 示例: .. code-block:: python
# 创建 hook telegram_hook = TelegramHook(telegram_conn_id=”telegram_default”) telegram_hook = TelegramHook() # 将使用 telegram_default # 或者 telegram_hook = TelegramHook(telegram_conn_id=’telegram_default’, chat_id=’-1xxx’) # 或者 telegram_hook = TelegramHook(token=’xxx:xxx’, chat_id=’-1xxx’)
# 调用 telegram bot client 的方法 telegram_hook.send_message(None, {“text”: “message”, “chat_id”: “-1xxx”}) # 或者 telegram_hook.send_message(None’, {“text”: “message”})
- 参数: