add server/channel config to disable command suggestions
This commit is contained in:
parent
35cc2d539d
commit
aa4511e0d9
1 changed files with 8 additions and 0 deletions
|
@ -3,12 +3,20 @@
|
|||
import difflib
|
||||
from src import ModuleManager, utils
|
||||
|
||||
SETTING = utils.BoolSetting("command-suggestions",
|
||||
"Disable/enable command suggestions")
|
||||
@utils.export("serverset", SETTING)
|
||||
@utils.export("channelset", SETTING)
|
||||
class Module(ModuleManager.BaseModule):
|
||||
def _all_command_hooks(self):
|
||||
return self.events.on("received.command").get_children()
|
||||
|
||||
@utils.hook("unknown.command")
|
||||
def unknown_command(self, event):
|
||||
if not event["server"].get_setting("command-suggestions",
|
||||
event["target"].get_setting("command-suggestions", True)):
|
||||
return
|
||||
|
||||
all_commands = self._all_command_hooks()
|
||||
match = difflib.get_close_matches(event["command"], all_commands,
|
||||
cutoff=0.7)
|
||||
|
|
Loading…
Reference in a new issue