From 5b81b760d26e6ded7f49acfe88964e7cdf7162d4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 30 May 2019 12:03:31 +0100 Subject: [PATCH] blame: Allow `~blame #last 2' etc. Ie, ~blame #last 1 = ~blame #last ~blame #last 2 = the last-but-one fish ~blame #last 3 = the last-but-two fish etc. Signed-off-by: Ian Jackson --- v2: Fixed off-by-one error in commit message. --- commands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commands.py b/commands.py index d6ba530..721089d 100755 --- a/commands.py +++ b/commands.py @@ -333,7 +333,14 @@ def blameq(bot,cmd,nick,conn,public,fishpond,cfgs): cwhat=' '.join(clist[2:]) kindsfile = "fish?" if clist[1]=="#last": - try: lmsg, lcfg = fishpond.last[0] + try: + n = abs(int(clist[2]))-1 + if n < 0: raise ValueError + except IndexError: n = 0 + except ValueError: + bot.automsg(public,nick,"Huh?") + return + try: lmsg, lcfg = fishpond.last[n] except IndexError: bot.automsg(public,nick,"Nothing") return -- 2.30.2