def ocr_err_upload(user_id, user_class, upload_date): """为管理员上报ocr错误的图片""" msg = "OCR无法识别以下图片:\n" err_list = [] err_imgid = [] class_menbers = dbconn.get_class_members(user_class) for i in range(0, len(class_menbers)): img_date = dbconn.check_status(class_menbers[i]) if (str(img_date) == str(upload_date)): img_info = dbconn.get_latest_img_info(class_menbers[i], upload_date)[0] #print(img_info) if (img_info['ocr_err_code'] == 1): print(img_info) err_list.append(img_info['file_name']) err_imgid.append(img_info['imgid']) for i in range(0, len(err_list)): cqCode = f"[CQ:image,file=file:{os.getcwd()}/images{err_list[i]}]" msg += f"id:{err_imgid[i]}\n" msg += f"{cqCode}\n" msg += f"数量:{len(err_list)}/{len(class_menbers)}\n" msg += "可人工核对,操作格式: /admin 核对@id@次数@分数,例如:\n核对id为233,次数66,分数99则输入:/admin 核对@233@66@99" goapi.sendMsg(user_id, msg) return msg
def send_alert(group_id, user_class, type='private'): group_menbers = dbconn.get_class_members(user_class) current_date = time.strftime("%Y-%m-%d", time.localtime()) alert_users = {} #user_id:last_date for user_id in group_menbers: #print(user_id) try: last_date = dbconn.check_status(user_id) except TypeError: #还没发过照片 alert_users[user_id] = '无记录' else: if (str(last_date) != str(current_date)): alert_users[user_id] = str(last_date)[5:] #print(alert_users) msg = f"今天还有{len(alert_users)}位小可爱未完成哦\n" if (type == 'private'): for user_id in alert_users.keys(): last_date = alert_users[user_id] msg += f"{dbconn.get_user(user_id)['user_name']}({alert_users[user_id]})\n" msg += f"{user_class} {current_date}\n完成情况:{len(group_menbers)-len(alert_users)}/{len(group_menbers)}" goapi.sendMsg(group_id, msg) elif (type == 'group'): for user_id in alert_users.keys(): last_date = alert_users[user_id] msg += f"[CQ:at,qq={user_id}]({alert_users[user_id]})\n" msg += f"{user_class} {current_date}\n完成情况:{len(group_menbers)-len(alert_users)}/{len(group_menbers)}" goapi.sendGroupMsg(group_id, msg)
def list_class_menbers(user_id, user_class): msg = f"{user_class}成员情况:\n" ret = dbconn.get_class_members(user_class) for i in range(0, len(ret)): msg += f"{ret[i]} {dbconn.get_user(str(ret[i]))['user_name']}\n" msg += f"共计{str(len(ret))}人" goapi.sendMsg(user_id, msg)
def send_images_info(user_id, user_class): """上报班级图片情况(次数和成绩)""" class_menbers = dbconn.get_class_members(user_class) today_upload_count = 0 upload_date = time.strftime("%Y-%m-%d", time.localtime()) msg = f"{user_class} {upload_date}情况:\n" for i in range(0, len(class_menbers)): if (str(dbconn.check_status(class_menbers[i])) == str(upload_date)): today_upload_count += 1 img_info = dbconn.get_latest_img_info(class_menbers[i], upload_date)[0] if (img_info['ocr_err_code'] == 0): msg += f"·{dbconn.get_user(class_menbers[i])['user_name']} 次数{img_info['ocr_times']} 分数{img_info['ocr_scores']}\n" else: msg += f"·{dbconn.get_user(class_menbers[i])['user_name']} 未识别到\n" msg += f"共计{today_upload_count}张照片" goapi.sendMsg(user_id, msg) return msg
def ocr_err_upload(user_id, user_class, upload_date): """为管理员上报ocr错误的图片""" msg = "OCR无法识别以下图片:\n" err_list = [] class_menbers = dbconn.get_class_members(user_class) for i in range(0, len(class_menbers)): img_date = dbconn.check_status(class_menbers[i]) if (str(img_date) == str(upload_date)): img_info = dbconn.get_latest_img_info(class_menbers[i], upload_date)[0] #print(img_info) if (img_info['ocr_err_code'] == 1): print(img_info) err_list.append(img_info['file_name']) for i in range(0, len(err_list)): cqCode = f"[CQ:image,file=file:{os.getcwd()}/images{err_list[i]}]" msg += f"{cqCode}\n" msg += f"数量:{len(err_list)}/{len(class_menbers)}" goapi.sendMsg(user_id, msg) return msg