RelayLink: reorder user in channel checks

This commit is contained in:
GLolol 2014-06-25 17:54:11 -07:00
parent 656a0d4053
commit 4bcce98436

19
RelayLink/plugin.py Normal file → Executable file
View File

@ -382,14 +382,20 @@ class RelayLink(callbacks.Plugin):
@internationalizeDocstring @internationalizeDocstring
def nicks(self, irc, msg, args, channel, optlist): def nicks(self, irc, msg, args, channel, optlist):
"""[<channel>] """[<channel>] [--count]
Returns the nicks of the people in the linked channels. Returns the nicks of the people in the linked channels.
<channel> is only necessary if the message <channel> is only necessary if the message
isn't sent on the channel itself.""" isn't sent on the channel itself.
If --count is specified, only the amount of """
keys = [option for (option, arg) in optlist] keys = [option for (option, arg) in optlist]
if irc.nested and 'count' not in keys: if irc.nested and 'count' not in keys:
irc.error('This command cannot be nested.', Raise=True) irc.error('This command cannot be nested.', Raise=True)
if msg.nick not in irc.state.channels[channel].users:
self.log.warning('RelayLink: %s on %s attempted to view'
' nicks in %s without being in it.'
% (msg.nick, irc.network, channel))
irc.error(('You are not in %s.' % channel), Raise=True)
# Include the local channel for nicks output # Include the local channel for nicks output
c = irc.state.channels[channel] c = irc.state.channels[channel]
totalUsers = len(c.users) totalUsers = len(c.users)
@ -414,15 +420,8 @@ class RelayLink(callbacks.Plugin):
for relay in self.relays: for relay in self.relays:
if relay.sourceChannel == channel and \ if relay.sourceChannel == channel and \
relay.sourceNetwork == irc.network: relay.sourceNetwork == irc.network:
# Little security function here to prevent spies :P
totalChans += 1 totalChans += 1
if msg.nick not in irc.state.channels[channel].users: if not relay.hasTargetIRC:
self.log.warning('RelayLink: %s on %s attempted to view'
' nicks in %s without being in it.'
% (msg.nick, irc.network, channel))
irc.error(_('You are not in %s.' % channel))
break
elif not relay.hasTargetIRC:
irc.reply(_('I haven\'t scraped the IRC object for %s ' irc.reply(_('I haven\'t scraped the IRC object for %s '
'yet. Try again in a minute or two.') % \ 'yet. Try again in a minute or two.') % \
relay.targetNetwork) relay.targetNetwork)