From b11c74eb0dbada7e15605c23d173834f6c22dd3a Mon Sep 17 00:00:00 2001 From: yeyang <746659424@qq.com> Date: Tue, 18 Apr 2023 20:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=BC=98=E5=8C=96=E8=BD=AC?= =?UTF-8?q?=E5=8F=91=E6=B6=88=E6=81=AF=E5=8D=A1=E7=89=87=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/fun.js | 3 +-- apps/groupAdmin/groupAdmin.js | 15 ++++++++++++--- apps/groupAdmin/groupBannedWords.js | 10 +++++----- constants/fun.js | 11 +++++++++++ lib/common/common.js | 25 ++++++++++++++++--------- model/api/funApi.js | 21 +++++++++++---------- 6 files changed, 56 insertions(+), 29 deletions(-) diff --git a/apps/fun.js b/apps/fun.js index 235c565..b9f9f48 100644 --- a/apps/fun.js +++ b/apps/fun.js @@ -3,7 +3,6 @@ import fetch from 'node-fetch' import _ from 'lodash' import { Config } from '../components/index.js' import { common, uploadRecord, QQApi, funApi } from '../model/index.js' -import { xiurenTypeId } from '../model/api/funApi.js' import { successImgs, faildsImgs, heisiType } from '../constants/fun.js' /** API请求错误文案 */ @@ -80,7 +79,7 @@ export class Fun extends plugin { fnc: 'acg' }, { - reg: `^#来点(${Object.keys(xiurenTypeId).join('|')})$`, + reg: `^#来点(${Object.keys(funApi.xiurenTypeId).join('|')})$`, fnc: 'xiuren' } diff --git a/apps/groupAdmin/groupAdmin.js b/apps/groupAdmin/groupAdmin.js index 0d995ae..8177f8b 100644 --- a/apps/groupAdmin/groupAdmin.js +++ b/apps/groupAdmin/groupAdmin.js @@ -379,7 +379,10 @@ export class GroupAdmin extends plugin { // 获取禁言列表 async Mutelist (e) { new Ga(e).getMuteList(e.group_id, true) - .then(res => common.getforwardMsg(e, res, { isxml: true })) + .then(res => common.getforwardMsg(e, res, { + isxml: true, + xmlTitle: '禁言列表' + })) .catch(err => e.reply(err.message)) } @@ -429,7 +432,10 @@ export class GroupAdmin extends plugin { `请发送:#确认清理${regRet[2]}${regRet[3]}没发言的人` ]) } - common.getforwardMsg(e, msg, { isxml: true }) + common.getforwardMsg(e, msg, { + isxml: true, + xmlTitle: e.msg.replace(/#|查看|清理/g, '') + }) } // 查看和清理从未发言的人 @@ -460,7 +466,10 @@ 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, { isxml: true })) + .then(res => common.getforwardMsg(e, res, { + isxml: true, + xmlTitle: e.msg.replace(/#|查看|清理/g, '') + })) .catch(err => e.reply(err.message)) } diff --git a/apps/groupAdmin/groupBannedWords.js b/apps/groupAdmin/groupBannedWords.js index d6241ce..544c99a 100644 --- a/apps/groupAdmin/groupBannedWords.js +++ b/apps/groupAdmin/groupBannedWords.js @@ -68,14 +68,14 @@ export class NewGroupBannedWords extends plugin { const type = groupBannedWords.data[rawBannedWords] const muteTime = GroupBannedWords.getMuteTime(e.group_id) const punishments = { - '1': async () => await e.member.kick(), - '2': async () => await e.member.mute(muteTime), - '3': async () => await e.recall(), - '4': async () => { + 1: async () => await e.member.kick(), + 2: async () => await e.member.mute(muteTime), + 3: async () => await e.recall(), + 4: async () => { await e.member.kick() await e.recall() }, - '5': async () => { + 5: async () => { await e.member.mute(muteTime) await e.recall() } diff --git a/constants/fun.js b/constants/fun.js index 27048eb..d1523fe 100644 --- a/constants/fun.js +++ b/constants/fun.js @@ -22,3 +22,14 @@ export const heisiType = { 网红: { type: 'mcn', page: 36 }, 美足: { type: 'meizu', page: 9 } } + +export const xiurenTypeId = { + 秀人: { + id: 117, + maxPage: 88 + }, + 足控: { + id: 229, + maxPage: 8 + } +} diff --git a/lib/common/common.js b/lib/common/common.js index 023e0f5..3605c9e 100644 --- a/lib/common/common.js +++ b/lib/common/common.js @@ -89,7 +89,7 @@ export default new class newCommon { * @param {number} options.info.user_id - 转发人QQ * @param {string|array} [options.fkmsg] - 风控消息,不传则默认消息 * @param {Boolean} [options.isxml] - 是否处理卡片,若为true则处理卡片 - * @param {Boolean} [options.isxmlMsg] - 处理卡片显示的消息 + * @param {Boolean} [options.xmlTitle] - XML 标题 * @param {Boolean} [options.oneMsg] - 用于只有一条消息,不用再转成二维数组 * @param {Boolean | import('icqq').Anonymous} [options.anony] - 匿名消息,若为true则发送匿名消息 * @returns {Promise} 消息发送结果的Promise对象 @@ -225,13 +225,20 @@ export default new class newCommon { } /** - * @description: 获取配置的撤回时间发送转发消息 - * @param {*} e oicq - * @param {array} msg 发送的消息 - * @param {string} fkmsg 风控消息 - * @param {object} data 其他参数 - * @return {object} 消息是否发送成功的对象 - */ + * 转发消息并根据权限撤回 + * @async + * @param {Object} e - 反馈的对象 + * @param {string|Object} msg - 要发送的消息字符串或对象 + * @param {Object} [data={}] - 附加的数据对象 + * @param {number} [data.recallMsg] - 消息撤回时间 + * @param {Object} [data.info] - 附加消息信息 + * @param {string} [data.info.nickname] - 用户昵称 + * @param {number} [data.info.user_id] - 用户ID + * @param {boolean} [data.isxml=true] - 是否特殊处理转发消息 + * @param {string} [data.xmlTitle] - XML 标题 + * @param {Object} [data.anony] - 附加的匿名数据对象 + * @returns {Promise} - Promise 对象,返回函数 `getforwardMsg()` 的返回值 + */ async recallSendForwardMsg (e, msg, data = {}) { let recalltime = setu.getRecallTime(e.group_id) let anony = Config.Notice.anonymous @@ -242,7 +249,7 @@ export default new class newCommon { user_id: 2854196306 }, isxml: true, - xmlTitle: '涩批(//// ^ ////)', + xmlTitle: e.msg, anony, ...data }) diff --git a/model/api/funApi.js b/model/api/funApi.js index d1cb22b..995af67 100644 --- a/model/api/funApi.js +++ b/model/api/funApi.js @@ -1,17 +1,18 @@ -import fetch from 'node-fetch' -import md5 from 'md5' import _ from 'lodash' -import request from '../../lib/request/request.js' +import md5 from 'md5' +import fetch from 'node-fetch' import { langType } from '../../constants/youdao.js' +import request from '../../lib/request/request.js' import { puppeteer } from '../index.js' +import { xiurenTypeId } from '../../constants/fun.js' + const API_ERROR = '出了点小问题,待会再试试吧' -export const xiurenTypeId = { - 秀人: { - id: 117, - maxPage: 88 - } -} + export default new class { + constructor () { + this.xiurenTypeId = xiurenTypeId + } + /** 有道翻译 */ async youdao (msg, to = 'auto', from = 'auto') { if (to != 'auto') to = langType.find(item => item.label == to)?.code @@ -188,7 +189,7 @@ export default new class { ) }) // 可扩展 - let handleType = xiurenTypeId[type] + let handleType = this.xiurenTypeId[type] let homeUrl = `https://www.lisiku1.com/forum-${handleType.id}-${_.random(1, handleType.maxPage)}.html` let html = await request.get(homeUrl).then(res => res.text()) let $ = cheerio.load(html)