Ejemplo n.º 1
0
def group_msg_handle(message):
    msg_dict = {
        "msg_type": "group",
        "number": get_number(message),
        "msg": "我听不懂"
    }
    #检测
    general_detect = group_msg_general_detection(message)
    db_detect = group_msg_db_detection(message)

    if general_detect != '':
        msg_dict["msg"] = general_detect
    elif db_detect != '':
        msg_dict["msg"] = db_detect
    else:
        logging_put("群聊中用户请求没有对应的信息:" + str(get_user_id(message)) + "-" +
                    get_raw_message(message))
        msg_dict["msg"] = group_msg_error(message)
    #没有at,则有四分之一的概率回复消息;at了则一定回复
    if at_robot(message):
        send_msg(msg_dict)
    else:
        if 1 == random.randint(1, 12):
            send_msg(msg_dict)
    return
Ejemplo n.º 2
0
def friend_recall_handle(message):
    if random.randint(1,2)==1:
        msg_dict={ 
            "msg_type":"private", 
            "number":str(message['user_id']), 
            "msg":"和个机器人聊天还撤回?" 
        }    
        send_msg(msg_dict)
    return 
Ejemplo n.º 3
0
def group_admin_handle(message):
    if random.randint(1,3)==1:
        msg_dict={ 
            "msg_type":"group", 
            "number":str(message['group_id']), 
            "msg":"新官上任~" 
        }
        send_msg(msg_dict) 
    return 
Ejemplo n.º 4
0
def group_recall_handle(message):
    if random.randint(1,2)==1:
        msg_dict={ 
            "msg_type":"group", 
            "number":str(message['group_id']), 
            "msg":"这个人说要请大家吃饭" 
        }
        send_msg(msg_dict) 
    return 
Ejemplo n.º 5
0
def group_increase_handle(message):
    msg_dict={ 
        "msg_type":"group", 
        "number":str(message['group_id']), 
        "msg":"" 
    }
    temp=random.randint(1,3)
    if temp==1:
        send_msg("老规矩,先爆照")
    elif temp==2:
        send_msg("小姐姐你好呀[CQ:face,id=108]")
    return
Ejemplo n.º 6
0
def send_subscribe(msg_type,num,subscribe):
    logging_put("给账号"+str(num)+"发送"+subscribe+"的订阅")

    msg_dict={ 
        "msg_type":msg_type, 
        "number":num, 
        "msg":""
    }
    #订阅内容分发
    if subscribe=='famousremark':
        msg_dict["msg"]=ss_content.famousremark_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【每日英语】订阅频道出现问题[CQ:face,id=37]"
    elif subscribe=="subwallpaper":
        msg_dict["msg"]=ss_content.wallpaper_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【每日必应壁纸】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"
    elif subscribe=="submusic":
        msg_dict["msg"]=ss_content.random_music_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【网易云每日推荐】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"
    elif subscribe=="subsexpic":
        msg_dict["msg"]=ss_content.sex_picture_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【每日美女】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"
    elif subscribe=="subweibohot":     
        msg_dict["msg"]=ss_content.weibo_hot_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【每日微博热搜】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"  
    elif subscribe=="sublifeskill":
        msg_dict["msg"]=ss_content.life_skill_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【每日生活小窍门】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"  
    elif subscribe=="subkaoyan":
        msg_dict["msg"]=ss_content.kaoyan_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【考研倒计时】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"  
    elif subscribe=="love_word":
        msg_dict["msg"]=ss_content.love_word_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【每日情话】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"  
    elif subscribe=="fuck_word":
        msg_dict["msg"]=ss_content.fuck_word_sub()
        if msg_dict["msg"]=="":
            msg_dict["msg"]="【周三骚话】订阅频道出现问题[CQ:face,id=37],请联系蝙蝠侠"      

    send_msg(msg_dict)
    return
Ejemplo n.º 7
0
def private_msg_handle(message):
    msg_dict = {
        "msg_type": "private",
        "number": get_number(message),
        "msg": "我听不懂"
    }
    #检测
    general_detect = private_msg_general_detection(message)
    db_detect = private_msg_db_detection(message)

    if general_detect != '':
        msg_dict["msg"] = general_detect
    elif db_detect != '':
        msg_dict["msg"] = db_detect
    else:
        logging_put("私聊中用户请求没有对应的信息:" + str(get_user_id(message)) + "-" +
                    get_raw_message(message))
        msg_dict["msg"] = private_msg_error()

    send_msg(msg_dict)
    return
Ejemplo n.º 8
0
def command_broadcast_handle(msg):
    if str(get_number(msg)) in admin_number:
        if len(get_raw_message(msg).split(' ', 1)) == 2:
            main_msg = get_raw_message(msg).split(' ', 1)[1]
            #得到好友和群组列表
            friends = get_friends_array()
            groups = get_groups_array()
            #得到黑名单
            blacklist = get_blacklist()
            for num in friends:
                if not num in blacklist:
                    #发送广播内容
                    msg_dict = {
                        "msg_type": "private",
                        "number": num,
                        "msg": ""
                    }
                    #防止广播信息闭合
                    main_msg.replace('"', '"')
                    main_msg.replace("'", ''')

                    msg_dict['msg'] = "[CQ:face,id=72]广播通知:" + main_msg
                    send_msg(msg_dict)
            for num in groups:
                if not num in blacklist:
                    #发送广播内容
                    msg_dict = {"msg_type": "group", "number": num, "msg": ""}
                    #防止广播信息闭合
                    main_msg.replace('"', '"')
                    main_msg.replace("'", ''')

                    msg_dict['msg'] = "[CQ:face,id=72]广播通知:" + main_msg
                    send_msg(msg_dict)
            return '广播成功[CQ:face,id=63]'
        else:
            return '请指明想要广播的内容'
    else:
        return '你没有权利让我广播'
def check_pass(message):
    if pick.get_post_type(message) == "message":
        if pick.get_message_type(message) == "private":
            command = pick.get_raw_message(message).split(" ")[0]
            number = str(pick.get_number(message))
            msg_dict = {
                "msg_type": "private",
                "number": pick.get_number(message),
                "msg": ""
            }
            #消息来源在黑名单中,则只识别是不是“#开机”
            if exist_number(number):
                #当前发消息者面前,我们是关机的
                if command == "#开机":
                    logging_put(number + "开启了我,执行者:" +
                                str(pick.get_user_id(message)))
                    #从黑名单中移除该number
                    del_number(number)
                    msg_dict['msg'] = "我们又见面了"
                    send_msg(msg_dict)
                #这次消息都不予通过
                return False
            else:
                #当前发消息者面前,我们是开机的
                if command == "#关机":
                    logging_put(number + "关闭了我,执行者:" +
                                str(pick.get_user_id(message)))
                    #向黑名单中加人该number
                    add_number(number)
                    msg_dict['msg'] = "使用“#开机”就可以再次开启我"
                    send_msg(msg_dict)
                    return False
                elif command == "#开机":
                    msg_dict['msg'] = "我现在就是开机状态[CQ:face,id=22]"
                    send_msg(msg_dict)
                    return False
                else:
                    return True
        elif pick.get_message_type(message) == "group":
            if pick.get_raw_message(message).split(
                    ' ')[0] == "[CQ:at,qq=1750133059]":
                #方便还原message
                ori = pick.get_raw_message(message)
                #更新原数据的原始信息
                pick.set_raw_message(
                    message,
                    pick.get_raw_message(message).split(' ', 1)[1])

                command = pick.get_raw_message(message).split(" ")[0]
                number = str(pick.get_number(message))
                msg_dict = {
                    "msg_type": "group",
                    "number": pick.get_number(message),
                    "msg": ""
                }
                #消息来源在黑名单中,则只识别是不是“#开机”
                if exist_number(number):
                    #当前发消息者面前,我们是关机的
                    if command == "#开机":
                        logging_put(number + "开启了我,执行者:" +
                                    str(pick.get_user_id(message)))
                        #从黑名单中移除该number
                        del_number(number)
                        msg_dict['msg'] = "我们又见面了"
                        send_msg(msg_dict)
                    #这次消息都不予通过
                    return False
                else:
                    #当前发消息者面前,我们是开机的
                    if command == "#关机":
                        logging_put(number + "关闭了我,执行者:" +
                                    str(pick.get_user_id(message)))
                        #向黑名单中加人该number
                        add_number(number)
                        msg_dict['msg'] = "使用“#开机”就可以再次开启我"
                        send_msg(msg_dict)
                        return False
                    elif command == "#开机":
                        msg_dict['msg'] = "我现在就是开机状态[CQ:face,id=22]"
                        send_msg(msg_dict)
                        return False
                    else:
                        #还原消息
                        pick.set_raw_message(message, ori)
                        return True
            else:
                if exist_number(number):
                    return False
                else:
                    return True
    elif pick.get_post_type(message) == "notice" or pick.get_post_type(
            message) == "request":
        try:
            user_id = message['user_id']
        except BaseException as e:
            #如果user_id都没有,则直接拦截
            return False
        #再尝试得到群号
        try:
            group_id = message['group_id']
        except BaseException as e:
            #有user_id,没有群id
            if exist_number(message['user_id']):
                return False
            else:
                return True
        #有群id
        if exist_number(message['group_id']):
            return False
        else:
            return True
    else:
        #三大消息以外应该是心跳消息,通行
        return True