mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Resolved issue #5688
This commit is contained in:
parent
0ea81c1269
commit
b038a1650e
@ -35,6 +35,7 @@ class DiscordNotificationService(BaseNotificationService):
|
|||||||
"""Initialize the service."""
|
"""Initialize the service."""
|
||||||
self.token = token
|
self.token = token
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
|
self.loggedin = 0
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_send_message(self, message, **kwargs):
|
def async_send_message(self, message, **kwargs):
|
||||||
@ -42,11 +43,13 @@ class DiscordNotificationService(BaseNotificationService):
|
|||||||
import discord
|
import discord
|
||||||
discord_bot = discord.Client(loop=self.hass.loop)
|
discord_bot = discord.Client(loop=self.hass.loop)
|
||||||
|
|
||||||
yield from discord_bot.login(self.token)
|
@discord_bot.event
|
||||||
|
@asyncio.coroutine
|
||||||
|
def on_ready():
|
||||||
|
for channelid in kwargs[ATTR_TARGET]:
|
||||||
|
channel = discord.Object(id=channelid)
|
||||||
|
yield from discord_bot.send_message(channel, message)
|
||||||
|
yield from discord_bot.logout()
|
||||||
|
|
||||||
for channelid in kwargs[ATTR_TARGET]:
|
yield from discord_bot.start(self.token)
|
||||||
channel = discord.Object(id=channelid)
|
|
||||||
yield from discord_bot.send_message(channel, message)
|
|
||||||
|
|
||||||
yield from discord_bot.logout()
|
|
||||||
yield from discord_bot.close()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user