diff --git a/ChangeLog b/ChangeLog index 6ccb92d0f..4727320c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ + * Added supybot.databases.plugins.channelSpecific, a channel + value that determines whether the database used for channel-based + plugins will be a channel-specific database or a global database. + + * Changed the way channel databases are handled; instead of + generating numerous #channel- files, instead we create a + subdirectory of the data directory named #channel, and then stick + all the files in there. + * Added several configuration variables to the Status plugin to determine how verbose the cpu command is. diff --git a/plugins/__init__.py b/plugins/__init__.py index a42b29aa4..aafbc38b6 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -112,10 +112,18 @@ class DBHandler(object): def makeChannelFilename(channel, filename): # XXX We should put channel stuff in its own directory. - assert filename == os.path.basename(filename) + assert filename == os.path.basename(filename), 'We don\'t handle dirs.' channel = ircutils.toLower(channel) - filename = '%s-%s' % (channel, filename) - return conf.supybot.directories.data.dirize(filename) + if conf.supybot.databases.plugins.channelSpecific.get(channel)(): + # Should we offer the old #channel-filename naming scheme? + dir = conf.supybot.directories.data.dirize(channel) + if not os.path.exists(dir): + os.mkdir(dir) + return os.path.join(dir, filename) + else: + return conf.supybot.directories.data.dirize(filename) +## filename = '%s-%s' % (channel, filename) +## return conf.supybot.directories.data.dirize(filename) # XXX: This shouldn't be a mixin. This should be contained by classes that # want such behavior. But at this point, it wouldn't gain much for us diff --git a/src/conf.py b/src/conf.py index 9bb4ee14b..5b5b46672 100644 --- a/src/conf.py +++ b/src/conf.py @@ -618,6 +618,12 @@ registerGlobalValue(supybot.databases.channels, 'filename', for the channels database. This file will go into the directory specified by the supybot.directories.conf variable.""")) +registerGroup(supybot.databases, 'plugins') +registerChannelValue(supybot.databases.plugins, 'channelSpecific', + registry.Boolean(True, """Determines whether database-based plugins that + can be channel-specific will be so. This can be overridden by individual + channels.""")) + ### # Protocol information. ###