async def on_message(self, message: Message): # Ignore all DMs if message.guild is None: return # Ignore all messages from this bot if message.author == self.user: return plugins = self.get_all_plugins(message.guild) # Do a special case for !help, since we need an overview of all plugins # to make it complete if message.clean_content == PluginCommand.PREFIX + 'help': help_message = '\n'.join( p.get_help(State.is_admin(message.author)) for p in plugins ) if not help_message: help_message = 'No commands are currently available.' else: help_message = \ 'The following commands are currently available:\n' \ + help_message await reply(message, help_message) return for plugin in plugins: if await plugin.process_message(message): break else: roleplay = self.get_roleplay_for_guild(message.guild.id) if roleplay and message.channel.name in roleplay.rooms: await self.get_chronicle(message.guild).log_player_message( message.author, message.channel, message.clean_content )
async def _lock_or_unlock( self, message: Message, location: str, lock: bool = True ): config = State.get_config(message.guild.id) channel: TextChannel = message.channel connection = self.roleplay.get_connection(channel.name, location) if not connection: await channel.send( f'No connection from {channel.name} to {location}.', delete_after=60*60 ) return connection_config = config['connections'][connection.name] if not State.is_admin(message.author) \ and message.author.id not in connection_config['k']: await channel.send( f'{message.author.mention} does not have the key to ' f'{location}.', delete_after=60*60 ) return locked = connection_config['l'] if locked and lock or not locked and not lock: await channel.send( f'Access to {location} is already ' f'{"locked" if lock else "unlocked"}.', delete_after=60*60 ) return self._update_connection( config["connections"], channel.name, location, locked=lock ) State.save_config(message.guild.id, config) await self.bot.save_guild_config(message.guild, config) await channel.send( f'{"Locked" if lock else "Unlocked"} access to {location}.' ) await message.delete() name = 'the GM' \ if State.is_admin(message.author) else message.author.display_name await self.bot.get_chronicle(message.guild).log_announcement( channel, f'Access from **{message.channel.name}** to **{location}** ' f'{"" if lock else "un"}locked by **{name}**' )