mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-16 06:16:53 +08:00
chore(api/core): apply ruff reformatting (#7624)
This commit is contained in:
@@ -7,25 +7,27 @@ from core.tools.tool.builtin_tool import BuiltinTool
|
||||
|
||||
|
||||
class SlackWebhookTool(BuiltinTool):
|
||||
def _invoke(self, user_id: str, tool_parameters: dict[str, Any]
|
||||
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||
def _invoke(
|
||||
self, user_id: str, tool_parameters: dict[str, Any]
|
||||
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||
"""
|
||||
Incoming Webhooks
|
||||
API Document: https://api.slack.com/messaging/webhooks
|
||||
Incoming Webhooks
|
||||
API Document: https://api.slack.com/messaging/webhooks
|
||||
"""
|
||||
|
||||
content = tool_parameters.get('content', '')
|
||||
content = tool_parameters.get("content", "")
|
||||
if not content:
|
||||
return self.create_text_message('Invalid parameter content')
|
||||
return self.create_text_message("Invalid parameter content")
|
||||
|
||||
webhook_url = tool_parameters.get('webhook_url', '')
|
||||
webhook_url = tool_parameters.get("webhook_url", "")
|
||||
|
||||
if not webhook_url.startswith('https://hooks.slack.com/'):
|
||||
if not webhook_url.startswith("https://hooks.slack.com/"):
|
||||
return self.create_text_message(
|
||||
f'Invalid parameter webhook_url ${webhook_url}, not a valid Slack webhook URL')
|
||||
f"Invalid parameter webhook_url ${webhook_url}, not a valid Slack webhook URL"
|
||||
)
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
params = {}
|
||||
payload = {
|
||||
@@ -38,6 +40,7 @@ class SlackWebhookTool(BuiltinTool):
|
||||
return self.create_text_message("Text message was sent successfully")
|
||||
else:
|
||||
return self.create_text_message(
|
||||
f"Failed to send the text message, status code: {res.status_code}, response: {res.text}")
|
||||
f"Failed to send the text message, status code: {res.status_code}, response: {res.text}"
|
||||
)
|
||||
except Exception as e:
|
||||
return self.create_text_message("Failed to send message through webhook. {}".format(e))
|
||||
return self.create_text_message("Failed to send message through webhook. {}".format(e))
|
||||
|
||||
Reference in New Issue
Block a user