mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Black
This commit is contained in:
@@ -7,17 +7,18 @@ import voluptuous as vol
|
||||
from homeassistant.const import CONF_TOKEN
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from homeassistant.components.notify import (ATTR_DATA, ATTR_TARGET,
|
||||
PLATFORM_SCHEMA,
|
||||
BaseNotificationService)
|
||||
from homeassistant.components.notify import (
|
||||
ATTR_DATA,
|
||||
ATTR_TARGET,
|
||||
PLATFORM_SCHEMA,
|
||||
BaseNotificationService,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_TOKEN): cv.string
|
||||
})
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_TOKEN): cv.string})
|
||||
|
||||
ATTR_IMAGES = 'images'
|
||||
ATTR_IMAGES = "images"
|
||||
|
||||
|
||||
def get_service(hass, config, discovery_info=None):
|
||||
@@ -60,8 +61,8 @@ class DiscordNotificationService(BaseNotificationService):
|
||||
|
||||
for image in data.get(ATTR_IMAGES):
|
||||
image_exists = await self.hass.async_add_executor_job(
|
||||
self.file_exists,
|
||||
image)
|
||||
self.file_exists, image
|
||||
)
|
||||
|
||||
if image_exists:
|
||||
images.append(image)
|
||||
@@ -78,9 +79,7 @@ class DiscordNotificationService(BaseNotificationService):
|
||||
channel = discord_bot.get_channel(channelid)
|
||||
|
||||
if channel is None:
|
||||
_LOGGER.warning(
|
||||
"Channel not found for id: %s",
|
||||
channelid)
|
||||
_LOGGER.warning("Channel not found for id: %s", channelid)
|
||||
continue
|
||||
|
||||
# Must create new instances of File for each channel.
|
||||
@@ -91,8 +90,7 @@ class DiscordNotificationService(BaseNotificationService):
|
||||
files.append(discord.File(image))
|
||||
|
||||
await channel.send(message, files=files)
|
||||
except (discord.errors.HTTPException,
|
||||
discord.errors.NotFound) as error:
|
||||
except (discord.errors.HTTPException, discord.errors.NotFound) as error:
|
||||
_LOGGER.warning("Communication error: %s", error)
|
||||
await discord_bot.logout()
|
||||
await discord_bot.close()
|
||||
|
||||
Reference in New Issue
Block a user