mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 07:34:08 +01:00
add vacuum method to clean up db. require admin capability by default to do this.
This commit is contained in:
parent
1a3d6c3821
commit
3eb6787f6d
@ -54,5 +54,8 @@ conf.registerChannelValue(MessageParser, 'keepRankInfo',
|
||||
conf.registerChannelValue(MessageParser, 'rankListLength',
|
||||
registry.Integer(20, """Determines the number of regexps returned
|
||||
by the triggerrank command."""))
|
||||
conf.registerChannelValue(MessageParser, 'requireVacuumCapability',
|
||||
registry.String('admin', """Determines the capability required (if any) to
|
||||
vacuum the database."""))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -362,6 +362,26 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
|
||||
irc.reply(", ".join(s))
|
||||
rank = wrap(rank, ['channel'])
|
||||
|
||||
def vacuum(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
|
||||
Vacuums the database for <channel>.
|
||||
See SQLite vacuum doc here: http://www.sqlite.org/lang_vacuum.html
|
||||
<channel> is only necessary if the message isn't sent in
|
||||
the channel itself.
|
||||
First check if user has the required capability specified in plugin
|
||||
config requireVacuumCapability.
|
||||
"""
|
||||
capability = self.registryValue('requireVacuumCapability')
|
||||
if capability:
|
||||
if not ircdb.checkCapability(msg.prefix, capability):
|
||||
irc.errorNoCapability(capability, Raise=True)
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""VACUUM""")
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
vacuum = wrap(vacuum, ['channel'])
|
||||
|
||||
Class = MessageParser
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user