From: Ian Jackson Date: Thu, 30 May 2019 11:03:31 +0000 (+0100) Subject: blame: Allow `~blame #last 2' etc. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~matthewv/git?a=commitdiff_plain;h=5b81b760d2;p=irc.git 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. --- 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