Ejemplo n.º 1
0
    async def startup_cleanup(self):
        Logging.info("starting bugs")
        # TODO: find out what the condition is we need to wait for instead of just sleep
        # await asyncio.sleep(20)

        # for name, cid in Configuration.get_var("channels").items():
        reporting_channel_ids = []
        for row in BugReportingChannel.select():
            cid = row.channelid
            name = f"{row.platform.platform}_{row.platform.branch}"
            guild_id = row.guild.serverid
            channel = self.bot.get_channel(cid)
            shutdown_key = f"{guild_id}_{name}_shutdown"
            shutdown_id = Configuration.get_persistent_var(shutdown_key)

            if shutdown_id is not None:
                Configuration.del_persistent_var(shutdown_key)
                try:
                    message = await channel.fetch_message(shutdown_id)
                    await message.delete()
                except (NotFound, HTTPException) as e:
                    pass
            reporting_channel_ids.append(cid)
        try:
            await self.send_bug_info(*reporting_channel_ids)
        except Exception as e:
            await Utils.handle_exception("bug startup failure", self.bot, e)
Ejemplo n.º 2
0
 async def on_guild_remove(self, guild):
     Configuration.del_persistent_var(f"min_react_lifespan_{guild.id}")
     Configuration.del_persistent_var(f"react_mutes_{guild.id}")
     del self.mutes[guild.id]
     del self.mute_duration[guild.id]
     del self.min_react_lifespan[guild.id]
     del self.recent_reactions[guild.id]
     del self.react_removers[guild.id]
     del self.react_adds[guild.id]
     del self.emoji[guild.id]
     del self.guilds[guild.id]
     if guild.id in self.react_watch_servers:
         self.deactivate_react_watch(guild.id)
     watch = ReactWatch.get(ReactWatch.serverid == guild.id)
     for e in watch.emoji:
         e.delete_instance()
     watch.delete_instance()
Ejemplo n.º 3
0
 async def startup_cleanup(self):
     restart_mid = Configuration.get_persistent_var("bot_restart_message_id")
     restart_cid = Configuration.get_persistent_var("bot_restart_channel_id")
     author_id = Configuration.get_persistent_var("bot_restart_author_id")
     Configuration.del_persistent_var("bot_restart_message_id", True)
     Configuration.del_persistent_var("bot_restart_channel_id", True)
     Configuration.del_persistent_var("bot_restart_author_id", True)
     # TODO: write pop_persistent_var
     if restart_cid and restart_mid:
         try:
             channel = self.bot.get_channel(restart_cid)
             message = await channel.fetch_message(restart_mid)
             author = self.bot.get_user(author_id)
             await message.edit(content=f"Restart complete {author.mention}")
         except Exception:
             pass
Ejemplo n.º 4
0
 async def on_guild_remove(self, guild):
     try:
         # These may not be stored if mute config is never used:
         Configuration.del_persistent_var(f"{guild.id}_mute_new_members",
                                          True)
         Configuration.del_persistent_var(
             f"{guild.id}_mute_minutes_old_account", True)
         Configuration.del_persistent_var(
             f"{guild.id}_mute_minutes_new_account", True)
     except KeyError as e:
         pass
     del self.mute_minutes_old_account[guild.id]
     del self.mute_minutes_new_account[guild.id]
     del self.welcome_talkers[guild.id]
     del self.mute_new_members[guild.id]
     del self.discord_verification_flow[guild.id]
     del self.join_cooldown[str(guild.id)]