mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Fixed bug in that you could add over top already-existing commands.
This commit is contained in:
parent
0857e3aca6
commit
fd97e8d634
@ -95,7 +95,7 @@ class LookupDB(plugins.DBHandler):
|
||||
class Lookup(callbacks.Privmsg):
|
||||
def __init__(self):
|
||||
callbacks.Privmsg.__init__(self)
|
||||
self.domains = sets.Set()
|
||||
self.lookupDomains = sets.Set()
|
||||
self.dbHandler = LookupDB(name=os.path.join(conf.dataDir, 'Lookup'))
|
||||
|
||||
def die(self):
|
||||
@ -108,7 +108,7 @@ class Lookup(callbacks.Privmsg):
|
||||
"""
|
||||
name = privmsgs.getArgs(args)
|
||||
name = callbacks.canonicalName(name)
|
||||
if name not in self.domains:
|
||||
if name not in self.lookupDomains:
|
||||
irc.error(msg, 'That\'s not a valid lookup to remove.')
|
||||
return
|
||||
db = self.dbHandler.getDb()
|
||||
@ -134,6 +134,10 @@ class Lookup(callbacks.Privmsg):
|
||||
(name, filename) = privmsgs.getArgs(args, required=2)
|
||||
name = utils.depluralize(name)
|
||||
name = callbacks.canonicalName(name)
|
||||
if hasattr(self, name):
|
||||
s = 'I already have a command in this plugin named %s' % name
|
||||
irc.error(msg, s)
|
||||
return
|
||||
db = self.dbHandler.getDb()
|
||||
cursor = db.cursor()
|
||||
try:
|
||||
@ -189,7 +193,7 @@ class Lookup(callbacks.Privmsg):
|
||||
f = types.FunctionType(f.func_code, f.func_globals,
|
||||
f.func_name, closure=f.func_closure)
|
||||
f.__doc__ = docstring
|
||||
self.domains.add(name)
|
||||
self.lookupDomains.add(name)
|
||||
setattr(self.__class__, name, f)
|
||||
|
||||
def _lookup(self, irc, msg, args):
|
||||
|
@ -83,6 +83,10 @@ class RSS(callbacks.Privmsg):
|
||||
websites prefer it).
|
||||
""" % (name, url)
|
||||
name = callbacks.canonicalName(name)
|
||||
if hasattr(self, name):
|
||||
s = 'I already have a command in this plugin named %s' % name
|
||||
irc.error(msg, s)
|
||||
return
|
||||
def f(self, irc, msg, args):
|
||||
args.insert(0, url)
|
||||
self.rss(irc, msg, args)
|
||||
|
@ -49,6 +49,12 @@ if sqlite:
|
||||
'your mom': 'my mom',
|
||||
'foo\\:bar': 'baz',
|
||||
}
|
||||
def testCantRemoveNonLookupMethod(self):
|
||||
self.assertError('remove lookup')
|
||||
|
||||
def testCantCreateLookupNamedLookup(self):
|
||||
self.assertError('lookup add lookup foo.supyfact')
|
||||
|
||||
def setUp(self):
|
||||
PluginTestCase.setUp(self)
|
||||
fd = file(os.path.join(conf.dataDir, 'foo.supyfact'), 'w')
|
||||
|
@ -50,6 +50,12 @@ class RSSTestCase(PluginTestCase, PluginDocumentation):
|
||||
self.assertError('slashdot')
|
||||
self.assertError('rss slashdot')
|
||||
|
||||
def testCantAddFeedNamedRss(self):
|
||||
self.assertError('rss add rss http://slashdot.org/slashdot.rss')
|
||||
|
||||
def testCantRemoveMethodThatIsntFeed(self):
|
||||
self.assertError('rss remvoe rss')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user