def get_s_c(): global ver input_sessdata = var_sess.get() input_csrf = var_csrf.get() ver = Verify(sessdata=input_sessdata, csrf=input_csrf) ret = ver.check()['code'] if ret == 0: tkinter.messagebox.showinfo(message='验证成功!') elif ret == -1: tkinter.messagebox.showwarning(message='csrf 校验失败') elif ret == -2: tkinter.messagebox.showwarning(message='SESSDATA值有误')
def getVerify(logger=getLogger('bot')): config = loadConfig(logger=logger) if 'account' in config and 'sessdata' in config['account']: logger.debug('发现本地账号,验证是否有效...') verify = Verify(sessdata=config['account']['sessdata'], csrf=config['account']['bili_jct']) ck = verify.check() if ck.get('code') != 0: logger.warning('本地记录的账号失效,重新登录...') logger.debug(f'错误代码:{ck["code"]}, 错误原因:{ck["message"]}') else: logger.debug('获取Verify成功') return verify return loginBilibili()