diff --git a/hausgeist.py b/hausgeist.py index e43628c7618890e938fc7afc3c827f05dcaad9ef..f5f95e85a33b57eacbd8d1755d899803fd1948e6 100644 --- a/hausgeist.py +++ b/hausgeist.py @@ -58,6 +58,18 @@ class HaugeBot(commands.Bot, ABC): return 0 + def get_channel(self, **kwargs): + if kwargs: + return self.get_channel(kwargs) + + return self.get_channel(self.CHANNEL) + + async def get_chatters(self): + return await self.get_chatters(self.CHANNEL) + + async def get_stream(self): + return await self.get_stream(self.CHANNEL) + bot = HaugeBot() diff --git a/pipi_cog.py b/pipi_cog.py index fa45bc93074765a0ce15e5d600ffed767e2e7710..2d3a36c5343efec0e25887a40eae62daa7bc2fe2 100644 --- a/pipi_cog.py +++ b/pipi_cog.py @@ -35,7 +35,7 @@ class PipiCog: self.pipi_task = asyncio.create_task(self.pipi_block_notification()) vote_ctr = 0 - chatters = await self.bot.get_chatters(self.bot.CHANNEL) + chatters = await self.bot.get_chatters() if message is not None: await self.bot.send_me(ctx, message, self.COLOR_0) @@ -75,14 +75,15 @@ class PipiCog: while True: await asyncio.sleep(self.PIPIMETER_LOOP * 60) - if await self.bot.get_stream(self.bot.CHANNEL): + if await self.bot.get_stream(): if offline_since >= self.RESET_THRESHOLD: self.pipi_votes = {} offline_since = 0 - channel = self.bot.get_channel(self.bot.CHANNEL) - message = Message(channel=channel) - await self.notify_pipi(message, use_timer=False) + if len(self.pipi_votes) > 0: + channel = self.bot.get_channel() + message = Message(channel=channel) + await self.notify_pipi(message, use_timer=False) else: offline_since += self.PIPIMETER_LOOP diff --git a/vote_cog.py b/vote_cog.py index 399324d10560f803c946e345a9008a7068c08b13..19062ad0af17130aae773d195c87d0e889d9ef8a 100644 --- a/vote_cog.py +++ b/vote_cog.py @@ -61,7 +61,7 @@ class VoteCog: if not self.vote_end_task.done() and len(self.votes) >= self.MIN_VOTES: await self.notify_vote_result(channel) self.vote_interim_task = asyncio.create_task( - self.vote_interim_voting(self.bot.get_channel(self.bot.CHANNEL))) + self.vote_interim_voting(self.bot.get_channel())) async def vote_block_votes(self): """ Just do nothing but sleep for VOTE_DELAY_INTERIM seconds """ @@ -89,7 +89,7 @@ class VoteCog: async def event_message(self, message): # make sure the bot ignores itself and nightbot - if message.author.name.lower() in [self.NICK.lower(), 'nightbot']: + if message.author.name.lower() in [self.bot.NICK.lower(), 'nightbot']: return # check if message is a vote @@ -110,9 +110,9 @@ class VoteCog: return if len(self.votes) == 0: - self.vote_end_task = asyncio.create_task(self.vote_end_voting(self.bot.get_channel(self.bot.CHANNEL))) + self.vote_end_task = asyncio.create_task(self.vote_end_voting(self.bot.get_channel())) self.vote_interim_task = asyncio.create_task( - self.vote_interim_voting(self.bot.get_channel(self.bot.CHANNEL))) + self.vote_interim_voting(self.bot.get_channel())) # should vote extend voting? if ctx.author.name not in self.votes or self.votes[ctx.author.name] != votetype: