From af5bab2f3ebcd97767d14257b8f2cb1c34f67c9d Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Mon, 26 Nov 2018 14:51:56 +0100 Subject: [PATCH] Give better hints in case of command errors The most common error interacting with the bot is omitting the "now" command. This change makes ptgbot issue a helpful suggestion, and clarifies a couple more error messages. It also provides usage help in case anyone asks for #help. Change-Id: Ifbee88ab15dbf0ed8c9f858072852381b9da168f --- ptgbot/bot.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ptgbot/bot.py b/ptgbot/bot.py index 51b63e2..08997ac 100644 --- a/ptgbot/bot.py +++ b/ptgbot/bot.py @@ -77,7 +77,8 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot): self.identify_msg_cap = True def usage(self, channel): - self.send(channel, "Format is '#TRACK COMMAND [PARAMETERS]'") + self.send(channel, "I accept commands in the following format: " + "'#TRACK COMMAND [PARAMETERS]'") self.send(channel, "See doc at: " + DOC_URL) def send_track_list(self, channel): @@ -104,9 +105,14 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot): return words = msg.split() + + if words[0] == '#help': + self.usage(chan) + return + if ((len(words) < 2) or (len(words) == 2 and words[1].lower() != 'clean')): - self.send(chan, "%s: Incorrect number of arguments" % (nick,)) + self.send(chan, "%s: Incorrect arguments" % (nick,)) self.usage(chan) return @@ -154,8 +160,9 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot): "(or not booked for %s)" % (nick, params, track)) else: - self.send(chan, "%s: unknown directive '%s'" % (nick, adverb)) - self.usage(chan) + self.send(chan, "%s: unknown directive '%s'. " + "Did you mean: %s now %s... ?" % + (nick, adverb, track, adverb)) return if msg.startswith('~'):