def WhatToPaiDui(self, groupName):
msgCount = {}
msgs = self.groupLastMsgsDict[groupName]
for msg in msgs:
if msg['Content'] not in msgCount:
msgCount[msg['Content']] = 0
msgCount[msg['Content']] += 1
contentToPaiDui = [ x for x in msgCount if msgCount[x] > 1 ]
if len(contentToPaiDui) == 0:
# No dui to pai
return
# it's possible that two duis are formed at the same time, but only one can pass the TTL check
for content in contentToPaiDui:
if (groupName, content) not in self.selfPaiDuiTTL or self.selfPaiDuiTTL == 0:
self.selfPaiDuiTTL[(groupName, content)] = self.maxSelfPaiDuiTTL
yield content # We use yield here because we still need to conitnue managing the TTL
else:
self.selfPaiDuiTTL[(groupName, content)] -= 1
评论列表
文章目录