From 930a4bcbc2f9f0109029a1ec485f95634df0583e Mon Sep 17 00:00:00 2001 From: jesopo Date: Sat, 6 Oct 2018 16:18:59 +0100 Subject: [PATCH] Correctly scope 'filename' in modules/script.py._load_scripts --- modules/scripts.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/scripts.py b/modules/scripts.py index 437be4f4..36491efa 100644 --- a/modules/scripts.py +++ b/modules/scripts.py @@ -16,10 +16,13 @@ class Module(object): if hashflag == "name" and value: name = value elif hashflag == "hook" and value: - hook = self.events.on(value).hook( - lambda x: self.call(x, filename, name)) + hook_fn = self._make_hook(filename, name) + hook = self.events.on(value).hook(hook_fn) self._hooks.append([value, hook]) + def _make_hook(self, filename, name): + return lambda event: self.call(event, filename, name) + @utils.hook("received.command.reloadscripts", permission="reloadscripts") def reload(self, event): for event_name, hook in self._hooks: