return True
@client.event
+async def on_typing(channel, user, when):
+ if user.id == client.user.id:
+ return
+ if user.bot:
+ return
+ if channel.is_private:
+ return
+ log.debug('{} is typing in {}'.format(user, channel))
+ await plugins.on_typing(channel, user, when)
+
+@client.event
async def on_message(message):
if message.author.id == client.user.id:
return
m = re.match(r'^(\S+)', raw)
if m is None:
+ await plugins.non_command_message(message)
return
command = m.group(1)
result = await builtin_commands(message, command, raw)
'on_ready',
'on_member_join',
'on_member_update',
+ 'on_typing',
'handle_command',
'handle_help',
'eddn_message',
+ 'non_command_message',
'not_our_message'
]
self.plugins_supporting_methods = {}
for name in self.method_cache('on_member_update'):
asyncio.ensure_future(self.call_coroutine(name, 'on_member_update', before, after))
+ async def on_typing(self, channel, user, when):
+ for name in self.method_cache('on_typing'):
+ asyncio.ensure_future(self.call_coroutine(name, 'on_typing', channel, user, when))
+
# Plugin can return True to force skipping other handlers.
async def handle_command(self, message, command, raw):
for name in self.method_cache('handle_command'):
log.debug('Plugin {} handled command {}.'.format(name, command))
continue
+ async def non_command_message(self, message):
+ for name in self.plugins():
+ if self.has_method(name, 'non_command_message'):
+ asyncio.ensure_future(self.call_coroutine(name, 'non_command_message', message))
+
async def not_our_message(self, message):
for name in self.plugins():
if self.has_method(name, 'not_our_message'):