PaiDuiHook.py 文件源码

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

项目:WechatForwardBot 作者: grapeot 项目源码 文件源码
def process(self, msg, type):
        if type != TEXT:
            return
        groupName = msg['User']['NickName']
        if any([ re.search(x, groupName) is not None for x in self.blacklist ]):
            return
        if re.search('^/', msg['Content']):
            return
        if self.isFromSelf(msg):
            # Stop processing if the message is from myself
            return

        self.updateGroupContentCache(msg, groupName)
        contentToPaiDui = list(self.WhatToPaiDui(groupName))
        if len(contentToPaiDui) > 1:
            logging.error('Multiple duis detected.')
        if len(contentToPaiDui) != 0:
            # Pai dui!
            itchat.send(msg['Content'], msg['FromUserName'])
            logging.info('Pai Dui! {0}.'.format(msg['Content']))
            # Update data structure to avoid Pai dui for multiple times.
            self.updateGroupContentCache({ 'Content': msg['Content'], 'FromSelf': True }, groupName)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号