From 09e3b082c19a98e43798f43aa5d2fe638688ad3b Mon Sep 17 00:00:00 2001 From: nemunaire Date: Thu, 21 Jan 2016 18:43:34 +0100 Subject: [PATCH] [alias] Give near alias in case of error --- modules/alias.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/alias.py b/modules/alias.py index 0e361b3..2ed48cb 100644 --- a/modules/alias.py +++ b/modules/alias.py @@ -4,12 +4,12 @@ import re from datetime import datetime, timezone -import shlex from nemubot import context from nemubot.exception import IMException from nemubot.hooks import hook from nemubot.message import Command +from nemubot.tools.human import guess from nemubot.tools.xmlparser.node import ModuleState from more import Response @@ -232,7 +232,8 @@ def cmd_alias(msg): channel=msg.channel) else: - raise IMException("%s is not an alias" % msg.args[0]) + wym = guess(alias.cmd, context.data.getNode("aliases").index) + raise IMException(msg.args[0] + " is not an alias." + (" Would you mean: %s?" % ", ".join(wym)) if len(wym) else "") @hook.command("unalias",