Seen: check to see if the bot is in target channel before doing anything.

Otherwise the check to see if user is in channel generated an error.
This commit is contained in:
Daniel Folkinshteyn 2012-08-30 15:34:28 -04:00
parent 031b09307e
commit c7ed79571a

View File

@ -218,6 +218,9 @@ class Seen(callbacks.Plugin):
saying. <channel> is only necessary if the message isn't sent on the saying. <channel> is only necessary if the message isn't sent on the
channel itself. <nick> may contain * as a wildcard. channel itself. <nick> may contain * as a wildcard.
""" """
if channel not in irc.state.channels.keys():
irc.error(format('I am not in %s.', channel))
return
if msg.nick not in irc.state.channels[channel].users: if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel)) irc.error(format('You must be in %s to use this command.', channel))
return return
@ -234,6 +237,9 @@ class Seen(callbacks.Plugin):
and returns the last time user was active in <channel>. <channel> is and returns the last time user was active in <channel>. <channel> is
only necessary if the message isn't sent on the channel itself. only necessary if the message isn't sent on the channel itself.
""" """
if channel not in irc.state.channels.keys():
irc.error(format('I am not in %s.', channel))
return
if msg.nick not in irc.state.channels[channel].users: if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel)) irc.error(format('You must be in %s to use this command.', channel))
return return
@ -270,6 +276,9 @@ class Seen(callbacks.Plugin):
Returns the last thing said in <channel>. <channel> is only necessary Returns the last thing said in <channel>. <channel> is only necessary
if the message isn't sent in the channel itself. if the message isn't sent in the channel itself.
""" """
if channel not in irc.state.channels.keys():
irc.error(format('I am not in %s.', channel))
return
if msg.nick not in irc.state.channels[channel].users: if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel)) irc.error(format('You must be in %s to use this command.', channel))
return return
@ -298,6 +307,9 @@ class Seen(callbacks.Plugin):
<channel> is only necessary if the message isn't sent in the channel <channel> is only necessary if the message isn't sent in the channel
itself. itself.
""" """
if channel not in irc.state.channels.keys():
irc.error(format('I am not in %s.', channel))
return
if msg.nick not in irc.state.channels[channel].users: if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel)) irc.error(format('You must be in %s to use this command.', channel))
return return
@ -309,6 +321,9 @@ class Seen(callbacks.Plugin):
Returns the messages since <nick> last left the channel. Returns the messages since <nick> last left the channel.
""" """
if channel not in irc.state.channels.keys():
irc.error(format('I am not in %s.', channel))
return
if msg.nick not in irc.state.channels[channel].users: if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel)) irc.error(format('You must be in %s to use this command.', channel))
return return