From 56a6799deb0fdcd77434baf85d8629450df783fc Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 10 Oct 2013 18:54:50 -0400 Subject: [PATCH] commands: Consolidate state.channel checks into getChannel Signed-off-by: James McCoy --- src/commands.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/commands.py b/src/commands.py index ca079d7a0..ef3d2c043 100644 --- a/src/commands.py +++ b/src/commands.py @@ -303,8 +303,7 @@ def getNetworkIrc(irc, msg, args, state, errorIfNoMatch=False): state.args.append(irc) def getHaveOp(irc, msg, args, state, action='do that'): - if not state.channel: - getChannel(irc, msg, args, state) + getChannel(irc, msg, args, state) if state.channel not in irc.state.channels: state.error('I\'m not even in %s.' % state.channel, Raise=True) if not irc.state.channels[state.channel].isOp(irc.nick): @@ -329,8 +328,7 @@ def getHostmask(irc, msg, args, state): def getBanmask(irc, msg, args, state): getHostmask(irc, msg, args, state) - if not state.channel: - getChannel(irc, msg, args, state) + getChannel(irc, msg, args, state) channel = state.channel banmaskstyle = conf.supybot.protocols.irc.banmask state.args[-1] = banmaskstyle.makeBanmask(state.args[-1]) @@ -406,6 +404,8 @@ def getSeenNick(irc, msg, args, state, errmsg=None): state.error(errmsg, Raise=True) def getChannel(irc, msg, args, state): + if state.channel: + return if args and irc.isChannel(args[0]): channel = args.pop(0) elif irc.isChannel(msg.args[0]): @@ -437,8 +437,7 @@ def getChannelDb(irc, msg, args, state, **kwargs): state.args.append(channel) def inChannel(irc, msg, args, state): - if not state.channel: - getChannel(irc, msg, args, state) + getChannel(irc, msg, args, state) if state.channel not in irc.state.channels: state.error('I\'m not in %s.' % state.channel, Raise=True) @@ -478,8 +477,7 @@ def getChannelOrNone(irc, msg, args, state): state.args.append(None) def checkChannelCapability(irc, msg, args, state, cap): - if not state.channel: - getChannel(irc, msg, args, state) + getChannel(irc, msg, args, state) cap = ircdb.canonicalCapability(cap) cap = ircdb.makeChannelCapability(state.channel, cap) if not ircdb.checkCapability(msg.prefix, cap):