Exemplo n.º 1
0
	async def on_message(self, message: Message) -> None:
		"""
		Allow for command chaining using `&&`
		"""
		if message.author.bot:
			return

		commands = message.content.split(" && ")
		for command in commands:
			message.content = command
			await self.invoke(await self.get_context(message))
Exemplo n.º 2
0
async def on_message_handler(bot: Bot, message: Message):
    """Handle an on_message event.

    First, verify that the bot can respond in the given channel.

    Then remove any spaces after the prefix. This would normally be achieved
    by using a callable prefix, but the Discord.py API does not support the
    use of spaces after symbols, only alphanumeric characters. This is a
    workaround.
    """
    try:
        if Config.POM_CHANNEL_NAMES:
            if message.channel.name not in Config.POM_CHANNEL_NAMES:
                return
    except AttributeError:
        if message.guild is None and not Debug.RESPOND_TO_DM:
            return

    if message.content.startswith(Config.PREFIX + " "):
        message.content = "".join(message.content.split(" ", 1))

    await bot.process_commands(message)
Exemplo n.º 3
0
	async def on_message(self, msg: Message):
		# if the message doesn't starts with the prefix or is sent by a bot, ignore it
		if msg.author.bot:
			return
		await self.module.handleEvent(
			'message',
			message=msg
		)
		if not msg.content.startswith(self.prefix):
			return
		msg.content = msg.content.replace(self.prefix, '', 1)
		cmd = msg.content.split(' ')
		print(f'command: {cmd[0]}, parameters: {cmd[ 1:len(cmd) ] if len(cmd) > 1 else None}, issuer: {msg.author.name}')
		if msg.content.startswith('reload'):
			await self.reload(msg)
		elif msg.content.startswith('module'):
			await self.module.mhandle(msg)
		else:
			await self.handleCommand(msg)
		await self.module.handleEvent(
			'command',
			message= msg
		)