mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
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
@ -193,14 +193,24 @@ class SlackNotificationService(BaseNotificationService):
|
|||||||
|
|
||||||
async def _async_send_text_only_message(self, targets, message, title, blocks):
|
async def _async_send_text_only_message(self, targets, message, title, blocks):
|
||||||
"""Send a text-only message."""
|
"""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 = {
|
tasks = {
|
||||||
target: self._client.chat_postMessage(
|
target: self._client.chat_postMessage(
|
||||||
channel=target,
|
**{
|
||||||
text=message,
|
"channel": target,
|
||||||
blocks=blocks,
|
"text": message,
|
||||||
icon_emoji=self._icon,
|
"blocks": blocks,
|
||||||
link_names=True,
|
"link_names": True,
|
||||||
username=self._username,
|
"username": username,
|
||||||
|
f"icon_{icon_type}": icon,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
for target in targets
|
for target in targets
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user