losetime=time.time()+300000
# initialise the urldb on startup
-c.urldb={}
+urldb={}
+lastexp=time.time()
+#expire urls if not asked about or seen for >71 hours
+expirelen=71*60*60
+#do an expiry run every hour
+expirevery=60*60
# Command processing: whenever something is said that the bot can hear,
# "command" is invoked and must decide what to do. This configuration
"die": quit,
"define": c.defineq,
"google": c.googleq,
-# "url": urlq,
+ "url": (c.urlq,urldb),
"units": c.unitq,
"help": c.helpq,
# "game": (c.gameq,game),
# eg !trout, ~trout etc.
def command(bot, cmd, nick, conn, public):
+ global urldb,lastexp,expirelen,expirevery
ours=0
try:
if public and cmd[0] in triggers:
except IndexError:
command=""
-# if public:
-# if c.urlre.search(cmd):
-# c.dourl(bot,conn,nick,cmd)
+ t=time.time()
+ if t - lastexp > expirevery:
+ c.urlexpire(urldb,expirelen)
+ lastexp=t
+
+ if public:
+ if c.urlre.search(cmd) and command.lower()!="url":
+ c.dourl(bot,conn,nick,cmd,urldb)
# karma: up
if command.endswith("++"):