Example #1
0
def get_one_homework(msg: dict, homework_type: str):
    if msg['CurrentPacket']['Data']['MsgType'] == 'FriendFileMsg':
        data = data_first = submit_queue.get()
        if_have = False
        while submit_queue.not_empty:
            if data["msg"] == "submit_homework" and \
                    data["type"] == homework_type and \
                    data['User'] == msg['CurrentPacket']['Data']['FromUin']:
                if_have = True
                break
            submit_queue.put(data)
            data = submit_queue.get()
            if data is data_first:
                break
        if if_have:
            file_info = json.loads(msg['CurrentPacket']['Data']['Content'])
            fun_save = setting_config.homework_list[0].homework_save_and_zip
            save_result = fun_save.save_XinJiao(
                file_info["FileID"], file_info["FileName"],
                setting_config.homework_list[0].homework_usr[data['User']])
            if save_result:
                ws_service.SendMsg(setting_config.host,
                                   setting_config.current_qq, "已收到,感谢使用",
                                   data['User'])
                setting_config.homework_list[0].move_no_finish_usr(
                    data['User'])
Example #2
0
def send_nodaka(nodaka_list: list, config: dict):
    nodaka_usr = []
    for group in config["solve_qq_group"]:
        response = ws_service.GetGroupUserList_nowait(config["host"], config["current_qq"], group)
        for usr in [(x["GroupCard"], x["MemberUin"]) for x in json.loads(response.content.decode('utf-8'))["MemberList"]]:
            if usr[0] in nodaka_list:
                nodaka_usr.append((usr[0], usr[1], group))
    if not nodaka_usr:
        ws_service.SendMsg(config['host'], config['current_qq'], "无人未打卡", config['admin_list'][0])
    for each_remind in nodaka_usr:
        response = ws_service.send_private_msg_v2(config['host'],
                                                  config['current_qq'],
                                                  group_id=each_remind[2],
                                                  to_usr_id=each_remind[1],
                                                  send_msg="同学,老师那边显示你未打卡,请同学尽快打卡")
        if response.text != "" and response.status_code == 200:
            ws_service.SendMsg(config['host'], config['current_qq'], "已提醒%s" % each_remind[0], config['admin_list'][0])
        time.sleep(10)
def get_no_finish_usr(msg: dict, homework_type: str, homework_index: int):
    if msg['CurrentPacket']['Data']['FromUin'] in setting_config.admin_list and \
            msg['CurrentPacket']['Data']['Content'] == "查看未交%s作业的人" % homework_type and \
            len(setting_config.homework_list) >= homework_index + 1:
        no_finish_usr_list = list(setting_config.homework_list[homework_index].
                                  homework_no_finish_usr.values())
        ws_service.SendMsg(
            setting_config.host, setting_config.current_qq, "%s\\r共有%d人" %
            ('\\r'.join(no_finish_usr_list), len(no_finish_usr_list)),
            msg['CurrentPacket']['Data']['FromUin'])
Example #4
0
def start_collect_one(msg: dict, homework_type: str):
    if msg['CurrentPacket']['Data']['Content'] == "交" + homework_type + "作业":
        if msg['CurrentPacket']['Data'][
                'FromUin'] in setting_config.homework_list[
                    0].homework_no_finish_usr:
            data = {
                "User": msg['CurrentPacket']['Data']['FromUin'],
                "msg": "submit_homework",
                "type": homework_type
            }
            submit_queue.put(data)
            ws_service.SendMsg(setting_config.host, setting_config.current_qq,
                               "请发送文件", data['User'])
Example #5
0
def if_solve(msg: dict, config: dict):
    if msg['CurrentPacket']['Data']['FromUin'] in config["admin_list"]:
        if msg['CurrentPacket']['Data']['Content'] == "提醒打卡":
            if_not_ok = ws_service.SendMsg(config['host'],
                                           config['current_qq'],
                                           "请发送图片",
                                           msg['CurrentPacket']['Data']['FromUin'])
            if not if_not_ok:
                data = {
                    "User": msg['CurrentPacket']['Data']['FromUin'],
                    "msg": "remind_daka",
                    "type": "物联网"
                }
                admin_queue.put(data)
            else:
                print("error")
def if_solve(msg: dict, homework_type: str):
    if msg['CurrentPacket']['Data']['FromUin'] in setting_config.admin_list:
        if msg['CurrentPacket']['Data'][
                'Content'] == "设定" + homework_type + "作业":
            if_not_ok = ws_service.SendMsg(
                setting_config.host, setting_config.current_qq,
                "开始设定%s作业,请输入作业名,作业次数,作业ddl;并用空格分隔开" % homework_type,
                msg['CurrentPacket']['Data']['FromUin'])
            if not if_not_ok:
                data = {
                    "User": msg['CurrentPacket']['Data']['FromUin'],
                    "msg": "start_new_homework",
                    "type": homework_type
                }
                admin_queue.put(data)
            else:
                print("error")
Example #7
0
def solve_nodaka(msg: dict, config: dict):
    if msg['CurrentPacket']['Data']['FromUin'] in config['admin_list'] and \
            msg['CurrentPacket']['Data']['MsgType'] == "PicMsg":
        data = data_first = admin_queue.get()
        while admin_queue.not_empty:
            if data["msg"] == "remind_daka" and data["type"] == '物联网':
                break
            admin_queue.put(data)
            data = admin_queue.get()
            if data is data_first:
                break
        if msg['CurrentPacket']['Data']['FromUin'] == data["User"] and \
                data["msg"] == "remind_daka":
            if data["type"] == "物联网":
                api_result = get_nodaka_usr.TXApiUse(
                    json.loads(msg['CurrentPacket']['Data']['Content'])['FriendPic'][0]["Url"])
                clean_it = get_nodaka_usr.CleanAPIData(api_result.get_result())
                ws_service.SendMsg(config['host'],
                                   config['current_qq'],
                                   "开始记录并解决当天未打开同学\\r%s" % " ".join(clean_it.nodata_list),
                                   msg['CurrentPacket']['Data']['FromUin'])
                send_nodaka(clean_it.nodata_list, config)
Example #8
0
def new_XinJiao_homework(name, times, ddl_input, owner):
    # ddl_input: "%Y-%m-%d %H"
    new_work = homework_info.HomeworkInfo(name, times, ddl_input + ":00:00", owner)
    new_work.set_usr(get_usr("./homework_collect/物联网信息统计表.xlsx"))
    homework_list.append(new_work)
    ws_service.SendMsg(host, current_qq, "作业情况如下:\\r%s" % str(new_work), new_work.get_own())