airflow.providers.discord.operators.discord_webhook¶
类¶
此 Operator 允许您使用传入的 Webhook 向 Discord 发送消息。 |
模块内容¶
- class airflow.providers.discord.operators.discord_webhook.DiscordWebhookOperator(*, http_conn_id=None, webhook_endpoint=None, message='', username=None, avatar_url=None, tts=False, proxy=None, **kwargs)[source]¶
基类:
airflow.providers.http.operators.http.HttpOperator
此 Operator 允许您使用传入的 Webhook 向 Discord 发送消息。
此 Operator 接受一个 Discord 连接 ID,其 extra 字段可以指定默认的相对 webhook endpoint。可以使用 webhook_endpoint 参数覆盖默认 endpoint (https://discordapp.com/developers/docs/resources/webhook)。
每个 Discord webhook 可以预先配置使用特定的 username 和 avatar_url。您可以在此 Operator 中覆盖这些默认设置。
- 参数:
http_conn_id (str | None) – http 连接 ID,其主机应为 “https://discord.com/api/”,并在 extra 字段中以 {'webhook_endpoint': 'webhooks/{webhook.id}/{webhook.token}'} 的形式指定默认 webhook endpoint
webhook_endpoint (str | None) – Discord webhook endpoint,形式为 “webhooks/{webhook.id}/{webhook.token}” (templated)
message (str) – 您希望发送到 Discord 频道的消息(最多 2000 个字符)。 (templated)
username (str | None) – 覆盖 webhook 的默认 username。 (templated)
avatar_url (str | None) – 覆盖 webhook 的默认 avatar
tts (bool) – 是否为文本转语音消息
proxy (str | None) – 用于进行 Discord webhook 调用的代理
- template_fields: collections.abc.Sequence[str] = ('username', 'message', 'webhook_endpoint')¶
- http_conn_id = None¶
- webhook_endpoint = None¶
- message = ''¶
- username = None¶
- avatar_url = None¶
- tts = False¶
- proxy = None¶
- property hook: airflow.providers.discord.hooks.discord_webhook.DiscordWebhookHook¶
根据连接类型获取 Http Hook。
- execute(context)¶
调用 DiscordWebhookHook 发送消息。