From ab1b270c96723912ccfce3e92891c2fd2b7a4f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=8C?= Date: Fri, 28 Jul 2023 13:05:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/default_config/bot.yaml | 2 +- lib/bot.js | 6 ------ lib/plugins/loader.js | 24 ++++++++++++++---------- plugins/adapter/go-cqhttp.js | 4 ++-- plugins/other/install.js | 1 + 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/config/default_config/bot.yaml b/config/default_config/bot.yaml index b89d9d4..1b6f8c7 100644 --- a/config/default_config/bot.yaml +++ b/config/default_config/bot.yaml @@ -1,7 +1,7 @@ # 日志等级:trace,debug,info,warn,fatal,mark,error,off # mark时只显示执行命令,不显示聊天记录 log_level: info -# HTTP 端口 +# 服务器端口 port: 2536 # chromium其他路径 diff --git a/lib/bot.js b/lib/bot.js index e1b2ab9..a9571cb 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -107,25 +107,19 @@ export default class Yunzai extends EventEmitter { user_id = Number(user_id) || String(user_id) const user = this.fl.get(user_id) if (user) return this[user.bot_id].pickFriend(user_id) - logger.error(`获取用户对象失败:找不到用户 ${logger.red(user_id)}`) - return false } pickGroup(group_id) { group_id = Number(group_id) || String(group_id) const group = this.gl.get(group_id) if (group) return this[group.bot_id].pickGroup(group_id) - logger.error(`获取群对象失败:找不到群 ${logger.red(group_id)}`) - return false } pickMember(group_id, user_id) { const group = this.pickGroup(group_id) if (group) return group.pickMember(user_id) - - return false } sendFriendMsg(bot_id, user_id, msg) { diff --git a/lib/plugins/loader.js b/lib/plugins/loader.js index 83266da..4e14302 100644 --- a/lib/plugins/loader.js +++ b/lib/plugins/loader.js @@ -494,9 +494,9 @@ class PluginsLoader { msg = [segment.reply(e.message_id), msg] } - let msgRes + let res try { - msgRes = await e.replyNew(msg) + res = await e.replyNew(msg) } catch (err) { if (typeof msg != "string") msg = lodash.truncate(JSON.stringify(msg), { length: 300 }) @@ -504,19 +504,23 @@ class PluginsLoader { logger.error(err) } - if (recallMsg > 0 && msgRes?.message_id) { + if (recallMsg > 0 && res?.message_id) { if (e.group?.recallMsg) - setTimeout(() => - e.group.recallMsg(msgRes.message_id), - recallMsg * 1000) + setTimeout(() => { + e.group.recallMsg(res.message_id) + if (e.message_id) + e.group.recallMsg(e.message_id) + }, recallMsg * 1000) else if (e.friend?.recallMsg) - setTimeout(() => - e.friend.recallMsg(msgRes.message_id), - recallMsg * 1000) + setTimeout(() => { + e.friend.recallMsg(res.message_id) + if (e.message_id) + e.friend.recallMsg(e.message_id) + }, recallMsg * 1000) } this.count(e, msg) - return msgRes + return res } } diff --git a/plugins/adapter/go-cqhttp.js b/plugins/adapter/go-cqhttp.js index fea4462..1b9387d 100644 --- a/plugins/adapter/go-cqhttp.js +++ b/plugins/adapter/go-cqhttp.js @@ -187,8 +187,8 @@ Bot.adapter.push(new class gocqhttpAdapter { guild_id: guild.guild_id, }))) array.push({ - ...guild, - ...channel, + guild, + channel, group_id: `${guild.guild_id}-${channel.channel_id}`, group_name: `${guild.guild_name}-${channel.channel_name}`, }) diff --git a/plugins/other/install.js b/plugins/other/install.js index b52a225..32b09fb 100644 --- a/plugins/other/install.js +++ b/plugins/other/install.js @@ -9,6 +9,7 @@ const list = { "TRSS-Plugin" :"https://Yunzai.TRSS.me", "yenai-plugin" :"https://gitee.com/yeyang52/yenai-plugin", "flower-plugin" :"https://gitee.com/Nwflower/flower-plugin", + "xianyu-plugin" :"https://gitee.com/suancaixianyu/xianyu-plugin", "earth-k-plugin":"https://gitee.com/SmallK111407/earth-k-plugin", "useless-plugin":"https://gitee.com/SmallK111407/useless-plugin", "StarRail-plugin" :"https://gitee.com/hewang1an/StarRail-plugin",