From a7a2cf383d631f6a217495ab05166dcdbdbe049e Mon Sep 17 00:00:00 2001 From: importantchoice <22687029+importantchoice@users.noreply.github.com> Date: Thu, 30 Nov 2017 12:12:33 +0100 Subject: [PATCH] Fix issue #14 - remove plugins on reload This fix for load_plugins will clear the plugin.cmds list to ensure that removed plugins don't remain in its cmds list. --- pinhook/bot.py | 3 +++ pinhook/plugin.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pinhook/bot.py b/pinhook/bot.py index 618a9a2..abb0a05 100644 --- a/pinhook/bot.py +++ b/pinhook/bot.py @@ -2,6 +2,7 @@ import imp import os import ssl import time +import pinhook.plugin import irc.bot @@ -48,6 +49,8 @@ class Bot(irc.bot.SingleServerIRCBot): setattr(self, a, kwarguments[a]) def load_plugins(self): + # clear plugin list to ensure no old plugins remain + pinhook.plugin.clear_plugins() # ensure plugin folder exists if not os.path.exists(self.plugin_dir): os.makedirs(self.plugin_dir) diff --git a/pinhook/plugin.py b/pinhook/plugin.py index d8be1ce..0f85615 100644 --- a/pinhook/plugin.py +++ b/pinhook/plugin.py @@ -21,6 +21,10 @@ def add_plugin(command, func): cmds.append({'cmd': command, 'func': func}) +def clear_plugins(): + cmds.clear() + + def register(command): def register_for_command(func): add_plugin(command, func)