Aka: Prevent overriding of other plugins commands.

This commit is contained in:
Valentin Lorentz 2013-08-25 01:06:31 +02:00
parent 10d9c43ab8
commit fba38a5df9
2 changed files with 18 additions and 1 deletions

View File

@ -242,6 +242,12 @@ class Aka(callbacks.Plugin):
def isCommandMethod(self, name):
if sys.version_info[0] < 3 and isinstance(name, str):
name = name.decode('utf8')
args = name.split(' ')
if len(args) > 1 and \
callbacks.canonicalName(args[0]) != self.canonicalName():
for cb in dynamic.irc.callbacks: # including this plugin
if cb.getCommand(args[0:-1]):
return False
channel = dynamic.channel or 'global'
return self._db.has_aka(channel, name) or \
self._db.has_aka('global', name) or \

View File

@ -151,8 +151,19 @@ class AkaChannelTestCase(ChannelPluginTestCase):
self.assertNotError('aka add "foo bar" "echo spam"')
self.assertResponse('foo bar', 'spam')
self.assertNotError('aka add "foo" "echo egg"')
self.assertResponse('foo bar', 'spam')
self.assertResponse('foo', 'egg')
# You could expect 'spam' here, but in fact, this is dangerous.
# Just imagine this session:
# <evil_user> aka add "echo foo" quit
# <bot> The operation succeeded.
# ...
# <owner> echo foo
# * bot has quit
self.assertResponse('foo bar', 'egg')
def testNoOverride(self):
self.assertNotError('aka add "echo foo" "echo bar"')
self.assertResponse('echo foo', 'foo')
def testRecursivity(self):
self.assertNotError('aka add fact '