mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +01:00
Conditional: Add --case-insensitive switch to @match.
This commit is contained in:
parent
f7f003a8a0
commit
1e8dddaa6a
@ -200,17 +200,24 @@ class Conditional(callbacks.Plugin):
|
||||
le = wrap(le, ['anything', 'anything'])
|
||||
|
||||
@internationalizeDocstring
|
||||
def match(self, irc, msg, args, item1, item2):
|
||||
"""<item1> <item2>
|
||||
def match(self, irc, msg, args, optlist, item1, item2):
|
||||
"""[--case-insensitive] <item1> <item2>
|
||||
|
||||
Determines if <item1> is a substring of <item2>.
|
||||
Returns true if <item1> is contained in <item2>.
|
||||
|
||||
Will only match case if --case-insensitive is not given.
|
||||
"""
|
||||
optlist = dict(optlist)
|
||||
if 'case-insensitive' in optlist:
|
||||
item1 = item1.lower()
|
||||
item2 = item2.lower()
|
||||
if item2.find(item1) != -1:
|
||||
irc.reply('true')
|
||||
else:
|
||||
irc.reply('false')
|
||||
match = wrap(match, ['something', 'something'])
|
||||
match = wrap(match, [getopts({'case-insensitive': ''}),
|
||||
'something', 'something'])
|
||||
|
||||
@internationalizeDocstring
|
||||
def nceq(self, irc, msg, args, item1, item2):
|
||||
|
@ -98,6 +98,8 @@ class ConditionalTestCase(PluginTestCase):
|
||||
def testMatch(self):
|
||||
self.assertRegexp('match bla mooblafoo', 'true')
|
||||
self.assertRegexp('match bla mooblfoo', 'false')
|
||||
self.assertRegexp('match Bla moobLafoo', 'false')
|
||||
self.assertRegexp('match --case-insensitive Bla moobLafoo', 'true')
|
||||
self.assertError('match bla bla stuff')
|
||||
|
||||
def testNceq(self):
|
||||
|
Loading…
Reference in New Issue
Block a user