mirror of https://github.com/Mikaela/Limnoria.git
We shouldn't confirm for alsos. Add some more ends and add starts. Also,
move the sqlite import inside of SqliteInfobotDB
This commit is contained in:
parent
cad43feff1
commit
c4b2d53468
|
@ -56,11 +56,6 @@ import supybot.privmsgs as privmsgs
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
try:
|
|
||||||
import sqlite
|
|
||||||
except ImportError:
|
|
||||||
raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
|
|
||||||
'plugin. Download it at <http://pysqlite.sf.net/>'
|
|
||||||
|
|
||||||
conf.registerPlugin('Infobot')
|
conf.registerPlugin('Infobot')
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.Infobot, 'personality',
|
conf.registerGlobalValue(conf.supybot.plugins.Infobot, 'personality',
|
||||||
|
@ -96,7 +91,15 @@ dunnos = ['Dunno',
|
||||||
'No idea',
|
'No idea',
|
||||||
'I don\'t know',
|
'I don\'t know',
|
||||||
'I have no idea',
|
'I have no idea',
|
||||||
'I don\'t have a clue',]
|
'I don\'t have a clue',
|
||||||
|
'Bugger all, I dunno',
|
||||||
|
'Wish I knew',]
|
||||||
|
starts = ['It has been said that ',
|
||||||
|
'I guess ',
|
||||||
|
'',
|
||||||
|
'hmm... ',
|
||||||
|
'Rumor has it ',
|
||||||
|
'Somebody said ',]
|
||||||
confirms = ['10-4',
|
confirms = ['10-4',
|
||||||
'Okay',
|
'Okay',
|
||||||
'Got it',
|
'Got it',
|
||||||
|
@ -226,11 +229,23 @@ class PickleInfobotDB(object):
|
||||||
|
|
||||||
class SqliteInfobotDB(object):
|
class SqliteInfobotDB(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
try:
|
||||||
|
import sqlite
|
||||||
|
except ImportError:
|
||||||
|
raise callbacks.Error, 'You need to have PySQLite installed to '\
|
||||||
|
'use this plugin. Download it at '\
|
||||||
|
'<http://pysqlite.sf.net/>'
|
||||||
self._changes = 0
|
self._changes = 0
|
||||||
self._responses = 0
|
self._responses = 0
|
||||||
self.db = None
|
self.db = None
|
||||||
|
|
||||||
def _getDb(self):
|
def _getDb(self):
|
||||||
|
try:
|
||||||
|
import sqlite
|
||||||
|
except ImportError:
|
||||||
|
raise callbacks.Error, 'You need to have PySQLite installed to '\
|
||||||
|
'use this plugin. Download it at '\
|
||||||
|
'<http://pysqlite.sf.net/>'
|
||||||
if self.db is not None:
|
if self.db is not None:
|
||||||
return self.db
|
return self.db
|
||||||
try:
|
try:
|
||||||
|
@ -598,7 +613,8 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
r"^(.+?)\s*\?[?!. ]*$"
|
r"^(.+?)\s*\?[?!. ]*$"
|
||||||
key = match.group(1)
|
key = match.group(1)
|
||||||
if self.addressed or self.registryValue('answerUnaddressedQuestions'):
|
if self.addressed or self.registryValue('answerUnaddressedQuestions'):
|
||||||
self.factoid(key) # Does the dunno'ing for us itself.
|
# Does the dunno'ing for us itself.
|
||||||
|
self.factoid(key, prepend=random.choice(starts))
|
||||||
|
|
||||||
def invalidCommand(self, irc, msg, tokens):
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
irc.finished = True
|
irc.finished = True
|
||||||
|
@ -611,7 +627,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
# It's a question.
|
# It's a question.
|
||||||
if self.addressed or \
|
if self.addressed or \
|
||||||
self.registryValue('answerUnaddressedQuestions'):
|
self.registryValue('answerUnaddressedQuestions'):
|
||||||
self.factoid(value)
|
self.factoid(value, prepend=random.choice(starts))
|
||||||
return
|
return
|
||||||
if not self.addressed and \
|
if not self.addressed and \
|
||||||
not self.registryValue('snarfUnaddressedDefinitions'):
|
not self.registryValue('snarfUnaddressedDefinitions'):
|
||||||
|
@ -657,7 +673,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
self.log.debug('Already have a %r key.', key)
|
self.log.debug('Already have a %r key.', key)
|
||||||
return
|
return
|
||||||
self.db.setAre(key, value)
|
self.db.setAre(key, value)
|
||||||
if self.addressed or self.force or also:
|
if self.addressed or self.force:
|
||||||
self.confirm()
|
self.confirm()
|
||||||
|
|
||||||
def stats(self, irc, msg, args):
|
def stats(self, irc, msg, args):
|
||||||
|
|
Loading…
Reference in New Issue