Commented out a debug log, change inChannel and checkChannelCapability to automatically run getChannel if there is no state.channel, and perhaps a few other minor tweaks.

This commit is contained in:
Jeremy Fincher 2004-10-02 16:52:26 +00:00
parent 349155191a
commit 21ef10f831

View File

@ -308,7 +308,7 @@ def getChannel(irc, msg, args, state):
state.args.append(channel) state.args.append(channel)
def inChannel(irc, msg, args, state): def inChannel(irc, msg, args, state):
assert not state.channel, 'inChannel acts as a channel' if not state.channel:
getChannel(irc, msg, args, state) getChannel(irc, msg, args, state)
if state.channel not in irc.state.channels: if state.channel not in irc.state.channels:
irc.error('I\'m not in %s.' % state.channel, Raise=True) irc.error('I\'m not in %s.' % state.channel, Raise=True)
@ -320,7 +320,7 @@ def getChannelOrNone(irc, msg, args, state):
state.args.append(None) state.args.append(None)
def checkChannelCapability(irc, msg, args, state, cap): def checkChannelCapability(irc, msg, args, state, cap):
assert not state.channel, 'checkChannelCapability acts as a channel.' if not state.channel:
getChannel(irc, msg, args, state) getChannel(irc, msg, args, state)
cap = ircdb.canonicalCapability(cap) cap = ircdb.canonicalCapability(cap)
cap = ircdb.makeChannelCapability(state.channel, cap) cap = ircdb.makeChannelCapability(state.channel, cap)
@ -375,6 +375,9 @@ def getUrl(irc, msg, args, state):
def getNow(irc, msg, args, state): def getNow(irc, msg, args, state):
state.args.append(int(time.time())) state.args.append(int(time.time()))
def getCommandName(irc, msg, args, state):
state.args.append(callbacks.canonicalName(args.pop(0)))
wrappers = ircutils.IrcDict({ wrappers = ircutils.IrcDict({
'id': getId, 'id': getId,
'int': getInt, 'int': getInt,
@ -394,6 +397,7 @@ wrappers = ircutils.IrcDict({
'lowered': getLowered, 'lowered': getLowered,
'anything': anything, 'anything': anything,
'something': getSomething, 'something': getSomething,
'commandName': getCommandName,
'text': anything, 'text': anything,
'somethingWithoutSpaces': getSomethingNoSpaces, 'somethingWithoutSpaces': getSomethingNoSpaces,
'capability': getSomethingNoSpaces, 'capability': getSomethingNoSpaces,
@ -508,7 +512,7 @@ def args(irc,msg,args, types=[], state=None,
else: else:
assert getopts[opt] == '' assert getopts[opt] == ''
state.getopts.append((opt, True)) state.getopts.append((opt, True))
log.debug('Finished getopts: %s', state.getopts) #log.debug('Finished getopts: %s', state.getopts)
# Second, we get out everything but the last argument (or, if combineRest # Second, we get out everything but the last argument (or, if combineRest
# is False, we'll clear out all the types). # is False, we'll clear out all the types).
@ -541,9 +545,9 @@ def args(irc,msg,args, types=[], state=None,
raise callbacks.ArgumentError raise callbacks.ArgumentError
if requireExtra and not args: if requireExtra and not args:
log.debug('requireExtra and not args: %r', args) log.debug('requireExtra and not args: %r', args)
log.debug('args: %r' % args) log.debug('command.args args: %r' % args)
log.debug('State.args: %r' % state.args) log.debug('command.args state.args: %r' % state.args)
log.debug('State.getopts: %r' % state.getopts) log.debug('command.args state.getopts: %r' % state.getopts)
return state return state
# These are used below, but we need to rename them so their names aren't # These are used below, but we need to rename them so their names aren't