maybe fix the unordered dick bug

This commit is contained in:
iou1name 2019-03-19 07:03:37 -04:00
parent 54ee7615b0
commit 041a95f3af

View File

@ -140,6 +140,7 @@ def dump_seen_db(bot):
@hook(True) @hook(True)
@require_chanmsg @require_chanmsg
def seen_hook(bot, trigger): def seen_hook(bot, trigger):
bot.memory["seen_lock"].acquire()
last = (time.time(), trigger.channel, trigger.group(0)) last = (time.time(), trigger.channel, trigger.group(0))
if not trigger.nick in bot.memory["seen"]: if not trigger.nick in bot.memory["seen"]:
first = (time.time(), trigger.channel, trigger.group(0)) first = (time.time(), trigger.channel, trigger.group(0))
@ -147,6 +148,7 @@ def seen_hook(bot, trigger):
first = bot.memory["seen"][trigger.nick][:3] first = bot.memory["seen"][trigger.nick][:3]
seen = first + last seen = first + last
bot.memory["seen"][trigger.nick] = seen bot.memory["seen"][trigger.nick] = seen
bot.memory["seen_lock"].release()
if time.time() - bot.memory["seen_last_dump"] > 1: if time.time() - bot.memory["seen_last_dump"] > 1:
# only dump once a minute at most # only dump once a minute at most