Add Slack url icon support (#38814)
* Add support for slack bot icons via URL * Removed as_user property from message send * Use f-strings rather than concatenation * Don't span lines with complex expression
This commit is contained in:
parent
5c9f29c43a
commit
91ead3be50
1 changed files with 16 additions and 6 deletions
|
@ -193,14 +193,24 @@ class SlackNotificationService(BaseNotificationService):
|
|||
|
||||
async def _async_send_text_only_message(self, targets, message, title, blocks):
|
||||
"""Send a text-only message."""
|
||||
username = self._username
|
||||
icon = self._icon
|
||||
|
||||
if self._icon.lower().startswith(("http://", "https://")):
|
||||
icon_type = "url"
|
||||
else:
|
||||
icon_type = "emoji"
|
||||
|
||||
tasks = {
|
||||
target: self._client.chat_postMessage(
|
||||
channel=target,
|
||||
text=message,
|
||||
blocks=blocks,
|
||||
icon_emoji=self._icon,
|
||||
link_names=True,
|
||||
username=self._username,
|
||||
**{
|
||||
"channel": target,
|
||||
"text": message,
|
||||
"blocks": blocks,
|
||||
"link_names": True,
|
||||
"username": username,
|
||||
f"icon_{icon_type}": icon,
|
||||
}
|
||||
)
|
||||
for target in targets
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue