diff --git a/src/commands.py b/src/commands.py index 403f07b87..b0cd8363f 100644 --- a/src/commands.py +++ b/src/commands.py @@ -238,14 +238,6 @@ def getBoolean(irc, msg, args, state): except ValueError: irc.errorInvalid('boolean', args[0]) -def getChannelDb(irc, msg, args, state, **kwargs): - if not conf.supybot.databases.plugins.channelSpecific(): - channel = conf.supybot.databases.plugins.channelSpecific.channel() - state.args.append(channel) - state.channel = channel - else: - getChannel(irc, msg, args, state, **kwargs) - def getNetworkIrc(irc, msg, args, state, errorIfNoMatch=False): if args: for otherIrc in world.ircs: @@ -365,6 +357,18 @@ def getChannel(irc, msg, args, state): state.channel = channel state.args.append(channel) +def getChannelDb(irc, msg, args, state, **kwargs): + channelSpecific = conf.supybot.databases.plugins.channelSpecific + try: + getChannel(irc, msg, args, state, **kwargs) + if state.channel and not conf.get(channelSpecific, state.channel): + state.channel = conf.get(channelSpecific.channel, state.channel) + except (callbacks.ArgumentError, IndexError): + if channelSpecific(): + raise + else: + state.channel = channelSpecific.channel() + def inChannel(irc, msg, args, state): if not state.channel: getChannel(irc, msg, args, state) diff --git a/src/conf.py b/src/conf.py index ffab34bc1..00be0949f 100644 --- a/src/conf.py +++ b/src/conf.py @@ -802,7 +802,7 @@ registerChannelValue(supybot.databases.plugins, 'channelSpecific', this variable to take effect; also note that you may wish to set supybot.databases.plugins.channelSpecific.channel appropriately if you wish to share a certain channel's databases globally.""")) -registerGlobalValue(supybot.databases.plugins.channelSpecific, 'channel', +registerChannelValue(supybot.databases.plugins.channelSpecific, 'channel', ValidChannel('#', """Determines what channel global (non-channel-specific) databases will be considered a part of. This is helpful if you've been running channel-specific for awhile and want to turn the databases for your