diff --git a/README.md b/README.md index eed373a..f9cbe63 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ up: # up的物品池,如果十连参数为 限时,up列表的装扮和人物 # 功能 - 雀魂相关功能,如模拟抽卡,查询玩家信息,定时播报玩家最近战绩 + - 天凤对局播报 - 入群欢迎 - 摸头、互亲、举牌、色图等图片相关功能 - 自定义回复 @@ -227,10 +228,10 @@ up: # up的物品池,如果十连参数为 限时,up列表的装扮和人物 [ ] 增加何切支持 - [?] 增加对天凤的支持 - - [ ] `要在自动查询牌谱时仍然能够对外相应` + [√] 增加对天凤的支持 + [ ] `改用异步爬虫` + [ ] 更多更多的功能 [?] 将所有功能都写进配置文件,提供高度自定义 @@ -242,6 +243,8 @@ up: # up的物品池,如果十连参数为 限时,up列表的装扮和人物 # 联系方式 QQ:1215791340 验证消息: 可爱的拉克丝 +群聊: 586468489 + 欢迎提交 需求、BUG、问题,也可以找我询问项目相关的问题 # 开源协议 diff --git a/config.yml b/config.yml index 4265e13..1644332 100644 --- a/config.yml +++ b/config.yml @@ -12,15 +12,20 @@ botconfig: botname: '' # 机器人名字 qq: 123456 # 机器人QQ commandpre: '' # 指令前缀 +master: 0 # 机器人主人 + mutegrouplist: - 0 searchfrequency: 6 # 查询频率,建议为 6 settings: # 各项开关 autogetpaipu: true # 自动获取雀魂牌谱 autowelcome: true # 自动欢迎新人 + nudgereply: true # 摸头事件 r18talk: true # 开启管理员词库 setu: false # 色图 silence: false # 全局沉默 + norepeat: false # 全局自动回复 + repeatconfig: # 回复、打断相关,要求值从上到下排序为从大到小,值为 百分数 repeatQ: 20 # 复读问号 的概率 repeatmsg: 1 # 复读的概率 @@ -32,3 +37,20 @@ welcomeinfo: # 新人入群欢迎词,%ps%为新人名字,%gn%为群聊名 - 欢迎%ps%加入%gn% whitelist: - 0 # 白名单 + +# 雀魂指令控制 +qhsettings: # 是否启用 + qhpt: true + qhinfo: true + qhsl: true + qhyb: true + disptgroup: # 在某群禁用 qhpt + - 0 + +# 在某群禁用 摸头事件 +disnudgegroup: + - 0 + +# 在某群关闭自动回复 +norepeatgroup: + - 0 \ No newline at end of file diff --git a/main.py b/main.py index 5b50e9b..db99713 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,8 @@ black_list['user'] = config['blacklist'] black_list['group'] = config['mutegrouplist'] whiteList = config['whitelist'] - admin = config['admin'] + admin:list = config['admin'] + master = config['master'] settings = config['settings'] botname = config['botconfig']['botname'] replydata = load_replydata() @@ -27,10 +28,13 @@ alarmclockgroup = config['alarmclockgroup'] silencegroup = config['silencegroup'] repeatconfig = config['repeatconfig'] - + norepeatgroup = config['norepeatgroup'] + qhsettings = config['qhsettings'] + disnudgegroup = config['disnudgegroup'] bot = create_bot(config) - - print(f"机器人{botname}启动中,QQ : {bot.qq},\nadapter : {bot.adapter_info}") + if master not in admin: + admin.append(master) + print(f"机器人{botname}启动中\tQQ : {bot.qq}\nadapter : {bot.adapter_info}") # 自动获取雀魂牌谱 @@ -48,13 +52,33 @@ async def autopaipu(): # 自动获取天凤对局 async def thautopaipu(): - print("开始查询天风对局信息") + print("开始查询天风结算信息") msglist = autoget_th_match() + print(f'正在进行的对局有{msglist}') for msgobj in msglist: for group in msgobj['groups']: await bot.send_group_message(group, msgobj['msg']) return + # 自动广播天凤对局开始信息 + async def thbroadcastmatch(): + print("开始查询天风对局信息") + msglist = auto_get_th_matching() + for msgobj in msglist: + for group in msgobj['groups']: + await bot.send_group_message(group, msgobj['msg']) + return + + + def get_groupsender_permission(event: GroupMessage): + return event.sender.permission + + + def is_havingadmin(event: GroupMessage): + if event.sender.permission == "MEMBER": + return False + return True + # 欢迎 @@ -79,6 +103,37 @@ async def welcome(event: MemberJoinEvent) -> None: return + @bot.on(GroupMessage) + async def addadmin(event: GroupMessage): + if event.sender.id == master: + msg = "".join(map(str, event.message_chain[Plain])) + m = re.match( + fr"^{commandpre}addadmin\s*(\d+)\s*$", msg.strip()) + if m: + if m.group(1) in admin: + admin.append(m.group(1)) + + with open(r'./config.yml', 'w') as file: + yaml.dump(config, file, allow_unicode=True) + return await bot.send(event, MessageChain(Plain(f" 已将 {m.group(1)} 添加为机器人管理员"))) + return + + + @bot.on(GroupMessage) + async def deladmin(event: GroupMessage): + if event.sender.id == master: + msg = "".join(map(str, event.message_chain[Plain])) + m = re.match( + fr"^{commandpre}deladmin\s*(\d+)\s*$", msg.strip()) + if m: + if not m.group(1) in admin: + admin.remove(m.group(1)) + + with open(r'./config.yml', 'w') as file: + yaml.dump(config, file, allow_unicode=True) + return await bot.send(event, MessageChain(Plain(f" 已将 {m.group(1)} 从机器人管理员中移出"))) + return + @bot.on(FriendMessage) async def on_friend_message(event: FriendMessage): if str(event.message_chain) == '你好': @@ -168,6 +223,42 @@ async def getmajsoulhelp(event: MessageEvent): ])) + # 禁用功能 + + @bot.on(GroupMessage) + async def disableqhplugin(event: GroupMessage): + # 匹配指令 + if is_havingadmin(event) or event.sender.id in admin: + msg = "".join(map(str, event.message_chain[Plain])) + m = re.match(fr'^{commandpre}disable\s*(\w+)\s*$', msg.strip()) + if m: + command = m.group(1) + group = event.group.id + if command == 'pt': + if not group in qhsettings['disptgroup']: + qhsettings['disptgroup'].append(group) + with open(r'./config.yml', 'w') as file: + yaml.dump(config, file, allow_unicode=True) + # return await bot.send(event,f'查分功能禁用成功') + + + @bot.on(GroupMessage) + async def enableqhplugin(event: GroupMessage): + # 匹配指令 + if is_havingadmin(event) or event.sender.id in admin: + msg = "".join(map(str, event.message_chain[Plain])) + m = re.match(fr'^{commandpre}enable\s*(\w+)\s*$', msg.strip()) + if m: + command = m.group(1) + group = event.group.id + if command == 'pt': + if group in qhsettings['disptgroup']: + qhsettings['disptgroup'].remove(group) + with open(r'./config.yml', 'w') as file: + yaml.dump(config, file, allow_unicode=True) + # return await bot.send(event, f'查分功能启用成功') + + # 查分 @bot.on(GroupMessage) @@ -176,8 +267,9 @@ async def qhpt(event: GroupMessage): # 匹配指令 m = re.match(fr'^{commandpre}(qhpt|雀魂分数)\s*(\w+)\s*$', msg.strip()) if m: - await bot.send(event, query(m.group(2))) - return + if qhsettings['qhpt'] and not event.group.id in qhsettings['disptgroup']: + await bot.send(event, query(m.group(2))) + return @bot.on(GroupMessage) @@ -299,54 +391,63 @@ async def addmajsoulwatch(event: GroupMessage): if m: if m.group(2): if m.group(2) == '限时': - result = drawcards(up=True) + result = drawcards(userid=event.sender.id, up=True) + if result['error']: + return await bot.send(event, MessageChain([At(event.sender.id), Plain(result['resultsmsg'])])) mergeimgs( result.get('results'), event.sender.id) await bot.send(event, MessageChain([ At(event.sender.id), Plain("\n 抽卡结果:\n"), Image(path=f"./images/MajSoulInfo/{event.sender.id}.png")])) - return await bot.send(event, MessageChain([ - At(event.sender.id), - Plain(result['resultsmsg']) - ])) + # return await bot.send(event, MessageChain([ + # At(event.sender.id), + # Plain(result['resultsmsg']) + # ])) elif m.group(2) == '常驻': - result = drawcards(up=False) + result = drawcards(userid=event.sender.id, up=False) + if result['error']: + return await bot.send(event, MessageChain([At(event.sender.id), Plain(result['resultsmsg'])])) mergeimgs( result.get('results'), event.sender.id) await bot.send(event, MessageChain([ At(event.sender.id), Plain("\n 抽卡结果:\n"), Image(path=f"./images/MajSoulInfo/{event.sender.id}.png")])) - return await bot.send(event, MessageChain([ - At(event.sender.id), - Plain(result['resultsmsg']) - ])) + # return await bot.send(event, MessageChain([ + # At(event.sender.id), + # Plain(result['resultsmsg']) + # ])) else: + result = drawcards(userid=event.sender.id, up=False) + if result['error']: + return await bot.send(event, MessageChain([At(event.sender.id), Plain(result['resultsmsg'])])) await bot.send(event, MessageChain([At(event.sender.id), Plain('参数输入有误,请输入“限时”或“常驻”,此次十连将输出常驻')])) - result = drawcards(up=False) mergeimgs( result.get('results'), event.sender.id) await bot.send(event, MessageChain([ At(event.sender.id), Plain("\n 抽卡结果:\n"), Image(path=f"./images/MajSoulInfo/{event.sender.id}.png")])) - return await bot.send(event, MessageChain([ - At(event.sender.id), - Plain(result['resultsmsg']) - ])) + # return await bot.send(event, MessageChain([ + # At(event.sender.id), + # Plain(result['resultsmsg']) + # ])) else: - result = drawcards(up=False) + result = drawcards(userid=event.sender.id, up=False) + if result['error']: + return await bot.send(event, MessageChain([At(event.sender.id), Plain(result['resultsmsg'])])) mergeimgs( result.get('results'), event.sender.id) await bot.send(event, MessageChain([ At(event.sender.id), Plain("\n 抽卡结果:\n"), Image(path=f"./images/MajSoulInfo/{event.sender.id}.png")])) - return await bot.send(event, MessageChain([ - At(event.sender.id), - Plain(result['resultsmsg']) - ])) + # return await bot.send(event, MessageChain([ + # At(event.sender.id), + # Plain(result['resultsmsg']) + # ])) + return '''天凤相关''' @@ -489,6 +590,29 @@ async def begroupsilencebygroup(event: GroupMessage): yaml.dump(config, file, allow_unicode=True) + # 关闭复读 + @bot.on(GroupMessage) + async def norepeatbygroup(event: GroupMessage): + msg = "".join(map(str, event.message_chain[Plain])) + userid = event.sender.id + # 匹配指令 + if userid in admin: + m = re.match(fr'^{commandpre}norepeat\s*(\w+)\s*$', msg.strip()) + if m: + if m.group(1).lower() == 'on' or m.group(1).lower() == 'true': + print(f'已将{event.group.id}的复读关闭') + if not event.group.id in norepeatgroup: + norepeatgroup.append(event.group.id) + with open(r'./config.yml', 'w') as file: + yaml.dump(config, file, allow_unicode=True) + else: + if event.group.id in norepeatgroup: + print(f'已将{event.group.id}的复读开启') + norepeatgroup.remove(event.group.id) + with open(r'./config.yml', 'w') as file: + yaml.dump(config, file, allow_unicode=True) + + # 添加白名单 @bot.on(GroupMessage) @@ -556,25 +680,27 @@ async def delblacklist(event: FriendMessage): @bot.on(GroupMessage) async def on_group_message(event: GroupMessage): - if not settings['silence']: + if not (settings['silence'] or settings['norepeat']): if not event.group.id in silencegroup: - count = random.random() * 100 - msg = event.message_chain[Plain] - senderid = event.sender.id - if senderid in whiteList: - return - if str(event.message_chain) in ['?', "?"] and count < repeatconfig['repeatQ']: - print(f"在{event.group.name}群,复读了一次?") - return await bot.send(event, "?") - if count < repeatconfig['interruptQQ']: - print(f"在{event.group.name}群,打断一次{msg}") - return await bot.send(event, random.choice(["¿", "??"])) - elif count < repeatconfig['interruptQ']: - print(f"在{event.group.name}群,打断一次{msg}") - return await bot.send(event, "?") - elif count < repeatconfig['repeatmsg']: - print(f"在{event.group.name}群,复读一次{msg}") - return await bot.send(event, event.message_chain) + if not event.group.id in norepeatgroup: + count = random.random() * 100 + msg = event.message_chain[Plain] + senderid = event.sender.id + if senderid in whiteList: + return + if str(event.message_chain) in ['?', "?"] and count < repeatconfig['repeatQ']: + print(f"在{event.group.name}群,复读了一次?") + return await bot.send(event, "?") + if count < repeatconfig['interruptQQ']: + print(f"在{event.group.name}群,打断一次{msg}") + return await bot.send(event, random.choice(["¿", "?????"])) + elif count < repeatconfig['interruptQ']: + print(f"在{event.group.name}群,打断一次{msg}") + return await bot.send(event, "?") + elif count < repeatconfig['repeatmsg']: + print(f"在{event.group.name}群,复读一次{msg}") + return await bot.send(event, event.message_chain) + return # 获取项目地址 @@ -673,7 +799,7 @@ async def on_kiss(event: GroupMessage): operator_id = event.sender.id target_id = event.message_chain.get_first(At).target if operator_id == target_id: - return await bot.send(event, MessageChain([Plain("请不要自交~😋")])) + return await bot.send(event, MessageChain([Plain("请不要自交~")])) else: await kiss(operator_id=operator_id, target_id=target_id) await bot.send(event, MessageChain( @@ -735,9 +861,9 @@ async def getuserscore(event: GroupMessage): @bot.on(NudgeEvent) async def Nudgepetpet(event: NudgeEvent): - if not settings['silence']: + if (not settings['silence']) or settings['nudgereply']: if event.subject.kind == 'Group': - if not event.subject.id in silencegroup: + if not (event.subject.id in silencegroup or event.subject.id in disnudgegroup): target = event.target if target == bot.qq: sender = event.from_id @@ -771,36 +897,6 @@ async def Nudgepetpet(event: NudgeEvent): # else: # await bot.send(event, "我是水群冠军!") - _task = None - - - @bot.on(Startup) - async def start_scheduler(_): - - async def timer(): - today_finished = False # 设置变量标识今天是会否完成任务,防止重复发送 - while True: - await asyncio.sleep(1) - now = datetime.datetime.now() - if now.hour == 7 and now.minute == 30 and not today_finished: # 每天早上 7:30 发送早安 - for group in alarmclockgroup: - await bot.send_group_message(group, "早上好") - today_finished = True - if now.hour == 7 and now.minute == 31: - today_finished = False # 早上 7:31,重置今天是否完成任务的标识 - - global _task - _task = asyncio.create_task(timer()) - - - @bot.on(Shutdown) - async def stop_scheduler(_): - # 退出时停止定时任务 - global _task - if _task: - _task.cancel() - - scheduler = AsyncIOScheduler(timezone="Asia/Shanghai") @@ -833,8 +929,8 @@ async def paiputimer(): except sqlite3.OperationalError: print("自动查询失败,可能是数据库不存在或者表不存在,牌谱查询将关闭") settings['autogetpaipu'] = False - if minute_now % 12 == 0: - await thautopaipu() + await thautopaipu() + await thbroadcastmatch() bot.run(port=17580) diff --git a/plugin/MajSoulInfo/__init__.py b/plugin/MajSoulInfo/__init__.py index 090d5fe..8f8f2b9 100644 --- a/plugin/MajSoulInfo/__init__.py +++ b/plugin/MajSoulInfo/__init__.py @@ -3,4 +3,46 @@ import os if not os.path.exists("./database/MajSoulInfo"): - os.mkdir("./database/MajSoulInfo") \ No newline at end of file + os.mkdir("./database/MajSoulInfo") + + +# cx = sqlite3.connect('./database/majsoul.sqlite') +cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') +cursor = cx.cursor() +cursor.execute("create table IF NOT EXISTS paipu(" + "id integer primary key," + "uuid varchar(50) UNIQUE," + "watchid integer," + "startTime varchar(50)," + "endTime varchar(50)," + "player1 varcher(50)," + "player2 varcher(50)," + "player3 varcher(50)," + "player4 varcher(50)" + ")") +cursor.execute('create table IF NOT EXISTS watchedplayer (' + 'id integer primary key,' + 'playerid integer,' + 'playername varchar(50) UNIQUE)') +cursor.execute("create table IF NOT EXISTS QQgroup(" + "id integer primary key ," + "groupid integer UNIQUE)") +cursor.execute("create table IF NOT EXISTS group2player(" + "id integer primary key," + "groupid integer," + "playerid integer," + "playername varchar(50)," + "UNIQUE(groupid,playerid) ON CONFLICT REPLACE)") +cursor.execute('create table IF NOT EXISTS qhplayer (' + 'id integer primary key,' + 'playerid integer,' + 'playername varchar(50) UNIQUE)') +cursor.execute("create table IF NOT EXISTS drawcards(" + "id integer primary key," + "userid int UNIQUE," + "drawcount int," + "lastdraw varchar(50)" + ")") +cx.commit() +cursor.close() +cx.close() \ No newline at end of file diff --git a/plugin/MajSoulInfo/majsoulinfo.py b/plugin/MajSoulInfo/majsoulinfo.py index 34949eb..def658f 100644 --- a/plugin/MajSoulInfo/majsoulinfo.py +++ b/plugin/MajSoulInfo/majsoulinfo.py @@ -1,3 +1,4 @@ +import datetime import math import os.path import time @@ -15,11 +16,12 @@ levellist = [[1200, 1400, 2000], [2800, 3200, 3600], [4000, 6000, 9000]] infomodel = dict(基本=['胡牌率', '放铳率', '自摸率', '默胡率', '流局率', '流听率', '副露率', '立直率', '胡了巡数', '平均打点', '平均铳点', '平均顺位', '被飞率'], - 立直=['立直率', '立直和了', '立直放铳A', '立直放铳B', '立直收支', '立直收入', '立直支出', '先制率', '追立率', '被追率', '立直巡目', '立直流局', '一发率', - '振听率', '立直多面', '立直好型'], - 更多=['最大连庄', '里宝率', '被炸率', '平均被炸点数', '放铳时立直率', '放铳时副露率', '副露后放铳率', '副露后流局率', '副露后和牌率', '打点效率', '铳点损失', - '净打点效率'], - 血统=['役满', '累计役满', '两立直', '流满', '最大累计番数', '平均起手向听']) + 立直=['立直率', '立直和了', '立直放铳A', '立直放铳B', '立直收支', '立直收入', '立直支出', '先制率', '追立率', '被追率', '立直巡目', '立直流局', + '一发率', + '振听率', '立直多面', '立直好型'], + 更多=['最大连庄', '里宝率', '被炸率', '平均被炸点数', '放铳时立直率', '放铳时副露率', '副露后放铳率', '副露后流局率', '副露后和牌率', '打点效率', '铳点损失', + '净打点效率'], + 血统=['役满', '累计役满', '两立直', '流满', '最大累计番数', '平均起手向听']) user_agent_list = [ "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36", @@ -77,13 +79,16 @@ def getinfo(username: str): return dict(error=True, muti3=muti3, muti4=muti4) -def getplayerdetail(playername: str, selecttype: str, selectlevel: list = None, model='基本') ->str: - if not model in ['基本','更多','立直','血统','all']: +def getplayerdetail(playername: str, selecttype: str, selectlevel: list = None, model='基本') -> str: + if not model in ['基本', '更多', '立直', '血统', 'all']: return "参数输入有误哦,可用的参数为'基本'、'更多'、'立直'、'血统'、'all'" xhr = "" - cx = sqlite3.connect('./database/majsoul.sqlite') + # cx = sqlite3.connect('./database/majsoul.sqlite') + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') + cursor = cx.cursor() - cursor.execute(f"select playerid from qhplayer where playername = '{playername}'") + cursor.execute( + f"select playerid from qhplayer where playername = '{playername}'") playerid = cursor.fetchall() cursor.close() s = requests.Session() @@ -101,13 +106,13 @@ def getplayerdetail(playername: str, selecttype: str, selectlevel: list = None, xhr = s.get( f"https://ak-data-5.sapk.ch/api/v2/pl4/player_extended_stats/{playerid}/1262304000000/{nowtime}?mode" f"=16.12.9.15.11.8", - timeout=5, + timeout=3, headers=headers) else: xhr = s.get( f"https://ak-data-1.sapk.ch/api/v2/pl3/player_extended_stats/{playerid}/1262304000000/{nowtime}?mode" f"=21.22.23.24.25.26", - timeout=5, + timeout=3, headers=headers) except requests.exceptions.ConnectionError as e: print(f"查询发生了错误:\t{e}\n") @@ -124,7 +129,7 @@ def getplayerdetail(playername: str, selecttype: str, selectlevel: list = None, if type(v) not in [list, dict]: if str(k) in ["id", "count"]: continue - if model in ['基本','更多','血统','立直']: + if model in ['基本', '更多', '血统', '立直']: if str(k) in infomodel.get(model): if type(v) == float: if str(k) not in ['平均起手向听', '立直巡目', '和了巡数']: @@ -148,9 +153,12 @@ def getsomeqhpaipu(playername: str, type="4", counts=5): nowtime = time.time() ptupdate = 0 nowtime = math.floor(nowtime / 10) * 10000 + 9999 - cx = sqlite3.connect('./database/majsoul.sqlite') + # cx = sqlite3.connect('./database/majsoul.sqlite') + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') + cursor = cx.cursor() - cursor.execute(f"select playerid from qhplayer where playername = '{playername}'") + cursor.execute( + f"select playerid from qhplayer where playername = '{playername}'") playerid = cursor.fetchall() cursor.close() cx.close() @@ -168,13 +176,13 @@ def getsomeqhpaipu(playername: str, type="4", counts=5): xhr = s.get( f"https://ak-data-1.sapk.ch/api/v2/pl3/player_records/{playerid}/{nowtime}/1262304000000" f"?limit={counts}&mode=21,22,23,24,25,26&descending=true", - headers=headers, timeout=5) + headers=headers, timeout=3) content = eval(xhr.text) else: xhr = s.get( f"https://ak-data-5.sapk.ch/api/v2/pl4/player_records/{playerid}/{nowtime}/1262304000000" f"?limit={counts}&mode=8,9,11,12,15,16&descending=true", - headers=headers, timeout=5) + headers=headers, timeout=3) content = eval(xhr.text) if len(content) == 0: return "未查询到对局信息" @@ -214,7 +222,7 @@ def getpaipu(playerid: str) -> dict: try: xhr4 = s.get( f"https://ak-data-1.sapk.ch/api/v2/pl4/player_records/{playerid}/{nowtime}/1262304000000" - "?limit=1&mode=8,9,11,12,15,16&descending=true", headers=headers, timeout=5) + "?limit=1&mode=8,9,11,12,15,16&descending=true", headers=headers, timeout=3) content['p4'] = eval(xhr4.text) # print(f'四麻对局信息:{eval(xhr.text)}') except requests.exceptions.ConnectionError as e: @@ -228,7 +236,7 @@ def getpaipu(playerid: str) -> dict: try: xhr3 = s.get( f"https://ak-data-1.sapk.ch/api/v2/pl3/player_records/{playerid}/{nowtime}/1262304000000" - "?limit=1&mode=21,22,23,24,25,26&descending=true", headers=headers, timeout=5) + "?limit=1&mode=21,22,23,24,25,26&descending=true", headers=headers, timeout=3) content['p3'] = eval(xhr3.text) # print(f'三麻对局信息:{eval(xhr.text)}') except requests.exceptions.ConnectionError as e: @@ -242,8 +250,11 @@ def getpaipu(playerid: str) -> dict: def jiexi(paipu: dict, playerid: int) -> list: hasNewPaipu = False - paipuInfo = "检测到新的对局信息:\n" - cx = sqlite3.connect('./database/majsoul.sqlite') + # paipuInfo = "检测到新的对局信息:\n" + paipuInfo = "" + # cx = sqlite3.connect('./database/majsoul.sqlite') + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') + cursor = cx.cursor() cx.commit() allpaipuinfo = [] @@ -383,7 +394,8 @@ def query(username: str) -> str: pass else: return "该用户不存在" - cx = sqlite3.connect("./database/majsoul.sqlite") + # cx = sqlite3.connect("./database/majsoul.sqlite") + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') cursor = cx.cursor() cx.commit() cursor.execute( @@ -402,7 +414,8 @@ def query(username: str) -> str: user_p3_levelinfo = userinfo['pl3'] user_p3_levelinfo = user_p3_levelinfo.get("level") p3_level = user_p3_levelinfo.get("id") - p3_score = int(user_p3_levelinfo.get("score")) + int(user_p3_levelinfo.get("delta")) + p3_score = int(user_p3_levelinfo.get("score")) + \ + int(user_p3_levelinfo.get("delta")) prtmsg += levelswitch(p3_level, p3_score, "三麻") except AttributeError: print("查询不到三麻段位") @@ -415,7 +428,8 @@ def query(username: str) -> str: user_p4_levelinfo = userinfo['pl4'] user_p4_levelinfo = user_p4_levelinfo.get("level") p4_level = user_p4_levelinfo.get("id") - p4_score = int(user_p4_levelinfo.get("score")) + int(user_p4_levelinfo.get("delta")) + p4_score = int(user_p4_levelinfo.get("score")) + \ + int(user_p4_levelinfo.get("delta")) prtmsg += levelswitch(p4_level, p4_score, "四麻") except AttributeError: print("查询不到四麻段位") @@ -423,11 +437,42 @@ def query(username: str) -> str: return prtmsg -def drawcards(up=False) -> dict: +def drawcards(userid: int, up=False) -> dict: if not os.path.exists('./images/MajsoulInfo'): os.mkdir('./images/MajsoulInfo') + + today = datetime.datetime.now().strftime("%Y-%m-%d") + # cx = sqlite3.connect("./database/majsoul.sqlite") + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') + cursor = cx.cursor() + cursor.execute( + f"select lastdraw,drawcount from drawcards where userid = {userid}") + user = cursor.fetchall() + if len(user) == 0: + cursor.execute( + f"insert into drawcards(userid,drawcount,lastdraw) values({userid},{3},'{today}')") + cx.commit() + cursor.execute( + f"select lastdraw,drawcount from drawcards where userid = {userid}") + user = cursor.fetchall() + lastdraw = user[0][0] + drawcount = user[0][1] + + if not (lastdraw == today): + cursor.execute( + f"update drawcards set drawcount = {3} , lastdraw = '{today}' where userid = {userid}") + cx.commit() + drawcount = 3 + if drawcount > 0: + drawcount = drawcount - 1 + cursor.execute( + f"update drawcards set drawcount = {drawcount} where userid = {userid}") + cx.commit() + else: + return dict(resultsmsg=" 你没有抽数惹,每人每天最多抽3次", error=True) baodi = False - drawcounts = {'0gift': 0, '1gift': 0, '2gift': 0, 'person': 0, 'decoration': 0} + drawcounts = {'0gift': 0, '1gift': 0, + '2gift': 0, 'person': 0, 'decoration': 0} results = [] resultsmsg = "\n您的抽卡结果依次为:\n" with open(r'./config/MajSoulInfo/drawcards.yml', 'r') as f: @@ -472,7 +517,8 @@ def drawcards(up=False) -> dict: decoration_name = random.choice(up_decoration) dec = decoration_name + '\n' drawcounts['decoration'] += 1 - results.append(f'./Images/decoration/{decoration_name}.jpg') + results.append( + f'./Images/decoration/{decoration_name}.jpg') resultsmsg += dec continue dec_index = random.randint(0, decoration['length'] - 1) @@ -485,7 +531,8 @@ def drawcards(up=False) -> dict: gifttype = random.randint(0, 10) if gifttype < 3: gift_index += 2 - elif gifttype < 9: + # elif gifttype < 9: + else: gift_index += 1 if count == 9 and drawcounts['2gift'] == 0: if gift['item'][gift_index]['rare'] == 2: @@ -501,12 +548,13 @@ def drawcards(up=False) -> dict: resultsmsg += gf if not count == 9: resultsmsg += '\n' - return dict(drawcounts=drawcounts, results=results, resultsmsg=resultsmsg, baodi=baodi) + return dict(drawcounts=drawcounts, results=results, resultsmsg=resultsmsg, baodi=baodi, error=False) def addwatch(playername: str, groupid: int): print(f'groupid= {groupid},playername= {playername}') - cx = sqlite3.connect("./database/majsoul.sqlite") + # cx = sqlite3.connect("./database/majsoul.sqlite") + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') cursor = cx.cursor() cx.commit() @@ -524,7 +572,8 @@ def addwatch(playername: str, groupid: int): # 群组已添加 pass try: - cursor.execute(f"select * from group2player where groupid = {groupid} and playerid = {playerid}") + cursor.execute( + f"select * from group2player where groupid = {groupid} and playerid = {playerid}") if len(cursor.fetchall()) == 0: cursor.execute( f"insert into group2player(groupid,playerid,playername) values({groupid},{playerid},'{playername}')") @@ -558,9 +607,12 @@ def getrank(playerinfo: dict): nextmonth = f"{int(year) + 1}-1" else: nextmonth = f"{year}-{int(month) + 1}" - cx = sqlite3.connect('./database/majsoul.sqlite') + # cx = sqlite3.connect('./database/majsoul.sqlite') + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') + cursor = cx.cursor() - cursor.execute(f"select playerid from qhplayer where playername = '{playername}'") + cursor.execute( + f"select playerid from qhplayer where playername = '{playername}'") playerid = cursor.fetchall() cursor.close() cx.close() @@ -581,11 +633,11 @@ def getrank(playerinfo: dict): if selecttype == "4": paipuresponse = session_paipu.get( f"https://ak-data-5.sapk.ch/api/v2/pl4/player_records/{playerid}/{nextmontht}/{selectmontht}" - "?mode=8,9,11,12,15,16&descending=true", headers=headers, timeout=5) + "?mode=8,9,11,12,15,16&descending=true", headers=headers, timeout=3) else: paipuresponse = session_paipu.get( f"https://ak-data-1.sapk.ch/api/v2/pl3/player_records/{playerid}/{nextmontht}/{selectmontht}" - "?mode=21,22,23,24,25,26&descending=true", headers=headers, timeout=5) + "?mode=21,22,23,24,25,26&descending=true", headers=headers, timeout=3) paipuresponse = eval(paipuresponse.text) paipumsg += f"总共进行了{len(paipuresponse)}场对局,共计" for players in paipuresponse: @@ -605,7 +657,8 @@ def getrank(playerinfo: dict): rankdict['fly'] += 1 break rank = rank - 1 - averagerank = (rankdict['1'] + rankdict['2'] * 2 + rankdict['3'] * 3 + rankdict['4'] * 4) / len(paipuresponse) + averagerank = (rankdict['1'] + rankdict['2'] * 2 + + rankdict['3'] * 3 + rankdict['4'] * 4) / len(paipuresponse) if selecttype == "4": paipumsg += f"{rankdict['1']}次①位,{rankdict['2']}次②位,{rankdict['3']}次③位,{rankdict['4']}次④位,平均顺位:{averagerank:1.2f}" else: @@ -626,13 +679,13 @@ def getrank(playerinfo: dict): inforesponse = session_info.get( f"https://ak-data-5.sapk.ch/api/v2/pl4/player_extended_stats/{playerid}/{selectmontht}/{nextmontht}?mode" f"=16.12.9.15.11.8", - timeout=5, + timeout=3, headers=headers) else: inforesponse = session_info.get( f"https://ak-data-1.sapk.ch/api/v2/pl3/player_extended_stats/{playerid}/{selectmontht}/{nextmontht}?mode" f"=21.22.23.24.25.26", - timeout=5, + timeout=3, headers=headers) inforesponse = eval(inforesponse.text.replace("null", "0.0")) infomsg = f"该月立直率: {inforesponse['立直率'] * 100 :2.2f}%, 副露率: {inforesponse['副露率'] * 100 :2.2f}%," \ @@ -649,7 +702,8 @@ def getrank(playerinfo: dict): def removewatch(playername: str, groupid: int) -> str: - cx = sqlite3.connect("./database/majsoul.sqlite") + # cx = sqlite3.connect("./database/majsoul.sqlite") + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') cursor = cx.cursor() cursor.execute( f"delete from group2player where playername = '{playername}' and groupid = {groupid}") @@ -667,7 +721,8 @@ def removewatch(playername: str, groupid: int) -> str: def getallwatcher(groupid: int) -> str: - cx = sqlite3.connect("./database/majsoul.sqlite") + # cx = sqlite3.connect("./database/majsoul.sqlite") + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') cursor = cx.cursor() cursor.execute( f"select playerid,playername from group2player where groupid = {groupid}") @@ -683,7 +738,8 @@ def getallwatcher(groupid: int) -> str: def autoQueryPaipu() -> list: - cx = sqlite3.connect("./database/majsoul.sqlite") + # cx = sqlite3.connect("./database/majsoul.sqlite") + cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') cursor = cx.cursor() cursor.execute(f"select playerid,playername from watchedplayer") players = cursor.fetchall() diff --git a/plugin/Petpet/__init__.py b/plugin/Petpet/__init__.py index f23202c..82342b5 100644 --- a/plugin/Petpet/__init__.py +++ b/plugin/Petpet/__init__.py @@ -1,4 +1,4 @@ -from plugin.Petpet.gif import * +from plugin.Petpet.gif import petpet import os diff --git a/plugin/TenHouPlugin/TenHou.py b/plugin/TenHouPlugin/TenHou.py index 4ed6934..97b6bf2 100644 --- a/plugin/TenHouPlugin/TenHou.py +++ b/plugin/TenHouPlugin/TenHou.py @@ -1,3 +1,4 @@ +import base64 import gzip import datetime import random @@ -20,6 +21,14 @@ "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15", ] +bordercast_temple = { + 1: " %player% 轻松拿下一位,实在太强啦", + 2: " %player% 悄悄拿下二位,稳稳上分", + 3: " %player% 精准避四,避开重大损失", + 4: " %player% 被安排了一个四位,库鲁西~", +} + + # 解压gz def un_gz(file_name): """ungz zip file""" @@ -32,10 +41,11 @@ def un_gz(file_name): g_file.close() # 关闭gzip对象 + # 自动抓取天风对局 -def autoget_th_match()->list: +def autoget_th_match() -> list: # tz = pytz.timezone('Asia/Tokyo') - tz= pytz.timezone('Asia/Shanghai') + tz = pytz.timezone('Asia/Shanghai') nowtime = datetime.datetime.now(tz=tz).strftime("%Y%m%d%H") # daytime = time.strftime("%Y-%m-%d", time.localtime()) daytime = datetime.datetime.now(tz=tz).strftime("%Y-%m-%d") @@ -48,39 +58,40 @@ def autoget_th_match()->list: os.remove(f'./data/TenHouPlugin/scb{nowtime}.log.gz') cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') cursor = cx.cursor() - cx.commit() cursor.execute("select playername from watchedplayer") result = cursor.fetchall() playername = [] for player in result: playername.append(player[0]) - print(playername) with open(f'./data/TenHouPlugin/scb{nowtime}.log', 'r', encoding='utf-8') as f: - # with open(f'./scb2022031811.log', 'r', encoding='utf-8') as f: lines = f.readlines() for line in lines: line = line.strip() datas = line.split('|') - startTime = datas[0].strip() + startTime = datas[0].replace('- ', '') duration = datas[1].strip() model = datas[2].strip() players = datas[3].strip() - plname = re.sub("[(\d+\.\-)]", "", players) + plname = re.sub(r"[(\d+\.\-)]", "", players) plname = plname.split(' ') players = players.split(' ') for p in plname: if p in playername: print(f"{datas}\n") - cursor.execute(f"select * from paipu where player1 = '{players[0]}' and startTime = '{daytime} {startTime}'") + cursor.execute( + f"select * from paipu where player1 = '{players[0]}' and startTime = '{daytime} {startTime}'") record = cursor.fetchall() if len(record) > 0: print("该记录已存在") break print(f"检测到{p}新的对局信息") - msg = "检测到新的对局信息:\n" + # msg = "检测到新的对局信息:\n" + msg = "" msg += f"{model}\n" - msg += f"结束时间: {daytime} {startTime} , 对局时长: {duration}\n" - msg += datas[3].strip() + msg += f"{daytime} {startTime} , 对局时长: {duration}\n" + order = get_matchorder(playerlist=players, playername=p) + msg += f"{bordercast_temple[order]}\n\n".replace('%player%', p) + msg += f" {datas[3].strip()}" if len(players) == 3: cursor.execute( f'insert into paipu(startTime,duration,model,player1,player2,player3,player4) values("{daytime} {startTime}","{duration}","{model}","{players[0]}","{players[1]}","{players[2]}","Null")') @@ -88,7 +99,7 @@ def autoget_th_match()->list: cursor.execute( f'insert into paipu(startTime,duration,model,player1,player2,player3,player4) values("{daytime} {startTime}","{duration}","{model}","{players[0]}","{players[1]}","{players[2]}","{players[3]}")') cx.commit() - msglist.append(dict(playername=p,msg=msg)) + msglist.append(dict(playername=p, msg=msg)) break os.remove(f'./data/TenHouPlugin/scb{nowtime}.log') cursor.close() @@ -97,28 +108,100 @@ def autoget_th_match()->list: return forwardmessage(msglist) -def forwardmessage(msglist:list) ->list: +def auto_get_th_matching(): + gamingplayer = get_gaming_thplayers() + cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') + # cx = sqlite3.connect('./TenHou.sqlite') + cursor = cx.cursor() + cursor.execute("select playername from watchedplayer") + result = cursor.fetchall() + watchedplayers = set() + for player in result: + watchedplayers.add(player[0]) + + response = requests.get('https://mjv.jp/0/wg/0.js', headers={'User-Agent': random.choice(user_agent_list)}, + allow_redirects=True) + text = response.text + text = text[6:-4] + text = text.replace('\r\n', '').replace('",', '";').replace('"', '').split(';') + nowmatches = [] + for infos in text: + info = infos.split(',') + duijuurl = info[0] + type = info[1] + time = info[2] + numberX = info[3] + players = [] + for i in range(4, len(info), 3): + dstr = base64.b64decode(info[i]).decode('utf-8') + info[i] = dstr + player = dict(playername=info[i], playerlevel=info[i + 1], playerrank=info[i + 2]) + players.append(player) + duiju = dict(url=duijuurl, type=type, time=time, numberX=numberX, players=players) + nowmatches.append(duiju) + + eligible_Matches = [] + for match in nowmatches: + matchplayer = get_thmatch_player(match) + player_t = ishaving_player_in_list(player_list=matchplayer, target_list=watchedplayers) + if player_t: + for gameplayer in gamingplayer: + if player_t == gameplayer['playername'] and gameplayer['url'] == match['url']: + # tempmatch = dict(playername=player_t, match=match) + # tempmatch = dict(playername=player_t, msg=matching2string(tempmatch)) + # eligible_Matches.append(tempmatch) + gameplayer['isgaming'] = 1 + break + else: + gamingplayer.append(dict(playername=player_t, url=match['url'], isgaming=2)) + tempmatch = dict(playername=player_t, match=match) + tempmatch = dict(playername=player_t, msg=matching2string(tempmatch)) + eligible_Matches.append(tempmatch) + print(eligible_Matches) + cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') + # cx = sqlite3.connect('./TenHou.sqlite') + cursor = cx.cursor() + print(gamingplayer) + for item in gamingplayer: + if item['isgaming'] == 2: + cursor.execute(f'''insert into isgaming(playername,url) values ("{item['playername']}","{item['url']}")''') + elif item['isgaming'] == 0: + cursor.execute( + f'''delete from isgaming where playername = '{item["playername"]}' and url = "{item['url']}" ''') + cx.commit() + cursor.close() + cx.close() + msglist = forwardmessage(eligible_Matches) + # print(msglist) + return msglist + + +# 转发消息,封装为 向 groupid 群聊 发送 msg 的格式 +# {playername,msg} -> {groupids,msg,playername} +def forwardmessage(msglist: list) -> list: messageChainList = [] cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') + # cx = sqlite3.connect('./TenHou.sqlite') cursor = cx.cursor() for item in msglist: groupids = [] cursor.execute(f'''select groupid from group2player where playername = "{item['playername']}"''') for g in cursor.fetchall(): groupids.append(g[0]) - messageChainList.append(dict(groups = groupids,msg = item['msg'])) + messageChainList.append(dict(groups=groupids, msg=item['msg'], playername=item['playername'])) cursor.close() cx.close() return messageChainList # 添加关注 -def addthwatch(playername:str,groupid:int): +def addthwatch(playername: str, groupid: int): cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') + # cx = sqlite3.connect('./TenHou.sqlite') cursor = cx.cursor() cursor.execute(f'select * from watchedplayer where playername = "{playername}"') - if len(cursor.fetchall())>0: + if len(cursor.fetchall()) > 0: print("该用户已添加进关注列表") else: cursor.execute(f'insert into watchedplayer(playername) values("{playername}")') @@ -126,7 +209,7 @@ def addthwatch(playername:str,groupid:int): print(f"已将{playername}添加到数据库") cursor.execute(f'select * from QQgroup where groupid = {groupid}') - if len(cursor.fetchall())>0: + if len(cursor.fetchall()) > 0: print("该群已注册进列表") else: cursor.execute(f'insert into QQgroup(groupid) values({groupid})') @@ -134,7 +217,7 @@ def addthwatch(playername:str,groupid:int): print(f"已将群组{groupid}添加到数据库") cursor.execute(f'select * from group2player where groupid = {groupid} and playername = "{playername}"') - if len(cursor.fetchall())>0: + if len(cursor.fetchall()) > 0: print("该用户已添加进此群的关注列表") return "该用户已添加进此群的关注列表,无需重复添加" else: @@ -147,12 +230,12 @@ def addthwatch(playername:str,groupid:int): return "添加成功" -def removethwatch(playername:str,groupid:int): +def removethwatch(playername: str, groupid: int): cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') cursor = cx.cursor() cursor.execute(f'select * from watchedplayer where playername = "{playername}"') - if len(cursor.fetchall()) ==0: + if len(cursor.fetchall()) == 0: print("未关注该用户") return "未关注该用户" else: @@ -171,7 +254,7 @@ def removethwatch(playername:str,groupid:int): return "删除成功" -def getthwatch(groupid :int) ->str: +def getthwatch(groupid: int) -> str: msg = "本群关注的天凤玩家有:\n" cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') cursor = cx.cursor() @@ -179,7 +262,69 @@ def getthwatch(groupid :int) ->str: cursor.execute(f'select playername from group2player where groupid = {groupid}') result = cursor.fetchall() for player in result: - msg+= player[0] + " " + msg += player[0] + " " + cursor.close() + cx.close() return msg +def get_matchorder(playerlist: list, playername: str) -> int: + # def get_score(e): + # return e['score'] + # + # playerwithscore = [] + # for p in playerlist: + # player, score = p.replace(')', '').split('(') + # playerwithscore.append(dict(playername=playername, score=int(score))) + # + # playerwithscore.sort(key=get_score, reverse=True) + + for i in range(4): + # if playername == playerwithscore[i]['playername']: + if playername == playerlist[i].split('(')[0]: + return i + 1 + + return 0 + + +def get_thmatch_player(match: dict) -> list: + players = list() + for player in match['players']: + players.append(player['playername']) + return players + + +def ishaving_player_in_list(player_list: list, target_list: set): + for player in player_list: + for target in target_list: + if player == target: + return player + return None + + +def matching2string(eligiblematch: dict) -> str: + playername = eligiblematch['playername'] + match = eligiblematch['match'] + # msg = f"{playername}正在{match['type']}乱杀,快来围观:\n" + msg = f"{playername}正在天凤乱杀,快来围观:\n" + msg += f"https://tenhou.net/3/?wg={match['url']} , 开始时间: {match['time']}\n" + for player in get_thmatch_player(match): + msg += f'{player} ' + return msg + + +def get_gaming_thplayers() -> list: + gamingplayer = [] + cx = sqlite3.connect('./database/TenHouPlugin/TenHou.sqlite') + # cx = sqlite3.connect('./TenHou.sqlite') + + cursor = cx.cursor() + cursor.execute(f"select * from isgaming") + for item in cursor.fetchall(): + gamingplayer.append(dict(playername=item[0], url=item[1], isgaming=0)) + cursor.close() + cx.commit() + return gamingplayer + +# addthwatch('soao',123) +# auto_get_th_matching() diff --git a/plugin/TenHouPlugin/__init__.py b/plugin/TenHouPlugin/__init__.py index 36ff1d7..0b4d705 100644 --- a/plugin/TenHouPlugin/__init__.py +++ b/plugin/TenHouPlugin/__init__.py @@ -1,6 +1,7 @@ import os +import sqlite3 -from plugin.TenHouPlugin.TenHou import * +from plugin.TenHouPlugin.TenHou import auto_get_th_matching,addthwatch,autoget_th_match,removethwatch,getthwatch if not os.path.exists("./database/TenHouPlugin"): os.mkdir("./database/TenHouPlugin") @@ -31,16 +32,11 @@ "player3 varcher(50)," "player4 varcher(50)" ")") -cursor.execute("create table IF NOT EXISTS prp(" # 玩家 最近牌谱 - "id integer primary key," - "startTime varchar(50)," - "model varchar(50)," - "duration varchar(50)," - "player1 varcher(50)," - "player2 varcher(50)," - "player3 varcher(50)," - "player4 varcher(50) default Null" +cursor.execute("create table if not exists isgaming(" + "playername varchar(50)," + "url varchar(20)" ")") + cx.commit() cursor.close() cx.close() diff --git a/plugin/preinit/load_application.py b/plugin/preinit/load_application.py index a7b761a..aacb8a6 100644 --- a/plugin/preinit/load_application.py +++ b/plugin/preinit/load_application.py @@ -21,21 +21,29 @@ def load_config() -> dict: botname = botconfig['botname'] silencegroup = config['silencegroup'] repeatconfig = config['repeatconfig'] + norepeatgroup = config['norepeatgroup'] + qhsettings = config['qhsettings'] + disnudgegroup = config['disnudgegroup'] + master = config['master'] if len(welcomeinfo) == 0: print("入群欢迎文本不存在,该功能将关闭") config['settings']['autowelcome'] = False return config except Exception as e: + print(f'{e} 缺失') print("文件打开错误,尝试生成初始文件中...") with open(r'./config.yml', 'w') as f: yaml.dump(dict(admin=[0], whitelist=[0], blacklist=[0], mutegrouplist=[0], welcomeinfo=["欢迎%ps%加入%gn%"], alarmclockgroup=[0], - silencegroup=[0], commandpre="", searchfrequency=6, - botconfig=dict(qq=123456, botname="", ), - repeatconfig=dict(repeatQ=20, repeatmsg=1, interruptQ=0.5, interruptQQ=0.1), - adapter=dict(verify_key='NekoRabi', host='localhost', - port=17280), - settings=dict(autogetpaipu=True, autowelcome=True, r18talk=True, setu=False, silence=False)), + silencegroup=[0], norepeatgroup=[0], disnudgegroup=[0], commandpre="", searchfrequency=6, + master=0,botconfig=dict(qq=123456, botname="", ), + repeatconfig=dict( + repeatQ=20, repeatmsg=1, interruptQ=0.5, interruptQQ=0.1), + adapter=dict(verify_key='NekoRabi', + host='localhost', port=17280), + settings=dict(autogetpaipu=True, autowelcome=True, r18talk=True, nudgereply=True, setu=False, + silence=False, norepeat=False), + qhsettings=dict(qhpt=True, qhinfo=True, qhsl=True, qhyb=True, disptgroup=[0])), f, allow_unicode=True) print("默认文件生成完成,请重新启动。") exit(0)