ChannelStats: Skip checks of nick in irc.state.channels[channel] when channel databases are linked.

It crashes with KeyError because databases.plugins.channelspecific sets
channel='#', which is a non-existent channel.
And it doesn't make sense to check for presence in channel if the DB is
shared between all channels anyway.
This commit is contained in:
Valentin Lorentz 2020-04-07 21:17:52 +02:00
parent c489d2e9be
commit 2bbd43fd85

View File

@ -242,6 +242,8 @@ class ChannelStats(callbacks.Plugin):
necessary if the message isn't sent on the channel itself. If <name>
isn't given, it defaults to the user sending the command.
"""
if channel != '#':
# Skip this check if databases.plugins.channelspecific is False.
if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel))
return
@ -303,6 +305,8 @@ class ChannelStats(callbacks.Plugin):
'kicks', 'kicked', 'topics', and 'modes'. Any simple mathematical
expression involving those variables is permitted.
"""
if channel != '#':
# Skip this check if databases.plugins.channelspecific is False.
if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel))
return