🐧:746659424
-💬:(暂无)
+💬:914247840
❤️:[打赏](https://yenai.trss.me/donate.html)
diff --git a/apps/admin.js b/apps/admin.js
index 172eaea..19bb909 100644
--- a/apps/admin.js
+++ b/apps/admin.js
@@ -13,7 +13,6 @@ const OtherCfgType = {
const SeSeCfgType = {
涩涩: 'sese',
涩涩pro: 'sesepro',
- 匿名: 'anonymous',
代理: {
name: 'proxy',
key: 'switchProxy'
@@ -181,12 +180,11 @@ export class Admin extends plugin {
async SeSe_Settings (e) {
let set = setu.getSeSeConfig(e)
let { proxy, pixiv, bika } = Config
- let { sese, sesepro, anonymous } = Config.getGroup(e.group_id)
- let { sese: _sese, sesepro: _sesepro, anonymous: _anonymous } = Config.getConfig('group')[e.group_id] ?? {}
+ let { sese, sesepro } = Config.getGroup(e.group_id)
+ let { sese: _sese, sesepro: _sesepro } = Config.getConfig('group')[e.group_id] ?? {}
let data = {
sese: getStatus(sese, _sese),
sesepro: getStatus(sesepro, _sesepro),
- anonymous: getStatus(anonymous, _anonymous),
r18: getStatus(set.r18),
cd: Number(set.cd),
recall: set.recall ? set.recall : '无',
diff --git a/apps/groupAdmin/groupAdmin.js b/apps/groupAdmin/groupAdmin.js
index 53f397d..31f275b 100644
--- a/apps/groupAdmin/groupAdmin.js
+++ b/apps/groupAdmin/groupAdmin.js
@@ -44,10 +44,6 @@ export class GroupAdmin extends plugin {
reg: '^#(设置|取消)管理(\\d+)?$',
fnc: 'SetAdmin'
},
- {
- reg: '^#(允许|禁止|开启|关闭)匿名$',
- fnc: 'AllowAnony'
- },
{
reg: '^#发群公告',
fnc: 'AddAnnounce'
@@ -248,15 +244,6 @@ export class GroupAdmin extends plugin {
type ? e.reply(`已经把「${name}」设置为管理啦!!`) : e.reply(`「${name}」的管理已经被我吃掉啦~`)
}
- // 匿名
- async AllowAnony (e) {
- if (!common.checkPermission(e, 'admin', 'admin')) { return true }
- let type = /(允许|开启)匿名/.test(e.msg)
- let res = await e.group.allowAnony(type)
- if (!res) return e.reply('❎ 未知错误', true)
- type ? e.reply('已把匿名开启了哦,可以藏起来了~') : e.reply('已关闭匿名,小贼们不准藏了~')
- }
-
// 发群公告
async AddAnnounce (e) {
if (!common.checkPermission(e, 'admin', 'admin')) { return true }
diff --git a/apps/groupAdmin/groupBannedWords.js b/apps/groupAdmin/groupBannedWords.js
index b85fe7b..ad419d8 100644
--- a/apps/groupAdmin/groupBannedWords.js
+++ b/apps/groupAdmin/groupBannedWords.js
@@ -109,11 +109,7 @@ export class NewGroupBannedWords extends plugin {
*/
#mute (time) {
const e = this.e
- if (e.anonymous) {
- e.group.muteAnony(e.anonymous.flag, time)
- } else {
- e.member.mute(time)
- }
+ e.member.mute(time)
}
/**
diff --git a/apps/pixiv.js b/apps/pixiv.js
index 7ea4cca..17823d6 100644
--- a/apps/pixiv.js
+++ b/apps/pixiv.js
@@ -195,7 +195,7 @@ export class NewPixiv extends plugin {
if (ispro && !await this._Authentication(e, 'sesepro', false)) return
await Pixiv.pximg(ispro)
- .then(res => ispro ? common.recallSendForwardMsg(e, [res]) : common.recallsendMsg(e, res, false, { anony: true }))
+ .then(res => ispro ? common.recallSendForwardMsg(e, [res]) : common.recallsendMsg(e, res, false))
.catch(err => common.handleException(e, err))
}
diff --git a/apps/update.js b/apps/update.js
index 3f6edc0..57b12e4 100644
--- a/apps/update.js
+++ b/apps/update.js
@@ -1,19 +1,5 @@
-import plugin from '../../../lib/plugins/plugin.js'
-import { createRequire } from 'module'
-import _ from 'lodash'
-import { Restart } from '../../other/restart.js'
-import common from '../lib/common/common.js'
-
-const require = createRequire(import.meta.url)
-const { exec, execSync } = require('child_process')
-
-// 是否在更新中
-let uping = false
-
-/**
- * 处理插件更新
- */
-export class Update extends plugin {
+import { update as Update } from '../../other/update.js'
+export class YenaiUpdate extends plugin {
constructor () {
super({
name: '椰奶更新插件',
@@ -28,221 +14,10 @@ export class Update extends plugin {
})
}
- /**
- * rule - 更新椰奶插件
- * @param e
- */
- async update (e) {
- if (!common.checkPermission(e, 'master')) return true
-
- /** 检查是否正在更新中 */
- if (uping) {
- await this.reply('已有命令更新中..请勿重复操作')
- return
- }
-
- /** 检查git安装 */
- if (!(await this.checkGit())) return
-
- const isForce = this.e.msg.includes('强制')
-
- /** 执行更新 */
- await this.runUpdate(isForce)
-
- /** 是否需要重启 */
- if (this.isUp) {
- // await this.reply("更新完毕,请重启云崽后生效")
- setTimeout(() => this.restart(), 2000)
- }
- }
-
- restart () {
- new Restart(this.e).restart()
- }
-
- /**
- * 椰奶插件更新函数
- * @param {boolean} isForce 是否为强制更新
- */
- async runUpdate (isForce) {
- const _path = './plugins/yenai-plugin/'
- let command = `git -C ${_path} pull --no-rebase`
- if (isForce) {
- command = `git -C ${_path} reset --hard origin && ${command}`
- this.e.reply('正在执行强制更新操作,请稍等')
- } else {
- this.e.reply('正在执行更新操作,请稍等')
- }
- /** 获取上次提交的commitId,用于获取日志时判断新增的更新日志 */
- this.oldCommitId = await this.getcommitId('yenai-plugin')
- uping = true
- let ret = await this.execSync(command)
- uping = false
-
- if (ret.error) {
- logger.mark(`${this.e.logFnc} 更新失败:椰奶插件`)
- this.gitErr(ret.error, ret.stdout)
- return false
- }
-
- /** 获取插件提交的最新时间 */
- let time = await this.getTime('yenai-plugin')
-
- if (/(Already up[ -]to[ -]date|已经是最新的)/.test(ret.stdout)) {
- await this.reply(`椰奶插件已经是最新版本\n最后更新时间:${time}`)
- } else {
- await this.reply(`椰奶插件\n最后更新时间:${time}`)
- this.isUp = true
- /** 获取椰奶组件的更新日志 */
- let log = await this.getLog('yenai-plugin')
- await this.reply(log)
- }
-
- logger.mark(`${this.e.logFnc} 最后更新时间:${time}`)
-
- return true
- }
-
- /**
- * 获取椰奶插件的更新日志
- * @param {string} plugin 插件名称
- */
- async getLog (plugin = '') {
- let cm = `cd ./plugins/${plugin}/ && git log -20 --oneline --pretty=format:"%h||[%cd] %s" --date=format:"%m-%d %H:%M"`
-
- let logAll
- try {
- logAll = await execSync(cm, { encoding: 'utf-8' })
- } catch (error) {
- logger.error(error.toString())
- this.reply(error.toString())
- }
-
- if (!logAll) return false
-
- logAll = logAll.split('\n')
-
- let log = []
- for (let str of logAll) {
- str = str.split('||')
- if (str[0] == this.oldCommitId) break
- if (str[1].includes('Merge branch')) continue
- log.push(str[1])
- }
- let line = log.length
- log = log.join('\n\n')
-
- if (log.length <= 0) return ''
-
- let end = ''
- end =
- '更多详细信息,请前往gitee查看\nhttps://gitee.com/yeyang52/yenai-plugin/blob/master/CHANGELOG.md'
- let forwardMsg = [
- `椰奶插件更新日志,共${line}条`, log, end
- ]
- log = await common.getforwardMsg(this.e, forwardMsg, {
- shouldSendMsg: false
- })
-
- return log
- }
-
- /**
- * 获取上次提交的commitId
- * @param {string} plugin 插件名称
- */
- async getcommitId (plugin = '') {
- let cm = `git -C ./plugins/${plugin}/ rev-parse --short HEAD`
-
- let commitId = await execSync(cm, { encoding: 'utf-8' })
- commitId = _.trim(commitId)
-
- return commitId
- }
-
- /**
- * 获取本次更新插件的最后一次提交时间
- * @param {string} plugin 插件名称
- */
- async getTime (plugin = '') {
- let cm = `cd ./plugins/${plugin}/ && git log -1 --oneline --pretty=format:"%cd" --date=format:"%m-%d %H:%M"`
-
- let time = ''
- try {
- time = await execSync(cm, { encoding: 'utf-8' })
- time = _.trim(time)
- } catch (error) {
- logger.error(error.toString())
- time = '获取时间失败'
- }
- return time
- }
-
- /**
- * 处理更新失败的相关函数
- * @param {string} err
- * @param {string} stdout
- */
- async gitErr (err, stdout) {
- let msg = '更新失败!'
- let errMsg = err.toString()
- stdout = stdout.toString()
-
- if (errMsg.includes('Timed out')) {
- let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
- await this.reply(msg + `\n连接超时:${remote}`)
- return
- }
-
- if (/Failed to connect|unable to access/g.test(errMsg)) {
- let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
- await this.reply(msg + `\n连接失败:${remote}`)
- return
- }
-
- if (errMsg.includes('be overwritten by merge')) {
- await this.reply(
- msg +
- `存在冲突:\n${errMsg}\n` +
- '请解决冲突后再更新,或者执行#强制更新,放弃本地修改'
- )
- return
- }
-
- if (stdout.includes('CONFLICT')) {
- await this.reply([
- msg + '存在冲突\n',
- errMsg,
- stdout,
- '\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改'
- ])
- return
- }
-
- await this.reply([errMsg, stdout])
- }
-
- /**
- * 异步执行git相关命令
- * @param {string} cmd git命令
- */
- async execSync (cmd) {
- return new Promise((resolve, reject) => {
- exec(cmd, { windowsHide: true }, (error, stdout, stderr) => {
- resolve({ error, stdout, stderr })
- })
- })
- }
-
- /**
- * 检查git是否安装
- */
- async checkGit () {
- let ret = await execSync('git --version', { encoding: 'utf-8' })
- if (!ret || !ret.includes('git version')) {
- await this.reply('请先安装git')
- return false
- }
- return true
+ async update (e = this.e) {
+ e.msg = `#${e.msg.includes('强制') ? '强制' : ''}更新yenai-plugin`
+ const up = new Update(e)
+ up.e = e
+ return up.update()
}
}
diff --git a/config/default_config/state.yaml b/config/default_config/state.yaml
index a567290..cbfc579 100644
--- a/config/default_config/state.yaml
+++ b/config/default_config/state.yaml
@@ -17,5 +17,5 @@ statusTask: true
#如果出现内存异常的情况可将此配置项开启,如果打开后报错请将监控任务关闭
statusPowerShellStart: false
-#背景图片api 默认https://api.suyanw.cn/api/comic2
-backdrop: "https://api.suyanw.cn/api/comic2"
+#背景图片api 默认 https://api.sretna.cn/layout/pe.php
+backdrop: "https://api.sretna.cn/layout/pe.php"
diff --git a/config/default_config/whole.yaml b/config/default_config/whole.yaml
index 908061a..136f11c 100644
--- a/config/default_config/whole.yaml
+++ b/config/default_config/whole.yaml
@@ -24,4 +24,3 @@ state: false #状态
deltime: 600 #删除缓存
sesepro: false #涩涩增强
renderScale: 100 #渲染精度
-anonymous: false #匿名
diff --git a/index.js b/index.js
index 385569c..943d44b 100644
--- a/index.js
+++ b/index.js
@@ -15,6 +15,12 @@ if (!global.segment) {
}
}
+global.ReplyError = class ReplyError extends Error {
+ constructor (message) {
+ super(message)
+ this.name = 'ReplyError'
+ }
+}
// 加载监听事件
const eventsPath = './plugins/yenai-plugin/apps/events'
const events = fs.readdirSync(eventsPath)
diff --git a/lib/common/error.js b/lib/common/error.js
new file mode 100644
index 0000000..f036a68
--- /dev/null
+++ b/lib/common/error.js
@@ -0,0 +1,9 @@
+// 直接回复错误类型
+global.ReplyError = class ReplyError extends Error {
+ constructor (message) {
+ super(message)
+ this.name = 'ReplyError'
+ }
+}
+
+throw new ReplyError('a')
diff --git a/lib/common/sendMsgMod.js b/lib/common/sendMsgMod.js
index 628126e..542a86b 100644
--- a/lib/common/sendMsgMod.js
+++ b/lib/common/sendMsgMod.js
@@ -33,7 +33,6 @@ export default class {
* @param {boolean} [options.isxml] - 处理卡片
* @param {boolean} [options.xmlTitle] - XML 标题
* @param {boolean} [options.oneMsg] - 用于只有一条消息,不用再转成二维数组
- * @param {boolean | import("icqq").Anonymous} [options.anony] - 匿名消息,若为true则发送匿名消息
* @param {boolean} [options.shouldSendMsg] - 是否直接发送消息,true为直接发送,否则返回需要发送的消息
* @returns {Promise${BotName} 已运行 ${runTime}
${onlineStatus}(${platform}) | ${botVersion}
收${recv || 0} | 发${sent || 0} | 图片${screenshot || 0} | 好友${friendQuantity} | 群${groupQuantity} | 群员${groupMemberQuantity}
-${BotName} 已运行 ${runTime} | 系统运行 ${systime}
-${calendar} | Node.js ${process.version} | ${process.platform} ${process.arch}
+Node.js ${process.version} | ${process.platform} ${process.arch} | 系统运行 ${systime}