From af1d04291dfde4a713a0ff21456e44d5d7e5866c Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 13 Dec 2004 06:18:41 +0000 Subject: [PATCH] Reimplementation of channeldb converter, respecting the channelValueness of supybot.databases.plugins.channelSpecific, and turned supybot.databases.plugins.channelSpecific.channel into a channelValue so channels can link their databases to other channels. --- src/commands.py | 20 ++++++++++++-------- src/conf.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) 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