mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-10-17 09:27:23 +02:00
Updated to add a few more configuration variables.
This commit is contained in:
parent
1f60dc36c2
commit
fda68a2252
@ -54,8 +54,8 @@ import ircmsgs
|
|||||||
import plugins
|
import plugins
|
||||||
import ircutils
|
import ircutils
|
||||||
import privmsgs
|
import privmsgs
|
||||||
|
import registry
|
||||||
import callbacks
|
import callbacks
|
||||||
import configurable
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sqlite
|
import sqlite
|
||||||
@ -63,25 +63,27 @@ except ImportError:
|
|||||||
raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
|
raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
|
||||||
'plugin. Download it at <http://pysqlite.sf.net/>'
|
'plugin. Download it at <http://pysqlite.sf.net/>'
|
||||||
|
|
||||||
def configure(onStart, afterConnect, advanced):
|
|
||||||
# This will be called by setup.py to configure this module. onStart and
|
|
||||||
# afterConnect are both lists. Append to onStart the commands you would
|
|
||||||
# like to be run when the bot is started; append to afterConnect the
|
|
||||||
# commands you would like to be run when the bot has finished connecting.
|
|
||||||
from questions import expect, anything, something, yn
|
|
||||||
onStart.append('load QuoteGrabs')
|
|
||||||
|
|
||||||
grabTime = 864000 # 10 days
|
|
||||||
minRandomLength = 8
|
|
||||||
minRandomWords = 3
|
|
||||||
|
|
||||||
conf.registerPlugin('QuoteGrabs')
|
conf.registerPlugin('QuoteGrabs')
|
||||||
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs, 'randomGrabber',
|
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs, 'randomGrabber',
|
||||||
registry.Boolean(False, """Determines whether the bot will randomly grab
|
registry.Boolean(False, """Determines whether the bot will randomly grab
|
||||||
possibly-suitable quotes for someone."""))
|
possibly-suitable quotes on occasion. The suitability of a given message
|
||||||
|
is determined by ..."""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber,
|
||||||
|
'averageTimeBetweenGrabs',
|
||||||
|
registry.PositiveInteger(864000, """Determines about how many seconds, on
|
||||||
|
average, should elapse between random grabs. This is only an average
|
||||||
|
value; grabs can happen from any time after half this time until never,
|
||||||
|
although that's unlikely to occur."""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber,
|
||||||
|
'minimumWords', registry.PositiveInteger(3, """Determines the minimum
|
||||||
|
number of words in a message for it to be considered for random
|
||||||
|
grabbing."""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.QuoteGrabs.randomGrabber,
|
||||||
|
'minimumCharacters', registry.PositiveInteger(8, """Determines the
|
||||||
|
minimum number of characters in a message for it to be considered for
|
||||||
|
random grabbing."""))
|
||||||
|
|
||||||
class QuoteGrabs(plugins.ChannelDBHandler,
|
class QuoteGrabs(plugins.ChannelDBHandler, callbacks.Privmsg):
|
||||||
callbacks.Privmsg):
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
plugins.ChannelDBHandler.__init__(self)
|
plugins.ChannelDBHandler.__init__(self)
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
@ -108,10 +110,11 @@ class QuoteGrabs(plugins.ChannelDBHandler,
|
|||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
channel = msg.args[0]
|
(channel, payload) = msg.args
|
||||||
if conf.supybot.plugins.QuoteGrabs.randomGrabber():
|
length = self.registryValue('randomGrabber.minimumLength', channel)
|
||||||
if len(msg.args[1]) > minRandomLength and \
|
words = self.registryValue('randomGrabber.minimumWords', channel)
|
||||||
len(msg.args[1].split()) > minRandomWords:
|
if self.registryValue('randomGrabber', channel):
|
||||||
|
if len(payload) > length and len(payload.split()) > words:
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT added_at FROM quotegrabs
|
cursor.execute("""SELECT added_at FROM quotegrabs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user