mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Added the stuff needed for channel karma.
This commit is contained in:
parent
d9a4a6da36
commit
dda4d61421
@ -158,6 +158,25 @@ class Utilities(callbacks.Privmsg):
|
||||
irc.reply(f(text))
|
||||
re = privmsgs.checkCapability(re, 'trusted')
|
||||
|
||||
def apply(self, irc, msg, args):
|
||||
"""<command> <text>
|
||||
|
||||
Tokenizes <text> and calls <command> with the resulting arguments.
|
||||
"""
|
||||
if not args:
|
||||
raise callbacks.ArgumentError
|
||||
command = args.pop(0)
|
||||
args = [token and token or '""' for token in args]
|
||||
text = privmsgs.getArgs(args)
|
||||
commands = command.split()
|
||||
commands = map(callbacks.canonicalName, commands)
|
||||
tokens = callbacks.tokenize(text)
|
||||
allTokens = commands + tokens
|
||||
print '***', allTokens
|
||||
Owner = irc.getCallback('Owner')
|
||||
Owner.processTokens(irc, msg, allTokens)
|
||||
|
||||
|
||||
|
||||
Class = Utilities
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -549,6 +549,18 @@ class Channel(callbacks.Privmsg):
|
||||
irc.reply(s)
|
||||
else:
|
||||
irc.reply('I\'m not currently lobotomized in any channels.')
|
||||
|
||||
def nicks(self, irc, msg, args):
|
||||
"""[<channel>]
|
||||
|
||||
Returns the nicks in <channel>. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
"""
|
||||
channel = privmsgs.getChannel(msg, args)
|
||||
L = list(irc.state.channels[channel].users)
|
||||
utils.sortBy(str.lower, L)
|
||||
irc.reply(utils.commaAndify(L))
|
||||
|
||||
|
||||
|
||||
Class = Channel
|
||||
|
48
src/Owner.py
48
src/Owner.py
@ -233,6 +233,30 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||
self.disambiguate(irc, elt, ambiguousCommands)
|
||||
return ambiguousCommands
|
||||
|
||||
def processTokens(self, irc, msg, tokens):
|
||||
ambiguousCommands = self.disambiguate(irc, tokens)
|
||||
if ambiguousCommands:
|
||||
if len(ambiguousCommands) == 1: # Common case.
|
||||
(command, names) = ambiguousCommands.popitem()
|
||||
names.sort()
|
||||
s = 'The command %r is available in the %s plugins. ' \
|
||||
'Please specify the plugin whose command you ' \
|
||||
'wish to call by using its name as a command ' \
|
||||
'before calling it.' % \
|
||||
(command, utils.commaAndify(names))
|
||||
else:
|
||||
L = []
|
||||
for (command, names) in ambiguousCommands.iteritems():
|
||||
names.sort()
|
||||
L.append('The command %r is available in the %s '
|
||||
'plugins' %
|
||||
(command, utils.commaAndify(names)))
|
||||
s = '%s; please specify from which plugins to ' \
|
||||
'call these commands.' % '; '.join(L)
|
||||
irc.queueMsg(callbacks.error(msg, s))
|
||||
else:
|
||||
callbacks.IrcObjectProxy(irc, msg, tokens)
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
callbacks.Privmsg.handled = False
|
||||
callbacks.Privmsg.errored = False
|
||||
@ -247,33 +271,11 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||
'of a nested command.'
|
||||
irc.queueMsg(callbacks.error(msg, s))
|
||||
return
|
||||
self.processTokens(irc, msg, tokens)
|
||||
except SyntaxError, e:
|
||||
callbacks.Privmsg.errored = True
|
||||
irc.queueMsg(callbacks.error(msg, str(e)))
|
||||
return
|
||||
ambiguousCommands = {}
|
||||
self.disambiguate(irc, tokens, ambiguousCommands)
|
||||
if ambiguousCommands:
|
||||
if len(ambiguousCommands) == 1: # Common case.
|
||||
(command, names) = ambiguousCommands.popitem()
|
||||
names.sort()
|
||||
s = 'The command %r is available in the %s plugins. ' \
|
||||
'Please specify the plugin whose command you ' \
|
||||
'wish to call by using its name as a command ' \
|
||||
'before calling it.' % \
|
||||
(command, utils.commaAndify(names))
|
||||
else:
|
||||
L = []
|
||||
for (command, names) in ambiguousCommands.iteritems():
|
||||
names.sort()
|
||||
L.append('The command %r is available in the %s '
|
||||
'plugins' %
|
||||
(command, utils.commaAndify(names)))
|
||||
s = '%s; please specify from which plugins to ' \
|
||||
'call these commands.' % '; '.join(L)
|
||||
irc.queueMsg(callbacks.error(msg, s))
|
||||
else:
|
||||
callbacks.IrcObjectProxy(irc, msg, tokens)
|
||||
|
||||
if conf.allowEval:
|
||||
def eval(self, irc, msg, args):
|
||||
|
Loading…
Reference in New Issue
Block a user