dondaum commented on code in PR #56911:
URL: https://github.com/apache/airflow/pull/56911#discussion_r2498338020
##########
providers/discord/src/airflow/providers/discord/hooks/discord_webhook.py:
##########
@@ -148,11 +177,100 @@ def execute(self) -> None:
# we only need https proxy for Discord
proxies = {"https": self.proxy}
- discord_payload = self._build_discord_payload()
+ discord_payload = self.handler.build_discord_payload(
+ tts=self.tts, message=self.message, username=self.username,
avatar_url=self.avatar_url
+ )
self.run(
endpoint=self.webhook_endpoint,
data=discord_payload,
headers={"Content-type": "application/json"},
extra_options={"proxies": proxies},
)
+
+
+class DiscordWebhookAsyncHook(HttpAsyncHook):
+ """
+ This hook allows you to post messages to Discord using incoming webhooks
using async HTTP.
+
+ Takes a Discord connection ID with a default relative webhook endpoint. The
+ default endpoint can be overridden using the webhook_endpoint parameter
+ (https://discordapp.com/developers/docs/resources/webhook).
+
+ Each Discord webhook can be pre-configured to use a specific username and
+ avatar_url. You can override these defaults in this hook.
+
+ :param http_conn_id: Http connection ID with host as
"https://discord.com/api/" and
+ default webhook endpoint in the extra field in the
form of
+ {"webhook_endpoint":
"webhooks/{webhook.id}/{webhook.token}"}
+ :param webhook_endpoint: Discord webhook endpoint in the form of
+ "webhooks/{webhook.id}/{webhook.token}"
+ :param message: The message you want to send to your Discord channel
+ (max 2000 characters)
+ :param username: Override the default username of the webhook
+ :param avatar_url: Override the default avatar of the webhook
+ :param tts: Is a text-to-speech message
+ :param proxy: Proxy to use to make the Discord webhook call
+ """
+
+ default_headers = {
+ "Content-Type": "application/json",
+ }
+ conn_name_attr = "http_conn_id"
+ default_conn_name = "discord_default"
+ conn_type = "discord"
+ hook_name = "Async Discord"
+
+ def __init__(
+ self,
+ http_conn_id: str = "",
Review Comment:
Changed.
--
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]