mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-10-14 17:59:29 +02:00
Fixed a bug in apply and added the shuffle command.
This commit is contained in:
parent
ec2d298d8b
commit
3e10b627c0
@ -39,6 +39,7 @@ __author__ = supybot.authors.jemfinch
|
|||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
|
|
||||||
import types
|
import types
|
||||||
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
@ -114,6 +115,15 @@ class Utilities(callbacks.Privmsg):
|
|||||||
irc.reply(text, prefixName=False)
|
irc.reply(text, prefixName=False)
|
||||||
echo = wrap(echo, ['text'])
|
echo = wrap(echo, ['text'])
|
||||||
|
|
||||||
|
def shuffle(self, irc, msg, args, things):
|
||||||
|
"""<arg> [<arg> ...]
|
||||||
|
|
||||||
|
Shuffles the arguments given it.
|
||||||
|
"""
|
||||||
|
random.shuffle(things)
|
||||||
|
irc.reply(' '.join(things))
|
||||||
|
shuffle = wrap(shuffle, [many('anything')])
|
||||||
|
|
||||||
def re(self, irc, msg, args, ff, text):
|
def re(self, irc, msg, args, ff, text):
|
||||||
"""<regexp> <text>
|
"""<regexp> <text>
|
||||||
|
|
||||||
@ -135,22 +145,20 @@ class Utilities(callbacks.Privmsg):
|
|||||||
first('regexpMatcher', 'regexpReplacer'),
|
first('regexpMatcher', 'regexpReplacer'),
|
||||||
'text'])
|
'text'])
|
||||||
|
|
||||||
def apply(self, irc, msg, args, command):
|
def apply(self, irc, msg, args, command, rest):
|
||||||
"""<command> <text>
|
"""<command> <text>
|
||||||
|
|
||||||
Tokenizes <text> and calls <command> with the resulting arguments.
|
Tokenizes <text> and calls <command> with the resulting arguments.
|
||||||
"""
|
"""
|
||||||
if not args:
|
args = [token and token or '""' for token in rest]
|
||||||
raise callbacks.ArgumentError
|
|
||||||
command = args.pop(0)
|
|
||||||
args = [token and token or '""' for token in args]
|
|
||||||
text = ' '.join(args)
|
text = ' '.join(args)
|
||||||
commands = command.split()
|
commands = command.split()
|
||||||
commands = map(callbacks.canonicalName, commands)
|
commands = map(callbacks.canonicalName, commands)
|
||||||
tokens = callbacks.tokenize(text)
|
tokens = callbacks.tokenize(text)
|
||||||
allTokens = commands + tokens
|
allTokens = commands + tokens
|
||||||
|
print '***', allTokens
|
||||||
self.Proxy(irc, msg, allTokens)
|
self.Proxy(irc, msg, allTokens)
|
||||||
apply = wrap(apply, ['something'], allowExtra=True)
|
apply = wrap(apply, ['something', many('anything')])
|
||||||
|
|
||||||
|
|
||||||
Class = Utilities
|
Class = Utilities
|
||||||
|
Loading…
Reference in New Issue
Block a user