PaiDuiHook.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:WechatForwardBot 作者: grapeot 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号