From cf43d997d5fc1eb6781ad409a4c6568b88a65879 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sun, 29 Nov 2020 21:07:06 +0200 Subject: [PATCH] some changes --- simplecommands/plugin.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/simplecommands/plugin.ts b/simplecommands/plugin.ts index 3d535ca..7c92e57 100644 --- a/simplecommands/plugin.ts +++ b/simplecommands/plugin.ts @@ -210,6 +210,7 @@ class SqueebotCommandsAPIPlugin extends Plugin { // Done } + @EventListener('message') public digest(msg: IMessage): void { if (msg.type !== EMessageType.message) { return; @@ -333,10 +334,11 @@ class SqueebotCommandsAPIPlugin extends Plugin { withAliases.push(spec); } - const matching = this.roomMatcher(msg, withAliases); + // Iteration 2: Match rooms for message + let matching = this.roomMatcher(msg, withAliases); - // Iteration 2: Match permissions for user - // TODO: permission matching + // Iteration 3: Match permissions for user + matching = this.permissionMatcher(msg, matching); const text = msg.data.text ? msg.data.text : msg.data; const argv = text.toLowerCase().split(' '); @@ -405,17 +407,14 @@ class SqueebotCommandsAPIPlugin extends Plugin { this.permissions = null; } - @EventListener('message') - messageHandler(msg: IMessage): void { - this.digest(msg); - } - @EventListener('pluginUnload') unloadEventHandler(plugin: string | Plugin): void { if (plugin === this.name || plugin === this) { logger.debug('[%s] shutting down..', this.name); this.config.save().then(() => this.emit('pluginUnloaded', this)); + } else { + this.unregisterPlugin((typeof plugin === 'string' ? plugin : plugin.manifest.name)); } } }