Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

commands.py: Add 'channelOrGlobal' converter.

  • Loading branch information...
commit d3da0c2efc790c2418f90fea4f9ceab5f2bfa7a2 1 parent 4d1a7ea
@ProgVal authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/commands.py
View
16 src/commands.py
@@ -511,6 +511,21 @@ def getChannelOrNone(irc, msg, args, state):
except callbacks.ArgumentError:
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):
if not state.channel:
getChannel(irc, msg, args, state)
@@ -679,6 +694,7 @@ def getText(irc, msg, args, state):
# something better
'capability': getSomethingNoSpaces,
'channel': getChannel,
+ 'channelOrGlobal': getChannelOrGlobal,
'channelDb': getChannelDb,
'checkCapability': checkCapability,
'checkCapabilityButIgnoreOwner': checkCapabilityButIgnoreOwner,
Please sign in to comment.
Something went wrong with that request. Please try again.