def send_message(self, message="", **kwargs):
"""Send a message to a user."""
import slacker
if kwargs.get(ATTR_TARGET) is None:
targets = [self._default_channel]
else:
targets = kwargs.get(ATTR_TARGET)
data = kwargs.get('data')
attachments = data.get('attachments') if data else None
for target in targets:
try:
self.slack.chat.post_message(target, message,
as_user=self._as_user,
username=self._username,
icon_emoji=self._icon,
attachments=attachments,
link_names=True)
except slacker.Error as err:
_LOGGER.error("Could not send slack notification. Error: %s",
err)
评论列表
文章目录