def check_all_skey_and_pskey(cfg): if not has_any_account_in_normal_run(cfg): return _show_head_line("启动时检查各账号skey/pskey/openid是否过期") QQLogin(cfg.common).check_and_download_chrome_ahead() if cfg.common.enable_multiprocessing and cfg.is_all_account_auto_login(): logger.info(color("bold_yellow") + f"已开启多进程模式({cfg.get_pool_size()}),并检测到所有账号均使用自动登录模式,将开启并行登录模式") get_pool().starmap( do_check_all_skey_and_pskey, [ (_idx + 1, account_config, cfg.common) for _idx, account_config in enumerate(cfg.account_configs) if account_config.is_enabled() ], ) logger.info("全部账号检查完毕") else: for _idx, account_config in enumerate(cfg.account_configs): idx = _idx + 1 if not account_config.is_enabled(): # 未启用的账户的账户不走该流程 continue do_check_all_skey_and_pskey(idx, account_config, cfg.common)
def check_all_skey_and_pskey(cfg, check_skey_only=False): if not has_any_account_in_normal_run(cfg): return _show_head_line("启动时检查各账号skey/pskey/openid是否过期") if cfg.common.enable_multiprocessing and cfg.is_all_account_auto_login(): logger.info(color("bold_yellow") + f"已开启多进程模式({cfg.get_pool_size()}),并检测到所有账号均使用自动登录模式,将开启并行登录模式") QQLogin(cfg.common).extract_portable_chrome_ahead() get_pool().starmap(do_check_all_skey_and_pskey, [(_idx + 1, _idx + 1, account_config, cfg.common, check_skey_only) for _idx, account_config in enumerate(cfg.account_configs) if account_config.is_enabled()]) logger.info("全部账号检查完毕") return # 串行登录 qq2index = {} for _idx, account_config in enumerate(cfg.account_configs): idx = _idx + 1 djcHelper = do_check_all_skey_and_pskey(idx, 1, account_config, cfg.common, check_skey_only) if djcHelper is None: continue qq = uin2qq(djcHelper.cfg.account_info.uin) if qq in qq2index: msg = f"第{idx}个账号的实际登录QQ {qq} 与第{qq2index[qq]}个账号的qq重复,是否重复扫描了?\n\n点击确认后,程序将清除本地登录记录,并退出运行。请重新运行并按顺序登录正确的账号~" logger.error(color("fg_bold_red") + msg) win32api.MessageBox(0, msg, "重复登录", win32con.MB_ICONINFORMATION) clear_login_status() sys.exit(-1) qq2index[qq] = idx
def auto_login_with_password(self, common_cfg, account, password, account_name): cached = self.load_token(account) if cached is not None: api.set_uin_skey(cached["uin"], cached["skey"], cached["p_skey"]) api.set_tgp_info(cached["tgp_id"], cached["tgp_ticket"]) if self.is_token_still_valid(): logger.info("use cached") return else: logger.warning("token invalided, try get new") ql = QQLogin(common_cfg) lr = ql.login(account, password, login_mode=ql.login_mode_wegame, name=account_name) logger.info(lr) api.login(lr.uin, lr.skey, lr.p_skey) self.save_token(account) logger.info("new login, token saved")
def update_skey_qr_login(self, query_data): qqLogin = QQLogin(self.common_cfg) loginResult = qqLogin.qr_login() self.save_uin_skey(loginResult.uin, loginResult.skey)