From 5272bf3a8614fd980733938b992a8f08563f1546 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 18 Aug 2017 18:30:22 +0200 Subject: [PATCH] Aka: Fix combination of required and optional arguments. Was broken by 7f43727835f72ffc7dd301458705cc3c30e40d46 (why?) --- plugins/Aka/plugin.py | 1 + plugins/Aka/test.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/plugins/Aka/plugin.py b/plugins/Aka/plugin.py index ecbd50c0a..f9e770a75 100644 --- a/plugins/Aka/plugin.py +++ b/plugins/Aka/plugin.py @@ -467,6 +467,7 @@ class Aka(callbacks.Plugin): replace(tokens, lambda s: dollarRe.sub(regexpReplace, s)) if biggestAt: assert not wildcard + args = args[biggestDollar:] replace(tokens, lambda s: atRe.sub(regexpReplace, s)) if wildcard: assert not biggestAt diff --git a/plugins/Aka/test.py b/plugins/Aka/test.py index acf7974e8..50ed3e79f 100644 --- a/plugins/Aka/test.py +++ b/plugins/Aka/test.py @@ -135,6 +135,11 @@ class AkaChannelTestCase(ChannelPluginTestCase): self.assertResponse('myrepr foo', '"foo"') self.assertResponse('myrepr ""', '""') + def testRequiredAndOptional(self): + self.assertNotError('aka add reqopt "echo req=$1, opt=@1"') + self.assertResponse('reqopt foo bar', 'req=foo, opt=bar') + self.assertResponse('reqopt foo', 'req=foo, opt=') + def testNoExtraSpaces(self): self.assertNotError('aka add foo "action takes $1\'s money"') self.assertResponse('foo bar', '\x01ACTION takes bar\'s money\x01')