diff options
| author | 2018-10-30 14:58:48 +0000 | |
|---|---|---|
| committer | 2018-10-30 14:58:48 +0000 | |
| commit | e07553c3627b80f20cdc81a35030bf0540924db8 (patch) | |
| tree | 0a81640b280e007cbe5d2cb956681068ab80c58e /modules/sed.py | |
| parent | Don't needlessly search a youtube URL before getting the information for it's (diff) | |
| signature | ||
Add type/return hints throughout src/ and, in doing so, fix some cyclical
references.
Diffstat (limited to 'modules/sed.py')
| -rw-r--r-- | modules/sed.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/sed.py b/modules/sed.py index 6de7b4af..7b98ab70 100644 --- a/modules/sed.py +++ b/modules/sed.py @@ -11,12 +11,16 @@ REGEX_SED = re.compile("^s/") "help": "Disable/Enable sed only looking at the messages sent by the user", "validate": utils.bool_or_none}) class Module(ModuleManager.BaseModule): + def _closest_setting(self, event, setting, default): + return event["channel"].get_setting(setting, + event["server"].get_setting(setting, default)) + @utils.hook("received.message.channel") def channel_message(self, event): sed_split = re.split(REGEX_SPLIT, event["message"], 3) if event["message"].startswith("s/") and len(sed_split) > 2: - if event["action"] or not utils.get_closest_setting( - event, "sed", False): + if event["action"] or not self._closest_setting(event, "sed", + False): return regex_flags = 0 @@ -48,9 +52,8 @@ class Module(ModuleManager.BaseModule): return replace = sed_split[2].replace("\\/", "/") - for_user = event["user"].nickname if utils.get_closest_setting( - event, "sed-sender-only", False - ) else None + for_user = event["user"].nickname if self._closest_setting(event, + "sed-sender-only", False) else None line = event["channel"].buffer.find(pattern, from_self=False, for_user=for_user, not_pattern=REGEX_SED) if line: |
