TelegramOperator¶
使用 TelegramOperator
來發送訊息到 Telegram 群組或特定聊天室。
使用 Operator (運算子)¶
使用 telegram_conn_id
參數來連線到 Telegram 用戶端,其連線 metadata (元數據) 結構如下
參數 |
輸入 |
---|---|
Password: string (字串) |
Telegram Bot API Token (Telegram 機器人 API 令牌) |
Host: string (字串) |
Telegram 群組/聊天室的 Chat ID (聊天室 ID) |
Connection Type: string (字串) |
telegram 作為連線類型 |
以下是 TelegramOperator 的使用範例
send_message_telegram_task = TelegramOperator(
task_id="send_message_telegram",
telegram_conn_id=CONN_ID,
chat_id=CHAT_ID,
text="Hello from Airflow!",
dag=dag,
)
注意
可以傳遞給 operator (運算子) 的參數將優先於 Airflow 連線 metadata (元數據) 中已給定的參數 (例如 Host
、Password
等等)。