From c7c24d9b091e943081447b696b8663ce31302d25 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Thu, 27 Oct 2016 08:42:11 +0100 Subject: [PATCH] Plugins can handle on_member_join(). --- app.py | 1 + plugins.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app.py b/app.py index e55ef29..e093997 100644 --- a/app.py +++ b/app.py @@ -796,6 +796,7 @@ def on_message(message): @client.event @asyncio.coroutine def on_member_join(member): + yield from plugins.on_member_join(member) channels = channels_to_greet() for channel in channels: result = should_greet_member_in(channel, member) diff --git a/plugins.py b/plugins.py index ca290b1..9694842 100644 --- a/plugins.py +++ b/plugins.py @@ -86,6 +86,12 @@ class Plugins(object): if self.has_method(name, 'on_ready'): asyncio.async(self.call_coroutine(name, 'on_ready')) + @asyncio.coroutine + def on_member_join(self, member): + for name in self.plugins(): + if self.has_method(name, 'on_member_join'): + asyncio.async(self.call_coroutine(name, 'on_member_join', member)) + # Plugin can return True to force skipping other handlers. @asyncio.coroutine def handle_command(self, message, command, raw): -- 2.7.4