mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
commands.py: Add 'channelOrGlobal' converter.
This commit is contained in:
parent
4d1a7ea32a
commit
d3da0c2efc
@ -511,6 +511,21 @@ def getChannelOrNone(irc, msg, args, state):
|
|||||||
except callbacks.ArgumentError:
|
except callbacks.ArgumentError:
|
||||||
state.args.append(None)
|
state.args.append(None)
|
||||||
|
|
||||||
|
def getChannelOrGlobal(irc, msg, args, state):
|
||||||
|
if args and args[0] == 'global':
|
||||||
|
channel = args.pop(0)
|
||||||
|
channel = 'global'
|
||||||
|
elif args and irc.isChannel(args[0]):
|
||||||
|
channel = args.pop(0)
|
||||||
|
state.channel = channel
|
||||||
|
elif irc.isChannel(msg.args[0]):
|
||||||
|
channel = msg.args[0]
|
||||||
|
state.channel = channel
|
||||||
|
else:
|
||||||
|
state.log.debug('Raising ArgumentError because there is no channel.')
|
||||||
|
raise callbacks.ArgumentError
|
||||||
|
state.args.append(channel)
|
||||||
|
|
||||||
def checkChannelCapability(irc, msg, args, state, cap):
|
def checkChannelCapability(irc, msg, args, state, cap):
|
||||||
if not state.channel:
|
if not state.channel:
|
||||||
getChannel(irc, msg, args, state)
|
getChannel(irc, msg, args, state)
|
||||||
@ -679,6 +694,7 @@ wrappers = ircutils.IrcDict({
|
|||||||
# something better
|
# something better
|
||||||
'capability': getSomethingNoSpaces,
|
'capability': getSomethingNoSpaces,
|
||||||
'channel': getChannel,
|
'channel': getChannel,
|
||||||
|
'channelOrGlobal': getChannelOrGlobal,
|
||||||
'channelDb': getChannelDb,
|
'channelDb': getChannelDb,
|
||||||
'checkCapability': checkCapability,
|
'checkCapability': checkCapability,
|
||||||
'checkCapabilityButIgnoreOwner': checkCapabilityButIgnoreOwner,
|
'checkCapabilityButIgnoreOwner': checkCapabilityButIgnoreOwner,
|
||||||
|
Loading…
Reference in New Issue
Block a user