Bantracker timezone defaults to UTC

Encyclopedia:
  calling @sync reloads the plugin after successfully downloading the new database
  allert command and relay channel and configurable per-channel
  (LoCo channels can set the relay to #ubuntu-irc if they want)
  Adding an alias without first creating a dummy factoid should be fixed
This commit is contained in:
Terence Simpson 2008-05-10 16:13:26 +01:00
parent dc653d3df1
commit 398938dbcd
4 changed files with 32 additions and 11 deletions

View File

@ -50,7 +50,7 @@ import supybot.conf as conf
import supybot.ircdb as ircdb
import sqlite, pytz, cPickle, datetime, time, random, md5
tz = 'Europe/Amsterdam'
tz = 'UTC'
def now():
return cPickle.dumps(datetime.datetime.now(pytz.timezone(tz)))

View File

@ -35,3 +35,9 @@ if world.testing:
Class = plugin.Class
configure = config.configure
def reloadPlugin():
reload(config)
reload(plugin)
Class = plugin.Class
configure = config.configure

View File

@ -24,7 +24,7 @@ conf.registerChannelValue(Encyclopedia, 'database',
registry.String('', 'Name of database to use'))
conf.registerGlobalValue(Encyclopedia, 'packagelookup',
registry.Boolean(True, "Whether to look up packages"))
conf.registerGlobalValue(Encyclopedia, 'relaychannel',
conf.registerChannelValue(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'))
@ -38,7 +38,7 @@ conf.registerGlobalValue(Encyclopedia, 'datadir',
registry.String('', 'Path to dir containing factoid databases',private=True))
conf.registerGlobalValue(Encyclopedia, 'aptdir',
registry.String('', 'Path to apt cache directory',private=True))
conf.registerGlobalValue(Encyclopedia, 'alert',
conf.registerChannelValue(Encyclopedia, 'alert',
registry.String('ops','factoid name used for alerts'))
conf.registerGlobalValue(Encyclopedia, 'remotedb',
registry.String('http://jussi01.com/ubuntu.db', 'Remote location of the master database'))

View File

@ -19,7 +19,13 @@ import sqlite, datetime, time
import supybot.registry as registry
import supybot.ircdb as ircdb
import supybot.conf as conf
import re, os, time
import sys, os, time
if sys.version_info >= (2, 5, 0)
import re
else:
import sre as re
import packages
reload(packages)
@ -227,7 +233,7 @@ class Encyclopedia(callbacks.Plugin):
return Factoid(f[0],f[1],f[2],f[3],f[4])
def resolve_alias(self, channel, factoid, loop=0):
if factoid and factoid.name == self.registryValue('alert'):
if factoid and factoid.name == self.registryValue('alert',channel):
self.alert = True
if loop >= 10:
return Factoid('','<reply> Error: infinite <alias> loop detected','','',0)
@ -327,8 +333,8 @@ class Encyclopedia(callbacks.Plugin):
or '~=' in lower_text or '<alias>' in lower_text or lower_text.startswith('forget') or lower_text.startswith('unforget'):
if not capab(msg.prefix, 'editfactoids'):
irc.reply("Your edit request has been forwarded to %s. Thank you for your attention to detail" %
self.registryValue('relaychannel'),private=True)
irc.queueMsg(ircmsgs.privmsg(self.registryValue('relaychannel'), "In %s, %s said: %s" %
self.registryValue('relaychannel',channel),private=True)
irc.queueMsg(ircmsgs.privmsg(self.registryValue('relaychannel',channel), "In %s, %s said: %s" %
(msg.args[0], msg.nick, msg.args[1])))
return
ret = self.factoid_edit(text, channel, msg.prefix)
@ -338,8 +344,8 @@ class Encyclopedia(callbacks.Plugin):
irc.error("I am only a bot, please don't think I'm intelligent :)")
else:
irc.reply("Your edit request has been forwarded to %s. Thank you for your attention to detail" %
self.registryValue('relaychannel'),private=True)
irc.queueMsg(ircmsgs.privmsg(self.registryValue('relaychannel'), "In %s, %s said: %s" %
self.registryValue('relaychannel',channel),private=True)
irc.queueMsg(ircmsgs.privmsg(self.registryValue('relaychannel',channel), "In %s, %s said: %s" %
(msg.args[0], msg.nick, msg.args[1])))
return
ret = self.factoid_add(text, channel, msg.prefix)
@ -378,7 +384,7 @@ class Encyclopedia(callbacks.Plugin):
#if msg.tagged('alert'):
if self.alert:
if target.startswith('#') and not target.endswith('bots'):
queue(irc, self.registryValue('relayChannel'), '%s called the ops in %s (%s)' % (msg.nick, msg.args[0], retmsg[:-2]))
queue(irc, self.registryValue('relayChannel',channel), '%s called the ops in %s (%s)' % (msg.nick, msg.args[0], retmsg[:-2]))
#queue(irc, self.registryValue('relayChannel'), retmsg + ret[0])
self.alert = False
for r in ret[1:]:
@ -394,6 +400,9 @@ class Encyclopedia(callbacks.Plugin):
(editor, factoid.name, str(datetime.datetime.now()), factoid.value))
db.commit()
if '<alias>' in text.lower() and not text.lower().startswith('no'):
return self.factoid_add(text,channel,editor)
if text.lower().startswith('forget '):
factoid = self.get_single_factoid(channel, text[7:])
if not factoid:
@ -558,9 +567,15 @@ class Encyclopedia(callbacks.Plugin):
fd2.write(newDb)
fd2.close()
def tryReload():
try:
sys.modules['Encyclopedia'].reloadPlugin()
except:
pass
# Having this configurable is nice, but could lead to errors in *my* code,
# So I'll just assume it's always going to be set to 'ubuntu'
# db = self.registryValue('database')
# db = self.registryValue('database',channel)
db = 'ubuntu'
dbpath = os.path.join(self.registryValue('datadir'), '%s.db' % db)
# We're moving files and downloading, lots can go wrong so use lots of try blocks.