mirror of https://github.com/Mikaela/Limnoria.git
Changed callerInChannel to callerInGivenChannel; added nickInChannel, added matches, and raised a subclass of KeyError from getConverter so we get prettier tracebacks.
This commit is contained in:
parent
425436b5f7
commit
9d0fa5e3ff
|
@ -531,7 +531,7 @@ class Misc(callbacks.Privmsg):
|
|||
'with': 'something',
|
||||
'from': 'something',
|
||||
'without': 'something',
|
||||
'in': 'callerInChannel',
|
||||
'in': 'callerInGivenChannel',
|
||||
'regexp': 'regexpMatcher',})])
|
||||
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ def onlyInChannel(irc, msg, args, state):
|
|||
state.channel = msg.args[0]
|
||||
state.args.append(state.channel)
|
||||
|
||||
def callerInChannel(irc, msg, args, state):
|
||||
def callerInGivenChannel(irc, msg, args, state):
|
||||
channel = args[0]
|
||||
if irc.isChannel(channel):
|
||||
if channel in irc.state.channels:
|
||||
|
@ -354,6 +354,12 @@ def callerInChannel(irc, msg, args, state):
|
|||
else:
|
||||
irc.errorInvalid('channel', args[0])
|
||||
|
||||
def nickInChannel(irc, msg, args, state):
|
||||
inChannel(irc, msg, args, state)
|
||||
if args[0] not in irc.state.channels[state.channel].users:
|
||||
irc.error('%s is not in %s.' % (args[0], state.channel), Raise=True)
|
||||
state.args.append(args.pop(0))
|
||||
|
||||
def getChannelOrNone(irc, msg, args, state):
|
||||
try:
|
||||
getChannel(irc, msg, args, state)
|
||||
|
@ -477,7 +483,8 @@ wrappers = ircutils.IrcDict({
|
|||
'channel': getChannel,
|
||||
'inChannel': inChannel,
|
||||
'onlyInChannel': onlyInChannel,
|
||||
'callerInChannel': callerInChannel,
|
||||
'nickInChannel': nickInChannel,
|
||||
'callerInGivenChannel': callerInGivenChannel,
|
||||
'plugin': getPlugin,
|
||||
'boolean': getBoolean,
|
||||
'lowered': getLowered,
|
||||
|
@ -492,6 +499,7 @@ wrappers = ircutils.IrcDict({
|
|||
'hostmask': getHostmask,
|
||||
'banmask': getBanmask,
|
||||
'user': getUser,
|
||||
'matches': getMatch,
|
||||
'public': public,
|
||||
'private': private,
|
||||
'otherUser': getOtherUser,
|
||||
|
@ -505,8 +513,14 @@ wrappers = ircutils.IrcDict({
|
|||
def addConverter(name, wrapper):
|
||||
wrappers[name] = wrapper
|
||||
|
||||
class UnknownConverter(KeyError):
|
||||
pass
|
||||
|
||||
def getConverter(name):
|
||||
try:
|
||||
return wrappers[name]
|
||||
except KeyError, e:
|
||||
raise UnknownConverter, str(e)
|
||||
|
||||
def callConverter(name, irc, msg, args, state, *L):
|
||||
getConverter(name)(irc, msg, args, state, *L)
|
||||
|
@ -557,6 +571,7 @@ class context(object):
|
|||
# additional means: Look for this (and make sure it's of this type). If
|
||||
# there are no arguments for us to check, then use our default.
|
||||
class additional(context):
|
||||
# XXX We should allow contexts as well as specs.
|
||||
def __init__(self, spec, default=None):
|
||||
self.__parent = super(additional, self)
|
||||
self.__parent.__init__(spec)
|
||||
|
|
Loading…
Reference in New Issue