From 91d44b020de708d946f5231064d658a99f4f65b3 Mon Sep 17 00:00:00 2001 From: yzhh <2596322644@qq.com> Date: Sun, 21 Nov 2021 21:20:07 +0800 Subject: [PATCH] update issue template --- core/bots/aiocqhttp/message.py | 4 ++-- core/bots/aiogram/message.py | 4 ++-- core/bots/discord/message.py | 4 ++-- core/parser/message.py | 8 +++---- core/unit_test/template.py | 1 + core/unused_bots/graia/message.py | 6 ++--- modules/bugtracker/bugtracker.py | 2 +- modules/github/repo.py | 2 +- modules/github/search.py | 2 +- modules/github/user.py | 2 +- modules/server/__init__.py | 37 ++++++++++++++++++------------- modules/server/server.py | 2 +- modules/user/userlib.py | 2 +- modules/wiki/wikilib.py | 8 +++---- 14 files changed, 45 insertions(+), 39 deletions(-) diff --git a/core/bots/aiocqhttp/message.py b/core/bots/aiocqhttp/message.py index 5db1d785..e30b5189 100644 --- a/core/bots/aiocqhttp/message.py +++ b/core/bots/aiocqhttp/message.py @@ -43,7 +43,7 @@ class MessageSession(MS): if isinstance(msgchain, str): msg = msg + (MessageSegment.text(msgchain if msgchain != '' else '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。' - '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=')) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+')) elif isinstance(msgchain, (list, tuple)): count = 0 for x in msgchain: @@ -56,7 +56,7 @@ class MessageSession(MS): count += 1 else: msg = msg + MessageSegment.text('发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。' - '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=') + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+') Logger.info(f'[Bot] -> [{self.target.targetId}]: {msg}') if self.target.targetFrom == 'QQ|Group': send = await bot.send_group_msg(group_id=self.session.target, message=msg) diff --git a/core/bots/aiogram/message.py b/core/bots/aiogram/message.py index 68a1a8e4..b465cddc 100644 --- a/core/bots/aiogram/message.py +++ b/core/bots/aiogram/message.py @@ -33,7 +33,7 @@ class MessageSession(MS): return await self.sendMessage('https://wdf.ink/6Oup') if isinstance(msgchain, str): if msgchain == '': - msgchain = '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=' + msgchain = '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' send = await bot.send_message(self.session.target, msgchain, reply_to_message_id=self.session.message.message_id if quote and self.session.message else None) elif isinstance(msgchain, (list, tuple)): @@ -61,7 +61,7 @@ class MessageSession(MS): send.append(send_) count += 1 else: - msgchain = '发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=' + msgchain = '发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' send = await bot.send_message(self.session.target, msgchain, reply_to_message_id=self.session.message.message_id if quote and self.session.message else None) return MessageSession(target=MsgInfo(targetId=0, senderId=0, senderName='', targetFrom='Telegram|Bot', diff --git a/core/bots/discord/message.py b/core/bots/discord/message.py index 5e1128f5..7231029f 100644 --- a/core/bots/discord/message.py +++ b/core/bots/discord/message.py @@ -33,7 +33,7 @@ class MessageSession(MS): return await self.sendMessage('https://wdf.ink/6Oup') if isinstance(msgchain, str): if msgchain == '': - msgchain = '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=' + msgchain = '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' send = await self.session.target.send(msgchain, reference=self.session.message if quote and self.session.message else None) elif isinstance(msgchain, (list, tuple)): @@ -54,7 +54,7 @@ class MessageSession(MS): send.append(send_) count += 1 else: - msgchain = '发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=' + msgchain = '发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' send = await self.session.target.send(msgchain, reference=self.session.message if quote and self.session.message else None) return MessageSession(target=MsgInfo(targetId=0, senderId=0, senderName='', targetFrom='Discord|Bot', diff --git a/core/parser/message.py b/core/parser/message.py index f310133b..c13d89ce 100644 --- a/core/parser/message.py +++ b/core/parser/message.py @@ -63,7 +63,7 @@ async def parser(msg: MessageSession): if senderInfo.query.isInBlockList and not senderInfo.query.isInAllowList or len(display) == 0: return if display[0] in command_prefix: # 检查消息前缀 - if len(display) <= 1: + if len(display) <= 1 or (display[0] == '~' and display[1] == '~'): return Logger.info( f'[{msg.target.senderId}{f" ({msg.target.targetId})" if msg.target.targetFrom != msg.target.senderFrom else ""}] -> [Bot]: {display}') @@ -124,7 +124,7 @@ async def parser(msg: MessageSession): continue if not module.match_list.set: await msg.sendMessage(f'发生错误:{command_first_word}未绑定任何命令,,请联系开发者处理。' - f'\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=。') + f'\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+。') continue none_doc = True for func in module.match_list.get(msg.target.targetFrom): @@ -158,7 +158,7 @@ async def parser(msg: MessageSession): traceback.print_exc() await msg.sendMessage( f'{command_first_word}模块的帮助信息有误,请联系开发者处理。' - f'\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=') + f'\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+') continue else: msg.parsed_msg = None @@ -177,7 +177,7 @@ async def parser(msg: MessageSession): except Exception as e: Logger.error(traceback.format_exc()) await msg.sendMessage('执行命令时发生错误,请报告机器人开发者:\n' + str( - e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=') + e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+') continue ExecutionLockList.remove(msg) diff --git a/core/unit_test/template.py b/core/unit_test/template.py index c9a916d6..00838b4e 100644 --- a/core/unit_test/template.py +++ b/core/unit_test/template.py @@ -12,6 +12,7 @@ class Template(MessageSession): image = True voice = False forward = False + delete = True async def sendMessage(self, msgchain, quote=True) -> MessageSession: if Secret.find(msgchain): diff --git a/core/unused_bots/graia/message.py b/core/unused_bots/graia/message.py index 4e032fde..0f49e900 100644 --- a/core/unused_bots/graia/message.py +++ b/core/unused_bots/graia/message.py @@ -23,7 +23,7 @@ from database.logging_message import LoggerMSG async def msgchain_gen(message) -> MessageChain: if isinstance(message, str): if message == '': - message = '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=' + message = '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' msgchain = MessageChain.create([Plain(message)]) elif isinstance(message, (list, tuple)): msgchain_list = [] @@ -36,13 +36,13 @@ async def msgchain_gen(message) -> MessageChain: msgchain_list.append(Voice().fromLocalFile(filepath=await slk_converter(x.path))) if not msgchain_list: msgchain_list.append(Plain( - '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=')) + '发生错误:机器人尝试发送空文本消息,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+')) msgchain = MessageChain.create(msgchain_list) elif isinstance(message, MessageChain): msgchain = message else: msgchain = MessageChain.create([Plain( - '发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=')]) + '发生错误:机器人尝试发送非法消息链,请联系机器人开发者解决问题。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+')]) return msgchain diff --git a/modules/bugtracker/bugtracker.py b/modules/bugtracker/bugtracker.py index 34632e27..53966f92 100644 --- a/modules/bugtracker/bugtracker.py +++ b/modules/bugtracker/bugtracker.py @@ -62,7 +62,7 @@ async def bugtracker_get(MojiraID): print(fields['fixVersions']) FixVersion = fields['fixVersions'][0]['name'] else: - return '发生错误:获取Json失败。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=' + return '发生错误:获取Json失败。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' msglist = [] if errmsg != '': msglist.append(errmsg) diff --git a/modules/github/repo.py b/modules/github/repo.py index 8ba91051..a82d9c71 100644 --- a/modules/github/repo.py +++ b/modules/github/repo.py @@ -62,5 +62,5 @@ Created {time_diff(result['created_at'])} ago | Updated {time_diff(result['updat path=f'https://opengraph.githubassets.com/c9f4179f4d560950b2355c82aa2b7750bffd945744f9b8ea3f93cc24779745a0/{result["full_name"]}')]) except Exception as e: await msg.sendMessage('发生错误:' + str( - e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=') + e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+') traceback.print_exc() diff --git a/modules/github/search.py b/modules/github/search.py index 6d9ee979..832a977e 100644 --- a/modules/github/search.py +++ b/modules/github/search.py @@ -27,5 +27,5 @@ async def search(msg: MessageSession): await msg.sendMessage(message) except Exception as error: await msg.sendMessage('发生错误:' + str( - error) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=') + error) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+') traceback.print_exc() diff --git a/modules/github/user.py b/modules/github/user.py index d6e19e07..55897d8c 100644 --- a/modules/github/user.py +++ b/modules/github/user.py @@ -43,5 +43,5 @@ Account Created {time_diff(result['created_at'])} ago | Latest activity {time_di await msg.sendMessage(message) except Exception as error: await msg.sendMessage('发生错误:' + str( - error) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=') + error) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+') traceback.print_exc() diff --git a/modules/server/__init__.py b/modules/server/__init__.py index 1f764588..ee6be53a 100644 --- a/modules/server/__init__.py +++ b/modules/server/__init__.py @@ -1,10 +1,14 @@ import asyncio -from core.component import on_command +from core.component import on_command, on_option from core.dirty_check import check from core.elements import MessageSession +from database import BotDBUtil from .server import server + +on_option('server_disable_revoke', desc='关闭server命令的自动撤回') # 临时解决方案,后续会改动,归属到toggle命令下 + s = on_command('server', alias='s', developers=['_LittleC_', 'OasisAkari']) @@ -12,33 +16,34 @@ s = on_command('server', alias='s', developers=['_LittleC_', 'OasisAkari']) ': [-r] {获取Minecraft Java/基岩版服务器motd。(原始信息)}', ': [-p] {获取Minecraft Java/基岩版服务器motd。(包括玩家信息)}']) async def main(msg: MessageSession): - raw = False - showplayer = False - if msg.parsed_msg['-r']: - raw = True - if msg.parsed_msg['-p']: - showplayer = True + enabled_addon = BotDBUtil.Module(msg).check_target_enabled_module('server_disable_revoke') gather_list = [] sm = ['j', 'b'] for x in sm: - gather_list.append(asyncio.ensure_future(s(msg, f'{msg.parsed_msg[":"]}', raw, showplayer, x))) + gather_list.append(asyncio.ensure_future(s( + msg, f'{msg.parsed_msg[":"]}', msg.parsed_msg['-r'], msg.parsed_msg['-p'], x, enabled_addon))) g = await asyncio.gather(*gather_list) if g == ['', '']: - send = await msg.sendMessage( - '发生错误:没有找到任何类型的Minecraft服务器。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=\n[90秒后撤回消息]') - await msg.sleep(90) - await send.delete() + msg_ = '发生错误:没有找到任何类型的Minecraft服务器。' \ + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' + if msg.Feature.delete and not enabled_addon: + msg_ += '[90秒后撤回消息]' + send = await msg.sendMessage(msg_) + if msg.Feature.delete and not enabled_addon: + await msg.sleep(90) + await send.delete() -async def s(msg: MessageSession, address, raw, showplayer, mode): +async def s(msg: MessageSession, address, raw, showplayer, mode, enabled_addon): sendmsg = await server(address, raw, showplayer, mode) if sendmsg != '': sendmsg = await check(sendmsg) for x in sendmsg: m = x['content'] - if msg.Feature.delete: + if msg.Feature.delete and not enabled_addon: m += '\n[90秒后撤回消息]' send = await msg.sendMessage(m) - await msg.sleep(90) - await send.delete() + if msg.Feature.delete and not enabled_addon: + await msg.sleep(90) + await send.delete() return sendmsg diff --git a/modules/server/server.py b/modules/server/server.py index 1e0e0e16..5560e0a0 100644 --- a/modules/server/server.py +++ b/modules/server/server.py @@ -76,7 +76,7 @@ async def server(address, raw=False, showplayer=False, mode='j'): except Exception: traceback.print_exc() servers.append( - "[JE]\n发生错误:调用API时发生错误。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=") + "[JE]\n发生错误:调用API时发生错误。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+") except Exception: traceback.print_exc() if raw: diff --git a/modules/user/userlib.py b/modules/user/userlib.py index 50dd3fd3..c3e64e01 100644 --- a/modules/user/userlib.py +++ b/modules/user/userlib.py @@ -231,4 +231,4 @@ async def GetUser(wikiurl, username, argv=None): else: traceback.print_exc() return '发生错误:' + str( - e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=' + e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+' diff --git a/modules/wiki/wikilib.py b/modules/wiki/wikilib.py index 5821d6c7..8ce69427 100644 --- a/modules/wiki/wikilib.py +++ b/modules/wiki/wikilib.py @@ -450,7 +450,7 @@ class wikilib: except Exception as e: traceback.print_exc() return {'status': 'done', 'text': '发生错误:' + str( - e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title='} + e) + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+'} async def main(self, api_endpoint_link, page_name, interwiki=None, template=False, headers=None, tryiw=0): print(api_endpoint_link) @@ -490,11 +490,11 @@ class wikilib: self.page_raw = await self.get_page_link() except asyncio.exceptions.TimeoutError: return {'status': 'done', - 'text': '发生错误:请求页面超时。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title='} + 'text': '发生错误:请求页面超时。\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+'} except Exception as e: traceback.print_exc() return {'status': 'done', - 'text': f'发生错误:{str(e)}\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title='} + 'text': f'发生错误:{str(e)}\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+'} if 'interwiki' in self.page_raw['query']: iwp = self.page_raw['query']['interwiki'][0] match_interwiki = re.match(r'^' + iwp['iw'] + r':(.*)', iwp['title']) @@ -517,4 +517,4 @@ class wikilib: return await self.step1() except Exception as e: traceback.print_exc() - return f'发生错误:{str(e)}' + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=5678.md&title=\n' + return f'发生错误:{str(e)}' + '\n错误汇报地址:https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=bug&template=report_bug.yaml&title=%5BBUG%5D%3A+\n'