mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-25 19:44:13 +01:00
Removed commands that were moved to String.
This commit is contained in:
parent
68ef3d86a4
commit
afd53f212d
@ -71,17 +71,6 @@ class Utilities(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
|
|
||||||
def strlen(self, irc, msg, args):
|
|
||||||
"""<text>
|
|
||||||
|
|
||||||
Returns the length of <text>.
|
|
||||||
"""
|
|
||||||
total = 0
|
|
||||||
for arg in args:
|
|
||||||
total += len(arg)
|
|
||||||
total += len(args)-1 # spaces between the arguments.
|
|
||||||
irc.reply(str(total))
|
|
||||||
|
|
||||||
def echo(self, irc, msg, args, text):
|
def echo(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
@ -103,27 +92,6 @@ class Utilities(callbacks.Plugin):
|
|||||||
irc.reply(' '.join(things))
|
irc.reply(' '.join(things))
|
||||||
shuffle = wrap(shuffle, [many('anything')])
|
shuffle = wrap(shuffle, [many('anything')])
|
||||||
|
|
||||||
def re(self, irc, msg, args, ff, text):
|
|
||||||
"""<regexp> <text>
|
|
||||||
|
|
||||||
If <regexp> is of the form m/regexp/flags, returns the portion of
|
|
||||||
<text> that matches the regexp. If <regexp> is of the form
|
|
||||||
s/regexp/replacement/flags, returns the result of applying such a
|
|
||||||
regexp to <text>
|
|
||||||
"""
|
|
||||||
if isinstance(ff, (types.FunctionType, types.MethodType)):
|
|
||||||
f = ff
|
|
||||||
else:
|
|
||||||
f = lambda s: ff.search(s) and ff.search(s).group(0) or ''
|
|
||||||
if f('') and len(f(' ')) > len(f(''))+1: # Matches the empty string.
|
|
||||||
s = 'You probably don\'t want to match the empty string.'
|
|
||||||
irc.error(s)
|
|
||||||
else:
|
|
||||||
irc.reply(f(text))
|
|
||||||
re = wrap(re, [('checkCapability', 'trusted'),
|
|
||||||
first('regexpMatcher', 'regexpReplacer'),
|
|
||||||
'text'])
|
|
||||||
|
|
||||||
def apply(self, irc, msg, args, command, rest):
|
def apply(self, irc, msg, args, command, rest):
|
||||||
"""<command> <text>
|
"""<command> <text>
|
||||||
|
|
||||||
|
@ -42,10 +42,6 @@ class UtilitiesTestCase(PluginTestCase):
|
|||||||
def testLast(self):
|
def testLast(self):
|
||||||
self.assertResponse('utilities last foo bar baz', 'baz')
|
self.assertResponse('utilities last foo bar baz', 'baz')
|
||||||
|
|
||||||
def testStrlen(self):
|
|
||||||
self.assertResponse('strlen %s' % ('s'*10), '10')
|
|
||||||
self.assertResponse('strlen a b', '3')
|
|
||||||
|
|
||||||
def testEcho(self):
|
def testEcho(self):
|
||||||
self.assertHelp('echo')
|
self.assertHelp('echo')
|
||||||
self.assertResponse('echo foo', 'foo')
|
self.assertResponse('echo foo', 'foo')
|
||||||
@ -56,30 +52,6 @@ class UtilitiesTestCase(PluginTestCase):
|
|||||||
def testEchoStandardSubstitute(self):
|
def testEchoStandardSubstitute(self):
|
||||||
self.assertNotRegexp('echo $nick', r'\$')
|
self.assertNotRegexp('echo $nick', r'\$')
|
||||||
|
|
||||||
def testRe(self):
|
|
||||||
self.assertResponse('re "m/system time/" foo bar system time baz',
|
|
||||||
'system time')
|
|
||||||
self.assertResponse('re s/user/luser/g user user', 'luser luser')
|
|
||||||
self.assertResponse('re s/user/luser/ user user', 'luser user')
|
|
||||||
self.assertNotRegexp('re m/foo/ bar', 'has no attribute')
|
|
||||||
self.assertResponse('re m/a\S+y/ "the bot angryman is hairy"','angry')
|
|
||||||
|
|
||||||
def testReNotEmptyString(self):
|
|
||||||
self.assertError('re s//foo/g blah')
|
|
||||||
|
|
||||||
def testReWorksWithJustCaret(self):
|
|
||||||
self.assertResponse('re s/^/foo/ bar', 'foobar')
|
|
||||||
|
|
||||||
def testReNoEscapingUnpackListOfWrongSize(self):
|
|
||||||
self.assertNotRegexp('re foo bar baz', 'unpack list of wrong size')
|
|
||||||
|
|
||||||
def testReBug850931(self):
|
|
||||||
self.assertResponse('re s/\b(\w+)\b/\1./g foo bar baz',
|
|
||||||
'foo. bar. baz.')
|
|
||||||
|
|
||||||
def testNotOverlongRe(self):
|
|
||||||
self.assertError('re [strjoin "" s/./ [eval \'xxx\'*400]] blah blah')
|
|
||||||
|
|
||||||
def testApply(self):
|
def testApply(self):
|
||||||
self.assertResponse('apply "utilities last" a', 'a')
|
self.assertResponse('apply "utilities last" a', 'a')
|
||||||
self.assertResponse('apply "utilities last" a b', 'b')
|
self.assertResponse('apply "utilities last" a b', 'b')
|
||||||
|
Loading…
Reference in New Issue
Block a user