diff --git a/bots/aiocqhttp/message.py b/bots/aiocqhttp/message.py index fc3212af8f..0758f13f3c 100644 --- a/bots/aiocqhttp/message.py +++ b/bots/aiocqhttp/message.py @@ -39,6 +39,7 @@ from core.utils.storedata import get_stored_list enable_analytics = Config("enable_analytics", False) +qq_typing_emoji = str(Config("qq_typing_emoji", 181, (str, int), table_name="bot_aiocqhttp")) class FinishedSession(FinishedSessionT): @@ -430,47 +431,31 @@ def __init__(self, msg: MessageSessionT): async def __aenter__(self): if self.msg.target.target_from == target_group_prefix: # wtf onebot 11 obi = await get_onebot_implementation() - if obi == "ntqq": + if obi in ["llonebot", "napcat"]: await bot.call_action( "set_msg_emoji_like", message_id=self.msg.session.message.message_id, - emoji_id=str( - Config( - "qq_typing_emoji", - 181, - (str, int), - table_name="bot_aiocqhttp", - ) - ), - ) + emoji_id=qq_typing_emoji) + elif obi == "lagrange": + await bot.call_action( + "set_group_reaction", + group_id=self.msg.session.target, + message_id=self.msg.session.message.message_id, + code=qq_typing_emoji, + is_add=True) else: if self.msg.session.sender in last_send_typing_time: - if ( - datetime.datetime.now().timestamp() - - last_send_typing_time[self.msg.session.sender] - <= 3600 - ): + if datetime.datetime.now().timestamp() - last_send_typing_time[self.msg.session.sender] <= 3600: return - last_send_typing_time[self.msg.session.sender] = ( - datetime.datetime.now().timestamp() - ) - - if obi == "lagrange": - await bot.call_action( - "group_poke", - group_id=self.msg.session.target, - user_id=self.msg.session.sender, - ) - elif obi == "shamrock": + last_send_typing_time[self.msg.session.sender] = datetime.datetime.now().timestamp() + if obi == "shamrock": await bot.send_group_msg( group_id=self.msg.session.target, - message=f"[CQ:touch,id={self.msg.session.sender}]", - ) + message=f"[CQ:touch,id={self.msg.session.sender}]") elif obi == "go-cqhttp": await bot.send_group_msg( group_id=self.msg.session.target, - message=f"[CQ:poke,qq={self.msg.session.sender}]", - ) + message=f"[CQ:poke,qq={self.msg.session.sender}]") else: pass diff --git a/bots/aiocqhttp/utils.py b/bots/aiocqhttp/utils.py index 8e909f1a0e..81ebb78071 100644 --- a/bots/aiocqhttp/utils.py +++ b/bots/aiocqhttp/utils.py @@ -14,8 +14,8 @@ async def get_onebot_implementation() -> Optional[str]: Logger.debug(str(data)) app_name = data.get("app_name") - if app_name in ["NapCat.Onebot", "LLOneBot"]: - app_name = "ntqq" + if app_name == "NapCat.Onebot": + app_name = "napcat" elif app_name == "Lagrange.OneBot": app_name = "lagrange" diff --git a/bots/qqbot/message.py b/bots/qqbot/message.py index 36371c3347..b7dff06656 100644 --- a/bots/qqbot/message.py +++ b/bots/qqbot/message.py @@ -120,6 +120,7 @@ async def send_message( ) if not msg_quote and quote: msg = f"<@{self.session.message.author.id}> \n" + msg + msg = "" if not msg else msg send = await self.session.message.reply( content=msg, file_image=send_img, message_reference=msg_quote ) @@ -151,6 +152,7 @@ async def send_message( if quote and not send_img else None ) + msg = "" if not msg else msg send = await self.session.message.reply( content=msg, file_image=send_img, message_reference=msg_quote ) @@ -183,6 +185,7 @@ async def send_message( ) if msg and self.session.message.id: msg = "\n" + msg + msg = "" if not msg else msg try: send = await self.session.message.reply( content=msg, @@ -235,6 +238,7 @@ async def send_message( file_type=1, file_data=await image_1.get_base64(), ) + msg = "" if not msg else msg try: send = await self.session.message.reply( content=msg, diff --git a/bots/web/bot.py b/bots/web/bot.py index f8541e80d6..02ad59479c 100644 --- a/bots/web/bot.py +++ b/bots/web/bot.py @@ -17,7 +17,7 @@ WEBUI_PORT = Config("webui_port", 8081, table_name="bot_web") Info.client_name = client_name -PrivateAssets.set(os.path.join(assets_path, "private", "api")) +PrivateAssets.set(os.path.join(assets_path, "private", "web")) def run_fastapi(): diff --git a/core/bot_init.py b/core/bot_init.py index cfc3ff8566..42836a7401 100644 --- a/core/bot_init.py +++ b/core/bot_init.py @@ -54,7 +54,7 @@ async def load_secret(): async def load_prompt(bot) -> None: - author_cache = os.path.join(PrivateAssets.path, "cache_restart_author") + author_cache = os.path.join(PrivateAssets.path, ".cache_restart_author") loader_cache = os.path.join(PrivateAssets.path, ".cache_loader") if os.path.exists(author_cache): with open(author_cache, "r", encoding="utf-8") as open_author_cache: @@ -70,8 +70,7 @@ async def load_prompt(bot) -> None: await m.send_direct_message( m.parent.locale.t("loader.load.success") ) - os.remove(author_cache) - os.remove(loader_cache) + os.remove(author_cache) __all__ = ["init_async", "load_prompt"] diff --git a/core/parser/message.py b/core/parser/message.py index db6d037f37..b1b205d117 100644 --- a/core/parser/message.py +++ b/core/parser/message.py @@ -26,6 +26,7 @@ from core.utils.message import remove_duplicate_space qq_account = Config("qq_account", cfg_type=(int, str), table_name='bot_aiocqhttp') +qq_limited_emoji = str(Config('qq_limited_emoji', 10060, (str, int), table_name='bot_aiocqhttp')) default_locale = Config("default_locale", cfg_type=str) enable_tos = Config('enable_tos', True) @@ -446,15 +447,24 @@ async def execute_submodule(msg: Bot.MessageSession, command_first_word): except SendMessageFailed: if msg.target.target_from == qq_group_prefix: # wtf onebot 11 obi = await get_onebot_implementation() - if obi == 'ntqq': - await msg.call_api('set_msg_emoji_like', message_id=msg.session.message.message_id, - emoji_id=str(Config('qq_limited_emoji', 10060, (str, int), table_name='bot_aiocqhttp'))) - elif obi == 'lagrange': - await msg.call_api('group_poke', group_id=msg.session.target, user_id=int(qq_account)) - elif obi == 'shamrock': - await msg.call_api('send_group_msg', group_id=msg.session.target, message=f'[CQ:touch,id={qq_account}]') - elif obi == 'go-cqhttp': - await msg.call_api('send_group_msg', group_id=msg.session.target, message=f'[CQ:poke,qq={qq_account}]') + if obi in ["llonebot", "napcat"]: + await msg.call_api("set_msg_emoji_like", + message_id=msg.session.message.message_id, + emoji_id=qq_limited_emoji) + elif obi == "lagrange": + await msg.call_api("set_group_reaction", + group_id=msg.session.target, + message_id=msg.session.message.message_id, + code=qq_limited_emoji, + is_add=True) + elif obi == "shamrock": + await msg.call_api("send_group_msg", + group_id=msg.session.target, + message=f"[CQ:touch,id={qq_account}]") + elif obi == "go-cqhttp": + await msg.call_api("send_group_msg", + group_id=msg.session.target, + message=f"[CQ:poke,qq={qq_account}]") else: pass await msg.send_message(msg.locale.t("error.message.limited")) diff --git a/modules/core/su_utils.py b/modules/core/su_utils.py index a33ec358fe..b5e5e6dba0 100644 --- a/modules/core/su_utils.py +++ b/modules/core/su_utils.py @@ -306,7 +306,7 @@ def restart(): def write_version_cache(msg: Bot.MessageSession): - update = os.path.join(PrivateAssets.path, 'cache_restart_author') + update = os.path.join(PrivateAssets.path, '.cache_restart_author') with open(update, 'wb') as write_version: write_version.write(json.dumps({'From': msg.target.target_from, 'ID': msg.target.target_id}))