diff --git a/apps/fun.js b/apps/fun.js index eb4280f..867956b 100644 --- a/apps/fun.js +++ b/apps/fun.js @@ -147,6 +147,7 @@ export class Fun extends plugin { try { res = await QQApi.thumbUp(e.user_id, 10) } catch (error) { + logger.error(error) return logger.error(`${e.logFnc}未检测到oicq或icqq无法进行点赞`) } logger.debug(`${e.logFnc}给${e.user_id}点赞`, res) diff --git a/apps/groupAdmin.js b/apps/groupAdmin.js index 0cd1891..c0bb3d6 100644 --- a/apps/groupAdmin.js +++ b/apps/groupAdmin.js @@ -376,7 +376,7 @@ export class GroupAdmin extends plugin { // 获取禁言列表 async Mutelist (e) { new Ga(e).getMuteList(e.group_id, true) - .then(res => common.getforwardMsg(e, res)) + .then(res => common.getforwardMsg(e, res, { isxml: true })) .catch(err => e.reply(err.message)) } @@ -426,7 +426,7 @@ export class GroupAdmin extends plugin { `请发送:#确认清理${regRet[2]}${regRet[3]}没发言的人` ]) } - common.getforwardMsg(e, msg) + common.getforwardMsg(e, msg, { isxml: true }) } // 查看和清理从未发言的人 @@ -457,7 +457,7 @@ export class GroupAdmin extends plugin { let page = e.msg.match(new RegExp(Numreg)) page = page ? common.translateChinaNum(page[0]) : 1 new Ga(e).getNeverSpeakInfo(e.group_id, page) - .then(res => common.getforwardMsg(e, res)) + .then(res => common.getforwardMsg(e, res, { isxml: true })) .catch(err => e.reply(err.message)) } @@ -471,7 +471,7 @@ export class GroupAdmin extends plugin { } else { msg = await new Ga(e).getRecentlyJoined(e.group_id, num) } - common.getforwardMsg(e, msg) + common.getforwardMsg(e, msg, { isxml: true }) } // 发送通知 diff --git a/apps/picSearch.js b/apps/picSearch.js index a0bc854..838aaf9 100644 --- a/apps/picSearch.js +++ b/apps/picSearch.js @@ -39,7 +39,7 @@ export class NewPicSearch extends plugin { .then(async res => { res.length == 1 ? common.recallsendMsg(e, res[0], true) - : common.recallSendForwardMsg(e, res, { isxmlMsg: false }) + : common.recallSendForwardMsg(e, res, { xmlTitle: false }) }) .catch(async err => { await e.reply(err.message) @@ -54,7 +54,7 @@ export class NewPicSearch extends plugin { if (!await this.Authentication(e)) return if (!await this.handelImg(e, 'Ascii2D')) return await PicSearch.Ascii2D(e.img[0]) - .then(res => common.recallSendForwardMsg(e, [...res.color, ...res.bovw], { isxmlMsg: false })) + .then(res => common.recallSendForwardMsg(e, [...res.color, ...res.bovw], { xmlTitle: false })) .catch(err => e.reply(err.message)) } diff --git a/lib/common/common.js b/lib/common/common.js index 08fefa8..8f32ce9 100644 --- a/lib/common/common.js +++ b/lib/common/common.js @@ -80,30 +80,25 @@ export default new class newCommon { /** * 发送转发消息 * @async - * @param {*} e - 发送消息的目标对象 - * @param {Array} message - 发送的消息数组 - * @param {Object} options - 发送消息的配置项 - * @param {Number} options.recallMsg - 撤回时间,单位秒,默认为0表示不撤回 - * @param {Object} options.info - 转发发送人信息 - * @param {String} options.info.nickname - 转发发送人昵称,默认为机器人的昵称 - * @param {Number} options.info.user_id - 转发发送人QQ,默认为机器人的QQ号 - * @param {String} options.fkmsg - 风控消息,不传则默认消息 - * @param {Boolean} options.isxml - 是否处理卡片,若为true则处理卡片 - * @param {Boolean} options.isxmlMsg - 是否处理卡片显示消息 - * @param {Boolean} options.oneMsg - 是否只有一条消息 - * @param {Boolean | import('icqq').Anonymous} options.anony - 匿名消息,若为true则发送匿名消息 - * @returns {Promise} - 消息发送结果的Promise对象 + * @param {object} e - 发送消息的目标对象 + * @param {Array} message - 发送的消息数组,数组每一项为转发消息的一条消息 + * @param {Object} [options] - 发送消息的配置项 + * @param {Number} [options.recallMsg=0] - 撤回时间,单位秒,默认为0表示不撤回 + * @param {{nickname:string,user_id:number}} [options.info] - 转发发送人信息 + * @param {string|array} [options.fkmsg] - 风控消息,不传则默认消息 + * @param {Boolean} [options.isxml] - 是否处理卡片,若为true则处理卡片 + * @param {Boolean} [options.isxmlMsg] - 处理卡片显示的消息 + * @param {Boolean} [options.oneMsg] - 用于只有一条消息,不用再转成二维数组 + * @param {Boolean | import('icqq').Anonymous} [options.anony] - 匿名消息,若为true则发送匿名消息 + * @returns {Promise} 消息发送结果的Promise对象 */ async getforwardMsg (e, message, { recallMsg = 0, - info = { - nickname: (e.bot ?? Bot).nickname, - user_id: (e.bot ?? Bot).uin - }, - fkmsg = '', - isxml = false, - isxmlMsg = '涩批(//// ^ ////)', - oneMsg = false, + info, + fkmsg, + isxml, + xmlTitle, + oneMsg, anony } = {}) { let forwardMsg = [] @@ -125,11 +120,11 @@ export default new class newCommon { if (isxml) { // 处理转发卡片 forwardMsg.data = forwardMsg.data.replace('', '') - if (isxmlMsg) { - forwardMsg.data = forwardMsg.data.replace(/\n/g, '') - .replace(/(.+?)<\/title>/g, '___') - .replace(/___+/, `<title color="#777777" size="26">${isxmlMsg}`) - } + } + if (xmlTitle) { + forwardMsg.data = forwardMsg.data.replace(/\n/g, '') + .replace(/(.+?)<\/title>/g, '___') + .replace(/___+/, `<title color="#777777" size="26">${xmlTitle}`) } let msgRes = await this.reply(e, forwardMsg, false, { anony, @@ -230,10 +225,10 @@ export default new class newCommon { /** * @description: 获取配置的撤回时间发送转发消息 * @param {*} e oicq - * @param {Array} msg 发送的消息 - * @param {String} fkmsg 风控消息 - * @param {Object} data 其他参数 - * @return {Object} 消息是否发送成功的对象 + * @param {array} msg 发送的消息 + * @param {string} fkmsg 风控消息 + * @param {object} data 其他参数 + * @return {object} 消息是否发送成功的对象 */ async recallSendForwardMsg (e, msg, data = {}) { let recalltime = setu.getRecallTime(e.group_id) @@ -245,6 +240,7 @@ export default new class newCommon { user_id: 2854196306 }, isxml: true, + xmlTitle: '涩批(//// ^ ////)', anony, ...data })