39
39
from network import freenode, freenodeSubstitution
41
41
factosConf = conf.supybot.plugins.Factos
42
tableConf = factosConf.sqlite.table
45
tableFact = objects.Table(objects.tblFactStruct, tableConf.fact())
46
# base table for record edits
47
tableHist = objects.Table(objects.tblHistStruct, tableConf.history())
48
tableHistRedo = objects.Table(objects.tblHistStruct, tableConf.redo())
49
# table for user hostmasks
50
tableUser = objects.databases.Table(objects.tblUserStruct, tableConf.users())
52
class FactosDB(objects.SqliteDB):
53
def __init__(self, filename, **kwargs):
54
self.__parent = super(FactosDB, self)
55
self.__parent.__init__(filename, tableFact, tableHist, tableHistRedo, tableUser,
43
FactosDB = objects.SqliteDB
58
44
class MultiFactosDB(MultiDB):
59
45
database = FactosDB
62
49
class Fact(objects.Fact):
63
50
"""Class for handling facts."""
65
dbTableHist = tableHist
66
51
prefix = conf.supybot.reply.whenAddressedBy.chars()[0]
67
52
regexp = u'[\w\-\.\#]+' # regexp for a valid fact name
68
53
formatChannel = staticmethod(formatChannel) # better use formatChannel from supyutils
125
class User(objects.User):
126
"""Class for handling users."""
130
110
def logInfo(irc, msg, s, fact=None):
131
111
"""Information logging."""
132
112
vars = {'msg': msg.args[1]}
814
hist = db.getHist(fact.name, channel=fact.channel, table=tableHistRedo)
794
hist = db.getHist(fact.name, channel=fact.channel, table=db.tableHistRedo)
817
797
hist = db.getHist(fact.name, channel=fact.channel)
1273
1253
fact.pull(channel)
1274
hist = db.getHistOne(fact.name, channel=fact.channel, table=tableHistRedo)
1254
hist = db.getHistOne(fact.name, channel=fact.channel, table=db.tableHistRedo)
1276
1256
db.updateHist(fact.getHist(), hist['history_id'], undo=False,
1277
1257
channel=fact.channel)
1294
1274
db = self.db.getDB(name=self.registryValue('sqlite.default', channel))
1296
1276
if 'all-channels' in self.options:
1297
tableList = db.getTables(all=self.registryValue('sqlite.table.fact'))
1277
tableList = db.getTables(all=db.tableFact.name) # FIXME
1299
1279
tableList = db.getTables(inChannel=channel)
1301
tableList = db.getTables(all=self.registryValue('sqlite.table.fact'))
1281
tableList = db.getTables(all=db.tableFact.name) # FIXME
1303
1283
#log.debug('Factos.search() tables=%s' % (tableList, ))
1304
1284
matchall = True