Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions homeassistant/components/discord/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def __init__(self, hass, token):
self.token = token
self.hass = hass

def file_exists(self, filename):
import os.path
Comment thread
cyrosy marked this conversation as resolved.
Outdated

return os.path.isfile(filename)

async def async_send_message(self, message, **kwargs):
"""Login to Discord, send message to channel(s) and log out."""
import discord
Expand All @@ -49,11 +54,14 @@ async def async_send_message(self, message, **kwargs):
data = kwargs.get(ATTR_DATA)

if ATTR_IMAGES in data:
import os.path
images = list()

for image in data.get(ATTR_IMAGES):
if os.path.isfile(image):
image_exists = await self.hass.async_add_executor_job(
self.file_exists,
Comment thread
cyrosy marked this conversation as resolved.
Outdated
image)

if image_exists:
images.append(image)
else:
_LOGGER.warning("Image not found: %s", image)
Expand Down