def test_check_identify(self):
     test1 = '湖北省防控指挥部'
     test2 = '这是谣言'
     test3 = '辟谣!'
     assert check_identify(test1) == True
     assert check_identify(test2) == True
     assert check_identify(test3) == True
示例#2
0
def text_reply(msg):
    if msg['FromUserName'] == itchat.originInstance.storageClass.userName and msg['ToUserName'] != 'filehelper':
        return
    if check_identify(msg.text):
        return
    # 鉴别
    identify_news([msg.text], itchat, msg['FromUserName'])
示例#3
0
def text_reply(msg):
    if msg['FromUserName'] == itchat.originInstance.storageClass.userName and msg[
            'ToUserName'] != 'filehelper':
        return
    if check_identify(msg.text):
        return
    # 获取文字摘要
    text_list = get_text_summary(msg.text, topK=2)
    # 鉴别
    identify_news(text_list, itchat, msg['FromUserName'])
示例#4
0
def text_reply(msg):
    if msg['FromUserName'] == itchat.originInstance.storageClass.userName and msg['ToUserName'] != 'filehelper':
        return
    if check_identify(msg.text) or len(msg.text) < 10:
        return
    # 判断是在否在关注的群列表里
    if not judge_whether_foucs_group(conn, itchat.originInstance.storageClass.nickName, msg['FromUserName']):
        return
    # 鉴别
    identify_news([msg.text], itchat, msg['FromUserName'])
示例#5
0
def text_reply(msg):
    if msg['FromUserName'] == itchat.originInstance.storageClass.userName and msg[
            'ToUserName'] != 'filehelper':
        return
    if len(msg.text) < 50:
        return
    focus_group = conn.smembers(USER_FOCUS_GROUP)
    if msg['FromUserName'] not in focus_group:
        return
    # 带有辟谣等字眼的信息直接返回
    if check_identify(msg.text):
        return
    # 获取文字摘要
    text_list = get_text_summary(msg.text, topK=2)
    # 鉴别
    identify_news(text_list, itchat, msg['FromUserName'])
def text_reply(msg):
    if msg['FromUserName'] == itchat.originInstance.storageClass.userName and msg[
            'ToUserName'] != 'filehelper':
        return
    if not judge_whether_foucs_group(
            conn, itchat.originInstance.storageClass.nickName,
            msg['FromUserName']):
        return
    if check_image(msg.fileName):
        msg.download(msg.fileName)
        # new_file = os.path.join(BASE_DIR, 'download_image/') + msg.fileName
        text_list = ocr(msg.fileName)
        # 删除图片
        remove_image(msg.fileName)
        # 带有辟谣等字眼的信息直接返回
        if len(text_list) == 0 or check_identify("".join(text_list)):
            return
        text_list = list(filter(lambda x: len(x) > 10, text_list))
        identify_news(text_list, itchat, msg['FromUserName'])
def text_reply(msg):
    if msg['FromUserName'] == itchat.originInstance.storageClass.userName and msg[
            'ToUserName'] != 'filehelper':
        return
    # 筛掉过短的长文和重复字段过多的长文
    if len(msg.text) < 50 or len(set(msg.text)) < 20:
        return
    # 带有辟谣等字眼的信息直接返回
    if check_identify(msg.text):
        return
    # 判断是在否在关注的群列表里
    if not judge_whether_foucs_group(
            conn, itchat.originInstance.storageClass.nickName,
            msg['FromUserName']):
        return
    # 获取文字摘要
    text_list = get_text_summary(msg.text, topK=2)
    # 鉴别
    identify_news(text_list, itchat, msg['FromUserName'])
示例#8
0
def text_reply(msg):
    if msg.isAt:
        if msg.text.find('查') == -1:
            itchat.send("嗯嗯!", toUserName=msg.user.UserName)
            return
        city = msg.text.split('查')
        if len(city) < 2:
            return
        city = city[1].strip()
        if len(city) > 10:
            return
        if city == '水表':
            itchat.send("水表在门外,请自便!", toUserName=msg.user.UserName)
            return
        if city == '':
            itchat.send("您想查啥?", toUserName=msg.user.UserName)
            return
        if city == '朝阳':
            itchat.send(CHAOYANG_INFO, toUserName=msg.user.UserName)
            return

        city = find_true_name_for_city(conn, city)
        push_info = get_ncvo_info_with_city(conn, [city], True)
        itchat.send(push_info + get_random_tail(),
                    toUserName=msg.user.UserName)
        return
    # 筛掉过短的长文和重复字段过多的长文
    if len(msg.text) < 50 or len(set(msg.text)) < 20:
        return
    # 带有辟谣等字眼的信息直接返回
    if check_identify(msg.text):
        return
    # 判断是在否在关注的群列表里
    if not judge_whether_foucs_group(
            conn, itchat.originInstance.storageClass.nickName,
            msg['FromUserName']):
        return
    # 获取文字摘要
    text_list = get_text_summary(msg.text, topK=2)
    # 鉴别
    identify_news(text_list, itchat, msg['FromUserName'])