def add_user(chat_id=None): get_argv() gl.pushprint("请登录(登录方式请仔细阅读文档,如果觉得这是让你下载,就是你没仔细读文档):", chat_id=chat_id) driver_login = Mydriver() cookies = driver_login.login(chat_id) driver_login.quit() if not cookies: gl.pushprint("登录超时。", chat_id=chat_id) return user.save_cookies(cookies) uid = user.get_userId(cookies) user_fullname = user.get_fullname(uid) user.update_last_user(uid) gl.pushprint(user_fullname + "登录成功", chat_id=chat_id)
def start_learn(uid, name): nohead, lock, stime = get_argv() print("是否无头模式:{0} {1}".format(nohead, os.getenv('Nohead'))) cookies = user.get_cookie(uid) if nohead == True: TechXueXi_mode = "3" else: try: if cfg["base"]["ModeType"]: print("默认选择模式:" + str(cfg["base"]["ModeType"]) + "\n" + "=" * 60) TechXueXi_mode = str(cfg["base"]["ModeType"]) except Exception as e: TechXueXi_mode = "3" if not name: user_fullname = user.get_fullname(uid) else: user_fullname = uid + "_" + name if not cookies or TechXueXi_mode == "0": msg = "" if name == "新用户": msg = "需要增加新用户,请扫码登录,否则请无视" else: msg = user_fullname + "登录信息失效,请重新扫码" print(msg) gl.pushprint(msg) driver_login = Mydriver() cookies = driver_login.login() driver_login.quit() if not cookies: print("登录超时") return user.save_cookies(cookies) uid = user.get_userId(cookies) user_fullname = user.get_fullname(uid) user.update_last_user(uid) output = "\n用户:" + user_fullname + "登录正常,开始学习...\n" article_index = user.get_article_index(uid) video_index = 1 # user.get_video_index(uid) total, scores = show_score(cookies) gl.pushprint(output) if TechXueXi_mode in ["1", "3"]: article_thread = threads.MyThread("文章学 xi ", article, uid, cookies, article_index, scores, lock=lock) video_thread = threads.MyThread("视频学 xi ", video, uid, cookies, video_index, scores, lock=lock) article_thread.start() video_thread.start() article_thread.join() video_thread.join() if TechXueXi_mode in ["2", "3"]: driver_default = Mydriver() print('开始每日答题……') daily(cookies, scores, driver_default=driver_default) if TechXueXi_mode in ["2", "3"]: print('开始每周答题……') weekly(cookies, scores, driver_default=driver_default) if nohead != True: print('开始专项答题……') zhuanxiang(cookies, scores, driver_default=driver_default) try: driver_default.quit() except Exception as e: gl.pushprint('driver_default 在 main 退出时出了一点小问题...') if TechXueXi_mode == "4": user.select_user() if TechXueXi_mode == "5": user.refresh_all_cookies(display_score=True) if TechXueXi_mode == "6": user.refresh_all_cookies(live_time=11.90) seconds_used = int(time.time() - start_time) print("总计用时 " + str(math.floor(seconds_used / 60)) + " 分 " + str(seconds_used % 60) + " 秒") show_scorePush(cookies) try: user.shutdown(stime) except Exception as e: pass
# user.select_user() print("=" * 60, '''\nTechXueXi 现支持以下模式(答题时请值守电脑旁处理少部分不正常的题目):''') print(cfg['base']['ModeText'] + '\n' + "=" * 60) # 模式提示文字请在 ./config/main.ini 处修改。 # TechXueXi_mode = input("请选择模式(输入对应数字)并回车: ") # 懒人之最版 TechXueXi_mode = cfg['base']['Mode'] info_shread = threads.MyThread("获取更新信息...", version.up_info) info_shread.start() # 1 创建用户标记,区分多个用户历史纪录 uid = user.get_default_userId() if not cookies: print("未找到有效登录信息,需要登录") driver_login = Mydriver(nohead=False) cookies = driver_login.login() user.save_cookies(cookies) uid = user.get_userId(cookies) user_fullname = user.get_fullname(uid) user.update_last_user(uid) try: driver_login.quit() except: print("wtf:退出webdriver失败?") pass article_index = user.get_article_index(uid) video_index = user.get_video_index(uid) total, scores = show_score(cookies) nohead, lock, stime = get_argv()
def start_learn(uid, name): # 0 读取版本信息 start_time = time.time() nohead, lock, stime, Single = get_argv() print("是否无头模式:{0} {1}".format(nohead, os.getenv('Nohead'))) cookies = user.get_cookie(uid) if nohead == True: TechXueXi_mode = "3" else: TechXueXi_mode = str(cfg_get("base.ModeType", 3)) print("当前选择模式:" + TechXueXi_mode + "\n" + "=" * 60) if not name: user_fullname = user.get_fullname(uid) name = user_fullname.split('_', 1)[1] else: user_fullname = uid + "_" + name if not cookies or TechXueXi_mode == "0": msg = "" if name == "新用户": msg = "需要增加新用户,请扫码登录,否则请无视" else: msg = name + " 登录信息失效,请重新扫码" # print(msg) gl.pushprint(msg, chat_id=uid) if gl.pushmode == "6": gl.pushprint("web模式跳过自动获取二维码,请手动点击添加按钮", chat_id=uid) print(color.red("【#️⃣】 若直接退出请运行:webserverListener.py")) return driver_login = Mydriver() cookies = driver_login.login() driver_login.quit() if not cookies: print("登录超时") return user.save_cookies(cookies) uid = user.get_userId(cookies) user_fullname = user.get_fullname(uid) name = user_fullname.split('_', 1)[1] user.update_last_user(uid) output = name + " 登录正常,开始学习...\n" article_index = user.get_article_index(uid) video_index = 1 # user.get_video_index(uid) total, scores = show_score(cookies) gl.pushprint(output, chat_id=uid) if TechXueXi_mode in ["1", "3"]: article_thread = threads.MyThread("文章学 xi ", article, uid, cookies, article_index, scores, lock=lock) video_thread = threads.MyThread("视频学 xi ", video, uid, cookies, video_index, scores, lock=lock) article_thread.start() video_thread.start() article_thread.join() video_thread.join() if TechXueXi_mode in ["2", "3"]: print('开始每日答题……') daily(cookies, scores) print('开始每周答题……') weekly(cookies, scores) if nohead != True or gl.zhuanxiang == True: print('开始专项答题……') zhuanxiang(cookies, scores) if TechXueXi_mode == "4": user.select_user() if TechXueXi_mode == "5": user.refresh_all_cookies(display_score=True) if TechXueXi_mode == "6": user.refresh_all_cookies(live_time=11.90) seconds_used = int(time.time() - start_time) gl.pushprint(name + " 总计用时 " + str(math.floor(seconds_used / 60)) + " 分 " + str(seconds_used % 60) + " 秒", chat_id=uid) show_scorePush(cookies, chat_id=uid) try: user.shutdown(stime) except Exception as e: pass