* Fixes in Mess
* Made Encyclopedia close/open database connections about hourly (depending on usage) * Encyclopedias prefixcha is now per-channel
This commit is contained in:
parent
bc89a4d644
commit
02f675df11
|
@ -28,7 +28,7 @@ conf.registerGlobalValue(Encyclopedia, 'relaychannel',
|
|||
registry.String('#ubuntu-ops', 'Relay channel for unauthorized edits'))
|
||||
conf.registerGlobalValue(Encyclopedia, 'notfoundmsg',
|
||||
registry.String('Factoid %s not found', 'Reply when factoid isn\'t found'))
|
||||
conf.registerGlobalValue(Encyclopedia,'prefixchar',
|
||||
conf.registerChannelValue(Encyclopedia,'prefixchar',
|
||||
registry.String('!','Prefix character for factoid display/editing'))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'searchorder',
|
||||
|
|
|
@ -141,17 +141,23 @@ class Encyclopedia(callbacks.Plugin):
|
|||
|
||||
def get_db(self, channel):
|
||||
db = self.registryValue('database',channel)
|
||||
if channel in self.databases:
|
||||
if self.databases[channel].time < time.time - 3600:
|
||||
self.databases[channel].close()
|
||||
self.databases.pop(channel)
|
||||
if channel not in self.databases:
|
||||
self.databases[channel] = sqlite.connect(os.path.join(self.registryValue('datadir'), '%s.db' % db))
|
||||
self.databases[channel].name = db
|
||||
self.databases[channel].time = time.time()
|
||||
return self.databases[channel]
|
||||
|
||||
def addressed(self, recipients, text, irc):
|
||||
if recipients[0] == '#':
|
||||
text = text.strip()
|
||||
if text.lower() == self.registryValue('prefixchar') + irc.nick.lower():
|
||||
if text.lower() == self.registryValue('prefixchar', channel=recipients) + irc.nick.lower():
|
||||
return irc.nick.lower()
|
||||
if len(text) and text[0] == self.registryValue('prefixchar'):
|
||||
if len(text) and text[0] ==
|
||||
self.registryValue('prefixchar',channel=recipients):
|
||||
text = text[1:]
|
||||
if text.lower().startswith(irc.nick.lower()) and (len(text) < 5 or not text[5].isalnum()):
|
||||
t2 = text[5:].strip()
|
||||
|
@ -168,7 +174,7 @@ class Encyclopedia(callbacks.Plugin):
|
|||
comm = text.split()[0]
|
||||
if c.isCommandMethod(comm) and not c.isDisabled(comm):
|
||||
return False
|
||||
if text[0] == self.registryValue('prefixchar'):
|
||||
if text[0] == self.registryValue('prefixchar',channel=recipients):
|
||||
return text[1:]
|
||||
return text
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import re
|
|||
from supybot.commands import *
|
||||
import supybot.plugins as plugins
|
||||
import supybot.ircutils as ircutils
|
||||
import random
|
||||
|
||||
class Lart(plugins.ChannelIdDatabasePlugin):
|
||||
_meRe = re.compile(r'\bme\b', re.I)
|
||||
|
@ -74,7 +75,8 @@ class Lart(plugins.ChannelIdDatabasePlugin):
|
|||
text = self._replaceFirstPerson(lart.text, msg.nick)
|
||||
if ircutils.strEqual(target, irc.nick) or \
|
||||
'ubotu' in target.lower() or 'ubugtu' in target.lower() or \
|
||||
'seveas' in target.lower():
|
||||
'seveas' in target.lower() or \
|
||||
((not msg.prefix.endswith('seveas')) and random.uniform(0,100) < 25):
|
||||
target = msg.nick
|
||||
reason = ''
|
||||
else:
|
||||
|
|
|
@ -52,7 +52,8 @@ for m in mess.keys():
|
|||
fd.close()
|
||||
|
||||
badwords = ['sex','masturbate','fuck','rape','dick','pussy','prostitute','hooker',
|
||||
'orgasm','sperm','cunt','penis','shit','piss','urin','bitch','semen','cock']
|
||||
'orgasm','sperm','cunt','penis','shit','piss','urin','bitch','semen','cock',
|
||||
'retarded']
|
||||
tagre = re.compile(r'<.*?>')
|
||||
def filter(txt,off):
|
||||
_txt = txt.lower()
|
||||
|
@ -69,7 +70,6 @@ def filter(txt,off):
|
|||
times = {}
|
||||
|
||||
def ok(func):
|
||||
func.offensive = False
|
||||
def newfunc(*args, **kwargs):
|
||||
global time
|
||||
plugin = args[0]
|
||||
|
@ -124,8 +124,12 @@ class Mess(callbacks.PluginRegexp):
|
|||
def messcb(self, irc, msg, args):
|
||||
"""General mess"""
|
||||
global data
|
||||
cmd = msg.args[1][1:]
|
||||
(loc, tx, off) = mess[cmd]
|
||||
cmd = msg.args[1].split()[-1]
|
||||
try:
|
||||
(loc, tx, off) = mess[cmd]
|
||||
except:
|
||||
cmd = cmd[1:]
|
||||
(loc, tx, off) = mess[cmd]
|
||||
if off and not self.registryValue('offensive', msg.args[0]):
|
||||
return
|
||||
if loc.startswith('http'):
|
||||
|
|
Loading…
Reference in New Issue