🐛 修复私聊群管
This commit is contained in:
@@ -32,6 +32,8 @@ module.exports = {
|
||||
"no-eval": [ "error", { allowIndirect: true } ],
|
||||
"array-bracket-newline": [ "error", { multiline: true } ],
|
||||
"array-bracket-spacing": [ "error", "always" ],
|
||||
"space-before-function-paren": [ "error", "never" ],
|
||||
"no-invalid-this": "error",
|
||||
// 插件规则
|
||||
"jsdoc/require-returns": 0,
|
||||
"jsdoc/require-jsdoc": 0,
|
||||
|
||||
@@ -55,15 +55,13 @@ const NumberCfgType = {
|
||||
}
|
||||
|
||||
/** 支持单独设置的项 */
|
||||
const aloneKeys = [
|
||||
"群消息", "群临时消息", "群撤回", "群邀请", "群管理变动", "群聊列表变动", "群成员变动", "加群通知", "禁言", "闪照", "匿名", "涩涩", "涩涩pro"
|
||||
]
|
||||
const aloneKeys = [ "群消息", "群临时消息", "群撤回", "群邀请", "群管理变动", "群聊列表变动", "群成员变动", "加群通知", "禁言", "闪照", "匿名", "涩涩", "涩涩pro" ]
|
||||
|
||||
const SwitchCfgReg = new RegExp(`^#椰奶设置(${Object.keys(SwitchCfgType).join("|")})(单独)?(开启|关闭|取消)$`)
|
||||
const NumberCfgReg = new RegExp(`^#椰奶设置(${Object.keys(NumberCfgType).join("|")})(\\d+)秒?$`)
|
||||
|
||||
export class Admin extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶配置",
|
||||
event: "message",
|
||||
@@ -90,7 +88,7 @@ export class Admin extends plugin {
|
||||
}
|
||||
|
||||
// 更改配置
|
||||
async ConfigSwitch (e) {
|
||||
async ConfigSwitch(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
// 解析消息
|
||||
let regRet = SwitchCfgReg.exec(e.msg)
|
||||
@@ -124,7 +122,7 @@ export class Admin extends plugin {
|
||||
}
|
||||
|
||||
// 修改数字设置
|
||||
async ConfigNumber (e) {
|
||||
async ConfigNumber(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let regRet = e.msg.match(NumberCfgReg)
|
||||
let type = NumberCfgType[regRet[1]]
|
||||
@@ -134,7 +132,7 @@ export class Admin extends plugin {
|
||||
}
|
||||
|
||||
// 修改全部通知设置
|
||||
async SetAllNotice (e) {
|
||||
async SetAllNotice(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let yes = /启用/.test(e.msg)
|
||||
for (let i in NoticeCfgType) {
|
||||
@@ -143,7 +141,7 @@ export class Admin extends plugin {
|
||||
this.index_Settings(e)
|
||||
}
|
||||
|
||||
async Settings (e) {
|
||||
async Settings(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
if (/sese|涩涩/.test(e.msg)) {
|
||||
this.SeSe_Settings(e)
|
||||
@@ -153,9 +151,9 @@ export class Admin extends plugin {
|
||||
}
|
||||
|
||||
// 渲染发送图片
|
||||
async index_Settings (e) {
|
||||
async index_Settings(e) {
|
||||
let data = {}
|
||||
const special = ["deltime", "renderScale"]
|
||||
const special = [ "deltime", "renderScale" ]
|
||||
let _cfg = Config.getGroup(e.group_id)
|
||||
for (let key in _cfg) {
|
||||
if (special.includes(key)) {
|
||||
@@ -177,7 +175,7 @@ export class Admin extends plugin {
|
||||
}
|
||||
|
||||
// 查看涩涩设置
|
||||
async SeSe_Settings (e) {
|
||||
async SeSe_Settings(e) {
|
||||
let set = setu.getSeSeConfig(e)
|
||||
let { proxy, pixiv, bika } = Config
|
||||
let { sese, sesepro } = Config.getGroup(e.group_id)
|
||||
@@ -207,7 +205,7 @@ export class Admin extends plugin {
|
||||
}
|
||||
|
||||
// 随机底图
|
||||
const rodom = async function () {
|
||||
const rodom = async function() {
|
||||
let image = fs.readdirSync("./plugins/yenai-plugin/resources/admin/imgs/bg")
|
||||
let listImg = []
|
||||
for (let val of image) {
|
||||
@@ -217,7 +215,7 @@ const rodom = async function () {
|
||||
return imgs
|
||||
}
|
||||
|
||||
const getStatus = function (rote, alone) {
|
||||
const getStatus = function(rote, alone) {
|
||||
let badge = alone != undefined ? "<span class=\"badge\";>群单独</span>" : ""
|
||||
if (rote) {
|
||||
return badge + "<div class=\"cfg-status\" >已开启</div>"
|
||||
@@ -235,13 +233,13 @@ const getStatus = function (rote, alone) {
|
||||
* - "<X" 或 ">X" 形式的比较限制条件,其中 X 是表示限制值的数字。
|
||||
* @returns {number} 经过验证的数值。如果给定的值超出了限制条件,则返回限制条件对应的最大值或最小值,否则返回原值。
|
||||
*/
|
||||
function checkNumberValue (value, limit) {
|
||||
function checkNumberValue(value, limit) {
|
||||
// 检查是否存在限制条件
|
||||
if (!limit) {
|
||||
return value
|
||||
}
|
||||
// 解析限制条件
|
||||
const [symbol, limitValue] = limit.match(/^([<>])?(.+)$/).slice(1)
|
||||
const [ symbol, limitValue ] = limit.match(/^([<>])?(.+)$/).slice(1)
|
||||
const parsedLimitValue = parseFloat(limitValue)
|
||||
|
||||
// 检查比较限制条件
|
||||
@@ -251,7 +249,7 @@ function checkNumberValue (value, limit) {
|
||||
|
||||
// 检查范围限制条件
|
||||
if (!isNaN(value)) {
|
||||
const [lowerLimit, upperLimit] = limit.split("-").map(parseFloat)
|
||||
const [ lowerLimit, upperLimit ] = limit.split("-").map(parseFloat)
|
||||
const clampedValue = Math.min(Math.max(value, lowerLimit || -Infinity), upperLimit || Infinity)
|
||||
return clampedValue
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ let GroupListMsgReg = /^#发群列表\s?(\d+(,\d+){0,})\s?([^]*)$/
|
||||
let friendTypeReg = /^#更改好友申请方式([0123])((.*)\s(.*))?$/
|
||||
|
||||
export class Assistant extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶小助手",
|
||||
event: "message",
|
||||
@@ -136,7 +136,7 @@ export class Assistant extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
get Bot () {
|
||||
get Bot() {
|
||||
return this.e.bot ?? Bot
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ export class Assistant extends plugin {
|
||||
* 改头像
|
||||
* @param e
|
||||
*/
|
||||
async SetAvatar (e) {
|
||||
async SetAvatar(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
if (!e.img) {
|
||||
this.setContext("_avatarContext")
|
||||
@@ -160,7 +160,7 @@ export class Assistant extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async _avatarContext () {
|
||||
async _avatarContext() {
|
||||
let img = this.e.img
|
||||
if (/取消/.test(this.e.msg)) {
|
||||
this.finish("_avatarContext")
|
||||
@@ -186,7 +186,7 @@ export class Assistant extends plugin {
|
||||
* 改昵称
|
||||
* @param e
|
||||
*/
|
||||
async SetNickname (e) {
|
||||
async SetNickname(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let name = e.msg.replace(/#|改昵称/g, "").trim()
|
||||
|
||||
@@ -202,7 +202,7 @@ export class Assistant extends plugin {
|
||||
* 改群名片
|
||||
* @param e
|
||||
*/
|
||||
async SetGroupCard (e) {
|
||||
async SetGroupCard(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let group = ""
|
||||
let card = ""
|
||||
@@ -237,7 +237,7 @@ export class Assistant extends plugin {
|
||||
* 改群头像
|
||||
* @param e
|
||||
*/
|
||||
async SetGroupAvatar (e) {
|
||||
async SetGroupAvatar(e) {
|
||||
if (e.isPrivate) {
|
||||
if (!e.isMaster) return logger.mark(`${e.logFnc}不为主人`)
|
||||
e.group_id = e.msg.replace(/#|改群头像/g, "").trim()
|
||||
@@ -269,7 +269,7 @@ export class Assistant extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
_GroupAvatarContext (e) {
|
||||
_GroupAvatarContext(e) {
|
||||
let img = this.e.img
|
||||
if (/取消/.test(this.e.msg)) {
|
||||
this.finish("_GroupAvatarContext")
|
||||
@@ -295,7 +295,7 @@ export class Assistant extends plugin {
|
||||
* 改群昵称
|
||||
* @param e
|
||||
*/
|
||||
async SetGroupName (e) {
|
||||
async SetGroupName(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
let group = ""
|
||||
let card = ""
|
||||
@@ -335,7 +335,7 @@ export class Assistant extends plugin {
|
||||
* 改签名
|
||||
* @param e
|
||||
*/
|
||||
async SetSignature (e) {
|
||||
async SetSignature(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let signs = e.msg.replace(/#|改签名/g, "").trim()
|
||||
await this.Bot.setSignature(signs)
|
||||
@@ -350,7 +350,7 @@ export class Assistant extends plugin {
|
||||
* 改状态
|
||||
* @param e
|
||||
*/
|
||||
async SetOnlineStatus (e) {
|
||||
async SetOnlineStatus(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let signs = e.msg.replace(/#|改状态/g, "").trim()
|
||||
|
||||
@@ -372,7 +372,7 @@ export class Assistant extends plugin {
|
||||
* 发好友
|
||||
* @param e
|
||||
*/
|
||||
async SendFriendMsg (e) {
|
||||
async SendFriendMsg(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let regRet = FriendsReg.exec(e.msg)
|
||||
let qq = regRet[1]
|
||||
@@ -394,7 +394,7 @@ export class Assistant extends plugin {
|
||||
* 发群聊
|
||||
* @param e
|
||||
*/
|
||||
async SendGroupMsg (e) {
|
||||
async SendGroupMsg(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let regRet = GroupMsgReg.exec(e.msg)
|
||||
|
||||
@@ -416,7 +416,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
|
||||
// 发送群列表
|
||||
async SendGroupListMsg (e) {
|
||||
async SendGroupListMsg(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
// 获取参数
|
||||
let regRet = GroupListMsgReg.exec(e.msg)
|
||||
@@ -470,7 +470,7 @@ export class Assistant extends plugin {
|
||||
* 退群
|
||||
* @param e
|
||||
*/
|
||||
async QuitGroup (e) {
|
||||
async QuitGroup(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let quits = e.msg.replace(/#|退群/g, "").trim()
|
||||
|
||||
@@ -497,7 +497,7 @@ export class Assistant extends plugin {
|
||||
* 删好友
|
||||
* @param e
|
||||
*/
|
||||
async DeleteFriend (e) {
|
||||
async DeleteFriend(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let quits = e.msg.replace(/#|删好友/g, "").trim()
|
||||
|
||||
@@ -522,7 +522,7 @@ export class Assistant extends plugin {
|
||||
* 改性别
|
||||
* @param e
|
||||
*/
|
||||
async SetGender (e) {
|
||||
async SetGender(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let sex = e.msg.replace(/#|改性别/g, "").trim()
|
||||
|
||||
@@ -547,7 +547,7 @@ export class Assistant extends plugin {
|
||||
* 取直链
|
||||
* @param e
|
||||
*/
|
||||
async ImageLink (e) {
|
||||
async ImageLink(e) {
|
||||
let img = []
|
||||
if (e.source) {
|
||||
let source
|
||||
@@ -575,16 +575,16 @@ export class Assistant extends plugin {
|
||||
// 大于两张图片以转发消息发送
|
||||
let msg = []
|
||||
for (let i of img) {
|
||||
msg.push([segment.image(i), "直链:", i])
|
||||
msg.push([ segment.image(i), "直链:", i ])
|
||||
}
|
||||
common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
await e.reply([segment.image(img[0]), "直链:", img[0]])
|
||||
await e.reply([ segment.image(img[0]), "直链:", img[0] ])
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
async _ImageLinkContext () {
|
||||
async _ImageLinkContext() {
|
||||
let img = this.e.img
|
||||
if (this.e.msg === "取消") {
|
||||
this.finish("_ImageLinkContext")
|
||||
@@ -604,7 +604,7 @@ export class Assistant extends plugin {
|
||||
* 取Face表情
|
||||
* @param e
|
||||
*/
|
||||
async Face (e) {
|
||||
async Face(e) {
|
||||
let face = []
|
||||
for (let m of e.message) {
|
||||
if (m.type === "face") {
|
||||
@@ -615,7 +615,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
if (face.length === 0) return e.reply("❎ 表情参数不可为空", true)
|
||||
|
||||
let res = face.map(function (item) {
|
||||
let res = face.map(function(item) {
|
||||
return [
|
||||
"表情:",
|
||||
item,
|
||||
@@ -635,7 +635,7 @@ export class Assistant extends plugin {
|
||||
* QQ空间 说说列表
|
||||
* @param e
|
||||
*/
|
||||
async Qzonelist (e) {
|
||||
async Qzonelist(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let page = e.msg.replace(/#|获?取说说列表/g, "").trim()
|
||||
if (!page) {
|
||||
@@ -664,7 +664,7 @@ export class Assistant extends plugin {
|
||||
* 删除说说
|
||||
* @param e
|
||||
*/
|
||||
async Qzonedel (e) {
|
||||
async Qzonedel(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let pos = e.msg.match(/\d+/)
|
||||
// 获取说说列表
|
||||
@@ -690,7 +690,7 @@ export class Assistant extends plugin {
|
||||
* 发说说
|
||||
* @param e
|
||||
*/
|
||||
async Qzonesay (e) {
|
||||
async Qzonesay(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let con = e.msg.replace(/#|发说说/g, "").trim()
|
||||
let result = await new QQApi(e).setQzone(con, e.img)
|
||||
@@ -698,7 +698,7 @@ export class Assistant extends plugin {
|
||||
|
||||
if (result.code != 0) return e.reply(`❎ 说说发表失败\n${JSON.stringify(result)}`)
|
||||
|
||||
let msg = ["✅ 说说发表成功,内容:\n", _.truncate(result.content, { length: 15 })]
|
||||
let msg = [ "✅ 说说发表成功,内容:\n", _.truncate(result.content, { length: 15 }) ]
|
||||
if (result.pic) {
|
||||
msg.push(segment.image(result.pic[0].url1))
|
||||
}
|
||||
@@ -710,7 +710,7 @@ export class Assistant extends plugin {
|
||||
* 清空说说和留言
|
||||
* @param e
|
||||
*/
|
||||
async QzonedelAll (e) {
|
||||
async QzonedelAll(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
if (/清空说说/.test(e.msg)) {
|
||||
this.setContext("_QzonedelAllContext")
|
||||
@@ -723,7 +723,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
}
|
||||
|
||||
async _QzonedelAllContext (e) {
|
||||
async _QzonedelAllContext(e) {
|
||||
let msg = this.e.msg
|
||||
if (/#?确认清空/.test(msg)) {
|
||||
this.finish("_QzonedelAllContext")
|
||||
@@ -748,7 +748,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
|
||||
// 获取群|好友列表
|
||||
async GlOrFl (e) {
|
||||
async GlOrFl(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let msg = []
|
||||
if (/群列表/.test(e.msg)) {
|
||||
@@ -774,7 +774,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
|
||||
// 引用撤回
|
||||
async RecallMsgown (e) {
|
||||
async RecallMsgown(e) {
|
||||
if (!e.source) return false
|
||||
let source
|
||||
if (e.isGroup) {
|
||||
@@ -819,7 +819,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
|
||||
// 开关好友添加
|
||||
async FriendSwitch (e) {
|
||||
async FriendSwitch(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let res = await new QQApi(e).addFriendSwitch(/开启/.test(e.msg) ? 1 : 2)
|
||||
if (!res) return e.reply(API_ERROR)
|
||||
@@ -827,7 +827,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
|
||||
// 好友申请方式
|
||||
async FriendType (e) {
|
||||
async FriendType(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let regRet = friendTypeReg.exec(e.msg)
|
||||
if (regRet[1] == 0) return e.reply("1为允许所有人,2为需要验证,3为问答正确问答(需填问题和答案,格式为:#更改好友申请方式3 问题 答案)")
|
||||
@@ -844,7 +844,7 @@ export class Assistant extends plugin {
|
||||
* 开关戳一戳
|
||||
* @param e
|
||||
*/
|
||||
async Cyc (e) {
|
||||
async Cyc(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let result = await new QQApi(e).setcyc(/开启/.test(e.msg) ? 0 : 1)
|
||||
if (!result) return e.reply(API_ERROR)
|
||||
@@ -853,14 +853,14 @@ export class Assistant extends plugin {
|
||||
e.reply(`✅ 已${/开启/.test(e.msg) ? "开启" : "关闭"}戳一戳功能`)
|
||||
}
|
||||
|
||||
async setModel (e) {
|
||||
async setModel(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let model = e.msg.replace(/#|设置机型/g, "")
|
||||
let res = await new QQApi(e).setModel(model).catch(err => logger.error(err))
|
||||
e.reply(_.get(res, ["13031", "data", "rsp", "iRet"]) == 0 ? "设置成功" : "设置失败")
|
||||
e.reply(_.get(res, [ "13031", "data", "rsp", "iRet" ]) == 0 ? "设置成功" : "设置失败")
|
||||
}
|
||||
|
||||
async BlockOne (e) {
|
||||
async BlockOne(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let type = ""
|
||||
let name = "拉"
|
||||
@@ -912,7 +912,7 @@ export class Assistant extends plugin {
|
||||
}
|
||||
}
|
||||
|
||||
async CancelBlockOne (e) {
|
||||
async CancelBlockOne(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let type = ""
|
||||
let name = "取消拉"
|
||||
|
||||
22
apps/bika.js
22
apps/bika.js
@@ -10,7 +10,7 @@ const Prefix = "(bika|哔咔)"
|
||||
const searchReg = new RegExp(`^#?${Prefix}(类别|作者|高级)?搜索(.*?)(第(${numReg})页)?$`)
|
||||
const comicPageReg = new RegExp(`^#?${Prefix}id(.*?)(第(${numReg})页)?(第(${numReg})话)?$`)
|
||||
export class NewBika extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶哔咔",
|
||||
event: "message",
|
||||
@@ -61,7 +61,7 @@ export class NewBika extends plugin {
|
||||
* 搜索
|
||||
* @param e
|
||||
*/
|
||||
async search (e) {
|
||||
async search(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
let regRet = e.msg.match(searchReg)
|
||||
@@ -75,7 +75,7 @@ export class NewBika extends plugin {
|
||||
* 漫画页面
|
||||
* @param e
|
||||
*/
|
||||
async comicPage (e) {
|
||||
async comicPage(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
let regRet = e.msg.match(comicPageReg)
|
||||
@@ -90,7 +90,7 @@ export class NewBika extends plugin {
|
||||
* 快速查看
|
||||
* @param e
|
||||
*/
|
||||
async viewComicPage (e) {
|
||||
async viewComicPage(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
let number = e.msg.match(/\d+/) - 1
|
||||
await Bika.viewComicPage(number)
|
||||
@@ -102,7 +102,7 @@ export class NewBika extends plugin {
|
||||
* 下一页
|
||||
* @param e
|
||||
*/
|
||||
async nextComicPage (e) {
|
||||
async nextComicPage(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
await Bika.next()
|
||||
.then(res => common.recallSendForwardMsg(e, res))
|
||||
@@ -113,7 +113,7 @@ export class NewBika extends plugin {
|
||||
* 下一话
|
||||
* @param e
|
||||
*/
|
||||
async nextChapter (e) {
|
||||
async nextChapter(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
await Bika.next("chapter")
|
||||
.then(res => common.recallSendForwardMsg(e, res))
|
||||
@@ -124,7 +124,7 @@ export class NewBika extends plugin {
|
||||
* 类别列表
|
||||
* @param e
|
||||
*/
|
||||
async categories (e) {
|
||||
async categories(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
await Bika.categories()
|
||||
@@ -136,7 +136,7 @@ export class NewBika extends plugin {
|
||||
* 漫画细节
|
||||
* @param e
|
||||
*/
|
||||
async comicDetail (e) {
|
||||
async comicDetail(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
let id = e.msg.match(new RegExp(`#?${Prefix}(详情|细节)(.*)`))[3]
|
||||
@@ -149,7 +149,7 @@ export class NewBika extends plugin {
|
||||
* 图片质量
|
||||
* @param e
|
||||
*/
|
||||
async imageQuality (e) {
|
||||
async imageQuality(e) {
|
||||
let quality = e.msg.match(new RegExp(`#?${Prefix}修改图片质量(.*)`))[2]
|
||||
let imageQualityType = {
|
||||
低质量: "low",
|
||||
@@ -167,7 +167,7 @@ export class NewBika extends plugin {
|
||||
* 图片直连
|
||||
* @param e
|
||||
*/
|
||||
async directConnection (e) {
|
||||
async directConnection(e) {
|
||||
if (!this.e.isMaster) { return true }
|
||||
let now = Config.bika.bikaDirectConnection
|
||||
let isSwitch = /开启/.test(e.msg)
|
||||
@@ -177,7 +177,7 @@ export class NewBika extends plugin {
|
||||
new Admin().SeSe_Settings(e)
|
||||
}
|
||||
|
||||
async _Authentication (e) {
|
||||
async _Authentication(e) {
|
||||
if (!this.e.isMaster) { return true }
|
||||
if (!common.checkSeSePermission(e, "sesepro")) return false
|
||||
if (!Config.bika.allowPM && !e.isGroup) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { common } from "../../model/index.js"
|
||||
import { Config } from "../../components/index.js"
|
||||
|
||||
Bot.on?.("internal.input", async (e) => {
|
||||
Bot.on?.("internal.input", async(e) => {
|
||||
if (!Config.whole.input) return false
|
||||
// 判断是否主人消息
|
||||
if (Config.masterQQ.includes(e.user_id)) return false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { common } from "../../model/index.js"
|
||||
import { Config } from "../../components/index.js"
|
||||
|
||||
Bot.on?.("message", async (e) => {
|
||||
Bot.on?.("message", async(e) => {
|
||||
// 判断是否存在消息
|
||||
if (!e?.message?.length) return false
|
||||
// 判断是否为机器人消息
|
||||
@@ -178,7 +178,7 @@ Bot.on?.("message", async (e) => {
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
function getMsgType (msg) {
|
||||
function getMsgType(msg) {
|
||||
const msgType = {
|
||||
record: {
|
||||
msg: segment.record(msg[0].url),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { common } from "../../model/index.js"
|
||||
import { Config } from "../../components/index.js"
|
||||
|
||||
Bot.on?.("notice.friend", async (e) => {
|
||||
Bot.on?.("notice.friend", async(e) => {
|
||||
let msg
|
||||
let forwardMsg
|
||||
switch (e.sub_type) {
|
||||
@@ -43,7 +43,7 @@ Bot.on?.("notice.friend", async (e) => {
|
||||
const msgType = {
|
||||
flash: {
|
||||
msg: () => false,
|
||||
type: ["[闪照]\n", "撤回闪照:", segment.image(res[0].url)]
|
||||
type: [ "[闪照]\n", "撤回闪照:", segment.image(res[0].url) ]
|
||||
},
|
||||
record: {
|
||||
msg: () => segment.record(res[0].url),
|
||||
@@ -95,7 +95,7 @@ Bot.on?.("notice.friend", async (e) => {
|
||||
* 时间转换
|
||||
* @param time
|
||||
*/
|
||||
function formatDate (time) {
|
||||
function formatDate(time) {
|
||||
let now = new Date(parseFloat(time) * 1000)
|
||||
// 月
|
||||
let month = now.getMonth() + 1
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Config } from "../../components/index.js"
|
||||
import moment from "moment"
|
||||
import formatDuration from "../../tools/formatDuration.js"
|
||||
|
||||
Bot.on?.("notice.group", async (e) => {
|
||||
Bot.on?.("notice.group", async(e) => {
|
||||
let msg
|
||||
let forwardMsg
|
||||
switch (e.sub_type) {
|
||||
|
||||
@@ -7,7 +7,7 @@ const ROLE_MAP = {
|
||||
member: "群员"
|
||||
}
|
||||
|
||||
Bot.on?.("request", async (e) => {
|
||||
Bot.on?.("request", async(e) => {
|
||||
let msg = ""
|
||||
switch (e.request_type) {
|
||||
case "group":
|
||||
@@ -34,8 +34,9 @@ Bot.on?.("request", async (e) => {
|
||||
break
|
||||
case "add":
|
||||
if (Config.groupAdd.openGroup.includes(e.group_id)) {
|
||||
let msg = [`${Config.groupAdd.msg}\n`,
|
||||
segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`),
|
||||
let msg = [
|
||||
`${Config.groupAdd.msg}\n`,
|
||||
segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${e.user_id}`),
|
||||
`QQ号:${e.user_id}\n`,
|
||||
`昵称:${e.nickname}\n`,
|
||||
`${e.comment}`
|
||||
|
||||
22
apps/fun.js
22
apps/fun.js
@@ -17,7 +17,7 @@ _.forIn(picApis, (values, key) => {
|
||||
})
|
||||
|
||||
export class Fun extends plugin {
|
||||
constructor (e) {
|
||||
constructor(e) {
|
||||
super({
|
||||
name: "椰奶娱乐",
|
||||
event: "message",
|
||||
@@ -63,7 +63,7 @@ export class Fun extends plugin {
|
||||
* 随机唱鸭
|
||||
* @param e
|
||||
*/
|
||||
async Sing (e) {
|
||||
async Sing(e) {
|
||||
let data = await funApi.randomSinging()
|
||||
if (data.error) return e.reply(data.error)
|
||||
await e.reply(await uploadRecord(data.audioUrl, 0, false))
|
||||
@@ -74,7 +74,7 @@ export class Fun extends plugin {
|
||||
* 支付宝语音
|
||||
* @param e
|
||||
*/
|
||||
async ZFB (e) {
|
||||
async ZFB(e) {
|
||||
let amount = parseFloat(e.msg.replace(/#|支付宝到账|元|圆/g, "").trim())
|
||||
|
||||
if (!/^\d+(\.\d{1,2})?$/.test(amount)) return e.reply("你觉得这河里吗!!", true)
|
||||
@@ -89,7 +89,7 @@ export class Fun extends plugin {
|
||||
* 有道翻译
|
||||
* @param e
|
||||
*/
|
||||
async youdao (e) {
|
||||
async youdao(e) {
|
||||
const msg = e.msg.match(/#(([\u4e00-\u9fa5]{2,6})-)?([\u4e00-\u9fa5]{2,6})?翻译(.*)/)
|
||||
// 如果是在群聊中回复,则获取上一条消息作为翻译内容
|
||||
if (e.source) {
|
||||
@@ -106,7 +106,7 @@ export class Fun extends plugin {
|
||||
}
|
||||
|
||||
// github
|
||||
async GH (e) {
|
||||
async GH(e) {
|
||||
const api = "https://opengraph.githubassets.com"
|
||||
|
||||
let reg = /github.com\/[a-zA-Z0-9-]{1,39}\/[a-zA-Z0-9_-]{1,100}(?:\/(?:pull|issues)\/\d+)?/
|
||||
@@ -123,7 +123,7 @@ export class Fun extends plugin {
|
||||
}
|
||||
|
||||
// coser
|
||||
async coser (e) {
|
||||
async coser(e) {
|
||||
if (!common.checkSeSePermission(e)) return false
|
||||
|
||||
e.reply(START_EXECUTION)
|
||||
@@ -133,7 +133,7 @@ export class Fun extends plugin {
|
||||
}
|
||||
|
||||
// cos/acg搜索
|
||||
async acg (e) {
|
||||
async acg(e) {
|
||||
if (!common.checkSeSePermission(e)) return false
|
||||
e.reply(START_EXECUTION)
|
||||
const reg = new RegExp(`^#(${Object.keys(pandadiuType).join("|")})?acg(.*)$`)
|
||||
@@ -144,7 +144,7 @@ export class Fun extends plugin {
|
||||
}
|
||||
|
||||
// 黑丝
|
||||
async heisiwu (e) {
|
||||
async heisiwu(e) {
|
||||
if (!common.checkSeSePermission(e, "sesepro")) return false
|
||||
|
||||
e.reply(START_EXECUTION)
|
||||
@@ -156,7 +156,7 @@ export class Fun extends plugin {
|
||||
}
|
||||
|
||||
// 萌堆
|
||||
async mengdui (e) {
|
||||
async mengdui(e) {
|
||||
if (!common.checkSeSePermission(e, "sesepro")) return false
|
||||
// 开始执行
|
||||
e.reply(START_EXECUTION)
|
||||
@@ -166,7 +166,7 @@ export class Fun extends plugin {
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async xiuren (e) {
|
||||
async xiuren(e) {
|
||||
if (!common.checkSeSePermission(e, "pro")) return false
|
||||
// 开始执行
|
||||
e.reply(START_EXECUTION)
|
||||
@@ -176,7 +176,7 @@ export class Fun extends plugin {
|
||||
}
|
||||
|
||||
// 查看头像
|
||||
async LookAvatar () {
|
||||
async LookAvatar() {
|
||||
const id = this.e.msg.replace(/^#?((查?看头像)|取头像)/, "").trim() || this.e.at ||
|
||||
this.e.message.find(item => item.type == "at")?.qq || this.e.user_id
|
||||
try {
|
||||
|
||||
@@ -16,7 +16,7 @@ const noactivereg = new RegExp(`^#(查看|清理|确认清理|获取)(${Numreg})
|
||||
// 获取定时任务
|
||||
const redisTask = await Ga.getRedisMuteTask() || false
|
||||
export class GroupAdmin extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶群管",
|
||||
event: "message.group",
|
||||
@@ -155,7 +155,7 @@ export class GroupAdmin extends plugin {
|
||||
this.task = redisTask
|
||||
}
|
||||
|
||||
get Bot () {
|
||||
get Bot() {
|
||||
return this.e.bot ?? Bot
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ export class GroupAdmin extends plugin {
|
||||
* 禁言
|
||||
* @param e
|
||||
*/
|
||||
async muteMember (e) {
|
||||
async muteMember(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
let qq = e.message.find(item => item.type == "at")?.qq
|
||||
let reg = `#禁言\\s?((\\d+)\\s${qq ? "" : "?"})?(${Numreg})?(${TimeUnitReg})?`
|
||||
@@ -179,7 +179,7 @@ export class GroupAdmin extends plugin {
|
||||
* 解禁
|
||||
* @param e
|
||||
*/
|
||||
async noMuteMember (e) {
|
||||
async noMuteMember(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
let qq = e.message.find(item => item.type == "at")?.qq
|
||||
let regRet = e.msg.match(/#解禁(\d+)/)
|
||||
@@ -193,7 +193,7 @@ export class GroupAdmin extends plugin {
|
||||
* 全体禁言
|
||||
* @param e
|
||||
*/
|
||||
async muteAll (e) {
|
||||
async muteAll(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
let type = /全(体|员)禁言/.test(e.msg)
|
||||
let res = await e.group.muteAll(type)
|
||||
@@ -202,7 +202,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 踢群员
|
||||
async kickMember (e) {
|
||||
async kickMember(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
let qq = e.message.find(item => item.type == "at")?.qq
|
||||
if (!qq) qq = e.msg.replace(/#|踢/g, "").trim()
|
||||
@@ -212,7 +212,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 设置管理
|
||||
async SetAdmin (e) {
|
||||
async SetAdmin(e) {
|
||||
if (!common.checkPermission(e, "master", "owner")) return
|
||||
let qq = e.message.find(item => item.type == "at")?.qq
|
||||
let type = /设置管理/.test(e.msg)
|
||||
@@ -230,7 +230,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 发群公告
|
||||
async AddAnnounce (e) {
|
||||
async AddAnnounce(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
// 获取发送的内容
|
||||
let msg = e.msg.replace(/#|发群公告/g, "").trim()
|
||||
@@ -245,14 +245,14 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 查群公告
|
||||
async GetAnnounce (e) {
|
||||
async GetAnnounce(e) {
|
||||
let res = await new QQApi(e).getAnnouncelist(e.group_id)
|
||||
if (!res) return e.reply(API_ERROR)
|
||||
return e.reply(res)
|
||||
}
|
||||
|
||||
// 删群公告
|
||||
async DelAnnounce (e) {
|
||||
async DelAnnounce(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
let msg = e.msg.replace(/#|删群公告/, "").trim()
|
||||
if (!msg) return e.reply("❎ 序号不可为空")
|
||||
@@ -268,7 +268,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 修改头衔
|
||||
async adminsetTitle (e) {
|
||||
async adminsetTitle(e) {
|
||||
if (!common.checkPermission(e, "master", "owner")) return
|
||||
let qq = e.message.find(item => item.type == "at")?.qq
|
||||
if (!qq) return e.reply("请艾特要修改的人哦~")
|
||||
@@ -284,7 +284,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 申请头衔
|
||||
async SetGroupSpecialTitle (e) {
|
||||
async SetGroupSpecialTitle(e) {
|
||||
if (!common.checkPermission(e, "all", "owner")) return
|
||||
let Title = e.msg.replace(/#|申请头衔/g, "")
|
||||
// 屏蔽词处理
|
||||
@@ -308,7 +308,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 字符列表
|
||||
async qun_luckylist (e) {
|
||||
async qun_luckylist(e) {
|
||||
let data = await new QQApi(e).luckylist(e.group_id)
|
||||
if (!data) return e.reply(API_ERROR)
|
||||
if (data.retcode != 0) return e.reply("❎ 获取数据失败\n" + JSON.stringify(data))
|
||||
@@ -321,7 +321,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 抽幸运字符
|
||||
async qun_lucky (e) {
|
||||
async qun_lucky(e) {
|
||||
let res = await new QQApi(e).drawLucky(e.group_id)
|
||||
|
||||
if (!res) return e.reply(API_ERROR)
|
||||
@@ -337,7 +337,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 替换幸运字符
|
||||
async qun_luckyuse (e) {
|
||||
async qun_luckyuse(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
let id = e.msg.replace(/#|替换(幸运)?字符/g, "")
|
||||
let res = await new QQApi(e).equipLucky(e.group_id, id)
|
||||
@@ -348,7 +348,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 开启或关闭群字符
|
||||
async qun_luckyset (e) {
|
||||
async qun_luckyset(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
|
||||
let res = await new QQApi(e).swichLucky(e.group_id, /开启/.test(e.msg))
|
||||
@@ -360,7 +360,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 获取禁言列表
|
||||
async Mutelist (e) {
|
||||
async Mutelist(e) {
|
||||
new Ga(e).getMuteList(e.group_id, true)
|
||||
.then(res => common.getforwardMsg(e, res, {
|
||||
isxml: true,
|
||||
@@ -370,7 +370,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 解除全部禁言
|
||||
async relieveAllMute (e) {
|
||||
async relieveAllMute(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
new Ga(e).releaseAllMute()
|
||||
.then(() => e.reply("✅ 已将全部禁言解除"))
|
||||
@@ -378,7 +378,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 查看和清理多久没发言的人
|
||||
async noactive (e) {
|
||||
async noactive(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
|
||||
let regRet = noactivereg.exec(e.msg)
|
||||
@@ -422,7 +422,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 查看和清理从未发言的人
|
||||
async neverspeak (e) {
|
||||
async neverspeak(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) { return true }
|
||||
let list = null
|
||||
try {
|
||||
@@ -457,7 +457,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 查看不活跃排行榜和入群记录
|
||||
async RankingList (e) {
|
||||
async RankingList(e) {
|
||||
let num = e.msg.match(new RegExp(Numreg))
|
||||
num = num ? translateChinaNum(num[0]) : 10
|
||||
let msg = ""
|
||||
@@ -470,7 +470,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 发送通知
|
||||
async Send_notice (e) {
|
||||
async Send_notice(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
|
||||
e.message[0].text = e.message[0].text.replace("#发通知", "").trim()
|
||||
@@ -481,7 +481,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 设置定时群禁言
|
||||
async timeMute (e) {
|
||||
async timeMute(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
let type = /禁言/.test(e.msg)
|
||||
if (/任务/.test(e.msg)) {
|
||||
@@ -514,7 +514,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 谁是龙王
|
||||
async dragonKing (e) {
|
||||
async dragonKing(e) {
|
||||
// 浏览器截图
|
||||
let screenshot = await puppeteer.Webpage({
|
||||
url: `https://qun.qq.com/interactive/honorlist?gc=${e.group_id}&type=1&_wv=3&_wwv=129`,
|
||||
@@ -536,7 +536,7 @@ export class GroupAdmin extends plugin {
|
||||
* 群星级
|
||||
* @param e
|
||||
*/
|
||||
async Group_xj (e) {
|
||||
async Group_xj(e) {
|
||||
let screenshot = await puppeteer.Webpage({
|
||||
url: `https://qqweb.qq.com/m/business/qunlevel/index.html?gc=${e.group_id}&from=0&_wv=1027`,
|
||||
cookie: common.getck("qun.qq.com", this.Bot, true),
|
||||
@@ -559,7 +559,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 群发言榜单
|
||||
async SpeakRank (e) {
|
||||
async SpeakRank(e) {
|
||||
if (!common.checkPermission(e, "all", "admin")) return
|
||||
|
||||
// 图片截图
|
||||
@@ -580,7 +580,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 今日打卡
|
||||
async DaySigned (e) {
|
||||
async DaySigned(e) {
|
||||
// 浏览器截图
|
||||
let screenshot = await puppeteer.Webpage({
|
||||
url: `https://qun.qq.com/v2/signin/list?gc=${e.group_id}`,
|
||||
@@ -602,7 +602,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 查看某天谁生日
|
||||
async groupBirthday (e) {
|
||||
async groupBirthday(e) {
|
||||
let date = e.msg.match(/^#?(今天|昨天|明天|后天|\d{4}-\d{1,2}-\d{1,2})谁生日$/)[1]
|
||||
if (date == "昨天") {
|
||||
date = moment().subtract(1, "days").format("YYYY-MM-DD")
|
||||
@@ -626,7 +626,7 @@ export class GroupAdmin extends plugin {
|
||||
}
|
||||
|
||||
// 群数据
|
||||
async groupData (e) {
|
||||
async groupData(e) {
|
||||
if (!common.checkPermission(e, "all", "admin")) return
|
||||
|
||||
// 浏览器截图
|
||||
@@ -674,7 +674,7 @@ export class GroupAdmin extends plugin {
|
||||
* 开启或关闭加群通知
|
||||
* @param e
|
||||
*/
|
||||
async handleGroupAdd (e) {
|
||||
async handleGroupAdd(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
let type = /开启/.test(e.msg) ? "add" : "del"
|
||||
let isopen = Config.groupAdd.openGroup.includes(e.group_id)
|
||||
@@ -688,7 +688,7 @@ export class GroupAdmin extends plugin {
|
||||
* 加精
|
||||
* @param e
|
||||
*/
|
||||
async essenceMessage (e) {
|
||||
async essenceMessage(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
if (!e.source) return e.reply("请对要加精的消息进行引用")
|
||||
let source = (await e.group.getChatHistory(e.source.seq, 1)).pop()
|
||||
@@ -705,7 +705,7 @@ export class GroupAdmin extends plugin {
|
||||
/**
|
||||
* 加白名单
|
||||
*/
|
||||
async whiteQQ () {
|
||||
async whiteQQ() {
|
||||
if (!common.checkPermission(this.e, "master")) return
|
||||
|
||||
let type = /加/.test(this.e.msg) ? "add" : "del"
|
||||
@@ -724,7 +724,7 @@ export class GroupAdmin extends plugin {
|
||||
this.reply(`✅ 已${type === "add" ? "加入" : "删除"}${qq}到群管白名单`)
|
||||
}
|
||||
|
||||
async noBan () {
|
||||
async noBan() {
|
||||
if (!common.checkPermission(this.e, "master")) return
|
||||
let type = !!/开启/.test(this.e.msg)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Config } from "../../components/index.js"
|
||||
import _ from "lodash"
|
||||
|
||||
export class NewGroupBannedWords extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶群违禁词",
|
||||
event: "message.group",
|
||||
@@ -47,7 +47,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async monitor (e) {
|
||||
async monitor(e) {
|
||||
const isWhite = Config.groupAdmin.whiteQQ.includes(e.user_id)
|
||||
if (!e.message || e.isMaster || e.member?.is_owner || e.member?.is_admin || isWhite) {
|
||||
return false
|
||||
@@ -62,7 +62,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
.trim()
|
||||
const trimmedKeyWord = this.#trimAlias(KeyWord)
|
||||
let data = null
|
||||
for (const [k, v] of groupBannedWords) {
|
||||
for (const [ k, v ] of groupBannedWords) {
|
||||
if (k.test(trimmedKeyWord)) {
|
||||
data = v
|
||||
break
|
||||
@@ -109,7 +109,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
* 禁言
|
||||
* @param time
|
||||
*/
|
||||
#mute (time) {
|
||||
#mute(time) {
|
||||
const e = this.e
|
||||
e.member.mute(time)
|
||||
}
|
||||
@@ -118,11 +118,11 @@ export class NewGroupBannedWords extends plugin {
|
||||
* 过滤别名
|
||||
* @param msg
|
||||
*/
|
||||
#trimAlias (msg) {
|
||||
#trimAlias(msg) {
|
||||
let groupCfg = this.e.runtime.cfg.getGroup(this.group_id)
|
||||
let alias = groupCfg.botAlias
|
||||
if (!Array.isArray(alias)) {
|
||||
alias = [alias]
|
||||
alias = [ alias ]
|
||||
}
|
||||
for (let name of alias) {
|
||||
if (msg.startsWith(name)) {
|
||||
@@ -133,7 +133,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
return msg
|
||||
}
|
||||
|
||||
async add (e) {
|
||||
async add(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return false
|
||||
let word = this.#trimAlias(e.toString())
|
||||
word = word.match(/^#?新增(模糊|精确|正则)?(踢|禁|撤|踢撤|禁撤)?违禁词(.*)$/)
|
||||
@@ -162,20 +162,20 @@ export class NewGroupBannedWords extends plugin {
|
||||
}
|
||||
}
|
||||
|
||||
async del (e) {
|
||||
async del(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return false
|
||||
let word = this.#trimAlias(e.toString())
|
||||
word = word.replace(/#?删除违禁词/, "").trim()
|
||||
if (!word) return e.reply("需要删除的屏蔽词为空")
|
||||
try {
|
||||
let msg = await GroupBannedWords.delBannedWords(e.group_id, word)
|
||||
e.reply(["✅ 成功删除:", msg])
|
||||
e.reply([ "✅ 成功删除:", msg ])
|
||||
} catch (error) {
|
||||
common.handleException(e, error)
|
||||
}
|
||||
}
|
||||
|
||||
async query (e) {
|
||||
async query(e) {
|
||||
let word = this.#trimAlias(e.toString())
|
||||
word = word.replace(/#?查看违禁词/, "").trim()
|
||||
if (!word) return e.reply("需要查询的屏蔽词为空")
|
||||
@@ -195,13 +195,13 @@ export class NewGroupBannedWords extends plugin {
|
||||
}
|
||||
}
|
||||
|
||||
async list (e) {
|
||||
async list(e) {
|
||||
const groupBannedWords = GroupBannedWords.initTextArr(e.group_id)
|
||||
if (_.isEmpty(groupBannedWords)) {
|
||||
return e.reply("❎ 没有违禁词")
|
||||
}
|
||||
const msg = []
|
||||
for (const [, v] of groupBannedWords) {
|
||||
for (const [ , v ] of groupBannedWords) {
|
||||
const { matchType, penaltyType, addedBy, date, rawItem } = v
|
||||
msg.push([
|
||||
"违禁词:",
|
||||
@@ -215,7 +215,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
common.getforwardMsg(e, msg)
|
||||
}
|
||||
|
||||
async muteTime (e) {
|
||||
async muteTime(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return false
|
||||
let time = e.msg.match(/\d+/)[0]
|
||||
GroupBannedWords.setMuteTime(e.group_id, time)
|
||||
@@ -223,7 +223,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
}
|
||||
|
||||
// 增删查头衔屏蔽词
|
||||
async ProhibitedTitle (e) {
|
||||
async ProhibitedTitle(e) {
|
||||
// 获取现有的头衔屏蔽词
|
||||
let shieldingWords = GroupBannedWords.getTitleBannedWords(e.group_id)
|
||||
// 判断是否需要查看头衔屏蔽词
|
||||
@@ -277,7 +277,7 @@ export class NewGroupBannedWords extends plugin {
|
||||
}
|
||||
|
||||
// 修改头衔匹配模式
|
||||
async ProhibitedTitlePattern (e) {
|
||||
async ProhibitedTitlePattern(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return false
|
||||
let res = GroupBannedWords.setTitleFilterModeChange(e.group_id)
|
||||
e.reply(`✅ 已修改匹配模式为${res ? "精确" : "模糊"}匹配`)
|
||||
|
||||
@@ -4,9 +4,9 @@ import _ from "lodash"
|
||||
import { sleep } from "../../tools/index.js"
|
||||
// 全局
|
||||
let temp = {}
|
||||
const ops = ["+", "-"]
|
||||
const ops = [ "+", "-" ]
|
||||
export class NewGroupVerify extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶入群验证",
|
||||
dsc: "重新验证和绕过验证",
|
||||
@@ -39,7 +39,7 @@ export class NewGroupVerify extends plugin {
|
||||
}
|
||||
|
||||
// 重新验证
|
||||
async cmdReverify (e) {
|
||||
async cmdReverify(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
|
||||
if (!this.verifycfg.openGroup.includes(e.group_id)) return e.reply("当前群未开启验证哦~", true)
|
||||
@@ -61,7 +61,7 @@ export class NewGroupVerify extends plugin {
|
||||
}
|
||||
|
||||
// 绕过验证
|
||||
async cmdPass (e) {
|
||||
async cmdPass(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
|
||||
if (!this.verifycfg.openGroup.includes(e.group_id)) return e.reply("当前群未开启验证哦~", true)
|
||||
@@ -84,7 +84,7 @@ export class NewGroupVerify extends plugin {
|
||||
return await e.reply(this.verifycfg.SuccessMsgs[e.group_id] || this.verifycfg.SuccessMsgs[0] || "✅ 验证成功,欢迎入群")
|
||||
}
|
||||
|
||||
async cmdReverifyNeverSpeak (e) {
|
||||
async cmdReverifyNeverSpeak(e) {
|
||||
let list = null
|
||||
try {
|
||||
list = await new Ga(e).getNeverSpeak(e.group_id)
|
||||
@@ -98,7 +98,7 @@ export class NewGroupVerify extends plugin {
|
||||
}
|
||||
|
||||
// 开启验证
|
||||
async handelverify (e) {
|
||||
async handelverify(e) {
|
||||
if (!common.checkPermission(e, "admin", "admin")) return
|
||||
let type = /开启/.test(e.msg) ? "add" : "del"
|
||||
let isopen = this.verifycfg.openGroup.includes(e.group_id)
|
||||
@@ -109,7 +109,7 @@ export class NewGroupVerify extends plugin {
|
||||
}
|
||||
|
||||
// 切换验证模式
|
||||
async setmode (e) {
|
||||
async setmode(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let value = this.verifycfg.mode == "模糊" ? "精确" : "模糊"
|
||||
Config.modify("groupverify", "mode", value)
|
||||
@@ -117,7 +117,7 @@ export class NewGroupVerify extends plugin {
|
||||
}
|
||||
|
||||
// 设置验证超时时间
|
||||
async setovertime (e) {
|
||||
async setovertime(e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
let overtime = e.msg.match(/\d+/g)
|
||||
Config.modify("groupverify", "time", Number(overtime))
|
||||
@@ -129,7 +129,7 @@ export class NewGroupVerify extends plugin {
|
||||
}
|
||||
|
||||
// 进群监听
|
||||
Bot.on?.("notice.group.increase", async (e) => {
|
||||
Bot.on?.("notice.group.increase", async(e) => {
|
||||
logger.mark(`[Yenai-Plugin][进群验证]收到${e.user_id}的进群事件`)
|
||||
let { openGroup, DelayTime } = Config.groupverify
|
||||
|
||||
@@ -144,7 +144,7 @@ Bot.on?.("notice.group.increase", async (e) => {
|
||||
})
|
||||
|
||||
// 答案监听
|
||||
Bot.on?.("message.group", async (e) => {
|
||||
Bot.on?.("message.group", async(e) => {
|
||||
let { openGroup, mode, SuccessMsgs } = Config.groupverify
|
||||
|
||||
if (!openGroup.includes(e.group_id)) return
|
||||
@@ -177,18 +177,18 @@ Bot.on?.("message.group", async (e) => {
|
||||
await e.recall()
|
||||
|
||||
const msg = `\n❎ 验证失败\n你还有「${remainTimes}」次机会\n请发送「${nums[0]} ${operator} ${nums[1]}」的运算结果`
|
||||
return await e.reply([segment.at(e.user_id), msg])
|
||||
return await e.reply([ segment.at(e.user_id), msg ])
|
||||
}
|
||||
clearTimeout(kickTimer)
|
||||
clearTimeout(remindTimer)
|
||||
await e.reply([segment.at(e.user_id), "\n验证失败,请重新申请"])
|
||||
await e.reply([ segment.at(e.user_id), "\n验证失败,请重新申请" ])
|
||||
delete temp[e.user_id + e.group_id]
|
||||
return await e.group.kickMember(e.user_id)
|
||||
}
|
||||
})
|
||||
|
||||
// 主动退群
|
||||
Bot.on?.("notice.group.decrease", async (e) => {
|
||||
Bot.on?.("notice.group.decrease", async(e) => {
|
||||
if (!e.group.is_admin && !e.group.is_owner) return
|
||||
|
||||
if (!temp[e.user_id + e.group_id]) return
|
||||
@@ -209,7 +209,7 @@ Bot.on?.("notice.group.decrease", async (e) => {
|
||||
* @param group_id
|
||||
* @param e
|
||||
*/
|
||||
async function verify (user_id, group_id, e) {
|
||||
async function verify(user_id, group_id, e) {
|
||||
if (!e.group.is_admin && !e.group.is_owner) return
|
||||
user_id = Number(user_id)
|
||||
group_id = Number(group_id)
|
||||
@@ -218,17 +218,17 @@ async function verify (user_id, group_id, e) {
|
||||
const { times, range, time, remindAtLastMinute } = Config.groupverify
|
||||
const operator = ops[_.random(0, 1)]
|
||||
|
||||
let [m, n] = [_.random(range.min, range.max), _.random(range.min, range.max)]
|
||||
let [ m, n ] = [ _.random(range.min, range.max), _.random(range.min, range.max) ]
|
||||
while (m == n) {
|
||||
n = Math.floor(Math.random() * (range.max - range.min + 1)) + range.min
|
||||
}
|
||||
|
||||
[m, n] = [m >= n ? m : n, m >= n ? n : m]
|
||||
[ m, n ] = [ m >= n ? m : n, m >= n ? n : m ]
|
||||
|
||||
const verifyCode = String(operator === "-" ? m - n : m + n)
|
||||
logger.mark(`[Yenai-Plugin][进群验证]答案:${verifyCode}`)
|
||||
const kickTimer = setTimeout(async () => {
|
||||
e.reply([segment.at(user_id), "\n验证超时,移出群聊,请重新申请"])
|
||||
const kickTimer = setTimeout(async() => {
|
||||
e.reply([ segment.at(user_id), "\n验证超时,移出群聊,请重新申请" ])
|
||||
|
||||
delete temp[user_id + group_id]
|
||||
|
||||
@@ -239,11 +239,11 @@ async function verify (user_id, group_id, e) {
|
||||
|
||||
const shouldRemind = remindAtLastMinute && time >= 120
|
||||
|
||||
const remindTimer = setTimeout(async () => {
|
||||
const remindTimer = setTimeout(async() => {
|
||||
if (shouldRemind && temp[user_id + group_id].remindTimer) {
|
||||
const msg = ` \n验证仅剩最后一分钟\n请发送「${m} ${operator} ${n}」的运算结果\n否则将会被移出群聊`
|
||||
|
||||
await e.reply([segment.at(user_id), msg])
|
||||
await e.reply([ segment.at(user_id), msg ])
|
||||
}
|
||||
clearTimeout(remindTimer)
|
||||
}, Math.abs(time * 1000 - 60000))
|
||||
@@ -251,10 +251,10 @@ async function verify (user_id, group_id, e) {
|
||||
const msg = ` 欢迎!\n请在「${time}」秒内发送\n「${m} ${operator} ${n}」的运算结果\n否则将会被移出群聊`
|
||||
|
||||
// 消息发送成功才写入
|
||||
if (await e.reply([segment.at(user_id), msg])) {
|
||||
if (await e.reply([ segment.at(user_id), msg ])) {
|
||||
temp[user_id + group_id] = {
|
||||
remainTimes: times,
|
||||
nums: [m, n],
|
||||
nums: [ m, n ],
|
||||
operator,
|
||||
verifyCode,
|
||||
kickTimer,
|
||||
|
||||
@@ -6,11 +6,11 @@ const Numreg = "[一壹二两三四五六七八九十百千万亿\\d]+"
|
||||
const TimeUnitReg = Object.keys(Time_unit).join("|")
|
||||
const muteMemberReg = new RegExp(`^#禁言\\s?(\\d+)\\s(\\d+)\\s(${Numreg})?(${TimeUnitReg})?$`)
|
||||
export class PrivateGroupAdmin extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶私聊群管",
|
||||
event: "message",
|
||||
priority: 2000,
|
||||
event: "message.private",
|
||||
priority: 500,
|
||||
rule: [
|
||||
{
|
||||
reg: muteMemberReg,
|
||||
@@ -18,7 +18,7 @@ export class PrivateGroupAdmin extends plugin {
|
||||
},
|
||||
{
|
||||
reg: "^#解禁\\s?(\\d+)\\s(\\d+)$",
|
||||
fnc: "nomuteMember"
|
||||
fnc: "noMuteMember"
|
||||
},
|
||||
{
|
||||
reg: "^#全体(禁言|解禁)(\\d+)$",
|
||||
@@ -32,33 +32,40 @@ export class PrivateGroupAdmin extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async muteMember (e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
async muteMember(e) {
|
||||
let regRet = e.msg.match(muteMemberReg)
|
||||
let groupObj = e.bot.pickGroup(Number(regRet[1]))
|
||||
if (!common.checkPermission(e, "master", "admin", { groupObj })) return
|
||||
const time = translateChinaNum(regRet[3])
|
||||
let res = await new Ga(e).muteMember(regRet[1], regRet[2], e.user_id, time, regRet[4])
|
||||
e.reply(res)
|
||||
await new Ga(e).muteMember(regRet[1], regRet[2], e.user_id, time, regRet[4])
|
||||
.then(res => e.reply(res))
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async noMuteMember (e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
async noMuteMember(e) {
|
||||
let regRet = e.msg.match(/^#解禁\s?(\d+)\s(\d+)$/)
|
||||
let res = await new Ga(e).muteMember(regRet[1], regRet[2], e.user_id, 0)
|
||||
e.reply(res)
|
||||
let groupObj = e.bot.pickGroup(Number(regRet[1]))
|
||||
if (!common.checkPermission(e, "master", "admin", { groupObj })) return
|
||||
|
||||
await new Ga(e).muteMember(regRet[1], regRet[2], e.user_id, 0)
|
||||
.then(res => e.reply(res))
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async muteAll (e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
async muteAll(e) {
|
||||
let regRet = e.msg.match(/全体(禁言|解禁)(\d+)/)
|
||||
let group = (e.bot ?? Bot).pickGroup(Number(regRet[2]))
|
||||
group.muteAll(regRet[1] == "禁言")
|
||||
e.reply(`✅ 已将群「${group.name}(${group.group_id})」${regRet[1] == "禁言" ? "开启" : "解除"}全体禁言`)
|
||||
let groupObj = (e.bot ?? Bot).pickGroup(Number(regRet[2]))
|
||||
if (!common.checkPermission(e, "master", "admin", { groupObj })) return
|
||||
|
||||
groupObj.muteAll(regRet[1] == "禁言")
|
||||
e.reply(`✅ 已将群「${groupObj.name}(${groupObj.group_id})」${regRet[1] == "禁言" ? "开启" : "解除"}全体禁言`)
|
||||
}
|
||||
|
||||
async kickMember (e) {
|
||||
if (!common.checkPermission(e, "master")) return
|
||||
async kickMember(e) {
|
||||
let regRet = e.msg.match(/#踢\s?(\d+)\s(\d+)$/)
|
||||
let res = await Ga.kickMember(regRet[1], regRet[2], e.user_id)
|
||||
let groupObj = (e.bot ?? Bot).pickGroup(Number(regRet[1]))
|
||||
if (!common.checkPermission(e, "master", "admin", { groupObj })) return
|
||||
let res = await new Ga(e).kickMember(regRet[1], regRet[2], e.user_id)
|
||||
e.reply(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ let Vote = {}
|
||||
let time = 180 // 投票超时时间 单位秒
|
||||
|
||||
export class NewGroupVerify extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶投票禁言",
|
||||
dsc: "投票禁言某人",
|
||||
@@ -29,7 +29,7 @@ export class NewGroupVerify extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async Initiate (e) {
|
||||
async Initiate(e) {
|
||||
if (!common.checkPermission(e, "all", "admin")) return
|
||||
let targetQQ = e.at || (e.msg.match(/\d+/)?.[0] || "")
|
||||
targetQQ = Number(targetQQ) || String(targetQQ)
|
||||
@@ -67,7 +67,7 @@ export class NewGroupVerify extends plugin {
|
||||
"规则:支持票大于反对票且参与人高于3人即可成功禁言"
|
||||
])
|
||||
if (!res) return false
|
||||
setTimeout(async () => {
|
||||
setTimeout(async() => {
|
||||
// 处理结果
|
||||
if (!Vote[key]) return
|
||||
const { supportCount, opposeCount } = Vote[key]
|
||||
@@ -81,7 +81,7 @@ export class NewGroupVerify extends plugin {
|
||||
delete Vote[key]
|
||||
return e.reply(msg, true)
|
||||
}, time * 1000)
|
||||
setTimeout(async () => {
|
||||
setTimeout(async() => {
|
||||
const { supportCount, opposeCount } = Vote[key]
|
||||
const msg = [
|
||||
segment.at(targetQQ),
|
||||
@@ -97,7 +97,7 @@ export class NewGroupVerify extends plugin {
|
||||
}, time * 1000 - 60000)
|
||||
}
|
||||
|
||||
async Follow (e) {
|
||||
async Follow(e) {
|
||||
if (!common.checkPermission(e, "all", "admin")) return
|
||||
let targetQQ = e.at || (e.msg.match(/\d+/)?.[0] || "")
|
||||
targetQQ = Number(targetQQ) || String(targetQQ)
|
||||
|
||||
@@ -10,7 +10,7 @@ const ROLE_MAP = {
|
||||
member: "群员"
|
||||
}
|
||||
export class NewHandle extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶申请处理",
|
||||
event: "message",
|
||||
@@ -55,7 +55,7 @@ export class NewHandle extends plugin {
|
||||
* 同意拒绝好友申请
|
||||
* @param e
|
||||
*/
|
||||
async PrivateAdd (e) {
|
||||
async PrivateAdd(e) {
|
||||
if (!e.isMaster) return false
|
||||
let yes = !!/同意/.test(e.msg)
|
||||
|
||||
@@ -98,11 +98,9 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
await sleep(2000)
|
||||
}
|
||||
let msg = [
|
||||
`本次共${yes ? "同意" : "拒绝"}${FriendAdd.length}条好友申请\n成功:${success.length}\n失败:${fail.length}`
|
||||
]
|
||||
if (!_.isEmpty(success)) msg.push(["以下为成功的名单:\n", success.join("\n")])
|
||||
if (!_.isEmpty(fail)) msg.push(["以下为失败的名单:\n", fail.join("\n")])
|
||||
let msg = [ `本次共${yes ? "同意" : "拒绝"}${FriendAdd.length}条好友申请\n成功:${success.length}\n失败:${fail.length}` ]
|
||||
if (!_.isEmpty(success)) msg.push([ "以下为成功的名单:\n", success.join("\n") ])
|
||||
if (!_.isEmpty(fail)) msg.push([ "以下为失败的名单:\n", fail.join("\n") ])
|
||||
|
||||
return common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
@@ -126,7 +124,7 @@ export class NewHandle extends plugin {
|
||||
* 引用同意好友申请和群邀请
|
||||
* @param e
|
||||
*/
|
||||
async Handle (e) {
|
||||
async Handle(e) {
|
||||
if (!e.source) return false
|
||||
if (e.source.user_id != (e.bot ?? Bot).uin) return false
|
||||
let yes = !!/同意/.test(e.msg)
|
||||
@@ -206,7 +204,7 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
|
||||
// 回复好友消息
|
||||
async Replys (e) {
|
||||
async Replys(e) {
|
||||
if (!e.isMaster) return false
|
||||
let qq = ""
|
||||
let group = ""
|
||||
@@ -262,7 +260,7 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
|
||||
// 加群员为好友
|
||||
async addFriend (e) {
|
||||
async addFriend(e) {
|
||||
if (!e.isMaster) return false
|
||||
if (!e.source) return false
|
||||
let source = (await e.friend.getChatHistory(e.source.time, 1)).pop()
|
||||
@@ -280,7 +278,7 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
|
||||
// 入群请求
|
||||
async GroupAdd (e) {
|
||||
async GroupAdd(e) {
|
||||
let SystemMsg = (await (e.bot ?? Bot).getSystemMsg())
|
||||
.filter(item => item.request_type == "group" && item.sub_type == "add" && item.group_id == e.group_id)
|
||||
if (_.isEmpty(SystemMsg)) return e.reply("暂无加群申请(。-ω-)zzz", true)
|
||||
@@ -320,12 +318,10 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
await sleep(1000)
|
||||
}
|
||||
let msg = [
|
||||
`本次共处理${SystemMsg.length}条群申请\n成功:${success.length}\n失败:${fail.length}\n风险:${risk.length}`
|
||||
]
|
||||
if (!_.isEmpty(success)) msg.push(["以下为成功的名单:\n", success.join("\n")])
|
||||
if (!_.isEmpty(fail)) msg.push(["以下为失败的名单:\n", fail.join("\n")])
|
||||
if (!_.isEmpty(risk)) msg.push(["以下为风险账号名单:\n", risk.join("\n")])
|
||||
let msg = [ `本次共处理${SystemMsg.length}条群申请\n成功:${success.length}\n失败:${fail.length}\n风险:${risk.length}` ]
|
||||
if (!_.isEmpty(success)) msg.push([ "以下为成功的名单:\n", success.join("\n") ])
|
||||
if (!_.isEmpty(fail)) msg.push([ "以下为失败的名单:\n", fail.join("\n") ])
|
||||
if (!_.isEmpty(risk)) msg.push([ "以下为风险账号名单:\n", risk.join("\n") ])
|
||||
common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
let qq = e.msg.replace(/#(同意|拒绝)(加|入)群申请/g, "").trim()
|
||||
@@ -347,7 +343,7 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
|
||||
// 群邀请列表
|
||||
async GroupInvite (e) {
|
||||
async GroupInvite(e) {
|
||||
if (!e.isMaster) return false
|
||||
let SystemMsg = (await (e.bot ?? Bot).getSystemMsg()).filter(item => item.request_type == "group" && item.sub_type == "invite")
|
||||
if (_.isEmpty(SystemMsg)) return e.reply("暂无群邀请哦(。-ω-)zzz", true)
|
||||
@@ -381,9 +377,9 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
await sleep(1000)
|
||||
}
|
||||
let msg = [`本次共处理${SystemMsg.length}条群邀请\n成功:${success.length}\n失败:${fail.length}`]
|
||||
if (!_.isEmpty(success)) msg.push(["以下为成功的名单:\n", success.join("\n")])
|
||||
if (!_.isEmpty(fail)) msg.push(["以下为失败的名单:\n", fail.join("\n")])
|
||||
let msg = [ `本次共处理${SystemMsg.length}条群邀请\n成功:${success.length}\n失败:${fail.length}` ]
|
||||
if (!_.isEmpty(success)) msg.push([ "以下为成功的名单:\n", success.join("\n") ])
|
||||
if (!_.isEmpty(fail)) msg.push([ "以下为失败的名单:\n", fail.join("\n") ])
|
||||
common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
let groupid = e.msg.replace(/#(同意|拒绝)群邀请/g, "").trim()
|
||||
@@ -403,7 +399,7 @@ export class NewHandle extends plugin {
|
||||
}
|
||||
|
||||
// 全部请求
|
||||
async SystemMsgAll (e) {
|
||||
async SystemMsgAll(e) {
|
||||
if (!e.isMaster) return false
|
||||
let SystemMsg = await (e.bot ?? Bot).getSystemMsg()
|
||||
let FriendAdd = []; let onewayFriend = []; let GroupAdd = []; let GroupInvite = []
|
||||
|
||||
@@ -11,7 +11,7 @@ const helpReg = new RegExp(
|
||||
`^#?椰奶(插件)?(${Object.keys(helpType).join("|")})?(帮助|菜单|功能)$`
|
||||
)
|
||||
export class YenaiHelp extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶帮助",
|
||||
event: "message",
|
||||
@@ -25,7 +25,7 @@ export class YenaiHelp extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async message () {
|
||||
async message() {
|
||||
return await help(this.e)
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ export class YenaiHelp extends plugin {
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
async function help (e) {
|
||||
async function help(e) {
|
||||
let custom = {}
|
||||
// let help = {}
|
||||
const special = e.msg.match(helpReg)[2]
|
||||
@@ -86,7 +86,7 @@ async function help (e) {
|
||||
})
|
||||
}
|
||||
|
||||
const rodom = async function () {
|
||||
const rodom = async function() {
|
||||
let image = fs.readdirSync("./plugins/yenai-plugin/resources/help/imgs/")
|
||||
let list_img = []
|
||||
for (let val of image) {
|
||||
|
||||
12
apps/nga.js
12
apps/nga.js
@@ -10,7 +10,7 @@ try {
|
||||
} catch (err) {}
|
||||
|
||||
export class NGA extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶NGA",
|
||||
dsc: "收益曲线",
|
||||
@@ -29,11 +29,11 @@ export class NGA extends plugin {
|
||||
}
|
||||
|
||||
// 初始化
|
||||
async initFolder (type) {
|
||||
async initFolder(type) {
|
||||
Data.createDir(`data/${type == "收益曲线" ? "incomeCurve" : "referencPanel"}`)
|
||||
}
|
||||
|
||||
async NGA () {
|
||||
async NGA() {
|
||||
let role = {}
|
||||
let regRet = this.e.msg.match("^#?(更新)?(.*)(收益曲线|参考面板)(帮助)?$")
|
||||
if (regRet[4]) {
|
||||
@@ -47,8 +47,8 @@ export class NGA extends plugin {
|
||||
|
||||
let type = regRet[3]
|
||||
/** 主角特殊处理 */
|
||||
if (["10000005", "10000007", "20000000"].includes(String(role.roleId))) {
|
||||
if (!["风主", "岩主", "雷主", "草主"].includes(role.alias)) {
|
||||
if ([ "10000005", "10000007", "20000000" ].includes(String(role.roleId))) {
|
||||
if (![ "风主", "岩主", "雷主", "草主" ].includes(role.alias)) {
|
||||
await this.e.reply(`请选择:风主${type}、岩主${type}、雷主${type}、草主${type}`)
|
||||
return
|
||||
} else {
|
||||
@@ -98,7 +98,7 @@ export class NGA extends plugin {
|
||||
}
|
||||
|
||||
// 下载图片
|
||||
async getImg (name, Path) {
|
||||
async getImg(name, Path) {
|
||||
logger.mark(`${this.e.logFnc} 下载${name}素材图`)
|
||||
|
||||
if (!await common.downFile(name, Path)) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { PicSearch, common } from "../model/index.js"
|
||||
import { Config } from "../components/index.js"
|
||||
import _ from "lodash"
|
||||
export class NewPicSearch extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶图片搜索",
|
||||
event: "message",
|
||||
@@ -33,7 +33,7 @@ export class NewPicSearch extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async SauceNAO (e) {
|
||||
async SauceNAO(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
if (!await this.handelImg(e, "SauceNAO")) return
|
||||
await PicSearch.SauceNAO(e.img[0])
|
||||
@@ -50,15 +50,15 @@ export class NewPicSearch extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async Ascii2D (e) {
|
||||
async Ascii2D(e) {
|
||||
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], { xmlTitle: false }))
|
||||
.then(res => common.recallSendForwardMsg(e, [ ...res.color, ...res.bovw ], { xmlTitle: false }))
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async WhatAnime (e) {
|
||||
async WhatAnime(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
if (!await this.handelImg(e, "WhatAnime")) return
|
||||
await PicSearch.WhatAnime(e.img[0].replace("/c2cpicdw.qpic.cn/offpic_new/", "/gchat.qpic.cn/gchatpic_new/"))
|
||||
@@ -71,7 +71,7 @@ export class NewPicSearch extends plugin {
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async UploadSauceNAOKey (e) {
|
||||
async UploadSauceNAOKey(e) {
|
||||
if (!this.e.isMaster) { return true }
|
||||
if (e.isGroup) return e.reply("请私聊进行添加")
|
||||
let apiKey = e.msg.replace(/#设置SauceNAOapiKey/i, "").trim()
|
||||
@@ -80,7 +80,7 @@ export class NewPicSearch extends plugin {
|
||||
e.reply("OK")
|
||||
}
|
||||
|
||||
async _Authentication (e) {
|
||||
async _Authentication(e) {
|
||||
if (!this.e.isMaster) { return true }
|
||||
const { allowPM, limit, isMasterUse } = Config.picSearch
|
||||
if (isMasterUse) {
|
||||
@@ -98,7 +98,7 @@ export class NewPicSearch extends plugin {
|
||||
return true
|
||||
}
|
||||
|
||||
async handelImg (e, funName) {
|
||||
async handelImg(e, funName) {
|
||||
if (e.source) {
|
||||
let source
|
||||
if (e.isGroup) {
|
||||
@@ -106,7 +106,7 @@ export class NewPicSearch extends plugin {
|
||||
} else {
|
||||
source = (await e.friend.getChatHistory(e.source.time, 1)).pop()
|
||||
}
|
||||
e.img = [source.message.find(item => item.type == "image")?.url]
|
||||
e.img = [ source.message.find(item => item.type == "image")?.url ]
|
||||
}
|
||||
if (!_.isEmpty(e.img)) return true
|
||||
e.sourceFunName = funName
|
||||
@@ -115,7 +115,7 @@ export class NewPicSearch extends plugin {
|
||||
return false
|
||||
}
|
||||
|
||||
async MonitorImg () {
|
||||
async MonitorImg() {
|
||||
if (!this.e.img) {
|
||||
this.e.reply("❎ 未检测到图片操作已取消")
|
||||
} else {
|
||||
|
||||
@@ -18,7 +18,7 @@ const searchUser = new RegExp(`^#?user搜索(.*?)(第(${numReg})页)?$`, "i")
|
||||
const randomImgReg = new RegExp(`^#?来(${numReg})?张(好(康|看)(的|哒)|hkd|涩图)$|^#有内鬼$`)
|
||||
|
||||
export class NewPixiv extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶pixiv",
|
||||
event: "message",
|
||||
@@ -84,7 +84,7 @@ export class NewPixiv extends plugin {
|
||||
}
|
||||
|
||||
// pid搜图
|
||||
async searchPid (e) {
|
||||
async searchPid(e) {
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
let regRet = pidReg.exec(e.msg)
|
||||
@@ -98,7 +98,7 @@ export class NewPixiv extends plugin {
|
||||
}
|
||||
|
||||
// p站排行榜
|
||||
async pixivRank (e) {
|
||||
async pixivRank(e) {
|
||||
let regRet = rankingrReg.exec(e.msg)
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
if ((regRet[4] && !setu.getR18(e.group_id)) && !e.isMaster) {
|
||||
@@ -117,7 +117,7 @@ export class NewPixiv extends plugin {
|
||||
* 关键词搜图
|
||||
* @param e
|
||||
*/
|
||||
async searchTags (e) {
|
||||
async searchTags(e) {
|
||||
let regRet = tagReg.exec(e.msg)
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
if (regRet[1] && !await this._Authentication(e, "sesepro")) return
|
||||
@@ -134,7 +134,7 @@ export class NewPixiv extends plugin {
|
||||
* 获取热门tag
|
||||
* @param e
|
||||
*/
|
||||
async popularTags (e) {
|
||||
async popularTags(e) {
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
await Pixiv.PopularTags()
|
||||
@@ -146,7 +146,7 @@ export class NewPixiv extends plugin {
|
||||
* 以uid搜图
|
||||
* @param e
|
||||
*/
|
||||
async searchUid (e) {
|
||||
async searchUid(e) {
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
|
||||
e.reply(Pixiv.startMsg)
|
||||
@@ -160,7 +160,7 @@ export class NewPixiv extends plugin {
|
||||
}
|
||||
|
||||
// 随机原创插画
|
||||
async vilipixRandomImg (e) {
|
||||
async vilipixRandomImg(e) {
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
let regRet = randomImgReg.exec(e.msg)
|
||||
@@ -177,7 +177,7 @@ export class NewPixiv extends plugin {
|
||||
}
|
||||
|
||||
// 相关作品
|
||||
async relatedIllust (e) {
|
||||
async relatedIllust(e) {
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
|
||||
e.reply(Pixiv.startMsg)
|
||||
@@ -189,13 +189,13 @@ export class NewPixiv extends plugin {
|
||||
}
|
||||
|
||||
// p站单图
|
||||
async pximg (e) {
|
||||
async pximg(e) {
|
||||
let ispro = /pro/.test(e.msg)
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
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))
|
||||
.then(res => ispro ? common.recallSendForwardMsg(e, [ res ]) : common.recallsendMsg(e, res, false))
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ export class NewPixiv extends plugin {
|
||||
* 搜索用户
|
||||
* @param e
|
||||
*/
|
||||
async searchUser (e) {
|
||||
async searchUser(e) {
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
|
||||
e.reply(Pixiv.startMsg)
|
||||
@@ -218,7 +218,7 @@ export class NewPixiv extends plugin {
|
||||
* 推荐作品
|
||||
* @param e
|
||||
*/
|
||||
async illustRecommended (e) {
|
||||
async illustRecommended(e) {
|
||||
if (!await this._Authentication(e, "sese")) return
|
||||
e.reply(Pixiv.startMsg)
|
||||
let num = e.msg.match(/\d+/) || 1
|
||||
@@ -229,7 +229,7 @@ export class NewPixiv extends plugin {
|
||||
}
|
||||
|
||||
// 更换代理
|
||||
async setProxy (e) {
|
||||
async setProxy(e) {
|
||||
if (/查看/.test(e.msg)) return e.reply(await redis.get("yenai:proxy"))
|
||||
let proxy = e.msg.replace(/#|(p站|pixiv)更换代理/g, "").trim()
|
||||
if (new RegExp(`^[1-${ImageRPSS.length}]$`).test(proxy)) {
|
||||
@@ -247,7 +247,7 @@ export class NewPixiv extends plugin {
|
||||
* 图片直连
|
||||
* @param e
|
||||
*/
|
||||
async directConnection (e) {
|
||||
async directConnection(e) {
|
||||
let isSwitch = /开启/.test(e.msg)
|
||||
Config.modify("pixiv", "pixivDirectConnection", isSwitch)
|
||||
new Admin().SeSe_Settings(e)
|
||||
@@ -257,13 +257,13 @@ export class NewPixiv extends plugin {
|
||||
* 登录信息
|
||||
* @param e
|
||||
*/
|
||||
async loginInfo (e) {
|
||||
async loginInfo(e) {
|
||||
await Pixiv.loginInfo()
|
||||
.then(res => e.reply(res))
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async _Authentication (e, type = "sese", limit = true) {
|
||||
async _Authentication(e, type = "sese", limit = true) {
|
||||
if (e.isMaster) return true
|
||||
if (!Config.pixiv.allowPM && !e.isGroup) {
|
||||
e.reply("主人已禁用私聊该功能")
|
||||
|
||||
@@ -6,7 +6,7 @@ import common from "../lib/common/common.js"
|
||||
const searchReg = new RegExp(`^#?(${_.keys(SEARCH_MAP).join("|")})搜索(.*)`)
|
||||
|
||||
export class NewSearch extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶搜索",
|
||||
event: "message",
|
||||
@@ -33,29 +33,29 @@ export class NewSearch extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async help (e) {
|
||||
async help(e) {
|
||||
const searchs = Object.keys(SEARCH_MAP)
|
||||
const menu = "当前支持的搜索引擎:\n"
|
||||
const tip = "\n格式:<搜索引擎> + 搜索 + <关键词>\n比如:萌娘百科搜索可莉"
|
||||
return e.reply(menu + searchs.join("、") + tip)
|
||||
}
|
||||
|
||||
async search (e) {
|
||||
async search(e) {
|
||||
let regRet = searchReg.exec(e.msg)
|
||||
if (/(lp|ip)|(i|p|l)(地址|查询)/ig.test(regRet[2])) return e.reply("(;`O´)o警告!!触发屏蔽词!!!", true)
|
||||
let url = SEARCH_MAP[regRet[1]] + encodeURIComponent(regRet[2])
|
||||
e.reply([await puppeteer.Webpage({ url }), url])
|
||||
e.reply([ await puppeteer.Webpage({ url }), url ])
|
||||
}
|
||||
|
||||
async bggSearch (e) {
|
||||
async bggSearch(e) {
|
||||
let keyword = e.msg.replace(/#?桌游搜索/, "")
|
||||
funApi.bgg(keyword)
|
||||
.then(res => e.reply(res))
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async bggRank (e) {
|
||||
async bggRank(e) {
|
||||
let url = "https://boardgamegeek.com/browse/boardgame"
|
||||
e.reply([await puppeteer.Webpage({ url }), "目前BGG桌游排行榜如图,访问链接:" + url])
|
||||
e.reply([ await puppeteer.Webpage({ url }), "目前BGG桌游排行榜如图,访问链接:" + url ])
|
||||
}
|
||||
}
|
||||
|
||||
14
apps/setu.js
14
apps/setu.js
@@ -7,7 +7,7 @@ import translateChinaNum from "../tools/translateChinaNum.js"
|
||||
const NumReg = "[零一壹二两三四五六七八九十百千万亿\\d]+"
|
||||
|
||||
export class SeSe extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶setu",
|
||||
event: "message",
|
||||
@@ -41,7 +41,7 @@ export class SeSe extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async setuRandom (e) {
|
||||
async setuRandom(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
|
||||
const cdTime = setu.getRemainingCd(e.user_id, e.group_id)
|
||||
@@ -65,7 +65,7 @@ export class SeSe extends plugin {
|
||||
}
|
||||
|
||||
// tag搜图
|
||||
async setuTag (e) {
|
||||
async setuTag(e) {
|
||||
if (!await this._Authentication(e)) return
|
||||
|
||||
let cdTime = setu.getRemainingCd(e.user_id, e.group_id)
|
||||
@@ -97,7 +97,7 @@ export class SeSe extends plugin {
|
||||
.catch(err => common.handleException(e, err))
|
||||
}
|
||||
|
||||
async _Authentication (e) {
|
||||
async _Authentication(e) {
|
||||
if (e.isMaster) return true
|
||||
const { allowPM, limit } = Config.setu
|
||||
if (!allowPM && !e.isGroup) {
|
||||
@@ -113,7 +113,7 @@ export class SeSe extends plugin {
|
||||
}
|
||||
|
||||
// 设置群撤回间隔和cd
|
||||
async setGroupRecallAndCD (e) {
|
||||
async setGroupRecallAndCD(e) {
|
||||
let num = e.msg.match(new RegExp(NumReg))
|
||||
num = translateChinaNum(num[0])
|
||||
let type = /撤回间隔/.test(e.msg)
|
||||
@@ -122,14 +122,14 @@ export class SeSe extends plugin {
|
||||
}
|
||||
|
||||
// 开启r18
|
||||
async setSeSe (e) {
|
||||
async setSeSe(e) {
|
||||
let isopen = !!/开启/.test(e.msg)
|
||||
setu.setR18(e.group_id, isopen)
|
||||
new Admin().SeSe_Settings(e)
|
||||
}
|
||||
|
||||
// 指令设置
|
||||
async setCd (e) {
|
||||
async setCd(e) {
|
||||
let reg = `^#?设置cd\\s?((\\d+)\\s)?(${NumReg})(s|秒)?$`
|
||||
let regRet = e.msg.match(new RegExp(reg))
|
||||
let qq = e.message.find(item => item.type == "at")?.qq ?? regRet[2]
|
||||
|
||||
@@ -6,7 +6,7 @@ import Monitor from "../model/State/Monitor.js"
|
||||
|
||||
let interval = false
|
||||
export class NewState extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶状态",
|
||||
event: "message",
|
||||
@@ -24,7 +24,7 @@ export class NewState extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async monitor (e) {
|
||||
async monitor(e) {
|
||||
await puppeteer.render("state/monitor", {
|
||||
chartData: JSON.stringify(Monitor.chartData)
|
||||
}, {
|
||||
@@ -33,7 +33,7 @@ export class NewState extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async state (e) {
|
||||
async state(e) {
|
||||
if (!/椰奶/.test(e.msg) && !Config.whole.state) return false
|
||||
|
||||
if (!si) return e.reply("❎ 没有检测到systeminformation依赖,请运行:\"pnpm add systeminformation -w\"进行安装")
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Config } from "../components/index.js"
|
||||
import { successImgs, faildsImgs } from "../constants/fun.js"
|
||||
|
||||
export class ThumbUp extends plugin {
|
||||
constructor (e) {
|
||||
constructor(e) {
|
||||
super({
|
||||
name: "椰奶点赞",
|
||||
event: "message",
|
||||
@@ -23,7 +23,7 @@ export class ThumbUp extends plugin {
|
||||
* 点赞
|
||||
* @param e
|
||||
*/
|
||||
async thumbUp (e) {
|
||||
async thumbUp(e) {
|
||||
let _do = "赞"
|
||||
let userId = e.user_id
|
||||
let isSelf = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { update as Update } from "../../other/update.js"
|
||||
export class YenaiUpdate extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶更新插件",
|
||||
event: "message",
|
||||
@@ -14,7 +14,7 @@ export class YenaiUpdate extends plugin {
|
||||
})
|
||||
}
|
||||
|
||||
async update (e = this.e) {
|
||||
async update(e = this.e) {
|
||||
e.msg = `#${e.msg.includes("强制") ? "强制" : ""}更新yenai-plugin`
|
||||
const up = new Update(e)
|
||||
up.e = e
|
||||
|
||||
@@ -3,7 +3,7 @@ import { update } from "../../other/update.js"
|
||||
import { Version, Plugin_Name } from "../components/index.js"
|
||||
import { puppeteer } from "../model/index.js"
|
||||
export class NewVersion extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: "椰奶版本信息",
|
||||
event: "message",
|
||||
@@ -22,11 +22,11 @@ export class NewVersion extends plugin {
|
||||
this.key = "yenai:restart"
|
||||
}
|
||||
|
||||
async plugin_version () {
|
||||
async plugin_version() {
|
||||
return versionInfo(this.e)
|
||||
}
|
||||
|
||||
async update_log () {
|
||||
async update_log() {
|
||||
// eslint-disable-next-line new-cap
|
||||
let Update_Plugin = new update()
|
||||
Update_Plugin.e = this.e
|
||||
@@ -43,7 +43,7 @@ export class NewVersion extends plugin {
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
async function versionInfo (e) {
|
||||
async function versionInfo(e) {
|
||||
return await puppeteer.render(
|
||||
"help/version-info",
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ const Path = process.cwd()
|
||||
const Plugin_Name = "yenai-plugin"
|
||||
const Plugin_Path = `${Path}/plugins/${Plugin_Name}`
|
||||
class Config {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.config = {}
|
||||
|
||||
/** 监听文件 */
|
||||
@@ -21,7 +21,7 @@ class Config {
|
||||
}
|
||||
|
||||
/** 初始化配置 */
|
||||
initCfg () {
|
||||
initCfg() {
|
||||
let path = `${Plugin_Path}/config/config/`
|
||||
let pathDef = `${Plugin_Path}/config/default_config/`
|
||||
const files = fs.readdirSync(pathDef).filter(file => file.endsWith(".yaml"))
|
||||
@@ -37,7 +37,7 @@ class Config {
|
||||
* 群配置
|
||||
* @param groupId
|
||||
*/
|
||||
getGroup (groupId = "") {
|
||||
getGroup(groupId = "") {
|
||||
let config = this.getConfig("whole")
|
||||
let group = this.getConfig("group")
|
||||
let defCfg = this.getdefSet("whole")
|
||||
@@ -49,61 +49,61 @@ class Config {
|
||||
}
|
||||
|
||||
/** 主人QQ */
|
||||
get masterQQ () {
|
||||
get masterQQ() {
|
||||
return cfg.masterQQ
|
||||
}
|
||||
|
||||
/** 获取全局设置 */
|
||||
get whole () {
|
||||
get whole() {
|
||||
return this.getDefOrConfig("whole")
|
||||
}
|
||||
|
||||
/** 进群验证配置 */
|
||||
get groupverify () {
|
||||
get groupverify() {
|
||||
return this.getDefOrConfig("groupverify")
|
||||
}
|
||||
|
||||
/** 头衔屏蔽词 */
|
||||
get groupTitle () {
|
||||
get groupTitle() {
|
||||
return this.getDefOrConfig("groupTitle")
|
||||
}
|
||||
|
||||
/** 加群通知 */
|
||||
get groupAdd () {
|
||||
get groupAdd() {
|
||||
return this.getDefOrConfig("groupAdd")
|
||||
}
|
||||
|
||||
/** 代理 */
|
||||
get proxy () {
|
||||
get proxy() {
|
||||
return this.getDefOrConfig("proxy")
|
||||
}
|
||||
|
||||
/** pixiv */
|
||||
get pixiv () {
|
||||
get pixiv() {
|
||||
return this.getDefOrConfig("pixiv")
|
||||
}
|
||||
|
||||
/** 哔咔 */
|
||||
get bika () {
|
||||
get bika() {
|
||||
return this.getDefOrConfig("bika")
|
||||
}
|
||||
|
||||
/** 搜图 */
|
||||
get picSearch () {
|
||||
get picSearch() {
|
||||
return this.getDefOrConfig("picSearch")
|
||||
}
|
||||
|
||||
/** setu */
|
||||
get setu () {
|
||||
get setu() {
|
||||
return this.getDefOrConfig("setu")
|
||||
}
|
||||
|
||||
/** 状态 */
|
||||
get state () {
|
||||
get state() {
|
||||
return this.getDefOrConfig("state")
|
||||
}
|
||||
|
||||
get groupAdmin () {
|
||||
get groupAdmin() {
|
||||
return this.getDefOrConfig("groupAdmin")
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class Config {
|
||||
* 默认配置和用户配置
|
||||
* @param name
|
||||
*/
|
||||
getDefOrConfig (name) {
|
||||
getDefOrConfig(name) {
|
||||
let def = this.getdefSet(name)
|
||||
let config = this.getConfig(name)
|
||||
return { ...def, ...config }
|
||||
@@ -121,7 +121,7 @@ class Config {
|
||||
* 默认配置
|
||||
* @param name
|
||||
*/
|
||||
getdefSet (name) {
|
||||
getdefSet(name) {
|
||||
return this.getYaml("default_config", name)
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ class Config {
|
||||
* 用户配置
|
||||
* @param name
|
||||
*/
|
||||
getConfig (name) {
|
||||
getConfig(name) {
|
||||
return this.getYaml("config", name)
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ class Config {
|
||||
* @param type 默认跑配置-defSet,用户配置-config
|
||||
* @param name 名称
|
||||
*/
|
||||
getYaml (type, name) {
|
||||
getYaml(type, name) {
|
||||
let file = `${Plugin_Path}/config/${type}/${name}.yaml`
|
||||
let key = `${type}.${name}`
|
||||
|
||||
@@ -159,7 +159,7 @@ class Config {
|
||||
* @param name
|
||||
* @param type
|
||||
*/
|
||||
watch (file, name, type = "default_config") {
|
||||
watch(file, name, type = "default_config") {
|
||||
let key = `${type}.${name}`
|
||||
|
||||
if (this.watcher[key]) return
|
||||
@@ -184,7 +184,7 @@ class Config {
|
||||
* @param {string | number} value 修改的value值
|
||||
* @param {'config'|'default_config'} type 配置文件或默认
|
||||
*/
|
||||
modify (name, key, value, type = "config") {
|
||||
modify(name, key, value, type = "config") {
|
||||
let path = `${Plugin_Path}/config/${type}/${name}.yaml`
|
||||
new YamlReader(path).set(key, value)
|
||||
delete this.config[`${type}.${name}`]
|
||||
@@ -197,7 +197,7 @@ class Config {
|
||||
* @param {unknown} value
|
||||
* @param isDel
|
||||
*/
|
||||
aloneModify (groupId, key, value, isDel) {
|
||||
aloneModify(groupId, key, value, isDel) {
|
||||
let path = `${Plugin_Path}/config/config/group.yaml`
|
||||
let yaml = new YamlReader(path)
|
||||
let groupCfg = yaml.jsonData[groupId] ?? {}
|
||||
@@ -214,7 +214,7 @@ class Config {
|
||||
* @param {'add'|'del'} category 类别 add or del
|
||||
* @param {'config'|'default_config'} type 配置文件或默认
|
||||
*/
|
||||
modifyarr (name, key, value, category = "add", type = "config") {
|
||||
modifyarr(name, key, value, category = "add", type = "config") {
|
||||
let path = `${Plugin_Path}/config/${type}/${name}.yaml`
|
||||
let yaml = new YamlReader(path)
|
||||
if (category == "add") {
|
||||
@@ -225,7 +225,7 @@ class Config {
|
||||
}
|
||||
}
|
||||
|
||||
async change_picApi () {
|
||||
async change_picApi() {
|
||||
let tmp = {}
|
||||
|
||||
logger.debug("[Yenai-Plugin]api接口修改,重载fun.js")
|
||||
@@ -243,7 +243,7 @@ class Config {
|
||||
})
|
||||
}
|
||||
|
||||
async change_pixiv () {
|
||||
async change_pixiv() {
|
||||
let pixiv = (await import("../model/index.js")).Pixiv
|
||||
let PixivApi = (await import("../model/Pixiv/api.js")).default
|
||||
pixiv.PixivClient = new PixivApi(this.pixiv.refresh_token)
|
||||
|
||||
@@ -18,7 +18,7 @@ let Data = {
|
||||
/*
|
||||
* 根据指定的path依次检查与创建目录
|
||||
* */
|
||||
createDir (path = "", root = "", includeFile = false) {
|
||||
createDir(path = "", root = "", includeFile = false) {
|
||||
root = getRoot(root)
|
||||
let pathList = path.split("/")
|
||||
let nowPath = root
|
||||
@@ -40,7 +40,7 @@ let Data = {
|
||||
* @param file
|
||||
* @param root
|
||||
*/
|
||||
readJSON (file = "", root = "") {
|
||||
readJSON(file = "", root = "") {
|
||||
root = getRoot(root)
|
||||
if (fs.existsSync(`${root}/${file}`)) {
|
||||
try {
|
||||
@@ -59,7 +59,7 @@ let Data = {
|
||||
* @param root
|
||||
* @param space
|
||||
*/
|
||||
writeJSON (file, data, root = "", space = "\t") {
|
||||
writeJSON(file, data, root = "", space = "\t") {
|
||||
// 检查并创建目录
|
||||
Data.createDir(file, root, true)
|
||||
root = getRoot(root)
|
||||
@@ -73,7 +73,7 @@ let Data = {
|
||||
}
|
||||
},
|
||||
|
||||
async getCacheJSON (key) {
|
||||
async getCacheJSON(key) {
|
||||
try {
|
||||
let txt = await redis.get(key)
|
||||
if (txt) {
|
||||
@@ -85,11 +85,11 @@ let Data = {
|
||||
return {}
|
||||
},
|
||||
|
||||
async setCacheJSON (key, data, EX = 3600 * 24 * 90) {
|
||||
async setCacheJSON(key, data, EX = 3600 * 24 * 90) {
|
||||
await redis.set(key, JSON.stringify(data), { EX })
|
||||
},
|
||||
|
||||
async importModule (file, root = "") {
|
||||
async importModule(file, root = "") {
|
||||
root = getRoot(root)
|
||||
if (!/\.js$/.test(file)) {
|
||||
file = file + ".js"
|
||||
@@ -105,16 +105,16 @@ let Data = {
|
||||
return {}
|
||||
},
|
||||
|
||||
async importDefault (file, root) {
|
||||
async importDefault(file, root) {
|
||||
let ret = await Data.importModule(file, root)
|
||||
return ret.default || {}
|
||||
},
|
||||
|
||||
async import (name) {
|
||||
async import(name) {
|
||||
return await Data.importModule(`components/optional-lib/${name}.js`)
|
||||
},
|
||||
|
||||
async importCfg (key) {
|
||||
async importCfg(key) {
|
||||
let sysCfg = await Data.importModule(`config/system/${key}_system.js`)
|
||||
let diyCfg = await Data.importModule(`config/${key}.js`)
|
||||
if (diyCfg.isSys) {
|
||||
@@ -139,7 +139,7 @@ let Data = {
|
||||
*
|
||||
* */
|
||||
|
||||
getData (target, keyList = "", cfg = {}) {
|
||||
getData(target, keyList = "", cfg = {}) {
|
||||
target = target || {}
|
||||
let defaultData = cfg.defaultData || {}
|
||||
let ret = {}
|
||||
@@ -166,12 +166,12 @@ let Data = {
|
||||
return ret
|
||||
},
|
||||
|
||||
getVal (target, keyFrom, defaultValue) {
|
||||
getVal(target, keyFrom, defaultValue) {
|
||||
return _.get(target, keyFrom, defaultValue)
|
||||
},
|
||||
|
||||
// 异步池,聚合请求
|
||||
async asyncPool (poolLimit, array, iteratorFn) {
|
||||
async asyncPool(poolLimit, array, iteratorFn) {
|
||||
const ret = [] // 存储所有的异步任务
|
||||
const executing = [] // 存储正在执行的异步任务
|
||||
for (const item of array) {
|
||||
@@ -195,12 +195,12 @@ let Data = {
|
||||
},
|
||||
|
||||
// sleep
|
||||
sleep (ms) {
|
||||
sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
},
|
||||
|
||||
// 获取默认值
|
||||
def () {
|
||||
def() {
|
||||
for (let idx in arguments) {
|
||||
if (!_.isUndefined(arguments[idx])) {
|
||||
return arguments[idx]
|
||||
@@ -214,7 +214,7 @@ let Data = {
|
||||
arr = arr.replace(/\s*(;|;|、|,)\s*/, ",")
|
||||
arr = arr.split(",")
|
||||
} else if (_.isNumber(arr)) {
|
||||
arr = [arr.toString()]
|
||||
arr = [ arr.toString() ]
|
||||
}
|
||||
_.forEach(arr, (str, idx) => {
|
||||
if (!_.isUndefined(str)) {
|
||||
@@ -223,7 +223,7 @@ let Data = {
|
||||
})
|
||||
},
|
||||
|
||||
regRet (reg, txt, idx) {
|
||||
regRet(reg, txt, idx) {
|
||||
if (reg && txt) {
|
||||
let ret = reg.exec(txt)
|
||||
if (ret && ret[idx]) {
|
||||
@@ -238,7 +238,7 @@ let Data = {
|
||||
* @param extension
|
||||
* @param excludeDir
|
||||
*/
|
||||
readDirRecursive (directory, extension, excludeDir) {
|
||||
readDirRecursive(directory, extension, excludeDir) {
|
||||
let files = fs.readdirSync(directory)
|
||||
|
||||
let jsFiles = files.filter(file => path.extname(file) === `.${extension}`)
|
||||
|
||||
@@ -11,7 +11,7 @@ let changelogs = []
|
||||
let currentVersion
|
||||
let versionCount = 2
|
||||
|
||||
const getLine = function (line) {
|
||||
const getLine = function(line) {
|
||||
line = line.replace(/(^\s*\*|\r)/g, "")
|
||||
line = line.replace(/\s*`([^`]+`)/g, "<span class=\"cmd\">$1")
|
||||
line = line.replace(/`\s*/g, "</span>")
|
||||
@@ -97,16 +97,16 @@ if (yunzaiName == "miao-yunzai") {
|
||||
yunzaiName = _.capitalize(yunzaiName)
|
||||
}
|
||||
let Version = {
|
||||
get ver () {
|
||||
get ver() {
|
||||
return currentVersion
|
||||
},
|
||||
get name () {
|
||||
get name() {
|
||||
return yunzaiName
|
||||
},
|
||||
get yunzai () {
|
||||
get yunzai() {
|
||||
return yunzai_ver
|
||||
},
|
||||
get logs () {
|
||||
get logs() {
|
||||
return changelogs
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ export default class YamlReader {
|
||||
* @param yamlPath yaml文件绝对路径
|
||||
* @param isWatch 是否监听文件变化
|
||||
*/
|
||||
constructor (yamlPath, isWatch = false) {
|
||||
constructor(yamlPath, isWatch = false) {
|
||||
this.yamlPath = yamlPath
|
||||
this.isWatch = isWatch
|
||||
this.initYaml()
|
||||
}
|
||||
|
||||
initYaml () {
|
||||
initYaml() {
|
||||
// parseDocument 将会保留注释
|
||||
this.document = YAML.parseDocument(fs.readFileSync(this.yamlPath, "utf8"))
|
||||
if (this.isWatch && !this.watcher) {
|
||||
@@ -31,7 +31,7 @@ export default class YamlReader {
|
||||
}
|
||||
|
||||
/** 返回读取的对象 */
|
||||
get jsonData () {
|
||||
get jsonData() {
|
||||
if (!this.document) {
|
||||
return null
|
||||
}
|
||||
@@ -39,42 +39,42 @@ export default class YamlReader {
|
||||
}
|
||||
|
||||
/* 检查集合是否包含key的值 */
|
||||
has (keyPath) {
|
||||
has(keyPath) {
|
||||
return this.document.hasIn(keyPath.split("."))
|
||||
}
|
||||
|
||||
/* 返回key的值 */
|
||||
get (keyPath) {
|
||||
get(keyPath) {
|
||||
return _.get(this.jsonData, keyPath)
|
||||
}
|
||||
|
||||
/* 修改某个key的值 */
|
||||
set (keyPath, value) {
|
||||
this.document.setIn([keyPath], value)
|
||||
set(keyPath, value) {
|
||||
this.document.setIn([ keyPath ], value)
|
||||
this.save()
|
||||
}
|
||||
|
||||
/* 删除key */
|
||||
delete (keyPath) {
|
||||
delete(keyPath) {
|
||||
this.document.deleteIn(keyPath.split("."))
|
||||
this.save()
|
||||
}
|
||||
|
||||
// 数组添加数据
|
||||
addIn (keyPath, value) {
|
||||
addIn(keyPath, value) {
|
||||
this.document.addIn(keyPath.split("."), value)
|
||||
this.save()
|
||||
}
|
||||
|
||||
// 彻底删除某个key
|
||||
deleteKey (keyPath) {
|
||||
deleteKey(keyPath) {
|
||||
let keys = keyPath.split(".")
|
||||
keys = this.mapParentKeys(keys)
|
||||
this.document.deleteIn(keys)
|
||||
this.save()
|
||||
}
|
||||
|
||||
save () {
|
||||
save() {
|
||||
this.isSave = true
|
||||
let yaml = this.document.toString()
|
||||
fs.writeFileSync(this.yamlPath, yaml, "utf8")
|
||||
|
||||
@@ -11,7 +11,7 @@ export const helpCfg = {
|
||||
columnCount: 3,
|
||||
colWidth: 265,
|
||||
theme: "all",
|
||||
themeExclude: ["default"],
|
||||
themeExclude: [ "default" ],
|
||||
style: {
|
||||
fontColor: "#ceb78b",
|
||||
descColor: "#eee",
|
||||
@@ -23,290 +23,297 @@ export const helpCfg = {
|
||||
}
|
||||
}
|
||||
|
||||
export const helpList = [{
|
||||
group: "基础功能",
|
||||
list: [{
|
||||
icon: 1,
|
||||
title: "#禁言 <@QQ> <时间>",
|
||||
desc: "=-="
|
||||
},
|
||||
export const helpList = [
|
||||
{
|
||||
icon: 2,
|
||||
title: "#解禁 <@QQ>",
|
||||
desc: "=-="
|
||||
},
|
||||
{
|
||||
icon: 3,
|
||||
title: "#全体禁言|解禁",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 16,
|
||||
title: "#发通知 <消息>",
|
||||
desc: "发送@全体的通知"
|
||||
},
|
||||
{
|
||||
title: "#踢 <@QQ>",
|
||||
desc: "顾名思义",
|
||||
icon: 4
|
||||
group: "基础功能",
|
||||
list: [
|
||||
{
|
||||
icon: 1,
|
||||
title: "#禁言 <@QQ> <时间>",
|
||||
desc: "=-="
|
||||
},
|
||||
{
|
||||
icon: 2,
|
||||
title: "#解禁 <@QQ>",
|
||||
desc: "=-="
|
||||
},
|
||||
{
|
||||
icon: 3,
|
||||
title: "#全体禁言|解禁",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 16,
|
||||
title: "#发通知 <消息>",
|
||||
desc: "发送@全体的通知"
|
||||
},
|
||||
{
|
||||
title: "#踢 <@QQ>",
|
||||
desc: "顾名思义",
|
||||
icon: 4
|
||||
}, {
|
||||
title: "#发群公告 <文字>",
|
||||
desc: "发送简易公告",
|
||||
icon: 16
|
||||
}, {
|
||||
title: "#查群公告$",
|
||||
desc: "查看现有公告",
|
||||
icon: 3
|
||||
}, {
|
||||
title: "#删群公告 <序号>",
|
||||
desc: "用查看公告获取序号",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#获取禁言列表",
|
||||
desc: "查看本群被禁言的人",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#解除全部禁言",
|
||||
desc: "解除本群全部被禁言的人",
|
||||
icon: 6
|
||||
},
|
||||
{
|
||||
title: "#查看n月没发言的人",
|
||||
desc: "查看多少天|周|月没发言的人",
|
||||
icon: 15
|
||||
},
|
||||
{
|
||||
title: "#清理n天没发言的人",
|
||||
desc: "清理多少天|周|月没发言的人",
|
||||
icon: 14
|
||||
},
|
||||
{
|
||||
title: "#查看从未发言的人",
|
||||
desc: "查看进群后从未发言的人",
|
||||
icon: 1
|
||||
},
|
||||
{
|
||||
title: "#清理从未发言的人",
|
||||
desc: "清理进群后从未发言的人",
|
||||
icon: 5
|
||||
},
|
||||
{
|
||||
title: "#查看不活跃排行榜",
|
||||
desc: "后面可以加数字",
|
||||
icon: 16
|
||||
},
|
||||
{
|
||||
title: "#查看最近入群情况",
|
||||
desc: "后面可以加数字",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#查看加群申请",
|
||||
desc: "查看本群的加群申请",
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
title: "#同意|拒绝加群申请<QQ>",
|
||||
desc: "处理本群的加群申请",
|
||||
icon: 19
|
||||
},
|
||||
{
|
||||
title: "#同意|拒绝全部加群申请",
|
||||
desc: "处理本群的全部加群申请",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#加|移精",
|
||||
desc: "回复消息进行加/移精",
|
||||
icon: 18
|
||||
}
|
||||
]
|
||||
}, {
|
||||
title: "#发群公告 <文字>",
|
||||
desc: "发送简易公告",
|
||||
icon: 16
|
||||
group: "字符",
|
||||
list: [
|
||||
{
|
||||
title: "#幸运字符列表",
|
||||
desc: "查看现有字符",
|
||||
icon: 16
|
||||
},
|
||||
{
|
||||
title: "#替换幸运字符+(id)",
|
||||
desc: "用列表获取id",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#抽幸运字符",
|
||||
desc: "bot抽取字符",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#开启|关闭幸运字符",
|
||||
desc: "=-=",
|
||||
icon: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "定时禁言",
|
||||
list: [
|
||||
{
|
||||
title: "#定时(禁言|解禁)00:00",
|
||||
desc: "设置定时可用cron表达式设置",
|
||||
icon: 12
|
||||
}, {
|
||||
title: "#定时禁言任务",
|
||||
desc: "查看禁言任务",
|
||||
icon: 10
|
||||
}, {
|
||||
title: "#取消定时(禁言|解禁)",
|
||||
desc: "取消查看禁言任务",
|
||||
icon: 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "群信息",
|
||||
list: [
|
||||
{
|
||||
icon: 2,
|
||||
title: "#群星级",
|
||||
desc: "查看群星级"
|
||||
},
|
||||
{
|
||||
title: "#今天谁生日",
|
||||
desc: "今天可换为昨天或后天或日期",
|
||||
icon: 12
|
||||
}, {
|
||||
title: "#哪个叼毛是龙王",
|
||||
desc: "查看谁是龙王",
|
||||
icon: 6
|
||||
}, {
|
||||
title: "#今日打卡",
|
||||
desc: "查看今日打卡",
|
||||
icon: 5
|
||||
}, {
|
||||
title: "#群数据(7天)?",
|
||||
desc: "活跃数据等",
|
||||
icon: 7
|
||||
}, {
|
||||
title: "#群发言榜单(7天)?",
|
||||
desc: "不加7天查看昨天的数据",
|
||||
icon: 16
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "其他",
|
||||
list: [
|
||||
{
|
||||
title: "#开启|关闭加群通知",
|
||||
desc: "将加群申请发送至群",
|
||||
icon: 2
|
||||
}, {
|
||||
title: "#群管(加|删)白 <@QQ>",
|
||||
desc: "白名单可以不被群管功能操作",
|
||||
icon: 1
|
||||
}, {
|
||||
title: "#开启|关闭白名单解禁",
|
||||
desc: "白名单被禁言时自动解禁",
|
||||
icon: 8
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "进群验证(更多设置请在config/groupverify.yaml进行设置)",
|
||||
list: [
|
||||
{
|
||||
title: "#开启验证",
|
||||
desc: "开启本群验证",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#关闭验证",
|
||||
desc: "关闭本群验证",
|
||||
icon: 15
|
||||
},
|
||||
{
|
||||
title: "#重新验证 <@群员>",
|
||||
desc: "重新发起验证",
|
||||
icon: 1
|
||||
}, {
|
||||
title: "#绕过验证 <@群员>",
|
||||
desc: "绕过本次验证",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#切换验证模式",
|
||||
desc: "更换答案匹配模式",
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
title: "#设置验证超时时间+(s)",
|
||||
desc: "多少秒后踢出",
|
||||
icon: 17
|
||||
}
|
||||
]
|
||||
}, {
|
||||
title: "#查群公告$",
|
||||
desc: "查看现有公告",
|
||||
icon: 3
|
||||
group: "违禁词",
|
||||
list: [
|
||||
{
|
||||
title: "#新增违禁词.*",
|
||||
desc: "文档查看具体用法",
|
||||
icon: 7
|
||||
},
|
||||
{
|
||||
title: "#删除违禁词.*",
|
||||
desc: "---",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#查看违禁词.*",
|
||||
desc: "---",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#违禁词列表",
|
||||
desc: "列表",
|
||||
icon: 17
|
||||
},
|
||||
{
|
||||
title: "#设置违禁词禁言时间400",
|
||||
desc: "禁言时间",
|
||||
icon: 11
|
||||
}
|
||||
]
|
||||
}, {
|
||||
title: "#删群公告 <序号>",
|
||||
desc: "用查看公告获取序号",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#获取禁言列表",
|
||||
desc: "查看本群被禁言的人",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#解除全部禁言",
|
||||
desc: "解除本群全部被禁言的人",
|
||||
icon: 6
|
||||
},
|
||||
{
|
||||
title: "#查看n月没发言的人",
|
||||
desc: "查看多少天|周|月没发言的人",
|
||||
icon: 15
|
||||
},
|
||||
{
|
||||
title: "#清理n天没发言的人",
|
||||
desc: "清理多少天|周|月没发言的人",
|
||||
icon: 14
|
||||
},
|
||||
{
|
||||
title: "#查看从未发言的人",
|
||||
desc: "查看进群后从未发言的人",
|
||||
icon: 1
|
||||
},
|
||||
{
|
||||
title: "#清理从未发言的人",
|
||||
desc: "清理进群后从未发言的人",
|
||||
icon: 5
|
||||
},
|
||||
{
|
||||
title: "#查看不活跃排行榜",
|
||||
desc: "后面可以加数字",
|
||||
icon: 16
|
||||
},
|
||||
{
|
||||
title: "#查看最近入群情况",
|
||||
desc: "后面可以加数字",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#查看加群申请",
|
||||
desc: "查看本群的加群申请",
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
title: "#同意|拒绝加群申请<QQ>",
|
||||
desc: "处理本群的加群申请",
|
||||
icon: 19
|
||||
},
|
||||
{
|
||||
title: "#同意|拒绝全部加群申请",
|
||||
desc: "处理本群的全部加群申请",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#加|移精",
|
||||
desc: "回复消息进行加/移精",
|
||||
icon: 18
|
||||
group: "Bot为群主可用",
|
||||
list: [
|
||||
{
|
||||
title: "#设置管理 <@QQ>",
|
||||
desc: "增加管理",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#取消管理 <@QQ> ",
|
||||
desc: "=-=",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#申请头衔 <头衔>",
|
||||
desc: "群员自己设置",
|
||||
icon: 19
|
||||
},
|
||||
{
|
||||
title: "#修改头衔 <@QQ> <头衔>",
|
||||
desc: "主人给别人设置",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#(增加|减少|查看)头衔屏蔽词",
|
||||
desc: "头衔屏蔽词",
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
title: "#切换头衔屏蔽词匹配模式",
|
||||
desc: "模糊匹配和精确匹配",
|
||||
icon: 13
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
group: "字符",
|
||||
list: [
|
||||
{
|
||||
title: "#幸运字符列表",
|
||||
desc: "查看现有字符",
|
||||
icon: 16
|
||||
},
|
||||
{
|
||||
title: "#替换幸运字符+(id)",
|
||||
desc: "用列表获取id",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#抽幸运字符",
|
||||
desc: "bot抽取字符",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#开启|关闭幸运字符",
|
||||
desc: "=-=",
|
||||
icon: 5
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "定时禁言",
|
||||
list: [
|
||||
{
|
||||
title: "#定时(禁言|解禁)00:00",
|
||||
desc: "设置定时可用cron表达式设置",
|
||||
icon: 12
|
||||
}, {
|
||||
title: "#定时禁言任务",
|
||||
desc: "查看禁言任务",
|
||||
icon: 10
|
||||
}, {
|
||||
title: "#取消定时(禁言|解禁)",
|
||||
desc: "取消查看禁言任务",
|
||||
icon: 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "群信息",
|
||||
list: [
|
||||
{
|
||||
icon: 2,
|
||||
title: "#群星级",
|
||||
desc: "查看群星级"
|
||||
},
|
||||
{
|
||||
title: "#今天谁生日",
|
||||
desc: "今天可换为昨天或后天或日期",
|
||||
icon: 12
|
||||
}, {
|
||||
title: "#哪个叼毛是龙王",
|
||||
desc: "查看谁是龙王",
|
||||
icon: 6
|
||||
}, {
|
||||
title: "#今日打卡",
|
||||
desc: "查看今日打卡",
|
||||
icon: 5
|
||||
}, {
|
||||
title: "#群数据(7天)?",
|
||||
desc: "活跃数据等",
|
||||
icon: 7
|
||||
}, {
|
||||
title: "#群发言榜单(7天)?",
|
||||
desc: "不加7天查看昨天的数据",
|
||||
icon: 16
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "其他",
|
||||
list: [
|
||||
{
|
||||
title: "#开启|关闭加群通知",
|
||||
desc: "将加群申请发送至群",
|
||||
icon: 2
|
||||
}, {
|
||||
title: "#群管(加|删)白 <@QQ>",
|
||||
desc: "白名单可以不被群管功能操作",
|
||||
icon: 1
|
||||
}, {
|
||||
title: "#开启|关闭白名单解禁",
|
||||
desc: "白名单被禁言时自动解禁",
|
||||
icon: 8
|
||||
}]
|
||||
},
|
||||
{
|
||||
group: "进群验证(更多设置请在config/groupverify.yaml进行设置)",
|
||||
list: [
|
||||
{
|
||||
title: "#开启验证",
|
||||
desc: "开启本群验证",
|
||||
icon: 4
|
||||
},
|
||||
{
|
||||
title: "#关闭验证",
|
||||
desc: "关闭本群验证",
|
||||
icon: 15
|
||||
},
|
||||
{
|
||||
title: "#重新验证 <@群员>",
|
||||
desc: "重新发起验证",
|
||||
icon: 1
|
||||
}, {
|
||||
title: "#绕过验证 <@群员>",
|
||||
desc: "绕过本次验证",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#切换验证模式",
|
||||
desc: "更换答案匹配模式",
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
title: "#设置验证超时时间+(s)",
|
||||
desc: "多少秒后踢出",
|
||||
icon: 17
|
||||
}]
|
||||
}, {
|
||||
group: "违禁词",
|
||||
list: [
|
||||
{
|
||||
title: "#新增违禁词.*",
|
||||
desc: "文档查看具体用法",
|
||||
icon: 7
|
||||
},
|
||||
{
|
||||
title: "#删除违禁词.*",
|
||||
desc: "---",
|
||||
icon: 3
|
||||
},
|
||||
{
|
||||
title: "#查看违禁词.*",
|
||||
desc: "---",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#违禁词列表",
|
||||
desc: "列表",
|
||||
icon: 17
|
||||
},
|
||||
{
|
||||
title: "#设置违禁词禁言时间400",
|
||||
desc: "禁言时间",
|
||||
icon: 11
|
||||
}]
|
||||
}, {
|
||||
group: "Bot为群主可用",
|
||||
list: [
|
||||
{
|
||||
title: "#设置管理 <@QQ>",
|
||||
desc: "增加管理",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#取消管理 <@QQ> ",
|
||||
desc: "=-=",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#申请头衔 <头衔>",
|
||||
desc: "群员自己设置",
|
||||
icon: 19
|
||||
},
|
||||
{
|
||||
title: "#修改头衔 <@QQ> <头衔>",
|
||||
desc: "主人给别人设置",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#(增加|减少|查看)头衔屏蔽词",
|
||||
desc: "头衔屏蔽词",
|
||||
icon: 2
|
||||
},
|
||||
{
|
||||
title: "#切换头衔屏蔽词匹配模式",
|
||||
desc: "模糊匹配和精确匹配",
|
||||
icon: 13
|
||||
}]
|
||||
}]
|
||||
]
|
||||
|
||||
export const isSys = true
|
||||
|
||||
@@ -11,7 +11,7 @@ export const helpCfg = {
|
||||
columnCount: 3,
|
||||
colWidth: 265,
|
||||
theme: "all",
|
||||
themeExclude: ["default"],
|
||||
themeExclude: [ "default" ],
|
||||
style: {
|
||||
fontColor: "#ceb78b",
|
||||
descColor: "#eee",
|
||||
@@ -23,277 +23,284 @@ export const helpCfg = {
|
||||
}
|
||||
}
|
||||
|
||||
export const helpList = [{
|
||||
group: "Bot相关",
|
||||
auth: "master",
|
||||
list: [{
|
||||
icon: 1,
|
||||
title: "#发好友 <QQ> <消息>",
|
||||
desc: "给好友发送一条涩涩的消息"
|
||||
export const helpList = [
|
||||
{
|
||||
group: "Bot相关",
|
||||
auth: "master",
|
||||
list: [
|
||||
{
|
||||
icon: 1,
|
||||
title: "#发好友 <QQ> <消息>",
|
||||
desc: "给好友发送一条涩涩的消息"
|
||||
},
|
||||
{
|
||||
icon: 2,
|
||||
title: "#发群聊 <群号> <消息>",
|
||||
desc: "给群聊发送一条涩涩的消息"
|
||||
},
|
||||
{
|
||||
icon: 3,
|
||||
title: "#改头像 <图片>",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 4,
|
||||
title: "#改状态 <状态> ",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 5,
|
||||
title: "#改昵称 <昵称> ",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 6,
|
||||
title: "#改签名 <签名> ",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
title: "#改性别 <性别> ",
|
||||
desc: "顾名思义",
|
||||
icon: 7
|
||||
},
|
||||
{
|
||||
title: "#改群名片 <名片> ",
|
||||
desc: "群里Bot自己的名片",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#改群昵称 <昵称>",
|
||||
desc: "改群的昵称",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#改群头像 <图片>",
|
||||
desc: "顾名思义",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#删好友 <QQ> ",
|
||||
desc: "删掉涩涩的好友",
|
||||
icon: 11
|
||||
},
|
||||
{
|
||||
title: "#退群 <群号> ",
|
||||
desc: "退掉涩涩的群",
|
||||
icon: 12
|
||||
},
|
||||
{
|
||||
title: "#获取群列表",
|
||||
desc: "获取Bot的所有群",
|
||||
icon: 13
|
||||
},
|
||||
{
|
||||
title: "#获取好友列表",
|
||||
desc: "获取Bot的所有好友",
|
||||
icon: 14
|
||||
},
|
||||
{
|
||||
title: "#取说说列表 <页数> ",
|
||||
desc: "获取Bot的说说列表",
|
||||
icon: 15
|
||||
},
|
||||
{
|
||||
title: "#发说说 <内容> ",
|
||||
desc: "发送一条涩涩的说说",
|
||||
icon: 16
|
||||
},
|
||||
{
|
||||
title: "#删说说 <序号>",
|
||||
desc: "用取说说列表获取序号",
|
||||
icon: 17
|
||||
},
|
||||
{
|
||||
title: "#清空说说",
|
||||
desc: "一键清空",
|
||||
icon: 18
|
||||
},
|
||||
{
|
||||
title: "#清空留言",
|
||||
desc: "一键清空留言",
|
||||
icon: 19
|
||||
}, {
|
||||
title: "#开启|关闭戳一戳",
|
||||
desc: "QQ的戳一戳开关",
|
||||
icon: 5
|
||||
}, {
|
||||
title: "#同意|拒绝全部好友申请",
|
||||
desc: "顾名思义",
|
||||
icon: 6
|
||||
}, {
|
||||
title: "#查看好友申请",
|
||||
desc: "查看现有好友申请",
|
||||
icon: 1
|
||||
},
|
||||
{
|
||||
title: "同意|拒绝好友申请 <QQ>",
|
||||
desc: "同意或拒绝好友申请",
|
||||
icon: 18
|
||||
},
|
||||
{
|
||||
title: "#查看群邀请",
|
||||
desc: "查看现有群邀请",
|
||||
icon: 3
|
||||
}, {
|
||||
title: "#同意|拒绝全部群邀请",
|
||||
desc: "同意或拒绝全部群邀请",
|
||||
icon: 15
|
||||
}, {
|
||||
title: "#同意|拒绝群邀请 <群号>",
|
||||
desc: "同意或拒绝全部群邀请",
|
||||
icon: 7
|
||||
}, {
|
||||
title: "#查看全部请求",
|
||||
desc: "查看所有请求",
|
||||
icon: 20
|
||||
}, {
|
||||
title: "#(开启|关闭)好友添加",
|
||||
desc: "是否开启好友添加",
|
||||
icon: 7
|
||||
}, {
|
||||
title: "#更改好友申请方式[0123]",
|
||||
desc: "带0参数为帮助",
|
||||
icon: 12
|
||||
}, {
|
||||
title: "#拉黑 #取消拉黑",
|
||||
desc: "可带at或直接键入qq,拉黑后面可带\"群\"",
|
||||
icon: 13
|
||||
}, {
|
||||
title: "#拉白 #取消拉白",
|
||||
desc: "用法与 #拉黑 相同",
|
||||
icon: 14
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
icon: 2,
|
||||
title: "#发群聊 <群号> <消息>",
|
||||
desc: "给群聊发送一条涩涩的消息"
|
||||
group: "娱乐功能",
|
||||
list: [
|
||||
{
|
||||
icon: 7,
|
||||
title: "#椰羊收益曲线",
|
||||
desc: "查看角色收益曲线"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#椰羊参考面板",
|
||||
desc: "查看角色参考面板"
|
||||
},
|
||||
{
|
||||
icon: 9,
|
||||
title: "#收益曲线帮助",
|
||||
desc: "=-="
|
||||
}, {
|
||||
icon: 20,
|
||||
title: "#唱歌",
|
||||
desc: "随机唱鸭"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#(全部)?赞我",
|
||||
desc: "给你点一个大大的赞"
|
||||
},
|
||||
{
|
||||
icon: 15,
|
||||
title: "#支付宝到账<数字>",
|
||||
desc: "听到账爽一下"
|
||||
}, {
|
||||
icon: 17,
|
||||
title: "#翻译",
|
||||
desc: "有道翻译"
|
||||
}, {
|
||||
icon: 9,
|
||||
title: "#搜索菜单",
|
||||
desc: "各大引擎搜索"
|
||||
}, {
|
||||
icon: 7,
|
||||
title: "#铃声搜索",
|
||||
desc: "铃声多多"
|
||||
}, {
|
||||
icon: 1,
|
||||
title: "#桌游搜索<关键词>",
|
||||
desc: "桌游搜索"
|
||||
}, {
|
||||
icon: 19,
|
||||
title: "#桌游排行",
|
||||
desc: "桌游排行"
|
||||
}, {
|
||||
title: "#看头像 <@QQ>",
|
||||
desc: "查看该用户的高清头像图片",
|
||||
icon: 16
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
icon: 3,
|
||||
title: "#改头像 <图片>",
|
||||
desc: "顾名思义"
|
||||
group: "搜图搜番",
|
||||
list: [
|
||||
{
|
||||
title: "#搜图",
|
||||
desc: "默认SauceNAO",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#搜番",
|
||||
desc: "WhatAnime",
|
||||
icon: 6
|
||||
},
|
||||
{
|
||||
title: "#(SauceNAO|sn)搜图",
|
||||
desc: "SauceNAO",
|
||||
icon: 1
|
||||
},
|
||||
{
|
||||
title: "#(Ascii2D|ac)搜图",
|
||||
desc: "Ascii2D",
|
||||
icon: 5
|
||||
},
|
||||
{
|
||||
title: "#设置SauceNAOApiKey<key>",
|
||||
desc: "SauceNAOApiKey",
|
||||
icon: 9
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
icon: 4,
|
||||
title: "#改状态 <状态> ",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 5,
|
||||
title: "#改昵称 <昵称> ",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 6,
|
||||
title: "#改签名 <签名> ",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
title: "#改性别 <性别> ",
|
||||
desc: "顾名思义",
|
||||
icon: 7
|
||||
},
|
||||
{
|
||||
title: "#改群名片 <名片> ",
|
||||
desc: "群里Bot自己的名片",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#改群昵称 <昵称>",
|
||||
desc: "改群的昵称",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#改群头像 <图片>",
|
||||
desc: "顾名思义",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#删好友 <QQ> ",
|
||||
desc: "删掉涩涩的好友",
|
||||
icon: 11
|
||||
},
|
||||
{
|
||||
title: "#退群 <群号> ",
|
||||
desc: "退掉涩涩的群",
|
||||
icon: 12
|
||||
},
|
||||
{
|
||||
title: "#获取群列表",
|
||||
desc: "获取Bot的所有群",
|
||||
icon: 13
|
||||
},
|
||||
{
|
||||
title: "#获取好友列表",
|
||||
desc: "获取Bot的所有好友",
|
||||
icon: 14
|
||||
},
|
||||
{
|
||||
title: "#取说说列表 <页数> ",
|
||||
desc: "获取Bot的说说列表",
|
||||
icon: 15
|
||||
},
|
||||
{
|
||||
title: "#发说说 <内容> ",
|
||||
desc: "发送一条涩涩的说说",
|
||||
icon: 16
|
||||
},
|
||||
{
|
||||
title: "#删说说 <序号>",
|
||||
desc: "用取说说列表获取序号",
|
||||
icon: 17
|
||||
},
|
||||
{
|
||||
title: "#清空说说",
|
||||
desc: "一键清空",
|
||||
icon: 18
|
||||
},
|
||||
{
|
||||
title: "#清空留言",
|
||||
desc: "一键清空留言",
|
||||
icon: 19
|
||||
}, {
|
||||
title: "#开启|关闭戳一戳",
|
||||
desc: "QQ的戳一戳开关",
|
||||
icon: 5
|
||||
}, {
|
||||
title: "#同意|拒绝全部好友申请",
|
||||
desc: "顾名思义",
|
||||
icon: 6
|
||||
}, {
|
||||
title: "#查看好友申请",
|
||||
desc: "查看现有好友申请",
|
||||
icon: 1
|
||||
},
|
||||
{
|
||||
title: "同意|拒绝好友申请 <QQ>",
|
||||
desc: "同意或拒绝好友申请",
|
||||
icon: 18
|
||||
},
|
||||
{
|
||||
title: "#查看群邀请",
|
||||
desc: "查看现有群邀请",
|
||||
icon: 3
|
||||
}, {
|
||||
title: "#同意|拒绝全部群邀请",
|
||||
desc: "同意或拒绝全部群邀请",
|
||||
icon: 15
|
||||
}, {
|
||||
title: "#同意|拒绝群邀请 <群号>",
|
||||
desc: "同意或拒绝全部群邀请",
|
||||
icon: 7
|
||||
}, {
|
||||
title: "#查看全部请求",
|
||||
desc: "查看所有请求",
|
||||
icon: 20
|
||||
}, {
|
||||
title: "#(开启|关闭)好友添加",
|
||||
desc: "是否开启好友添加",
|
||||
icon: 7
|
||||
}, {
|
||||
title: "#更改好友申请方式[0123]",
|
||||
desc: "带0参数为帮助",
|
||||
icon: 12
|
||||
}, {
|
||||
title: "#拉黑 #取消拉黑",
|
||||
desc: "可带at或直接键入qq,拉黑后面可带\"群\"",
|
||||
icon: 13
|
||||
}, {
|
||||
title: "#拉白 #取消拉白",
|
||||
desc: "用法与 #拉黑 相同",
|
||||
icon: 14
|
||||
}]
|
||||
},
|
||||
{
|
||||
group: "娱乐功能",
|
||||
list: [
|
||||
{
|
||||
icon: 7,
|
||||
title: "#椰羊收益曲线",
|
||||
desc: "查看角色收益曲线"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#椰羊参考面板",
|
||||
desc: "查看角色参考面板"
|
||||
},
|
||||
{
|
||||
icon: 9,
|
||||
title: "#收益曲线帮助",
|
||||
desc: "=-="
|
||||
}, {
|
||||
icon: 20,
|
||||
title: "#唱歌",
|
||||
desc: "随机唱鸭"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#(全部)?赞我",
|
||||
desc: "给你点一个大大的赞"
|
||||
},
|
||||
{
|
||||
icon: 15,
|
||||
title: "#支付宝到账<数字>",
|
||||
desc: "听到账爽一下"
|
||||
}, {
|
||||
icon: 17,
|
||||
title: "#翻译",
|
||||
desc: "有道翻译"
|
||||
}, {
|
||||
icon: 9,
|
||||
title: "#搜索菜单",
|
||||
desc: "各大引擎搜索"
|
||||
}, {
|
||||
icon: 7,
|
||||
title: "#铃声搜索",
|
||||
desc: "铃声多多"
|
||||
}, {
|
||||
icon: 1,
|
||||
title: "#桌游搜索<关键词>",
|
||||
desc: "桌游搜索"
|
||||
}, {
|
||||
icon: 19,
|
||||
title: "#桌游排行",
|
||||
desc: "桌游排行"
|
||||
}, {
|
||||
title: "#看头像 <@QQ>",
|
||||
desc: "查看该用户的高清头像图片",
|
||||
icon: 16
|
||||
}]
|
||||
},
|
||||
{
|
||||
group: "搜图搜番",
|
||||
list: [
|
||||
{
|
||||
title: "#搜图",
|
||||
desc: "默认SauceNAO",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#搜番",
|
||||
desc: "WhatAnime",
|
||||
icon: 6
|
||||
},
|
||||
{
|
||||
title: "#(SauceNAO|sn)搜图",
|
||||
desc: "SauceNAO",
|
||||
icon: 1
|
||||
},
|
||||
{
|
||||
title: "#(Ascii2D|ac)搜图",
|
||||
desc: "Ascii2D",
|
||||
icon: 5
|
||||
},
|
||||
{
|
||||
title: "#设置SauceNAOApiKey<key>",
|
||||
desc: "SauceNAOApiKey",
|
||||
icon: 9
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "设置,版本相关",
|
||||
auth: "master",
|
||||
list: [{
|
||||
icon: 8,
|
||||
title: "#椰奶设置",
|
||||
desc: "查看椰奶设置"
|
||||
},
|
||||
{
|
||||
icon: 1,
|
||||
title: "#椰奶(强制)更新",
|
||||
desc: "更新椰奶"
|
||||
},
|
||||
{
|
||||
icon: 15,
|
||||
title: "#椰奶版本",
|
||||
desc: "查看版本信息"
|
||||
},
|
||||
{
|
||||
icon: 12,
|
||||
title: "#椰奶更新日志",
|
||||
desc: "查看更新日志"
|
||||
}, {
|
||||
icon: 8,
|
||||
title: "#椰奶状态(pro)?",
|
||||
desc: "查看系统状态"
|
||||
}, {
|
||||
icon: 3,
|
||||
title: "#椰奶群管帮助",
|
||||
desc: "群管帮助"
|
||||
}, {
|
||||
icon: 12,
|
||||
title: "#椰奶(启|禁)用全部通知",
|
||||
desc: "一键启用或禁用全部通知"
|
||||
}]
|
||||
}]
|
||||
group: "设置,版本相关",
|
||||
auth: "master",
|
||||
list: [
|
||||
{
|
||||
icon: 8,
|
||||
title: "#椰奶设置",
|
||||
desc: "查看椰奶设置"
|
||||
},
|
||||
{
|
||||
icon: 1,
|
||||
title: "#椰奶(强制)更新",
|
||||
desc: "更新椰奶"
|
||||
},
|
||||
{
|
||||
icon: 15,
|
||||
title: "#椰奶版本",
|
||||
desc: "查看版本信息"
|
||||
},
|
||||
{
|
||||
icon: 12,
|
||||
title: "#椰奶更新日志",
|
||||
desc: "查看更新日志"
|
||||
}, {
|
||||
icon: 8,
|
||||
title: "#椰奶状态(pro)?",
|
||||
desc: "查看系统状态"
|
||||
}, {
|
||||
icon: 3,
|
||||
title: "#椰奶群管帮助",
|
||||
desc: "群管帮助"
|
||||
}, {
|
||||
icon: 12,
|
||||
title: "#椰奶(启|禁)用全部通知",
|
||||
desc: "一键启用或禁用全部通知"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
export const isSys = true
|
||||
|
||||
@@ -5,7 +5,7 @@ export const helpCfg = {
|
||||
columnCount: 3,
|
||||
colWidth: 265,
|
||||
theme: "all",
|
||||
themeExclude: ["default"],
|
||||
themeExclude: [ "default" ],
|
||||
style: {
|
||||
fontColor: "#ceb78b",
|
||||
descColor: "#eee",
|
||||
@@ -17,121 +17,125 @@ export const helpCfg = {
|
||||
}
|
||||
}
|
||||
|
||||
export const helpList = [{
|
||||
group: "Pixiv",
|
||||
list: [{
|
||||
icon: 1,
|
||||
title: "#无内鬼 #setu",
|
||||
desc: "luoli接口随机图片"
|
||||
export const helpList = [
|
||||
{
|
||||
group: "Pixiv",
|
||||
list: [
|
||||
{
|
||||
icon: 1,
|
||||
title: "#无内鬼 #setu",
|
||||
desc: "luoli接口随机图片"
|
||||
},
|
||||
{
|
||||
icon: 2,
|
||||
title: "#椰奶tag <关键词*3>",
|
||||
desc: "luoli接口搜索tag"
|
||||
},
|
||||
{
|
||||
icon: 3,
|
||||
title: "#来(n)张好康的",
|
||||
desc: "国内镜像站接口,比较健康"
|
||||
},
|
||||
{
|
||||
icon: 4,
|
||||
title: "#pximg(pro)?",
|
||||
desc: "随机图片"
|
||||
},
|
||||
{
|
||||
icon: 5,
|
||||
title: "#查看热门tag",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 6,
|
||||
title: "#Pid搜图 <pid>",
|
||||
desc: "图片详情信息"
|
||||
},
|
||||
{
|
||||
title: "#tag(pro)搜图 <关键词>",
|
||||
desc: "不加Pro为国内镜像站接口",
|
||||
icon: 7
|
||||
},
|
||||
{
|
||||
title: "#Uid搜图 <uid或画师名>",
|
||||
desc: "搜索画师插画",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#相关作品 <Pid>",
|
||||
desc: "作品的相关作品",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#看看<类型>榜",
|
||||
desc: "Pixiv榜单",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#来(n)?张推荐图",
|
||||
desc: "登录后使用",
|
||||
icon: 19
|
||||
},
|
||||
{
|
||||
title: "#pixiv登录信息",
|
||||
desc: "登录后使用",
|
||||
icon: 19
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
icon: 2,
|
||||
title: "#椰奶tag <关键词*3>",
|
||||
desc: "luoli接口搜索tag"
|
||||
group: "哔咔",
|
||||
list: [
|
||||
{
|
||||
icon: 7,
|
||||
title: "#哔咔搜索<关键词>",
|
||||
desc: "更多使用请查看文档"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#哔咔id<id>(第n页)?(第n话)?",
|
||||
desc: "查看作品详情"
|
||||
},
|
||||
{
|
||||
icon: 9,
|
||||
title: "#哔咔类别列表",
|
||||
desc: "适用于类别搜索"
|
||||
}, {
|
||||
icon: 20,
|
||||
title: "#哔咔看<1~20>",
|
||||
desc: "搜索后使用"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#哔咔下一页",
|
||||
desc: "快速翻页"
|
||||
},
|
||||
{
|
||||
icon: 15,
|
||||
title: "#哔咔下一话",
|
||||
desc: "快速下一话"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
icon: 3,
|
||||
title: "#来(n)张好康的",
|
||||
desc: "国内镜像站接口,比较健康"
|
||||
},
|
||||
{
|
||||
icon: 4,
|
||||
title: "#pximg(pro)?",
|
||||
desc: "随机图片"
|
||||
},
|
||||
{
|
||||
icon: 5,
|
||||
title: "#查看热门tag",
|
||||
desc: "顾名思义"
|
||||
},
|
||||
{
|
||||
icon: 6,
|
||||
title: "#Pid搜图 <pid>",
|
||||
desc: "图片详情信息"
|
||||
},
|
||||
{
|
||||
title: "#tag(pro)搜图 <关键词>",
|
||||
desc: "不加Pro为国内镜像站接口",
|
||||
icon: 7
|
||||
},
|
||||
{
|
||||
title: "#Uid搜图 <uid或画师名>",
|
||||
desc: "搜索画师插画",
|
||||
icon: 8
|
||||
},
|
||||
{
|
||||
title: "#相关作品 <Pid>",
|
||||
desc: "作品的相关作品",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#看看<类型>榜",
|
||||
desc: "Pixiv榜单",
|
||||
icon: 10
|
||||
},
|
||||
{
|
||||
title: "#来(n)?张推荐图",
|
||||
desc: "登录后使用",
|
||||
icon: 19
|
||||
},
|
||||
{
|
||||
title: "#pixiv登录信息",
|
||||
desc: "登录后使用",
|
||||
icon: 19
|
||||
group: "其他",
|
||||
list: [
|
||||
{
|
||||
icon: 15,
|
||||
title: "#coser",
|
||||
desc: "养眼=-="
|
||||
}, {
|
||||
title: "#acg刻晴",
|
||||
desc: "acgcos",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#来点xxx",
|
||||
desc: "xxx",
|
||||
icon: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
group: "哔咔",
|
||||
list: [
|
||||
{
|
||||
icon: 7,
|
||||
title: "#哔咔搜索<关键词>",
|
||||
desc: "更多使用请查看文档"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#哔咔id<id>(第n页)?(第n话)?",
|
||||
desc: "查看作品详情"
|
||||
},
|
||||
{
|
||||
icon: 9,
|
||||
title: "#哔咔类别列表",
|
||||
desc: "适用于类别搜索"
|
||||
}, {
|
||||
icon: 20,
|
||||
title: "#哔咔看<1~20>",
|
||||
desc: "搜索后使用"
|
||||
},
|
||||
{
|
||||
icon: 13,
|
||||
title: "#哔咔下一页",
|
||||
desc: "快速翻页"
|
||||
},
|
||||
{
|
||||
icon: 15,
|
||||
title: "#哔咔下一话",
|
||||
desc: "快速下一话"
|
||||
}]
|
||||
},
|
||||
{
|
||||
group: "其他",
|
||||
list: [
|
||||
{
|
||||
icon: 15,
|
||||
title: "#coser",
|
||||
desc: "养眼=-="
|
||||
}, {
|
||||
title: "#acg刻晴",
|
||||
desc: "acgcos",
|
||||
icon: 9
|
||||
},
|
||||
{
|
||||
title: "#来点xxx",
|
||||
desc: "xxx",
|
||||
icon: 1
|
||||
}
|
||||
]
|
||||
}]
|
||||
]
|
||||
|
||||
export const isSys = true
|
||||
|
||||
128
constants/fun.js
128
constants/fun.js
@@ -5,9 +5,7 @@ export const successImgs = [
|
||||
]
|
||||
|
||||
/** 点赞失败回复的图片 */
|
||||
export const faildsImgs = [
|
||||
"https://xiaobai.klizi.cn/API/ce/paa.php?qq="
|
||||
]
|
||||
export const faildsImgs = [ "https://xiaobai.klizi.cn/API/ce/paa.php?qq=" ]
|
||||
|
||||
export const heisiType = {
|
||||
"白丝": { type: "baisi", page: 17 },
|
||||
@@ -56,64 +54,66 @@ export const pandadiuType = {
|
||||
}
|
||||
}
|
||||
|
||||
export const youDaoLangType = [{
|
||||
code: "ar",
|
||||
label: "阿拉伯语",
|
||||
alphabet: "A"
|
||||
}, {
|
||||
code: "de",
|
||||
label: "德语",
|
||||
alphabet: "D"
|
||||
}, {
|
||||
code: "ru",
|
||||
label: "俄语",
|
||||
alphabet: "E"
|
||||
}, {
|
||||
code: "fr",
|
||||
label: "法语",
|
||||
alphabet: "F"
|
||||
}, {
|
||||
code: "ko",
|
||||
label: "韩语",
|
||||
alphabet: "H"
|
||||
}, {
|
||||
code: "nl",
|
||||
label: "荷兰语",
|
||||
alphabet: "H"
|
||||
}, {
|
||||
code: "pt",
|
||||
label: "葡萄牙语",
|
||||
alphabet: "P"
|
||||
}, {
|
||||
code: "ja",
|
||||
label: "日语",
|
||||
alphabet: "R"
|
||||
}, {
|
||||
code: "th",
|
||||
label: "泰语",
|
||||
alphabet: "T"
|
||||
}, {
|
||||
code: "es",
|
||||
label: "西班牙语",
|
||||
alphabet: "X"
|
||||
}, {
|
||||
code: "en",
|
||||
label: "英语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "it",
|
||||
label: "意大利语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "vi",
|
||||
label: "越南语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "id",
|
||||
label: "印度尼西亚语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "zh-CHS",
|
||||
label: "中文",
|
||||
alphabet: "Z"
|
||||
}]
|
||||
export const youDaoLangType = [
|
||||
{
|
||||
code: "ar",
|
||||
label: "阿拉伯语",
|
||||
alphabet: "A"
|
||||
}, {
|
||||
code: "de",
|
||||
label: "德语",
|
||||
alphabet: "D"
|
||||
}, {
|
||||
code: "ru",
|
||||
label: "俄语",
|
||||
alphabet: "E"
|
||||
}, {
|
||||
code: "fr",
|
||||
label: "法语",
|
||||
alphabet: "F"
|
||||
}, {
|
||||
code: "ko",
|
||||
label: "韩语",
|
||||
alphabet: "H"
|
||||
}, {
|
||||
code: "nl",
|
||||
label: "荷兰语",
|
||||
alphabet: "H"
|
||||
}, {
|
||||
code: "pt",
|
||||
label: "葡萄牙语",
|
||||
alphabet: "P"
|
||||
}, {
|
||||
code: "ja",
|
||||
label: "日语",
|
||||
alphabet: "R"
|
||||
}, {
|
||||
code: "th",
|
||||
label: "泰语",
|
||||
alphabet: "T"
|
||||
}, {
|
||||
code: "es",
|
||||
label: "西班牙语",
|
||||
alphabet: "X"
|
||||
}, {
|
||||
code: "en",
|
||||
label: "英语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "it",
|
||||
label: "意大利语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "vi",
|
||||
label: "越南语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "id",
|
||||
label: "印度尼西亚语",
|
||||
alphabet: "Y"
|
||||
}, {
|
||||
code: "zh-CHS",
|
||||
label: "中文",
|
||||
alphabet: "Z"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -11,7 +11,7 @@ const Plugin_Path = `${Path}/plugins/yenai-plugin`
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export function supportGuoba () {
|
||||
export function supportGuoba() {
|
||||
return {
|
||||
pluginInfo: {
|
||||
name: "yenai-plugin",
|
||||
@@ -370,7 +370,7 @@ export function supportGuoba () {
|
||||
|
||||
],
|
||||
// 获取配置数据方法(用于前端填充显示数据)
|
||||
getConfigData () {
|
||||
getConfigData() {
|
||||
return {
|
||||
whole: Config.whole,
|
||||
pixiv: Config.pixiv,
|
||||
@@ -380,7 +380,7 @@ export function supportGuoba () {
|
||||
},
|
||||
|
||||
// 设置配置的方法(前端点确定后调用的方法)
|
||||
setConfigData (data, { Result }) {
|
||||
setConfigData(data, { Result }) {
|
||||
for (let key in data) Config.modify(...key.split("."), data[key])
|
||||
|
||||
return Result.ok({}, "保存成功辣ε(*´・ω・)з")
|
||||
|
||||
2
index.js
2
index.js
@@ -8,7 +8,7 @@ logger.info(chalk.rgb(134, 142, 204)(`椰奶插件${Ver.ver}初始化~`))
|
||||
logger.info(chalk.rgb(253, 235, 255)("-------------------------"))
|
||||
|
||||
global.ReplyError = class ReplyError extends Error {
|
||||
constructor (message) {
|
||||
constructor(message) {
|
||||
super(message)
|
||||
this.name = "ReplyError"
|
||||
}
|
||||
|
||||
@@ -17,25 +17,30 @@ export default new class extends sendMsgMod {
|
||||
* @param {*} e - 接收到的事件对象
|
||||
* @param {"master"|"admin"|"owner"|"all"} [permission] - 命令所需的权限
|
||||
* @param {"admin"|"owner"|"all"} [role] - 用户的权限
|
||||
* @param root0
|
||||
* @param root0.groupObj
|
||||
* @returns {boolean} - 是否具有权限
|
||||
*/
|
||||
checkPermission (e, permission = "all", role = "all") {
|
||||
if (role == "owner" && !e.group.is_owner) {
|
||||
e.reply("我连群主都木有,这种事怎么可能做到的辣!!!", true)
|
||||
checkPermission(e, permission = "all", role = "all", { groupObj = e.group } = {}) {
|
||||
console.log(groupObj)
|
||||
if (!groupObj) throw new Error("未获取到群对象")
|
||||
if (role == "owner" && !groupObj.is_owner) {
|
||||
e.reply("❎ Bot权限不足,需要群主权限", true)
|
||||
return false
|
||||
} else if (role == "admin" && !e.group.is_admin && !e.group.is_owner) {
|
||||
e.reply("我连管理员都木有,这种事怎么可能做到的辣!!!", true)
|
||||
} else if (role == "admin" && !groupObj.is_admin && !groupObj.is_owner) {
|
||||
e.reply("❎ Bot权限不足,需要管理员权限", true)
|
||||
return false
|
||||
}
|
||||
// 判断权限
|
||||
if (e.isMaster || a.includes(md5(String(e.user_id)))) return true
|
||||
let memberObj = groupObj.pickMember(e.user_id)
|
||||
if (permission == "master") {
|
||||
e.reply("❎ 该命令仅限主人可用", true)
|
||||
return false
|
||||
} else if (permission == "owner" && !e.member.is_owner) {
|
||||
} else if (permission == "owner" && !memberObj.is_owner) {
|
||||
e.reply("❎ 该命令仅限群主可用", true)
|
||||
return false
|
||||
} else if (permission == "admin" && !e.member.is_admin && !e.member.is_owner) {
|
||||
} else if (permission == "admin" && !memberObj.is_admin && !memberObj.is_owner) {
|
||||
e.reply("❎ 该命令仅限管理可用")
|
||||
return false
|
||||
}
|
||||
@@ -48,7 +53,7 @@ export default new class extends sendMsgMod {
|
||||
* @param {"sesse"|"sesepro"} type 权限类型
|
||||
* @returns {boolean}
|
||||
*/
|
||||
checkSeSePermission (e, type = "sese") {
|
||||
checkSeSePermission(e, type = "sese") {
|
||||
if (e.isMaster || a.includes(md5(String(e.user_id)))) return true
|
||||
const { sese, sesepro } = Config.getGroup(e.group_id)
|
||||
if (type == "sese" && !sese && !sesepro) {
|
||||
@@ -69,7 +74,7 @@ export default new class extends sendMsgMod {
|
||||
* @param {number} maxlimit 最大限制
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async limit (userId, key, maxlimit) {
|
||||
async limit(userId, key, maxlimit) {
|
||||
if (maxlimit <= 0) return true
|
||||
let redisKey = `yenai:${key}:limit:${userId}`
|
||||
let nowNum = await redis.get(redisKey)
|
||||
@@ -89,7 +94,7 @@ export default new class extends sendMsgMod {
|
||||
* @param {boolean} [transformation] 转换为Puppeteer浏览器使用的ck
|
||||
* @returns {object}
|
||||
*/
|
||||
getck (data, bot = Bot, transformation) {
|
||||
getck(data, bot = Bot, transformation) {
|
||||
let cookie = bot.cookies[data]
|
||||
let ck = cookie.replace(/=/g, "\":\"").replace(/;/g, "", "").replace(/ /g, "").trim()
|
||||
ck = ck.substring(0, ck.length - 2)
|
||||
@@ -115,7 +120,7 @@ export default new class extends sendMsgMod {
|
||||
* @param {Array} omits - 需要忽略的属性列表。默认为空数组,表示不忽略任何属性。
|
||||
* @returns {boolean} - 如果对象或数组中的所有值都是空值,则返回 true;否则返回 false。
|
||||
*/
|
||||
checkIfEmpty (data, omits) {
|
||||
checkIfEmpty(data, omits) {
|
||||
const filteredData = _.omit(data, omits)
|
||||
return _.every(filteredData, (value) =>
|
||||
_.isPlainObject(value) ? this.checkIfEmpty(value) : _.isEmpty(value))
|
||||
@@ -129,7 +134,7 @@ export default new class extends sendMsgMod {
|
||||
* @param {string} options.MsgTemplate - 错误消息的模板。
|
||||
* @returns {Promise<import("icqq").MessageRet>|false} 如果 ErrorObj 不是 Error 的实例,则返回 false;否则返回oicq消息返回值。
|
||||
*/
|
||||
handleException (e, ErrorObj, { MsgTemplate } = {}) {
|
||||
handleException(e, ErrorObj, { MsgTemplate } = {}) {
|
||||
if (!(ErrorObj instanceof Error)) return false
|
||||
let ErrMsg = ""
|
||||
if (ErrorObj instanceof ReplyError) {
|
||||
|
||||
@@ -8,7 +8,7 @@ export default class {
|
||||
* 给主人发消息
|
||||
* @param msg
|
||||
*/
|
||||
async sendMasterMsg (msg) {
|
||||
async sendMasterMsg(msg) {
|
||||
if (Config.whole.notificationsAll) {
|
||||
// 发送全部管理
|
||||
for (let index of Config.masterQQ) {
|
||||
@@ -36,7 +36,7 @@ export default class {
|
||||
* @param {boolean} [options.shouldSendMsg] - 是否直接发送消息,true为直接发送,否则返回需要发送的消息
|
||||
* @returns {Promise<import("icqq").MessageRet|import("icqq").XmlElem|import("icqq").JsonElem>} 消息发送结果的Promise对象
|
||||
*/
|
||||
async getforwardMsg (e, message, {
|
||||
async getforwardMsg(e, message, {
|
||||
recallMsg = 0,
|
||||
info,
|
||||
fkmsg,
|
||||
@@ -71,7 +71,7 @@ export default class {
|
||||
if (typeof (forwardMsg.data) === "object") {
|
||||
let detail = forwardMsg.data?.meta?.detail
|
||||
if (detail) {
|
||||
detail.news = [{ text: xmlTitle }]
|
||||
detail.news = [ { text: xmlTitle } ]
|
||||
}
|
||||
} else {
|
||||
forwardMsg.data = forwardMsg.data
|
||||
@@ -103,7 +103,7 @@ export default class {
|
||||
* @param {boolean | number} data.at 是否艾特该成员
|
||||
* @returns {Promise<import("icqq").MessageRet>} 返回发送消息后的结果对象
|
||||
*/
|
||||
async reply (e, msg, quote, {
|
||||
async reply(e, msg, quote, {
|
||||
recallMsg = 0,
|
||||
fkmsg = "",
|
||||
at = false
|
||||
@@ -122,9 +122,9 @@ export default class {
|
||||
}
|
||||
|
||||
if (Array.isArray(msg)) {
|
||||
msg = [segment.at(at, text), ...msg]
|
||||
msg = [ segment.at(at, text), ...msg ]
|
||||
} else {
|
||||
msg = [segment.at(at, text), msg]
|
||||
msg = [ segment.at(at, text), msg ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ export default class {
|
||||
* @param {boolean} data.fkmsg 风控消息
|
||||
* @returns {Promise<import("icqq").MessageRet>}
|
||||
*/
|
||||
async recallsendMsg (e, msg, quote, data = {}) {
|
||||
async recallsendMsg(e, msg, quote, data = {}) {
|
||||
let recallMsg = setu.getRecallTime(e.group_id)
|
||||
let msgRes = this.reply(e, msg, quote, {
|
||||
recallMsg,
|
||||
@@ -179,7 +179,7 @@ export default class {
|
||||
* @param {string} [data.xmlTitle] - XML 标题
|
||||
* @returns {Promise<any>} - Promise 对象,返回函数 `getforwardMsg()` 的返回值
|
||||
*/
|
||||
async recallSendForwardMsg (e, msg, data = {}) {
|
||||
async recallSendForwardMsg(e, msg, data = {}) {
|
||||
let recalltime = setu.getRecallTime(e.group_id)
|
||||
return await this.getforwardMsg(e, msg, {
|
||||
recallMsg: recalltime,
|
||||
|
||||
@@ -11,11 +11,11 @@ import puppeteer from "puppeteer"
|
||||
// } catch {}
|
||||
|
||||
export default new class extends render {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super()
|
||||
this.browser = false
|
||||
this.config = {
|
||||
args: ["--no-sandbox"],
|
||||
args: [ "--no-sandbox" ],
|
||||
headless: "new"
|
||||
}
|
||||
this.lock = false
|
||||
@@ -40,7 +40,7 @@ export default new class extends render {
|
||||
* @param {Array|false} [options.click] - 点击事件
|
||||
* @returns {Promise<import('icqq').segment.image>} Promise对象,如果截图成功返回构造图片消息,否则返回false
|
||||
*/
|
||||
async Webpage ({
|
||||
async Webpage({
|
||||
url,
|
||||
headers = false,
|
||||
setViewport = false,
|
||||
@@ -123,7 +123,7 @@ export default new class extends render {
|
||||
return segment.image(buff)
|
||||
}
|
||||
|
||||
async launch () {
|
||||
async launch() {
|
||||
if (this.browser) return this.browser
|
||||
logger.mark("[Yenai-Plugin]Puppeteer launching")
|
||||
// if (!puppeteer) {
|
||||
@@ -160,7 +160,7 @@ export default new class extends render {
|
||||
* @returns {object} - 包含 URL 和页面数据的对象。
|
||||
* @throws 如果导航或页面数据检索失败,将抛出错误。
|
||||
*/
|
||||
async get (url, waitSelector) {
|
||||
async get(url, waitSelector) {
|
||||
if (!(await this.launch())) {
|
||||
return false
|
||||
}
|
||||
@@ -186,11 +186,11 @@ export default new class extends render {
|
||||
}
|
||||
|
||||
/** 重启 */
|
||||
restart () {
|
||||
restart() {
|
||||
/** 截图超过重启数时,自动关闭重启浏览器,避免生成速度越来越慢 */
|
||||
if (this.renderNum % this.restartNum === 0) {
|
||||
if (this.shoting.length <= 0) {
|
||||
setTimeout(async () => {
|
||||
setTimeout(async() => {
|
||||
if (this.browser) {
|
||||
await this.browser.close().catch((err) => logger.error(err))
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ export default class {
|
||||
* @param {object} params 参数
|
||||
* @param {object} cfg
|
||||
*/
|
||||
async render (path, params, cfg) {
|
||||
let [app, tpl] = path.split("/")
|
||||
async render(path, params, cfg) {
|
||||
let [ app, tpl ] = path.split("/")
|
||||
let { e } = cfg
|
||||
let layoutPath =
|
||||
process.cwd() + `/plugins/${Plugin_Name}/resources/common/layout/`
|
||||
@@ -57,7 +57,7 @@ export default class {
|
||||
return cfg.retMsgId ? ret : true
|
||||
}
|
||||
|
||||
#scale (pct = 1) {
|
||||
#scale(pct = 1) {
|
||||
let scale = Config.whole.renderScale
|
||||
scale = Math.min(2, Math.max(0.5, scale / 100))
|
||||
pct = pct * scale
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import HttpsProxyAgentOrig from "https-proxy-agent"
|
||||
|
||||
export class HttpsProxyAgent extends HttpsProxyAgentOrig.HttpsProxyAgent {
|
||||
constructor (opts) {
|
||||
constructor(opts) {
|
||||
super(opts)
|
||||
this.tlsConnectionOptions = opts.tls
|
||||
const connect = this.connect.bind(this)
|
||||
|
||||
@@ -8,14 +8,14 @@ const CHROME_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
||||
const POSTMAN_UA = "PostmanRuntime/7.29.0"
|
||||
|
||||
class HTTPResponseError extends Error {
|
||||
constructor (response) {
|
||||
constructor(response) {
|
||||
super(`HTTP Error Response: ${response.status} ${response.statusText}`)
|
||||
this.response = response
|
||||
}
|
||||
}
|
||||
|
||||
class RequestError extends Error {
|
||||
constructor (message) {
|
||||
constructor(message) {
|
||||
super(message)
|
||||
this.name = "RequestError"
|
||||
}
|
||||
@@ -32,7 +32,7 @@ const checkStatus = response => {
|
||||
|
||||
export const qs = (obj) => {
|
||||
let res = ""
|
||||
for (const [k, v] of Object.entries(obj)) { res += `${k}=${encodeURIComponent(v)}&` }
|
||||
for (const [ k, v ] of Object.entries(obj)) { res += `${k}=${encodeURIComponent(v)}&` }
|
||||
return res.slice(0, res.length - 1)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export default new class {
|
||||
* @returns {Promise<Response|*>} - HTTP响应或响应数据
|
||||
* @throws {Error} - 如果请求失败,则抛出错误
|
||||
*/
|
||||
async get (url, options = {}) {
|
||||
async get(url, options = {}) {
|
||||
// 处理参数
|
||||
if (options.params) {
|
||||
url = url + "?" + qs(options.params)
|
||||
@@ -92,7 +92,7 @@ export default new class {
|
||||
* @returns {Promise<Response|*>} - HTTP响应或响应数据
|
||||
* @throws {Error} - 如果请求失败,则抛出错误
|
||||
*/
|
||||
async post (url, options = {}) {
|
||||
async post(url, options = {}) {
|
||||
options.method = "POST"
|
||||
options.headers = {
|
||||
"User-Agent": CHROME_UA,
|
||||
@@ -140,7 +140,7 @@ export default new class {
|
||||
* @param {object} options.params 请求参数
|
||||
* @returns {Promise<Response|*>}
|
||||
*/
|
||||
async cfGet (url, options = {}) {
|
||||
async cfGet(url, options = {}) {
|
||||
options.agent = this.getAgent(true)
|
||||
options.headers = {
|
||||
"User-Agent": POSTMAN_UA,
|
||||
@@ -156,7 +156,7 @@ export default new class {
|
||||
* @param {object | string} options.data 请求参数
|
||||
* @returns {Promise<Response|*>}
|
||||
*/
|
||||
async cfPost (url, options = {}) {
|
||||
async cfPost(url, options = {}) {
|
||||
options.agent = this.getAgent(true)
|
||||
options.headers = {
|
||||
"User-Agent": POSTMAN_UA,
|
||||
@@ -165,7 +165,7 @@ export default new class {
|
||||
return this.post(url, options)
|
||||
}
|
||||
|
||||
getAgent (cf) {
|
||||
getAgent(cf) {
|
||||
let { proxyAddress, switchProxy } = Config.proxy
|
||||
let { cfTLSVersion } = Config.picSearch
|
||||
return cf
|
||||
@@ -180,7 +180,7 @@ export default new class {
|
||||
* @param {string} str
|
||||
* @param {import('tls').SecureVersion} tlsVersion
|
||||
*/
|
||||
getTlsVersionAgent (str, tlsVersion) {
|
||||
getTlsVersionAgent(str, tlsVersion) {
|
||||
const tlsOpts = {
|
||||
maxVersion: tlsVersion,
|
||||
minVersion: tlsVersion
|
||||
@@ -213,7 +213,7 @@ export default new class {
|
||||
* @param {object} options.headers 请求头
|
||||
* @returns {Promise<import('icqq').ImageElem>} 构造图片消息
|
||||
*/
|
||||
async proxyRequestImg (url, { cache, timeout, headers } = {}) {
|
||||
async proxyRequestImg(url, { cache, timeout, headers } = {}) {
|
||||
if (!this.getAgent()) return segment.image(url, cache, timeout, headers)
|
||||
let Request = await this.get(url, {
|
||||
headers
|
||||
|
||||
@@ -3,7 +3,7 @@ import request from "../lib/request/request.js"
|
||||
import { Config } from "../components/index.js"
|
||||
|
||||
export default new (class {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.domain = "https://api.obfs.dev/api/bika"
|
||||
this.hearder = {
|
||||
headers: {
|
||||
@@ -14,7 +14,7 @@ export default new (class {
|
||||
this.idNext = null
|
||||
}
|
||||
|
||||
get imgproxy () {
|
||||
get imgproxy() {
|
||||
return Config.bika.bikaDirectConnection ? undefined : `https://${Config.bika.bikaImageProxy}/`
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ export default new (class {
|
||||
* @throws {Error} 当未找到作品时,会抛出异常
|
||||
* @returns {Array<string>} 返回搜索结果信息数组
|
||||
*/
|
||||
async search (keyword, page = 1, type = "advanced", sort = "ld") {
|
||||
async search(keyword, page = 1, type = "advanced", sort = "ld") {
|
||||
let types = [
|
||||
{
|
||||
alias: ["关键词", "advanced", "高级"],
|
||||
alias: [ "关键词", "advanced", "高级" ],
|
||||
url: `${this.domain}/advanced_search?keyword=${keyword}&page=${page}&sort=${sort}`
|
||||
},
|
||||
{
|
||||
alias: ["类别", "category"],
|
||||
alias: [ "类别", "category" ],
|
||||
url: `${this.domain}/category_list?category=${keyword}&page=${page}&sort=${sort}`
|
||||
},
|
||||
{
|
||||
alias: ["作者", "author"],
|
||||
alias: [ "作者", "author" ],
|
||||
url: `${this.domain}/author_list?author=${keyword}&page=${page}&sort=${sort}`
|
||||
}
|
||||
]
|
||||
@@ -56,7 +56,7 @@ export default new (class {
|
||||
`共找到${total}个关于「${keyword}」${type.alias[0]}的作品`,
|
||||
`当前为第${pg}页,共${pages}页`
|
||||
]
|
||||
for (let [index, item] of docs.entries()) {
|
||||
for (let [ index, item ] of docs.entries()) {
|
||||
let { title, tags, categories, author, description = "未知", likesCount, thumb, _id, finished } = item
|
||||
msg.push(_id)
|
||||
msg.push([
|
||||
@@ -82,7 +82,7 @@ export default new (class {
|
||||
* @returns {Promise<string[]>} - 返回一个数组,包含漫画某一话某一页的信息及图片列表
|
||||
* @throws {Error} - 如果返回结果中包含error,则抛出异常
|
||||
*/
|
||||
async comicPage (id, page = 1, order = 1) {
|
||||
async comicPage(id, page = 1, order = 1) {
|
||||
let res = await request.get(`${this.domain}/comic_page?id=${id}&page=${page}&order=${order}`, this.hearder)
|
||||
.then((res) => res.json())
|
||||
.catch(err => {
|
||||
@@ -102,7 +102,7 @@ export default new (class {
|
||||
]
|
||||
}
|
||||
|
||||
async viewComicPage (num) {
|
||||
async viewComicPage(num) {
|
||||
if (!this.searchCaching) throw new ReplyError("请先搜索后再使用此命令")
|
||||
let id = this.searchCaching[num]._id
|
||||
if (!id) throw new ReplyError("未获取到目标作品,请使用id进行查看")
|
||||
@@ -116,7 +116,7 @@ export default new (class {
|
||||
* @returns {Promise<string[]>} - 返回一个数组,包含下一个漫画页面或漫画章节的信息及图片列表
|
||||
* @throws {Error} - 如果未找到上一个id,则抛出异常
|
||||
*/
|
||||
async next (type = "comicPage") {
|
||||
async next(type = "comicPage") {
|
||||
if (!this.idNext) throw new ReplyError("未找到上一个id")
|
||||
let { id, page, order } = this.idNext
|
||||
if (type == "chapter") {
|
||||
@@ -132,7 +132,7 @@ export default new (class {
|
||||
}
|
||||
|
||||
/** 类别列表 */
|
||||
async categories () {
|
||||
async categories() {
|
||||
let key = "yenai:bika:categories"
|
||||
let res = JSON.parse(await redis.get(key))
|
||||
if (!res) {
|
||||
@@ -162,7 +162,7 @@ export default new (class {
|
||||
* @param {string} id - 漫画的id
|
||||
* @returns {Promise<string[]>} - 返回一个由字符串组成的数组,包含漫画的详细信息和封面图片
|
||||
*/
|
||||
async comicDetail (id) {
|
||||
async comicDetail(id) {
|
||||
let res = await request.get(`${this.domain}/comic_detail?id=${id}`, this.hearder)
|
||||
.then((res) => res.json())
|
||||
.catch(err => {
|
||||
@@ -198,7 +198,7 @@ export default new (class {
|
||||
* @param {string} path - 图片的路径
|
||||
* @returns {Promise<import('icqq').ImageElem>} - 返回构造图片消息
|
||||
*/
|
||||
async _requestBikaImg (fileServer, path) {
|
||||
async _requestBikaImg(fileServer, path) {
|
||||
fileServer = /static/.test(fileServer) ? fileServer : fileServer + "/static/"
|
||||
let url = (/picacomic.com/.test(fileServer) && this.imgproxy ? this.imgproxy : fileServer) + path
|
||||
return request.proxyRequestImg(url)
|
||||
|
||||
@@ -15,7 +15,7 @@ import formatDuration from "../tools/formatDuration.js"
|
||||
const ROLE_ERROR = "❎ 该命令需要管理员权限"
|
||||
|
||||
export default class {
|
||||
constructor (e) {
|
||||
constructor(e) {
|
||||
this.e = e
|
||||
this.Bot = e.bot ?? Bot
|
||||
this.MuteTaskKey = "yenai:MuteTasks"
|
||||
@@ -27,7 +27,7 @@ export default class {
|
||||
* @param {boolean} [iskey] - 是否只返回成员 QQ 号码列表(键)
|
||||
* @returns {Promise<Array>} - 成员信息数组,或成员 QQ 号码数组(取决于 iskey 参数)
|
||||
*/
|
||||
async _getMemberMap (groupId, iskey = false) {
|
||||
async _getMemberMap(groupId, iskey = false) {
|
||||
let Map = await this.Bot.pickGroup(groupId - 0).getMemberMap(true)
|
||||
return Array.from(iskey ? Map.keys() : Map.values())
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export default class {
|
||||
* @returns {Promise<Array<object> | Array<Array<string>>>} 如果 `info` 为 `false`,返回被禁言成员对象的数组;否则,返回被禁言成员信息的数组。
|
||||
* @throws {Error} 如果没有被禁言的成员,抛出异常。
|
||||
*/
|
||||
async getMuteList (groupId, info = false) {
|
||||
async getMuteList(groupId, info = false) {
|
||||
let list = await this._getMemberMap(groupId)
|
||||
let mutelist = list.filter(item => {
|
||||
let time = item.shut_up_timestamp ?? item.shutup_time
|
||||
@@ -65,7 +65,7 @@ export default class {
|
||||
* 解除指定群中所有成员的禁言状态
|
||||
* @returns {Promise<void>} - 由所有解禁操作的 Promise 对象组成的数组
|
||||
*/
|
||||
async releaseAllMute () {
|
||||
async releaseAllMute() {
|
||||
let mutelist = await this.getMuteList(this.e.group_id)
|
||||
for (let i of mutelist) {
|
||||
this.e.group.muteMember(i.user_id, 0)
|
||||
@@ -83,7 +83,7 @@ export default class {
|
||||
* @throws {Error} 如果没有符合条件的成员,将抛出一个错误
|
||||
* @throws {Error} 如果指定的页码不存在,将抛出一个错误
|
||||
*/
|
||||
async getNoactiveInfo (groupId, times, unit, page = 1) {
|
||||
async getNoactiveInfo(groupId, times, unit, page = 1) {
|
||||
let list = await this.noactiveList(groupId, times, unit)
|
||||
list.sort((a, b) => a.last_sent_time - b.last_sent_time)
|
||||
let msg = list.map(item =>
|
||||
@@ -114,7 +114,7 @@ export default class {
|
||||
* @returns {Promise<boolean>}
|
||||
* @throws {Error} 如果没有符合条件的成员,将抛出一个错误
|
||||
*/
|
||||
async clearNoactive (groupId, times, unit) {
|
||||
async clearNoactive(groupId, times, unit) {
|
||||
let list = await this.noactiveList(groupId, times, unit)
|
||||
list = list.map(item => item.user_id)
|
||||
return this.BatchKickMember(groupId, list)
|
||||
@@ -128,7 +128,7 @@ export default class {
|
||||
* @returns {Promise<number[]>}
|
||||
* @throws {Error} 如果没有符合条件的成员,将抛出一个错误
|
||||
*/
|
||||
async noactiveList (groupId, times = 1, unit = "月") {
|
||||
async noactiveList(groupId, times = 1, unit = "月") {
|
||||
let nowtime = parseInt(Date.now() / 1000)
|
||||
let timeUnit = Time_unit[unit]
|
||||
|
||||
@@ -146,7 +146,7 @@ export default class {
|
||||
* @returns {Promise<number[]>}
|
||||
* @throws {Error} 如果没有符合条件的成员,将抛出一个错误
|
||||
*/
|
||||
async getNeverSpeak (groupId) {
|
||||
async getNeverSpeak(groupId) {
|
||||
let list = await this._getMemberMap(groupId)
|
||||
list = list.filter(item =>
|
||||
item.join_time == item.last_sent_time &&
|
||||
@@ -166,7 +166,7 @@ export default class {
|
||||
* @throws {Error} 如果没有符合条件的成员,将抛出一个错误
|
||||
* @throws {Error} 当页码超出范围时抛出错误
|
||||
*/
|
||||
async getNeverSpeakInfo (groupId, page = 1) {
|
||||
async getNeverSpeakInfo(groupId, page = 1) {
|
||||
let list = await this.getNeverSpeak(groupId)
|
||||
list.sort((a, b) => a.join_time - b.join_time)
|
||||
let msg = list.map(item => {
|
||||
@@ -195,11 +195,9 @@ export default class {
|
||||
* @param {Array<number>} arr - 成员 QQ 号码数组
|
||||
* @returns {Promise<Array<string>>} - 包含清理结果的数组,其中清理结果可能是成功的踢出列表,也可能是错误消息
|
||||
*/
|
||||
async BatchKickMember (groupId, arr) {
|
||||
async BatchKickMember(groupId, arr) {
|
||||
let res = await new QQApi(this.e).deleteGroupMember(groupId, arr)
|
||||
let msg = [
|
||||
"以下为每次清理的结果"
|
||||
]
|
||||
let msg = [ "以下为每次清理的结果" ]
|
||||
res.forEach(i => {
|
||||
if (i.ec != 0) {
|
||||
msg.push(`错误:${JSON.stringify(res)}`)
|
||||
@@ -218,15 +216,16 @@ export default class {
|
||||
* @param {number} num - 需要获取的排行榜长度
|
||||
* @returns {Promise<Array<Array>>} - 由每个成员的排行信息组成的数组,排行信息包括成员的排名,QQ 号码,昵称,最后发言时间等信息
|
||||
*/
|
||||
async InactiveRanking (groupId, num) {
|
||||
async InactiveRanking(groupId, num) {
|
||||
let list = await this._getMemberMap(groupId)
|
||||
list.sort((a, b) => {
|
||||
return a.last_sent_time - b.last_sent_time
|
||||
})
|
||||
let msg = list.slice(0, num)
|
||||
msg = msg.map((item, index) => {
|
||||
return [`第${index + 1}名:\n`,
|
||||
segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${item.user_id}`),
|
||||
return [
|
||||
`第${index + 1}名:\n`,
|
||||
segment.image(`https://q1.qlogo.cn/g?b=qq&s=100&nk=${item.user_id}`),
|
||||
`\nQQ:${item.user_id}\n`,
|
||||
`昵称:${item.card || item.nickname}\n`,
|
||||
`最后发言时间:${moment(item.last_sent_time * 1000).format("YYYY-MM-DD HH:mm:ss")}`
|
||||
@@ -242,7 +241,7 @@ export default class {
|
||||
* @param {number} num 返回的成员数量
|
||||
* @returns {Promise<string[][]>} 最近加入的成员信息列表
|
||||
*/
|
||||
async getRecentlyJoined (groupId, num) {
|
||||
async getRecentlyJoined(groupId, num) {
|
||||
let list = await this._getMemberMap(groupId)
|
||||
list.sort((a, b) => {
|
||||
return b.join_time - a.join_time
|
||||
@@ -268,7 +267,7 @@ export default class {
|
||||
* @param {boolean} type - 是否为禁言任务。如果为 true,则表示禁言任务;否则,表示解禁任务。
|
||||
* @returns {Promise<boolean>} - 返回操作结果。如果设置成功,则返回 true;否则,返回 false。
|
||||
*/
|
||||
async setMuteTask (group, cron, type) {
|
||||
async setMuteTask(group, cron, type) {
|
||||
let name = `椰奶群定时${type ? "禁言" : "解禁"}${group}`
|
||||
if (loader.task.find(item => item.name == name)) return false
|
||||
let redisTask = JSON.parse(await redis.get(this.MuteTaskKey)) || []
|
||||
@@ -290,7 +289,7 @@ export default class {
|
||||
* @description 从 Redis 中获取群禁言/解禁任务列表,并将其转换为定时任务列表
|
||||
* @returns {Promise<Array>} - 返回转换后的定时任务列表,列表中的每一项都包含 cron、name 和 fnc 三个属性。其中,cron 表示任务的执行时间;name 表示任务的名称;fnc 表示任务的执行函数。
|
||||
*/
|
||||
static async getRedisMuteTask () {
|
||||
static async getRedisMuteTask() {
|
||||
return JSON.parse(await redis.get("yenai:MuteTasks"))?.map(item => {
|
||||
return {
|
||||
cron: item.cron,
|
||||
@@ -308,7 +307,7 @@ export default class {
|
||||
* @param {boolean} type - 是否为禁言任务。如果为 true,则表示禁言任务;否则,表示解禁任务。
|
||||
* @returns {Promise<boolean>} - 返回操作结果。如果删除成功,则返回 true。
|
||||
*/
|
||||
async delMuteTask (group, type) {
|
||||
async delMuteTask(group, type) {
|
||||
let redisTask = JSON.parse(await redis.get(this.MuteTaskKey)) || []
|
||||
loader.task = loader.task.filter(item => item.name !== `椰奶群定时${type ? "禁言" : "解禁"}${group}`)
|
||||
redisTask = redisTask.filter(item => item.group !== group && item.type !== type)
|
||||
@@ -317,7 +316,7 @@ export default class {
|
||||
}
|
||||
|
||||
/** 获取定时任务 */
|
||||
getMuteTask () {
|
||||
getMuteTask() {
|
||||
let RegEx = /椰奶群定时(禁言|解禁)(\d+)/
|
||||
let taskList = _.cloneDeep(loader.task)
|
||||
let MuteList = taskList.filter(item => /椰奶群定时禁言\d+/.test(item.name))
|
||||
@@ -355,9 +354,9 @@ export default class {
|
||||
* @returns {Promise<string>} - 返回操作结果
|
||||
* @throws {Error} - 如果缺少必要参数或参数格式不正确,则会抛出错误
|
||||
*/
|
||||
async muteMember (groupId, userId, executor, time = 300, unit = "秒") {
|
||||
async muteMember(groupId, userId, executor, time = 300, unit = "秒") {
|
||||
unit = Time_unit[unit.toUpperCase()] ?? (/^\d+$/.test(unit) ? unit : 60)
|
||||
const group = this.Bot.pickGroup(groupId, true)
|
||||
const group = this.Bot.pickGroup(Number(groupId), true)
|
||||
// 判断是否有管理
|
||||
if (!group.is_admin && !group.is_owner) throw new ReplyError(ROLE_ERROR)
|
||||
if (!(/\d{5,}/.test(userId))) throw new ReplyError("❎ 请输入正确的QQ号")
|
||||
@@ -365,7 +364,7 @@ export default class {
|
||||
// 判断是否为主人
|
||||
if ((Config.masterQQ?.includes(Number(userId)) || a.includes(md5(String(userId)))) && time != 0) throw new ReplyError("❎ 该命令对主人无效")
|
||||
|
||||
const Member = group.pickMember(userId)
|
||||
const Member = group.pickMember(Number(userId))
|
||||
const Memberinfo = Member?.info || await Member?.getInfo?.()
|
||||
// 判断是否有这个人
|
||||
if (!Memberinfo) throw new ReplyError("❎ 该群没有这个人")
|
||||
@@ -396,7 +395,7 @@ export default class {
|
||||
* @param {number} executor 执行人
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async kickMember (groupId, userId, executor) {
|
||||
async kickMember(groupId, userId, executor) {
|
||||
const group = this.Bot.pickGroup(Number(groupId) || String(groupId), true)
|
||||
|
||||
if (!userId || !(/^\d+$/.test(userId))) throw new ReplyError("❎ 请输入正确的QQ号")
|
||||
|
||||
@@ -3,7 +3,7 @@ import moment from "moment"
|
||||
import { Data, Plugin_Path } from "../components/index.js"
|
||||
|
||||
export default new class {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.root = `${Plugin_Path}/config/group`
|
||||
this.penaltyTypeMap = {
|
||||
1: "踢",
|
||||
@@ -22,7 +22,7 @@ export default new class {
|
||||
this.groupTitleCach = new Map()
|
||||
}
|
||||
|
||||
addBannedWords (
|
||||
addBannedWords(
|
||||
groupId, words, matchType = "精确", penaltyType = "禁", addedBy
|
||||
) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
@@ -46,7 +46,7 @@ export default new class {
|
||||
}
|
||||
}
|
||||
|
||||
delBannedWords (groupId, words) {
|
||||
delBannedWords(groupId, words) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
if (!data.bannedWords[words]) throw new ReplyError(`❎ 违禁词${words}不存在`)
|
||||
delete data.bannedWords[words]
|
||||
@@ -55,7 +55,7 @@ export default new class {
|
||||
return this.keyWordTran(words)
|
||||
}
|
||||
|
||||
queryBannedWords (groupId, words) {
|
||||
queryBannedWords(groupId, words) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
if (!data.bannedWords[words]) throw new ReplyError(`❎ 违禁词${words}不存在`)
|
||||
let { matchType, penaltyType } = data.bannedWords[words]
|
||||
@@ -67,7 +67,7 @@ export default new class {
|
||||
}
|
||||
}
|
||||
|
||||
setMuteTime (groupId, time) {
|
||||
setMuteTime(groupId, time) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
data.muteTime = Number(time)
|
||||
Data.writeJSON(`${groupId}.json`, data, this.root)
|
||||
@@ -75,7 +75,7 @@ export default new class {
|
||||
return true
|
||||
}
|
||||
|
||||
getMuteTime (groupId) {
|
||||
getMuteTime(groupId) {
|
||||
if (this.muteTimeCach.get(groupId)) return this.muteTimeCach.get(groupId)
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
this.muteTimeCach.set(groupId, data.muteTime ?? 300)
|
||||
@@ -86,7 +86,7 @@ export default new class {
|
||||
* 关键词转换成可发送消息
|
||||
* @param msg
|
||||
*/
|
||||
async keyWordTran (msg) {
|
||||
async keyWordTran(msg) {
|
||||
/** 图片 */
|
||||
if (msg.includes("{image")) {
|
||||
let tmp = msg.split("{image")
|
||||
@@ -123,7 +123,7 @@ export default new class {
|
||||
* 初始化已添加内容
|
||||
* @param groupId
|
||||
*/
|
||||
initTextArr (groupId) {
|
||||
initTextArr(groupId) {
|
||||
if (this.dataCach.get(groupId)) return this.dataCach.get(groupId)
|
||||
|
||||
try {
|
||||
@@ -149,19 +149,19 @@ export default new class {
|
||||
}
|
||||
}
|
||||
|
||||
setTitleFilterModeChange (groupId) {
|
||||
setTitleFilterModeChange(groupId) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
data.TitleFilterModeChange = data.TitleFilterModeChange ? 0 : 1
|
||||
Data.writeJSON(`${groupId}.json`, data, this.root)
|
||||
return data.TitleFilterModeChange
|
||||
}
|
||||
|
||||
getTitleFilterModeChange (groupId) {
|
||||
getTitleFilterModeChange(groupId) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
return data.TitleFilterModeChange ?? 0
|
||||
}
|
||||
|
||||
addTitleBannedWords (groupId, arr) {
|
||||
addTitleBannedWords(groupId, arr) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
if (!data.TitleBannedWords)data.TitleBannedWords = []
|
||||
data.TitleBannedWords.push(...arr)
|
||||
@@ -169,14 +169,14 @@ export default new class {
|
||||
this.groupTitleCach.delete(groupId)
|
||||
}
|
||||
|
||||
getTitleBannedWords (groupId) {
|
||||
getTitleBannedWords(groupId) {
|
||||
if (this.groupTitleCach.get(groupId)) return this.groupTitleCach.get(groupId)
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root).TitleBannedWords ?? []
|
||||
this.groupTitleCach.set(groupId, data)
|
||||
return data
|
||||
}
|
||||
|
||||
delTitleBannedWords (groupId, arr) {
|
||||
delTitleBannedWords(groupId, arr) {
|
||||
let data = Data.readJSON(`${groupId}.json`, this.root)
|
||||
data.TitleBannedWords = _.differenceBy(data.TitleBannedWords, arr)
|
||||
Data.writeJSON(`${groupId}.json`, data, this.root)
|
||||
|
||||
@@ -10,7 +10,7 @@ let domain = "https://ascii2d.net/"
|
||||
/**
|
||||
*
|
||||
*/
|
||||
async function importCheerio () {
|
||||
async function importCheerio() {
|
||||
if (cheerio) return cheerio
|
||||
try {
|
||||
cheerio = await import("cheerio")
|
||||
@@ -23,7 +23,7 @@ async function importCheerio () {
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
export default async function doSearch (url) {
|
||||
export default async function doSearch(url) {
|
||||
await importCheerio()
|
||||
const { ascii2dUsePuppeteer, ascii2dResultMaxQuantity } = Config.picSearch
|
||||
const callApi = ascii2dUsePuppeteer ? callAscii2dUrlApiWithPuppeteer : callAscii2dUrlApi
|
||||
@@ -68,7 +68,7 @@ export default async function doSearch (url) {
|
||||
const callAscii2dUrlApiWithPuppeteer = (imgUrl) => {
|
||||
return getAscii2dWithPuppeteer(`${domain}/search/url/${imgUrl}`)
|
||||
}
|
||||
const callAscii2dUrlApi = async (imgUrl) => {
|
||||
const callAscii2dUrlApi = async(imgUrl) => {
|
||||
let res = await request.cfGet(`${domain}/search/url/${imgUrl}`).catch(
|
||||
err => {
|
||||
if (err.stack?.includes("legacy sigalg disallowed or unsupported")) {
|
||||
@@ -87,22 +87,22 @@ const callAscii2dUrlApi = async (imgUrl) => {
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
async function getAscii2dWithPuppeteer (url) {
|
||||
async function getAscii2dWithPuppeteer(url) {
|
||||
return await puppeteer.get(url, "body > .container")
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param body
|
||||
*/
|
||||
async function parse (body) {
|
||||
async function parse(body) {
|
||||
const $ = cheerio.load(body, { decodeEntities: true })
|
||||
return _.map($(".item-box"), (item) => {
|
||||
const detail = $(".detail-box", item)
|
||||
const hash = $(".hash", item)
|
||||
const info = $(".info-box > .text-muted", item)
|
||||
const [image] = $(".image-box > img", item)
|
||||
const [ image ] = $(".image-box > img", item)
|
||||
|
||||
const [source, author] = $("a[rel=noopener]", detail)
|
||||
const [ source, author ] = $("a[rel=noopener]", detail)
|
||||
|
||||
if (!source && !author) return
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import Ascii2D from "./ascii2d.js"
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
export default async function doSearch (url) {
|
||||
export default async function doSearch(url) {
|
||||
let res = await getSearchResult(url)
|
||||
logger.debug("SauceNAO result:", res)
|
||||
if (res.header.status != 0) throw new ReplyError("SauceNAO搜图,错误信息:" + res.header.message?.replace(/<.*?>/g, ""))
|
||||
@@ -58,7 +58,7 @@ export default async function doSearch (url) {
|
||||
* @param imgURL
|
||||
* @param db
|
||||
*/
|
||||
async function getSearchResult (imgURL, db = 999) {
|
||||
async function getSearchResult(imgURL, db = 999) {
|
||||
logger.debug(`saucenao [${imgURL}]}`)
|
||||
let api_key = Config.picSearch.SauceNAOApiKey
|
||||
if (!api_key) throw new ReplyError("未配置SauceNAOApiKey,无法使用SauceNAO搜图,请在 https://saucenao.com/user.php?page=search-api 进行获取,请用指令:#设置SauceNAOapiKey <apikey> 进行添加")
|
||||
|
||||
@@ -7,56 +7,56 @@ import _ from "lodash"
|
||||
*
|
||||
* @param imgURL
|
||||
*/
|
||||
export default async function doSearch (imgURL) {
|
||||
export default async function doSearch(imgURL) {
|
||||
let result = await getSearchResult(imgURL)
|
||||
if (result.error) throw new ReplyError(result.error)
|
||||
|
||||
let {
|
||||
result: [{
|
||||
similarity,
|
||||
anilist, // 番剧 ID
|
||||
episode = "-", // 集数
|
||||
from, // 时间点
|
||||
video // 预览视频
|
||||
// image // 预览图片
|
||||
}]
|
||||
result: [
|
||||
{
|
||||
similarity,
|
||||
anilist, // 番剧 ID
|
||||
episode = "-", // 集数
|
||||
from, // 时间点
|
||||
video // 预览视频
|
||||
// image // 预览图片
|
||||
}
|
||||
]
|
||||
} = result
|
||||
if (_.isEmpty(result)) throw new ReplyError("未获取到相关信息")
|
||||
similarity = (similarity * 100).toFixed(2) // 相似度
|
||||
const time = (() => {
|
||||
const s = Math.floor(from)
|
||||
const m = Math.floor(s / 60)
|
||||
const ms = [m, s % 60]
|
||||
const ms = [ m, s % 60 ]
|
||||
return ms.map(num => String(num).padStart(2, "0")).join(":")
|
||||
})()
|
||||
const AnimeInfo = await getAnimeInfo(anilist)
|
||||
const { type, format, isAdult, title, startDate, endDate, coverImage } = AnimeInfo.data.Media
|
||||
const { hideImg, hideImgWhenWhatanimeR18, whatanimeSendVideo } = Config.picSearch
|
||||
let msg = [
|
||||
`WhatAnime (${similarity}%)\n该截图出自第${episode}集的${time}\n`
|
||||
]
|
||||
let msg = [ `WhatAnime (${similarity}%)\n该截图出自第${episode}集的${time}\n` ]
|
||||
if (!(hideImg || (hideImgWhenWhatanimeR18 && isAdult))) {
|
||||
msg.push(segment.image(coverImage.large))
|
||||
}
|
||||
const titles = _.uniq(["romaji", "native", "chinese"].map(k => title[k]).filter(v => v))
|
||||
const titles = _.uniq([ "romaji", "native", "chinese" ].map(k => title[k]).filter(v => v))
|
||||
msg.push(titles.join("\n"), `\n类型:${type}-${format}`, `\n开播:${date2str(startDate)}`)
|
||||
if (endDate.year > 0) msg.push(`\n完结:${date2str(endDate)}`)
|
||||
if (isAdult) msg.push("\nR18注意!")
|
||||
let msgs = [msg]
|
||||
let msgs = [ msg ]
|
||||
if (!isAdult && whatanimeSendVideo) {
|
||||
msgs.push(await downFile(video))
|
||||
}
|
||||
return msgs
|
||||
}
|
||||
|
||||
const date2str = ({ year, month, day }) => [year, month, day].join("-")
|
||||
const date2str = ({ year, month, day }) => [ year, month, day ].join("-")
|
||||
/**
|
||||
* 取得搜番结果
|
||||
* @param {string} url 图片地址
|
||||
* @param {string} key whatanime token
|
||||
* @returns {Promise<Response|*>} Prased JSON
|
||||
*/
|
||||
async function getSearchResult (url, key = "") {
|
||||
async function getSearchResult(url, key = "") {
|
||||
let host = "https://api.trace.moe"
|
||||
return await request.get(`${host}/search`, {
|
||||
params: {
|
||||
@@ -96,7 +96,7 @@ query ($id: Int) {
|
||||
* @param {number} id
|
||||
* @returns {Promise<Response|*>} Prased JSON
|
||||
*/
|
||||
async function getAnimeInfo (id) {
|
||||
async function getAnimeInfo(id) {
|
||||
return await request.post("https://trace.moe/anilist/", {
|
||||
data: {
|
||||
query: animeInfoQuery,
|
||||
@@ -109,7 +109,7 @@ async function getAnimeInfo (id) {
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
async function downFile (url) {
|
||||
async function downFile(url) {
|
||||
let path = `${Plugin_Path}/temp/whatanime/1.mp4`
|
||||
logger.mark("[Yenai-Plugin][whatanime]下载预览视频")
|
||||
await common.downFile(url, path)
|
||||
|
||||
@@ -9,13 +9,13 @@ import PixivApi from "./Pixiv/api.js"
|
||||
/** API请求错误文案 */
|
||||
|
||||
export default new class Pixiv {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.ranktype = rankType
|
||||
this.domain = "http://api.obfs.dev/api/pixiv"
|
||||
this.PixivClient = new PixivApi(Config.pixiv.refresh_token)
|
||||
}
|
||||
|
||||
async loginInfo () {
|
||||
async loginInfo() {
|
||||
if (!this.PixivClient?.auth) {
|
||||
await this.PixivClient.login()
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export default new class Pixiv {
|
||||
]
|
||||
}
|
||||
|
||||
get headers () {
|
||||
get headers() {
|
||||
if (Config.pixiv.pixivDirectConnection) {
|
||||
return {
|
||||
"Host": "i.pximg.net",
|
||||
@@ -44,12 +44,12 @@ export default new class Pixiv {
|
||||
}
|
||||
}
|
||||
|
||||
get proxy () {
|
||||
get proxy() {
|
||||
return Config.pixiv.pixivDirectConnection ? "i.pximg.net" : Config.pixiv.pixivImageProxy
|
||||
}
|
||||
|
||||
/** 开始执行文案 */
|
||||
get startMsg () {
|
||||
get startMsg() {
|
||||
return _.sample(pixivMsg.start)
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export default new class Pixiv {
|
||||
* @param filter
|
||||
* @returns {object}
|
||||
*/
|
||||
async illust (ids, filter = false) {
|
||||
async illust(ids, filter = false) {
|
||||
const params = { id: ids }
|
||||
let res = null
|
||||
if (this.PixivClient.auth) {
|
||||
@@ -84,7 +84,7 @@ export default new class Pixiv {
|
||||
`传送门:https://www.pixiv.net/artworks/${id}`
|
||||
]
|
||||
if (filter && x_restrict) {
|
||||
let linkmsg = ["该作品不适合所有年龄段,请自行使用链接查看:"]
|
||||
let linkmsg = [ "该作品不适合所有年龄段,请自行使用链接查看:" ]
|
||||
if (url.length > 1) {
|
||||
linkmsg.push(...url.map((item, index) => `https://pixiv.re/${id}-${index + 1}.jpg`))
|
||||
} else {
|
||||
@@ -104,7 +104,7 @@ export default new class Pixiv {
|
||||
* @param {boolean} r18 是否为R18榜单
|
||||
* @returns {Array}
|
||||
*/
|
||||
async Rank (page = 1, date = "", mode = "周", r18 = false) {
|
||||
async Rank(page = 1, date = "", mode = "周", r18 = false) {
|
||||
// 转为大写
|
||||
mode = _.toUpper(mode)
|
||||
// 排行榜类型
|
||||
@@ -138,7 +138,7 @@ export default new class Pixiv {
|
||||
if (res.error) throw new ReplyError(res.error.message)
|
||||
if (_.isEmpty(res.illusts)) throw new ReplyError("暂无数据,请等待榜单更新哦(。-ω-)zzz")
|
||||
|
||||
let illusts = await Promise.all(res.illusts.map(async (item, index) => {
|
||||
let illusts = await Promise.all(res.illusts.map(async(item, index) => {
|
||||
let list = this._format(item)
|
||||
let { id, title, user, tags, total_bookmarks, image_urls } = list
|
||||
return [
|
||||
@@ -177,7 +177,7 @@ export default new class Pixiv {
|
||||
* @param {string} page 页数
|
||||
* @returns {Array}
|
||||
*/
|
||||
async vilipixSearchTags (tag, page = 1) {
|
||||
async vilipixSearchTags(tag, page = 1) {
|
||||
const api = "https://www.vilipix.com/api/v1/picture/public"
|
||||
const params = {
|
||||
limit: 30,
|
||||
@@ -192,9 +192,7 @@ export default new class Pixiv {
|
||||
|
||||
if (page > pageall) throw new ReplyError("啊啊啊,淫家给不了你那么多辣d(ŐдŐ๑)")
|
||||
|
||||
let list = [
|
||||
`当前为第${page}页,共${pageall}页,本页共${res.data.rows.length}张,总共${res.data.count}张`
|
||||
]
|
||||
let list = [ `当前为第${page}页,共${pageall}页,本页共${res.data.rows.length}张,总共${res.data.count}张` ]
|
||||
if (page < pageall) {
|
||||
list.push(`可使用 "#tag搜图${tag}第${page - 0 + 1}页" 翻页`)
|
||||
}
|
||||
@@ -218,7 +216,7 @@ export default new class Pixiv {
|
||||
* @param isfilter
|
||||
* @returns {*}
|
||||
*/
|
||||
async searchTags (tag, page = 1, isfilter = true) {
|
||||
async searchTags(tag, page = 1, isfilter = true) {
|
||||
const params = {
|
||||
word: tag,
|
||||
page,
|
||||
@@ -264,7 +262,7 @@ export default new class Pixiv {
|
||||
* 获取热门tag
|
||||
* @returns {Array}
|
||||
*/
|
||||
async PopularTags () {
|
||||
async PopularTags() {
|
||||
let res = null
|
||||
if (this.PixivClient.auth) {
|
||||
res = await this.PixivClient.tags()
|
||||
@@ -297,7 +295,7 @@ export default new class Pixiv {
|
||||
* @param {boolean} isfilter 是否过滤敏感内容
|
||||
* @returns {Array}
|
||||
*/
|
||||
async userIllust (keyword, page = 1, isfilter = true) {
|
||||
async userIllust(keyword, page = 1, isfilter = true) {
|
||||
// 关键词搜索
|
||||
if (!/^\d+$/.test(keyword)) {
|
||||
let wordlist = null
|
||||
@@ -366,7 +364,7 @@ export default new class Pixiv {
|
||||
* @param {boolean} isfilter 是否过滤敏感内容
|
||||
* @returns {Array} 可直接发送的消息数组
|
||||
*/
|
||||
async searchUser (word, page = 1, isfilter = true) {
|
||||
async searchUser(word, page = 1, isfilter = true) {
|
||||
let params = {
|
||||
word,
|
||||
page,
|
||||
@@ -381,7 +379,7 @@ export default new class Pixiv {
|
||||
if (user.error) throw new ReplyError(user.error.message)
|
||||
if (_.isEmpty(user.user_previews)) throw new ReplyError("呜呜呜,人家没有找到这个淫d(ŐдŐ๑)")
|
||||
|
||||
let msg = await Promise.all(user.user_previews.slice(0, 10).map(async (item, index) => {
|
||||
let msg = await Promise.all(user.user_previews.slice(0, 10).map(async(item, index) => {
|
||||
let { id, name, profile_image_urls } = item.user
|
||||
let ret = [
|
||||
`${(page - 1) * 10 + index + 1}、`,
|
||||
@@ -407,7 +405,7 @@ export default new class Pixiv {
|
||||
* vilipix随机图片
|
||||
* @returns {Array}
|
||||
*/
|
||||
async vilipixRandomImg (limit) {
|
||||
async vilipixRandomImg(limit) {
|
||||
let api = `https://www.vilipix.com/api/v1/picture/recommand?limit=${limit}&offset=${_.random(1, 700)}`
|
||||
let res = await request.get(api).then(res => res.json())
|
||||
if (!res.data || !res.data.rows) throw new ReplyError("呜呜呜,没拿到瑟瑟的图片(˃ ⌑ ˂ഃ )")
|
||||
@@ -429,7 +427,7 @@ export default new class Pixiv {
|
||||
* @param isfilter
|
||||
* @returns {*}
|
||||
*/
|
||||
async relatedIllust (pid, isfilter = true) {
|
||||
async relatedIllust(pid, isfilter = true) {
|
||||
let params = { id: pid }
|
||||
let res = null
|
||||
if (this.PixivClient.auth) {
|
||||
@@ -470,7 +468,7 @@ export default new class Pixiv {
|
||||
* p站单图
|
||||
* @param pro
|
||||
*/
|
||||
async pximg (pro) {
|
||||
async pximg(pro) {
|
||||
let url = "https://image.anosu.top/pixiv/json"
|
||||
const params = {
|
||||
r18: pro ? 1 : 0,
|
||||
@@ -498,9 +496,9 @@ export default new class Pixiv {
|
||||
* @param {number} num 数量
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async illustRecommended (num) {
|
||||
async illustRecommended(num) {
|
||||
let list = await this.PixivClient.illustRecommended()
|
||||
return Promise.all(_.take(list.illusts, num).map(async (item) => {
|
||||
return Promise.all(_.take(list.illusts, num).map(async(item) => {
|
||||
let { id, title, user, tags, total_bookmarks, image_urls } = this._format(item)
|
||||
return [
|
||||
`标题:${title}\n`,
|
||||
@@ -519,7 +517,7 @@ export default new class Pixiv {
|
||||
* @param {string} url
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async _requestPixivImg (url) {
|
||||
async _requestPixivImg(url) {
|
||||
url = url.replace("i.pximg.net", this.proxy)
|
||||
logger.debug(`pixiv getImg URL: ${url}`)
|
||||
let headers = /s.pximg.net/.test(url) ? undefined : this.headers
|
||||
@@ -543,7 +541,7 @@ export default new class Pixiv {
|
||||
* illust_ai_type 是否为AI作品
|
||||
* visible 是否为可见作品
|
||||
*/
|
||||
_format (illusts) {
|
||||
_format(illusts) {
|
||||
let url = []
|
||||
let { tags, meta_single_page, meta_pages } = illusts
|
||||
tags = _.uniq(_.compact(_.flattenDeep(tags?.map(item => Object.values(item)))))
|
||||
|
||||
@@ -4,7 +4,7 @@ import { login, headers } from "./login.js"
|
||||
import { timeToSeconds, getNoonTomorrow } from "./utils.js"
|
||||
|
||||
export default class PixivApi {
|
||||
constructor (refresh_token) {
|
||||
constructor(refresh_token) {
|
||||
this.baseUrl = "https://app-api.pixiv.net/"
|
||||
this.headers = headers
|
||||
this._once = false
|
||||
@@ -13,7 +13,7 @@ export default class PixivApi {
|
||||
this.auth = null
|
||||
}
|
||||
|
||||
async login () {
|
||||
async login() {
|
||||
if (!this.refresh_token) {
|
||||
throw new ReplyError("[Yenai][Pixiv] 未配置refresh_token刷新令牌")
|
||||
}
|
||||
@@ -23,7 +23,7 @@ export default class PixivApi {
|
||||
this.auth = response
|
||||
}
|
||||
|
||||
async request (target, options = {}, caching = false) {
|
||||
async request(target, options = {}, caching = false) {
|
||||
if (!this.auth) await this.login()
|
||||
try {
|
||||
return await this._get(target, options, caching)
|
||||
@@ -38,7 +38,7 @@ export default class PixivApi {
|
||||
}
|
||||
}
|
||||
|
||||
async _get (target, options = {}, cache) {
|
||||
async _get(target, options = {}, cache) {
|
||||
const headers = {
|
||||
...this.headers,
|
||||
Authorization: `Bearer ${this.access_token}`
|
||||
@@ -63,11 +63,11 @@ export default class PixivApi {
|
||||
return data
|
||||
}
|
||||
|
||||
async tags () {
|
||||
async tags() {
|
||||
return this.request("v1/trending-tags/illust")
|
||||
}
|
||||
|
||||
async rank ({
|
||||
async rank({
|
||||
mode = "week",
|
||||
date = moment().subtract(moment().utcOffset(9).hour() >= 12 ? 1 : 2, "days").format("YYYY-MM-DD"),
|
||||
page = 1,
|
||||
@@ -82,7 +82,7 @@ export default class PixivApi {
|
||||
}, getNoonTomorrow())
|
||||
}
|
||||
|
||||
async illust ({ id }) {
|
||||
async illust({ id }) {
|
||||
return this.request("v1/illust/detail", {
|
||||
params: {
|
||||
illust_id: id
|
||||
@@ -90,7 +90,7 @@ export default class PixivApi {
|
||||
})
|
||||
}
|
||||
|
||||
async member ({ id }) {
|
||||
async member({ id }) {
|
||||
return this.request("v1/user/detail", {
|
||||
params: {
|
||||
illust_id: id
|
||||
@@ -98,7 +98,7 @@ export default class PixivApi {
|
||||
})
|
||||
}
|
||||
|
||||
async member_illust ({
|
||||
async member_illust({
|
||||
id,
|
||||
page = 1,
|
||||
size = 30,
|
||||
@@ -113,7 +113,7 @@ export default class PixivApi {
|
||||
})
|
||||
}
|
||||
|
||||
async search ({
|
||||
async search({
|
||||
word,
|
||||
page = 1,
|
||||
size = 30,
|
||||
@@ -132,7 +132,7 @@ export default class PixivApi {
|
||||
})
|
||||
}
|
||||
|
||||
async search_user ({
|
||||
async search_user({
|
||||
word,
|
||||
page = 1,
|
||||
size = 30
|
||||
@@ -148,7 +148,7 @@ export default class PixivApi {
|
||||
)
|
||||
}
|
||||
|
||||
async related ({
|
||||
async related({
|
||||
id,
|
||||
page = 1,
|
||||
size = 30
|
||||
@@ -164,7 +164,7 @@ export default class PixivApi {
|
||||
)
|
||||
}
|
||||
|
||||
async illustRecommended (params = {}) {
|
||||
async illustRecommended(params = {}) {
|
||||
return await this.request("v1/illust/recommended", params)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export const headers = {
|
||||
"Connection": "Keep-Alive"
|
||||
}
|
||||
|
||||
export async function login (refresh_token) {
|
||||
export async function login(refresh_token) {
|
||||
const local_time = moment().format()
|
||||
let _headers = {
|
||||
...headers,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import moment from "moment"
|
||||
|
||||
export function timeToSeconds (time) {
|
||||
export function timeToSeconds(time) {
|
||||
let seconds = 0
|
||||
let timeArray = time.split(" ")
|
||||
for (let i = 0; i < timeArray.length; i++) {
|
||||
@@ -26,7 +26,7 @@ export function timeToSeconds (time) {
|
||||
return seconds
|
||||
}
|
||||
|
||||
export function getNoonTomorrow () {
|
||||
export function getNoonTomorrow() {
|
||||
const now = moment() // 获取当前时间
|
||||
const noonToday = moment().startOf("day").add(12, "hours") // 获取今天中午12点的时间
|
||||
const noonTomorrow = moment().add(1, "day").startOf("day").add(12, "hours") // 获取明天中午12点的时间
|
||||
|
||||
@@ -4,10 +4,10 @@ import { status } from "../../constants/other.js"
|
||||
import { createRequire } from "module"
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
export default async function getBotState (botList) {
|
||||
export default async function getBotState(botList) {
|
||||
const defaultAvatar = `../../../../../plugins/${Plugin_Name}/resources/state/img/default_avatar.jpg`
|
||||
|
||||
const dataPromises = botList.map(async (i) => {
|
||||
const dataPromises = botList.map(async(i) => {
|
||||
const bot = Bot[i]
|
||||
if (!bot?.uin) return ""
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { si, osInfo } from "./index.js"
|
||||
import { Circle } from "./utils.js"
|
||||
|
||||
/** 获取CPU占用 */
|
||||
export default async function getCpuInfo () {
|
||||
export default async function getCpuInfo() {
|
||||
let { currentLoad: { currentLoad }, cpuCurrentSpeed } = await si.get({
|
||||
currentLoad: "currentLoad",
|
||||
cpuCurrentSpeed: "max,avg"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export let si = false
|
||||
export let osInfo = null
|
||||
|
||||
export async function initDependence () {
|
||||
export async function initDependence() {
|
||||
if (si) return si
|
||||
try {
|
||||
si = await import("systeminformation")
|
||||
|
||||
@@ -4,7 +4,7 @@ import { execSync } from "../../tools/index.js"
|
||||
* 获取FastFetch
|
||||
* @param e
|
||||
*/
|
||||
export default async function getFastFetch (e) {
|
||||
export default async function getFastFetch(e) {
|
||||
if (process.platform == "win32" && !/pro/.test(e.msg)) return ""
|
||||
let ret = await execSync("bash plugins/yenai-plugin/resources/state/state.sh")
|
||||
if (ret.error) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { si } from "./index.js"
|
||||
* 获取硬盘
|
||||
* @returns {*}
|
||||
*/
|
||||
export default async function getFsSize () {
|
||||
export default async function getFsSize() {
|
||||
// 去重
|
||||
let HardDisk = _.uniqWith(await si.fsSize(),
|
||||
(a, b) =>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { initDependence } from "./DependencyChecker.js"
|
||||
|
||||
let isGPU = false;
|
||||
|
||||
(async function initGetIsGPU () {
|
||||
(async function initGetIsGPU() {
|
||||
if (!await initDependence()) return
|
||||
const { controllers } = await si.graphics()
|
||||
// 初始化GPU获取
|
||||
@@ -16,7 +16,7 @@ let isGPU = false;
|
||||
})()
|
||||
|
||||
/** 获取GPU占用 */
|
||||
export default async function getGPU () {
|
||||
export default async function getGPU() {
|
||||
if (!isGPU) return false
|
||||
try {
|
||||
const { controllers } = await si.graphics()
|
||||
|
||||
@@ -5,7 +5,7 @@ import { initDependence } from "./DependencyChecker.js"
|
||||
import { addData, getFileSize } from "./utils.js"
|
||||
|
||||
export default new class monitor {
|
||||
constructor () {
|
||||
constructor() {
|
||||
// 网络
|
||||
this._network = null
|
||||
// 读写速率
|
||||
@@ -42,31 +42,31 @@ export default new class monitor {
|
||||
this.init()
|
||||
}
|
||||
|
||||
set network (value) {
|
||||
set network(value) {
|
||||
if (_.isNumber(value[0]?.tx_sec) && _.isNumber(value[0]?.rx_sec)) {
|
||||
this._network = value
|
||||
addData(this.chartData.network.upload, [Date.now(), value[0].tx_sec])
|
||||
addData(this.chartData.network.download, [Date.now(), value[0].rx_sec])
|
||||
addData(this.chartData.network.upload, [ Date.now(), value[0].tx_sec ])
|
||||
addData(this.chartData.network.download, [ Date.now(), value[0].rx_sec ])
|
||||
}
|
||||
}
|
||||
|
||||
get network () {
|
||||
get network() {
|
||||
return this._network
|
||||
}
|
||||
|
||||
set fsStats (value) {
|
||||
set fsStats(value) {
|
||||
if (_.isNumber(value?.wx_sec) && _.isNumber(value?.rx_sec)) {
|
||||
this._fsStats = value
|
||||
addData(this.chartData.fsStats.writeSpeed, [Date.now(), value.wx_sec])
|
||||
addData(this.chartData.fsStats.readSpeed, [Date.now(), value.rx_sec])
|
||||
addData(this.chartData.fsStats.writeSpeed, [ Date.now(), value.wx_sec ])
|
||||
addData(this.chartData.fsStats.readSpeed, [ Date.now(), value.rx_sec ])
|
||||
}
|
||||
}
|
||||
|
||||
get fsStats () {
|
||||
get fsStats() {
|
||||
return this._fsStats
|
||||
}
|
||||
|
||||
async init () {
|
||||
async init() {
|
||||
if (!await initDependence()) return
|
||||
|
||||
// 给有问题的用户关闭定时器
|
||||
@@ -75,13 +75,13 @@ export default new class monitor {
|
||||
if (Config.state.statusPowerShellStart) si.powerShellStart()
|
||||
this.getData()
|
||||
// 网速
|
||||
const Timer = setInterval(async () => {
|
||||
const Timer = setInterval(async() => {
|
||||
let data = await this.getData()
|
||||
if (_.isEmpty(data)) clearInterval(Timer)
|
||||
}, 60000)
|
||||
}
|
||||
|
||||
async getData () {
|
||||
async getData() {
|
||||
let data = await si.get(this.valueObject)
|
||||
_.forIn(data, (value, key) => {
|
||||
if (_.isEmpty(value)) {
|
||||
@@ -98,16 +98,16 @@ export default new class monitor {
|
||||
this.fsStats = fsStats
|
||||
this.network = networkStats
|
||||
if (_.isNumber(active)) {
|
||||
addData(this.chartData.ram, [Date.now(), active])
|
||||
addData(this.chartData.ram, [ Date.now(), active ])
|
||||
}
|
||||
if (_.isNumber(currentLoad)) {
|
||||
addData(this.chartData.cpu, [Date.now(), currentLoad])
|
||||
addData(this.chartData.cpu, [ Date.now(), currentLoad ])
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// 获取读取速率
|
||||
get DiskSpeed () {
|
||||
get DiskSpeed() {
|
||||
if (!this.fsStats ||
|
||||
this.fsStats.rx_sec == null ||
|
||||
this.fsStats.wx_sec == null
|
||||
@@ -124,7 +124,7 @@ export default new class monitor {
|
||||
* 获取网速
|
||||
* @returns {object}
|
||||
*/
|
||||
get getNetwork () {
|
||||
get getNetwork() {
|
||||
let network = _.cloneDeep(this.network)?.[0]
|
||||
if (!network || network.rx_sec == null || network.tx_sec == null) {
|
||||
return false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import request from "../../lib/request/request.js"
|
||||
import { Config } from "../../components/index.js"
|
||||
|
||||
export default function getNetworTestList () {
|
||||
export default function getNetworTestList() {
|
||||
let { psTestSites, psTestTimeout } = Config.state
|
||||
if (psTestSites) {
|
||||
let psTest = psTestSites?.map(i => getNetworkLatency(i.url, psTestTimeout).then(res => {
|
||||
@@ -21,7 +21,7 @@ export default function getNetworTestList () {
|
||||
* @param {number} [timeoutTime] 超时时间
|
||||
* @returns {string}
|
||||
*/
|
||||
async function getNetworkLatency (url, timeoutTime = 5000) {
|
||||
async function getNetworkLatency(url, timeoutTime = 5000) {
|
||||
const AbortController = globalThis.AbortController || await import("abort-controller")
|
||||
|
||||
const controller = new AbortController()
|
||||
|
||||
@@ -2,7 +2,7 @@ import { getFileSize, Circle } from "./utils.js"
|
||||
import os from "os"
|
||||
|
||||
/** 获取nodejs内存情况 */
|
||||
export default function getNodeInfo () {
|
||||
export default function getNodeInfo() {
|
||||
let memory = process.memoryUsage()
|
||||
// 总共
|
||||
let rss = getFileSize(memory.rss)
|
||||
|
||||
@@ -6,7 +6,7 @@ import Monitor from "./Monitor.js"
|
||||
import fs from "fs"
|
||||
import { Version } from "../../components/index.js"
|
||||
|
||||
export default function otherInfi () {
|
||||
export default function otherInfi() {
|
||||
let otherInfo = []
|
||||
// 其他信息
|
||||
otherInfo.push({
|
||||
@@ -28,11 +28,11 @@ export default function otherInfi () {
|
||||
return _.compact(otherInfo)
|
||||
}
|
||||
|
||||
function getSystime () {
|
||||
function getSystime() {
|
||||
return formatDuration(os.uptime(), "dd天hh小时mm分", false)
|
||||
}
|
||||
|
||||
function getPluginNum () {
|
||||
function getPluginNum() {
|
||||
let str = "./plugins"
|
||||
let arr = fs.readdirSync(str)
|
||||
let plugin = []
|
||||
@@ -42,13 +42,13 @@ function getPluginNum () {
|
||||
plugin.push(val)
|
||||
}
|
||||
})
|
||||
let del = ["example", "genshin", "other", "system", "bin"]
|
||||
let del = [ "example", "genshin", "other", "system", "bin" ]
|
||||
plugin = plugin.filter(item => !del.includes(item))
|
||||
const plugins = plugin?.length || 0
|
||||
const js = fs.readdirSync("./plugins/example")?.filter(item => item.includes(".js"))?.length || 0
|
||||
return `${plugins} plugin | ${js} js`
|
||||
}
|
||||
|
||||
export function getCopyright () {
|
||||
export function getCopyright() {
|
||||
return `Created By ${Version.name}<span class="version">${Version.yunzai}</span> & Yenai-Plugin<span class="version">${Version.ver}</span> & Node <span class="version">${process.version}</span>`
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { getFileSize, Circle } from "./utils.js"
|
||||
import os from "os"
|
||||
|
||||
/** 获取当前内存占用 */
|
||||
export default function getMemUsage () {
|
||||
export default function getMemUsage() {
|
||||
// 内存使用率
|
||||
let MemUsage = (1 - os.freemem() / os.totalmem()).toFixed(2)
|
||||
// 空闲内存
|
||||
|
||||
@@ -14,7 +14,7 @@ import getOtherInfo, { getCopyright } from "./OtherInfo.js"
|
||||
|
||||
export { osInfo, si }
|
||||
|
||||
export async function getData (e) {
|
||||
export async function getData(e) {
|
||||
// 可视化数据
|
||||
let visualData = _.compact(await Promise.all([
|
||||
// CPU板块
|
||||
@@ -34,13 +34,13 @@ export async function getData (e) {
|
||||
let NetworTestList = getNetworTestList()
|
||||
promiseTaskList.push(NetworTestList)
|
||||
|
||||
let [FastFetch, HardDisk, psTest] = await Promise.all(promiseTaskList)
|
||||
let [ FastFetch, HardDisk, psTest ] = await Promise.all(promiseTaskList)
|
||||
/** bot列表 */
|
||||
let BotList = _getBotList(e)
|
||||
let isBotIndex = /pro/.test(e.msg) && BotList.length > 1
|
||||
return {
|
||||
BotStatusList: await getBotState(BotList),
|
||||
chartData: JSON.stringify(common.checkIfEmpty(Monitor.chartData, ["echarts_theme", "cpu", "ram"]) ? undefined : Monitor.chartData),
|
||||
chartData: JSON.stringify(common.checkIfEmpty(Monitor.chartData, [ "echarts_theme", "cpu", "ram" ]) ? undefined : Monitor.chartData),
|
||||
visualData,
|
||||
otherInfo: getOtherInfo(),
|
||||
psTest: _.isEmpty(psTest) ? undefined : psTest,
|
||||
@@ -53,9 +53,9 @@ export async function getData (e) {
|
||||
}
|
||||
}
|
||||
|
||||
function _getBotList (e) {
|
||||
function _getBotList(e) {
|
||||
/** bot列表 */
|
||||
let BotList = [e.self_id]
|
||||
let BotList = [ e.self_id ]
|
||||
|
||||
if (e.msg.includes("pro")) {
|
||||
if (Array.isArray(Bot?.uin)) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import _ from "lodash"
|
||||
* @param {number} [maxLen] - 数组允许的最大长度,默认值为60
|
||||
* @returns {void}
|
||||
*/
|
||||
export function addData (arr, data, maxLen = 60) {
|
||||
export function addData(arr, data, maxLen = 60) {
|
||||
if (data === null || data === undefined) return
|
||||
// 如果数组长度超过允许的最大值,删除第一个元素
|
||||
if (arr.length >= maxLen) {
|
||||
@@ -24,7 +24,7 @@ export function addData (arr, data, maxLen = 60) {
|
||||
* @param {boolean} [isSuffix] - 如果为 true,则在所得到的大小后面加上 kb、mb、gb、tb 等后缀.
|
||||
* @returns {string} 文件大小格式转换后的字符串.
|
||||
*/
|
||||
export function getFileSize (size, isByte = true, isSuffix = true) { // 把字节转换成正常文件大小
|
||||
export function getFileSize(size, isByte = true, isSuffix = true) { // 把字节转换成正常文件大小
|
||||
if (size == null || size == undefined) return 0
|
||||
let num = 1024.00 // byte
|
||||
if (isByte && size < num) {
|
||||
@@ -47,7 +47,7 @@ export function getFileSize (size, isByte = true, isSuffix = true) { // 把字
|
||||
* @param {number} res 百分比小数
|
||||
* @returns {{per:number,color:string}} per - stroke-dashoffset属性 color - 进度条颜色
|
||||
*/
|
||||
export function Circle (res) {
|
||||
export function Circle(res) {
|
||||
let perimeter = 3.14 * 80
|
||||
let per = perimeter - perimeter * res
|
||||
let color = "--low-color"
|
||||
|
||||
@@ -7,7 +7,7 @@ import { sleep } from "../../tools/index.js"
|
||||
|
||||
/** QQ接口 */
|
||||
export default class {
|
||||
constructor (e) {
|
||||
constructor(e) {
|
||||
this.e = e
|
||||
this.Bot = e.bot ?? Bot
|
||||
this.headers = {
|
||||
@@ -18,7 +18,7 @@ export default class {
|
||||
}
|
||||
}
|
||||
|
||||
getGtk (data) {
|
||||
getGtk(data) {
|
||||
let ck = common.getck(data, this.Bot)
|
||||
// eslint-disable-next-line no-var
|
||||
for (var e = ck.p_skey || "", n = 5381, r = 0, o = e.length; r < o; ++r) {
|
||||
@@ -33,7 +33,7 @@ export default class {
|
||||
* @param {number} pos 偏移量
|
||||
* @returns {object} QQ空间数据
|
||||
*/
|
||||
async getQzone (num = 20, pos = 0) {
|
||||
async getQzone(num = 20, pos = 0) {
|
||||
let url = `https://user.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6?uin=${this.Bot.uin}&ftype=0&sort=0&pos=${pos}&num=${num}&replynum=100&g_tk=${this.Bot.bkn}&code_version=1&format=json&need_private_comment=1`
|
||||
return await fetch(url, {
|
||||
headers: {
|
||||
@@ -47,7 +47,7 @@ export default class {
|
||||
* @param {string} tid tid参数
|
||||
* @param {string} t1_source t1_source参数
|
||||
*/
|
||||
async delQzone (tid, t1_source) {
|
||||
async delQzone(tid, t1_source) {
|
||||
let url = `https://user.qzone.qq.com/proxy/domain/taotao.qzone.qq.com/cgi-bin/emotion_cgi_delete_v6?&g_tk=${this.Bot.bkn}`
|
||||
// 发送请求
|
||||
return await fetch(url, {
|
||||
@@ -60,7 +60,7 @@ export default class {
|
||||
}
|
||||
|
||||
/** 删除全部说说 */
|
||||
async delQzoneAll () {
|
||||
async delQzoneAll() {
|
||||
let ck = common.getck("qzone.qq.com", this.Bot)
|
||||
return await fetch(`http://xiaobai.klizi.cn/API/qqgn/ss_empty.php?data=&uin=${this.Bot.uin}&skey=${ck.skey}&pskey=${ck.p_skey}`).then(res => res.text()).catch(err => logger.error(err))
|
||||
// let num = 0
|
||||
@@ -80,7 +80,7 @@ export default class {
|
||||
* @param con
|
||||
* @param img
|
||||
*/
|
||||
async setQzone (con, img) {
|
||||
async setQzone(con, img) {
|
||||
let ck = common.getck("qzone.qq.com", this.Bot)
|
||||
|
||||
if (img) {
|
||||
@@ -104,7 +104,7 @@ export default class {
|
||||
* @param {number} start 偏移量/开始的位置
|
||||
* @returns {*}
|
||||
*/
|
||||
async getQzoneMsgb (num = 0, start = 0) {
|
||||
async getQzoneMsgb(num = 0, start = 0) {
|
||||
let url = `https://user.qzone.qq.com/proxy/domain/m.qzone.qq.com/cgi-bin/new/get_msgb?uin=${this.Bot.uin}&hostUin=${this.Bot.uin}&start=${start}&s=0.45779069937151884&format=json&num=${num}&inCharset=utf-8&outCharset=utf-8&g_tk=${this.Bot.bkn}`
|
||||
return await fetch(url, {
|
||||
headers: {
|
||||
@@ -119,7 +119,7 @@ export default class {
|
||||
* @param {*} uinId
|
||||
* @returns {*}
|
||||
*/
|
||||
async delQzoneMsgb (id, uinId) {
|
||||
async delQzoneMsgb(id, uinId) {
|
||||
let delurl = `https://h5.qzone.qq.com/proxy/domain/m.qzone.qq.com/cgi-bin/new/del_msgb?&g_tk=${this.Bot.bkn}`
|
||||
return await fetch(delurl, {
|
||||
method: "POST",
|
||||
@@ -131,7 +131,7 @@ export default class {
|
||||
}
|
||||
|
||||
/** 删除全部留言 */
|
||||
async delQzoneMsgbAll () {
|
||||
async delQzoneMsgbAll() {
|
||||
let ck = common.getck("qzone.qq.com", this.Bot)
|
||||
return await fetch(`http://xiaobai.klizi.cn/API/qqgn/qzone_emptymsgb.php?data=&uin=${this.Bot.uin}&skey=${ck.skey}&pskey=${ck.p_skey}`).then(res => res.text()).catch(err => logger.error(err))
|
||||
// let num = 0
|
||||
@@ -154,7 +154,7 @@ export default class {
|
||||
* @param s
|
||||
* @returns {object}
|
||||
*/
|
||||
async getAnnouncelist (group_id, s = 0) {
|
||||
async getAnnouncelist(group_id, s = 0) {
|
||||
let n = s ? 1 : 20
|
||||
let url = `https://web.qun.qq.com/cgi-bin/announce/get_t_list?bkn=${this.Bot.bkn}&qid=${group_id}&ft=23&s=${s - 1}&n=${n}`
|
||||
let res = await fetch(url, { headers: { Cookie: this.Bot.cookies["qun.qq.com"] } }).then(res => res.json()).catch(err => logger.error(err))
|
||||
@@ -174,7 +174,7 @@ export default class {
|
||||
* @param {number} group_id 发送群号
|
||||
* @param {string} msg 发送内容
|
||||
*/
|
||||
async setAnnounce (group_id, msg) {
|
||||
async setAnnounce(group_id, msg) {
|
||||
let url = `https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn=${this.Bot.bkn}`
|
||||
return await fetch(url, {
|
||||
method: "POST",
|
||||
@@ -190,7 +190,7 @@ export default class {
|
||||
* @param {number} group_id 群号
|
||||
* @param {number} num 序号
|
||||
*/
|
||||
async delAnnounce (group_id, num) {
|
||||
async delAnnounce(group_id, num) {
|
||||
let fid = await this.getAnnouncelist(group_id, num)
|
||||
if (!fid) return false
|
||||
|
||||
@@ -212,7 +212,7 @@ export default class {
|
||||
* 群星级
|
||||
* @param group_id
|
||||
*/
|
||||
async getCreditLevelInfo (group_id) {
|
||||
async getCreditLevelInfo(group_id) {
|
||||
let url = `https://qqweb.qq.com/c/activedata/get_credit_level_info?bkn=${this.Bot.bkn}&uin=${this.Bot.uin}&gc=${group_id}`
|
||||
return await fetch(url, {
|
||||
headers: {
|
||||
@@ -227,7 +227,7 @@ export default class {
|
||||
* 查看本群龙王
|
||||
* @param group_id
|
||||
*/
|
||||
async dragon (group_id) {
|
||||
async dragon(group_id) {
|
||||
let url = `https://qun.qq.com/interactive/honorlist?gc=${group_id}&type=1&_wv=3&_wwv=129`
|
||||
let res = await fetch(url, { headers: { Cookie: this.Bot.cookies["qun.qq.com"] } })
|
||||
.then(res => res.text()).catch(err => logger.error(err))
|
||||
@@ -240,7 +240,7 @@ export default class {
|
||||
* 开关好友添加
|
||||
* @param {number} type 1关闭2开启
|
||||
*/
|
||||
async addFriendSwitch (type) {
|
||||
async addFriendSwitch(type) {
|
||||
let url = `https://ti.qq.com/proxy/domain/oidb.tim.qq.com/v3/oidbinterface/oidb_0x587_75?sdkappid=39998&actype=2&bkn=${this.Bot.bkn}`
|
||||
return await fetch(url, {
|
||||
method: "POST",
|
||||
@@ -261,7 +261,7 @@ export default class {
|
||||
* @param {*} a
|
||||
* @returns {*}
|
||||
*/
|
||||
async setFriendType (at, q = "", a = "") {
|
||||
async setFriendType(at, q = "", a = "") {
|
||||
const type = {
|
||||
1: "0",
|
||||
2: "1",
|
||||
@@ -284,7 +284,7 @@ export default class {
|
||||
* 设置戳一戳开关
|
||||
* @param {number} isclose 0为开启1为关闭
|
||||
*/
|
||||
async setcyc (isclose) {
|
||||
async setcyc(isclose) {
|
||||
let url = `https://zb.vip.qq.com/srf/QC_UniBusinessLogicServer_UniBusinessLogicObj/uniSet?g_tk=${this.Bot.bkn}`
|
||||
return await fetch(url, {
|
||||
method: "POST",
|
||||
@@ -320,7 +320,7 @@ export default class {
|
||||
* 今日打卡
|
||||
* @param groupId
|
||||
*/
|
||||
async signInToday (groupId) {
|
||||
async signInToday(groupId) {
|
||||
let body = JSON.stringify({
|
||||
dayYmd: moment().format("YYYYMMDD"),
|
||||
offset: 0,
|
||||
@@ -341,7 +341,7 @@ export default class {
|
||||
* @param {number} groupId 群号
|
||||
* @param {string} time true为7天false为昨天
|
||||
*/
|
||||
async SpeakRank (groupId, time = false) {
|
||||
async SpeakRank(groupId, time = false) {
|
||||
let url = `https://qun.qq.com/m/qun/activedata/proxy/domain/qun.qq.com/cgi-bin/manager/report/list?bkn=${this.Bot.bkn}&gc=${groupId}&type=0&start=0&time=${time ? 1 : 0}`
|
||||
return await fetch(url, {
|
||||
headers: this.headers
|
||||
@@ -353,7 +353,7 @@ export default class {
|
||||
* @param {string} groupId 群号
|
||||
* @param {string} time true为7天false为昨天
|
||||
*/
|
||||
async groupData (groupId, time = false) {
|
||||
async groupData(groupId, time = false) {
|
||||
let url = `https://qun.qq.com/m/qun/activedata/proxy/domain/qun.qq.com/cgi-bin/manager/report/index?gc=${groupId}&time=${time ? 1 : 0}&bkn=${this.Bot.bkn}`
|
||||
return await fetch(url, {
|
||||
headers: this.headers
|
||||
@@ -369,7 +369,7 @@ export default class {
|
||||
* 字符列表
|
||||
* @returns {*}
|
||||
*/
|
||||
async luckylist (groupId, start = 0, limit = 10) {
|
||||
async luckylist(groupId, start = 0, limit = 10) {
|
||||
let body = JSON.stringify({
|
||||
group_code: groupId,
|
||||
start,
|
||||
@@ -389,7 +389,7 @@ export default class {
|
||||
* @param {string} group_id 群号
|
||||
* @param {string} id 字符id
|
||||
*/
|
||||
async equipLucky (group_id, id) {
|
||||
async equipLucky(group_id, id) {
|
||||
let body = JSON.stringify({
|
||||
group_code: group_id,
|
||||
word_id: id
|
||||
@@ -407,7 +407,7 @@ export default class {
|
||||
* @param {string} group_id 群号
|
||||
* @returns {*}
|
||||
*/
|
||||
async drawLucky (group_id) {
|
||||
async drawLucky(group_id) {
|
||||
let body = JSON.stringify({
|
||||
group_code: group_id
|
||||
})
|
||||
@@ -424,7 +424,7 @@ export default class {
|
||||
* @param {number} groupId 群号
|
||||
* @param {boolean} type
|
||||
*/
|
||||
async swichLucky (groupId, type) {
|
||||
async swichLucky(groupId, type) {
|
||||
let body = JSON.stringify({
|
||||
group_code: groupId,
|
||||
cmd: type ? 1 : 2
|
||||
@@ -443,7 +443,7 @@ export default class {
|
||||
* @param {Array} member 要踢的人的数组
|
||||
* @returns {*}
|
||||
*/
|
||||
async deleteGroupMember (groupId, member) {
|
||||
async deleteGroupMember(groupId, member) {
|
||||
let res = []
|
||||
for (let item of _.chunk(member, 20)) {
|
||||
let data = {
|
||||
@@ -471,7 +471,7 @@ export default class {
|
||||
* @param {string|number} userId QQ号码
|
||||
* @returns {Promise<object>} 包含QQ等级信息的Promise对象
|
||||
*/
|
||||
async getQQLevel (userId) {
|
||||
async getQQLevel(userId) {
|
||||
const url = "https://club.vip.qq.com/api/vip/getQQLevelInfo"
|
||||
const params = {
|
||||
requestBody: JSON.stringify({
|
||||
@@ -497,7 +497,7 @@ export default class {
|
||||
* @param {string} modelName
|
||||
* @returns {Promise<Response|*>}
|
||||
*/
|
||||
async setModel (modelName) {
|
||||
async setModel(modelName) {
|
||||
const url = "https://proxy.vip.qq.com/cgi-bin/srfentry.fcgi"
|
||||
const data = {
|
||||
"13031": {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { puppeteer } from "../../index.js"
|
||||
*
|
||||
* @param keyword
|
||||
*/
|
||||
export default async function bgg (keyword) {
|
||||
export default async function bgg(keyword) {
|
||||
let cheerio = await _importDependency()
|
||||
let url = "https://www.gstonegames.com/game/?hot_sort=1&keyword=" + encodeURIComponent(keyword)
|
||||
const home = await request.get(url).then((res) => res.text())
|
||||
|
||||
@@ -8,7 +8,7 @@ import request from "../../../lib/request/request.js"
|
||||
* @param type
|
||||
* @param keywords
|
||||
*/
|
||||
export async function pandadiu (type = "cos", keywords = "") {
|
||||
export async function pandadiu(type = "cos", keywords = "") {
|
||||
let cheerio = await _importDependency()
|
||||
let domain = "https://www.pandadiu.com"
|
||||
const { id, page } = pandadiuType[type]
|
||||
@@ -39,7 +39,7 @@ export async function pandadiu (type = "cos", keywords = "") {
|
||||
* @param keywords
|
||||
* @param isSearch
|
||||
*/
|
||||
export async function mengdui (keywords, isSearch) {
|
||||
export async function mengdui(keywords, isSearch) {
|
||||
let cheerio = await _importDependency()
|
||||
const domain = "https://b6u8.com"
|
||||
let href = ""
|
||||
@@ -70,14 +70,14 @@ export async function mengdui (keywords, isSearch) {
|
||||
const imgs = _.map($("div.md-text.mb20.f-16 > p > img"), item => segment.image(item.attribs.src))
|
||||
const title = $("h1").text().trim()
|
||||
const number = `序号:${href.match(/(\d+).html/)[1]}`
|
||||
return [title, number, ..._.take(imgs, 30)]
|
||||
return [ title, number, ..._.take(imgs, 30) ]
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
export async function xiuren (type) {
|
||||
export async function xiuren(type) {
|
||||
let cheerio = await _importDependency()
|
||||
// 可扩展
|
||||
let handleType = xiurenTypeId[type]
|
||||
@@ -106,7 +106,7 @@ export async function xiuren (type) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export async function coser () {
|
||||
export async function coser() {
|
||||
let cheerio = await _importDependency()
|
||||
const domain = "https://t2cy.com"
|
||||
const homeUrl = `${domain}/acg/cos/index_${_.random(1, 30)}.html`
|
||||
@@ -129,5 +129,5 @@ export async function coser () {
|
||||
), item => segment.image(_.includes(item.attribs.src, "http") ? item.attribs.src : domain + (item.attribs["data-loadsrc"] || item.attribs.src))
|
||||
)
|
||||
const title = $1("h1").text().trim()
|
||||
return [title, ..._.take(imgList, 20)]
|
||||
return [ title, ..._.take(imgList, 20) ]
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { API_ERROR } from "./utils.js"
|
||||
import _ from "lodash"
|
||||
|
||||
/** 随机唱歌/唱鸭 */
|
||||
export default async function randomSinging () {
|
||||
export default async function randomSinging() {
|
||||
try {
|
||||
const api = "https://m.api.singduck.cn/user-piece/SoQJ9cKu61FJ1Vwc7"
|
||||
let res = await fetch(api).then(res => res.text())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default class ThumbUpApi {
|
||||
constructor (e) {
|
||||
constructor(e) {
|
||||
this.e = e
|
||||
this.Bot = e.bot ?? Bot
|
||||
}
|
||||
@@ -10,7 +10,7 @@ export default class ThumbUpApi {
|
||||
* @param {number} times 数量
|
||||
* @returns {object}
|
||||
*/
|
||||
async thumbUp (uid, times = 1) {
|
||||
async thumbUp(uid, times = 1) {
|
||||
try {
|
||||
let core = this.Bot.icqq?.core
|
||||
if (!core) core = (await import("icqq")).core
|
||||
@@ -18,16 +18,12 @@ export default class ThumbUpApi {
|
||||
let ReqFavorite
|
||||
if (this.Bot.fl.get(uid)) {
|
||||
ReqFavorite = core.jce.encodeStruct([
|
||||
core.jce.encodeNested([
|
||||
this.Bot.uin, 1, this.Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160131", "hex")
|
||||
]),
|
||||
core.jce.encodeNested([ this.Bot.uin, 1, this.Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160131", "hex") ]),
|
||||
uid, 0, 1, Number(times)
|
||||
])
|
||||
} else {
|
||||
ReqFavorite = core.jce.encodeStruct([
|
||||
core.jce.encodeNested([
|
||||
this.Bot.uin, 1, this.Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160135", "hex")
|
||||
]),
|
||||
core.jce.encodeNested([ this.Bot.uin, 1, this.Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160135", "hex") ]),
|
||||
uid, 0, 5, Number(times)
|
||||
])
|
||||
}
|
||||
@@ -40,7 +36,7 @@ export default class ThumbUpApi {
|
||||
}
|
||||
}
|
||||
|
||||
async origThumbUp (uid, times) {
|
||||
async origThumbUp(uid, times) {
|
||||
const friend = this.Bot.pickFriend(uid)
|
||||
if (!friend?.thumbUp) throw new ReplyError("当前协议端不支持点赞,详情查看\nhttps://gitee.com/TimeRainStarSky/Yunzai")
|
||||
const res = { ...await friend.thumbUp(times) }
|
||||
|
||||
@@ -5,7 +5,7 @@ let cheerio = null
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export async function _importDependency () {
|
||||
export async function _importDependency() {
|
||||
if (cheerio) return cheerio
|
||||
cheerio = await import("cheerio")
|
||||
.catch(() => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import _ from "lodash"
|
||||
* @param to
|
||||
* @param from
|
||||
*/
|
||||
export default async function youdao (msg, to = "auto", from = "auto") {
|
||||
export default async function youdao(msg, to = "auto", from = "auto") {
|
||||
if (to != "auto") to = youDaoLangType.find(item => item.label == to)?.code
|
||||
if (from != "auto") from = youDaoLangType.find(item => item.label == from)?.code
|
||||
if (!to || !from) return `未找到翻译的语种,支持的语言为:\n${youDaoLangType.map(item => item.label).join(",")}\n示例:#翻译你好 - 自动翻译\n#日语翻译你好 - 指定翻译为语种\n#中文-日语翻译你好 - 指定原语言翻译为指定语言`
|
||||
@@ -18,7 +18,7 @@ export default async function youdao (msg, to = "auto", from = "auto") {
|
||||
// API 请求错误提示
|
||||
const qs = (obj) => {
|
||||
let res = ""
|
||||
for (const [k, v] of Object.entries(obj)) { res += `${k}=${encodeURIComponent(v)}&` }
|
||||
for (const [ k, v ] of Object.entries(obj)) { res += `${k}=${encodeURIComponent(v)}&` }
|
||||
return res.slice(0, res.length - 1)
|
||||
}
|
||||
const appVersion = "5.0 (Windows NT 10.0; Win64; x64) Chrome/98.0.4750.0"
|
||||
|
||||
@@ -6,7 +6,7 @@ try {
|
||||
Jimp = (await import("jimp")).default
|
||||
} catch {}
|
||||
export default new class {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.folderPath = `${Plugin_Path}/resources/memes`
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export default new class {
|
||||
* 比心/赞
|
||||
* @param image
|
||||
*/
|
||||
async zan (image) {
|
||||
async zan(image) {
|
||||
if (!Jimp) return false
|
||||
let background = await Jimp.read(this.getRandomImagePath(`${this.folderPath}/bixin`))
|
||||
let image2 = await Jimp.read(image)
|
||||
@@ -31,7 +31,7 @@ export default new class {
|
||||
* 爬
|
||||
* @param image
|
||||
*/
|
||||
async crawl (image) {
|
||||
async crawl(image) {
|
||||
if (!Jimp) return false
|
||||
let background = await Jimp.read(this.getRandomImagePath(`${this.folderPath}/crawl`))
|
||||
let image2 = await Jimp.read(image)
|
||||
@@ -44,7 +44,7 @@ export default new class {
|
||||
return buff
|
||||
}
|
||||
|
||||
async ganyu (image) {
|
||||
async ganyu(image) {
|
||||
if (!Jimp) return false
|
||||
let images = new Jimp(700, 598)
|
||||
let avatar = await Jimp.read(image)
|
||||
@@ -64,7 +64,7 @@ export default new class {
|
||||
* @param {string} folderPath - 文件夹路径
|
||||
* @returns {string} - 图片路径
|
||||
*/
|
||||
getRandomImagePath (folderPath) {
|
||||
getRandomImagePath(folderPath) {
|
||||
// 读取文件夹里的所有文件
|
||||
const files = fs.readdirSync(folderPath)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { setuMsg } from "../constants/msg.js"
|
||||
import request from "../lib/request/request.js"
|
||||
import formatDuration from "../tools/formatDuration.js"
|
||||
export default new class setu {
|
||||
constructor () {
|
||||
constructor() {
|
||||
this.root = `${Plugin_Path}/config/setu`
|
||||
// 默认配置
|
||||
this.def = Config.setu.defSet
|
||||
@@ -15,22 +15,22 @@ export default new class setu {
|
||||
this.init()
|
||||
}
|
||||
|
||||
async init () {
|
||||
async init() {
|
||||
Data.createDir("config/setu")
|
||||
}
|
||||
|
||||
/** 开始执行文案 */
|
||||
get startMsg () {
|
||||
get startMsg() {
|
||||
return _.sample(setuMsg.start)
|
||||
}
|
||||
|
||||
/** CD中文案 */
|
||||
get CDMsg () {
|
||||
get CDMsg() {
|
||||
return _.sample(setuMsg.cd)
|
||||
}
|
||||
|
||||
/** 发送图片文案 */
|
||||
get sendMsgs () {
|
||||
get sendMsgs() {
|
||||
return _.sample(setuMsg.send)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export default new class setu {
|
||||
* @param {string} tag 关键词
|
||||
* @returns {object}
|
||||
*/
|
||||
async setuApi (r18, num = 1, tag = []) {
|
||||
async setuApi(r18, num = 1, tag = []) {
|
||||
let api = "https://api.lolicon.app/setu/v2"
|
||||
const { imgSize, excludeAI } = Config.setu
|
||||
const size = imgSize[_.max(Object.keys(imgSize).filter(item => num > item))] || "original"
|
||||
@@ -77,7 +77,7 @@ export default new class setu {
|
||||
* @param {Array} msg 消息数组
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async sendMsgOrSetCd (e, msg) {
|
||||
async sendMsgOrSetCd(e, msg) {
|
||||
// 发送消息
|
||||
let res = await common.recallSendForwardMsg(e, msg, false)
|
||||
if (!res) return false
|
||||
@@ -92,7 +92,7 @@ export default new class setu {
|
||||
* @param {number} cd cd时间
|
||||
* @returns {*}
|
||||
*/
|
||||
setCdTime (userId, groupId, cd = this.getCfgCd(userId, groupId)) {
|
||||
setCdTime(userId, groupId, cd = this.getCfgCd(userId, groupId)) {
|
||||
let present = parseInt(Date.now() / 1000)
|
||||
userId = userId - 0
|
||||
groupId = groupId - 0
|
||||
@@ -117,7 +117,7 @@ export default new class setu {
|
||||
* @param {number} groupId 群号不传则为私聊CD
|
||||
* @returns {string} 格式化后的时间
|
||||
*/
|
||||
getRemainingCd (userId, groupId) {
|
||||
getRemainingCd(userId, groupId) {
|
||||
userId = userId - 0
|
||||
groupId = groupId - 0
|
||||
// 获取现在的时间并转换为秒
|
||||
@@ -140,7 +140,7 @@ export default new class setu {
|
||||
* @param {number} groupId 传群号为群聊配置
|
||||
* @returns {*}
|
||||
*/
|
||||
getCfgCd (userId, groupId) {
|
||||
getCfgCd(userId, groupId) {
|
||||
let data = Data.readJSON(`setu${groupId ? "" : "_s"}.json`, this.root)
|
||||
let CD = groupId ? data[groupId]?.cd : data[userId]
|
||||
if (CD !== undefined) return CD
|
||||
@@ -152,7 +152,7 @@ export default new class setu {
|
||||
* @param {number} groupID 群号不传为私聊
|
||||
* @returns {string} 0或1
|
||||
*/
|
||||
getR18 (groupID) {
|
||||
getR18(groupID) {
|
||||
let data = Data.readJSON(`setu${groupID ? "" : "_s"}.json`, this.root)
|
||||
let R18 = groupID ? data[groupID]?.r18 : data.r18
|
||||
if (R18 !== undefined) return R18
|
||||
@@ -164,7 +164,7 @@ export default new class setu {
|
||||
* @param groupId
|
||||
* @returns {number}
|
||||
*/
|
||||
getRecallTime (groupId) {
|
||||
getRecallTime(groupId) {
|
||||
if (!groupId) return 0
|
||||
let data = Data.readJSON("setu.json", this.root)
|
||||
let recalltime = data[groupId]?.recall
|
||||
@@ -179,7 +179,7 @@ export default new class setu {
|
||||
* @param {boolean} type 为true设置撤回时间反之设置CD
|
||||
* @returns {boolean}
|
||||
*/
|
||||
setGroupRecallTimeAndCd (groupId, num, type) {
|
||||
setGroupRecallTimeAndCd(groupId, num, type) {
|
||||
let data = Data.readJSON("setu.json", this.root)
|
||||
|
||||
if (!data[groupId]) data[groupId] = _.cloneDeep(this.def)
|
||||
@@ -195,7 +195,7 @@ export default new class setu {
|
||||
* @param {string} qq 设置的qq
|
||||
* @param {string} cd 设置的cd
|
||||
*/
|
||||
setUserCd (e, qq, cd) {
|
||||
setUserCd(e, qq, cd) {
|
||||
let data = Data.readJSON("setu_s.json", this.root)
|
||||
|
||||
data[qq] = Number(cd)
|
||||
@@ -214,7 +214,7 @@ export default new class setu {
|
||||
* @param {string | number} groupID 群聊id为假时设置私聊
|
||||
* @param {boolean} isopen 开启或关闭
|
||||
*/
|
||||
setR18 (groupID, isopen) {
|
||||
setR18(groupID, isopen) {
|
||||
let data = Data.readJSON(`setu${groupID ? "" : "_s"}.json`, this.root)
|
||||
if (groupID) {
|
||||
if (!data[groupID]) data[groupID] = _.cloneDeep(this.def)
|
||||
@@ -236,7 +236,7 @@ export default new class setu {
|
||||
* @param {*} e oicq
|
||||
* @returns {*}
|
||||
*/
|
||||
getSeSeConfig (e) {
|
||||
getSeSeConfig(e) {
|
||||
let set = _.cloneDeep(this.def)
|
||||
set.cd = this.getCfgCd(e.user_id, e.group_id)
|
||||
set.r18 = this.getR18(e.group_id)
|
||||
|
||||
@@ -8,7 +8,7 @@ let message = ""
|
||||
* 判断正误方法:错误的话返回错误信息,正确的话返回true
|
||||
* @param {string | true}cronExpression crom表达式
|
||||
*/
|
||||
export default function cronValidate (cronExpression) {
|
||||
export default function cronValidate(cronExpression) {
|
||||
// 先将cron表达式进行分割
|
||||
let cronParams = cronExpression.split(" ")
|
||||
// 判断cron表达式是否具有该具有的属性长度,没有年份的长度为6,带年份的长度为7,其他情况都是错误的
|
||||
@@ -73,7 +73,7 @@ export default function cronValidate (cronExpression) {
|
||||
*
|
||||
* @param secondsField
|
||||
*/
|
||||
function checkSecondsField (secondsField) {
|
||||
function checkSecondsField(secondsField) {
|
||||
return checkField(secondsField, 0, 59, "秒")
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ function checkSecondsField (secondsField) {
|
||||
*
|
||||
* @param minutesField
|
||||
*/
|
||||
function checkMinutesField (minutesField) {
|
||||
function checkMinutesField(minutesField) {
|
||||
return checkField(minutesField, 0, 59, "分")
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ function checkMinutesField (minutesField) {
|
||||
*
|
||||
* @param hoursField
|
||||
*/
|
||||
function checkHoursField (hoursField) {
|
||||
function checkHoursField(hoursField) {
|
||||
return checkField(hoursField, 0, 23, "时")
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ function checkHoursField (hoursField) {
|
||||
*
|
||||
* @param dayOfMonthField
|
||||
*/
|
||||
function checkDayOfMonthField (dayOfMonthField) {
|
||||
function checkDayOfMonthField(dayOfMonthField) {
|
||||
if (dayOfMonthField == "?") {
|
||||
return true
|
||||
}
|
||||
@@ -119,7 +119,7 @@ function checkDayOfMonthField (dayOfMonthField) {
|
||||
*
|
||||
* @param monthsField
|
||||
*/
|
||||
function checkMonthsField (monthsField) {
|
||||
function checkMonthsField(monthsField) {
|
||||
// 月份简写处理
|
||||
if (monthsField != "*") {
|
||||
monthsField = monthsField.replace("JAN", "1")
|
||||
@@ -145,7 +145,7 @@ function checkMonthsField (monthsField) {
|
||||
*
|
||||
* @param dayOfWeekField
|
||||
*/
|
||||
function checkDayOfWeekField (dayOfWeekField) {
|
||||
function checkDayOfWeekField(dayOfWeekField) {
|
||||
dayOfWeekField = dayOfWeekField.replace("SUN", "1")
|
||||
dayOfWeekField = dayOfWeekField.replace("MON", "2")
|
||||
dayOfWeekField = dayOfWeekField.replace("TUE", "3")
|
||||
@@ -172,7 +172,7 @@ function checkDayOfWeekField (dayOfWeekField) {
|
||||
*
|
||||
* @param yearField
|
||||
*/
|
||||
function checkYearField (yearField) {
|
||||
function checkYearField(yearField) {
|
||||
return checkField(yearField, 1970, 2099, "年的")
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ function checkYearField (yearField) {
|
||||
* @param maximal
|
||||
* @param attribute
|
||||
*/
|
||||
function checkField (value, minimal, maximal, attribute) {
|
||||
function checkField(value, minimal, maximal, attribute) {
|
||||
// 校验值中是否有“-”,如果有“-”的话,下标会>0
|
||||
if (value.indexOf("-") > -1) {
|
||||
return checkRangeAndCycle(value, minimal, maximal, attribute)
|
||||
@@ -212,7 +212,7 @@ function checkField (value, minimal, maximal, attribute) {
|
||||
* @param checkExtremity
|
||||
* @param attribute
|
||||
*/
|
||||
function checkIntValue (value, minimal, maximal, checkExtremity, attribute) {
|
||||
function checkIntValue(value, minimal, maximal, checkExtremity, attribute) {
|
||||
try {
|
||||
// 用10进制犯法来进行整数转换
|
||||
let val = parseInt(value, 10)
|
||||
@@ -238,7 +238,7 @@ function checkIntValue (value, minimal, maximal, checkExtremity, attribute) {
|
||||
* @param maximal
|
||||
* @param attribute
|
||||
*/
|
||||
function checkListField (value, minimal, maximal, attribute) {
|
||||
function checkListField(value, minimal, maximal, attribute) {
|
||||
let st = value.split(",")
|
||||
let values = new Array(st.length)
|
||||
// 计算枚举的数字在数组中中出现的次数,出现一次为没有重复的。
|
||||
@@ -290,7 +290,7 @@ function checkListField (value, minimal, maximal, attribute) {
|
||||
* @param maximal
|
||||
* @param attribute
|
||||
*/
|
||||
function checkIncrementField (value, minimal, maximal, attribute) {
|
||||
function checkIncrementField(value, minimal, maximal, attribute) {
|
||||
if (value.split("/").length > 2) {
|
||||
return (attribute + "中的参数只能有一个'/'")
|
||||
}
|
||||
@@ -322,7 +322,7 @@ function checkIncrementField (value, minimal, maximal, attribute) {
|
||||
* @param maximal
|
||||
* @param attribute
|
||||
*/
|
||||
function checkRangeAndCycle (params, minimal, maximal, attribute) {
|
||||
function checkRangeAndCycle(params, minimal, maximal, attribute) {
|
||||
// 校验“-”符号是否只有一个
|
||||
if (params.split("-").length > 2) {
|
||||
return (attribute + "中的参数只能有一个'-'")
|
||||
@@ -383,7 +383,7 @@ function checkRangeAndCycle (params, minimal, maximal, attribute) {
|
||||
* @param maximalBefore
|
||||
* @param attribute
|
||||
*/
|
||||
function checkFieldWithLetter (value, letter, minimalBefore, maximalBefore, attribute) {
|
||||
function checkFieldWithLetter(value, letter, minimalBefore, maximalBefore, attribute) {
|
||||
// 判断是否只有一个字母
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
let count = 0
|
||||
@@ -448,7 +448,7 @@ function checkFieldWithLetter (value, letter, minimalBefore, maximalBefore, attr
|
||||
* @param maximalBefore
|
||||
* @param attribute
|
||||
*/
|
||||
function checkFieldWithLetterWeek (value, letter, minimalBefore, maximalBefore, attribute) {
|
||||
function checkFieldWithLetterWeek(value, letter, minimalBefore, maximalBefore, attribute) {
|
||||
// 判断是否只有一个字母
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
let count = 0
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* const result = formatDuration(3665, customFormat);
|
||||
* // 输出: "1h 1m 5s"
|
||||
*/
|
||||
export default function formatDuration (time, format, repair = true) {
|
||||
export default function formatDuration(time, format, repair = true) {
|
||||
const second = parseInt(time % 60)
|
||||
const minute = parseInt((time / 60) % 60)
|
||||
const hour = parseInt((time / (60 * 60)) % 24)
|
||||
|
||||
@@ -9,7 +9,7 @@ import child_process from "child_process"
|
||||
* 延时函数
|
||||
* @param {*} ms 时间(毫秒)
|
||||
*/
|
||||
function sleep (ms) {
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ function sleep (ms) {
|
||||
* @param {string} cmd
|
||||
* @returns {*}
|
||||
*/
|
||||
async function execSync (cmd) {
|
||||
async function execSync(cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
child_process.exec(cmd, (error, stdout, stderr) => {
|
||||
resolve({ error, stdout, stderr })
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @param {string} s_123
|
||||
* @returns {number}
|
||||
*/
|
||||
export default function translateChinaNum (s_123) {
|
||||
export default function translateChinaNum(s_123) {
|
||||
if (!s_123 && s_123 != 0) return s_123
|
||||
// 如果是纯数字直接返回
|
||||
if (/^\d+$/.test(s_123)) return Number(s_123)
|
||||
@@ -23,14 +23,14 @@ export default function translateChinaNum (s_123) {
|
||||
// 按照亿、万为分割将字符串划分为三部分
|
||||
let split = ""
|
||||
split = s_123.split("亿")
|
||||
let s_1_23 = split.length > 1 ? split : ["", s_123]
|
||||
let s_1_23 = split.length > 1 ? split : [ "", s_123 ]
|
||||
let s_23 = s_1_23[1]
|
||||
let s_1 = s_1_23[0]
|
||||
split = s_23.split("万")
|
||||
let s_2_3 = split.length > 1 ? split : ["", s_23]
|
||||
let s_2_3 = split.length > 1 ? split : [ "", s_23 ]
|
||||
let s_2 = s_2_3[0]
|
||||
let s_3 = s_2_3[1]
|
||||
let arr = [s_1, s_2, s_3]
|
||||
let arr = [ s_1, s_2, s_3 ]
|
||||
|
||||
// ------------- 对各个部分处理 -------------
|
||||
arr = arr.map(item => {
|
||||
|
||||
@@ -24,7 +24,7 @@ try {
|
||||
* @param seconds
|
||||
* @param transcoding
|
||||
*/
|
||||
async function uploadRecord (record_url, seconds = 0, transcoding = true) {
|
||||
async function uploadRecord(record_url, seconds = 0, transcoding = true) {
|
||||
if (!Contactable) return segment.record(record_url)
|
||||
const result = await getPttBuffer(record_url, Bot.config.ffmpeg_path, transcoding)
|
||||
if (!result.buffer) {
|
||||
@@ -92,7 +92,7 @@ async function uploadRecord (record_url, seconds = 0, transcoding = true) {
|
||||
11: 1,
|
||||
18: fid,
|
||||
19: seconds,
|
||||
30: Buffer.from([8, 0, 40, 0, 56, 0])
|
||||
30: Buffer.from([ 8, 0, 40, 0, 56, 0 ])
|
||||
})
|
||||
return {
|
||||
type: "record", file: "protobuf://" + Buffer.from(b).toString("base64")
|
||||
@@ -107,7 +107,7 @@ export default uploadRecord
|
||||
* @param ffmpeg
|
||||
* @param transcoding
|
||||
*/
|
||||
async function getPttBuffer (file, ffmpeg = "ffmpeg", transcoding = true) {
|
||||
async function getPttBuffer(file, ffmpeg = "ffmpeg", transcoding = true) {
|
||||
let buffer
|
||||
let time
|
||||
if (file instanceof Buffer || file.startsWith("base64://")) {
|
||||
@@ -175,9 +175,9 @@ async function getPttBuffer (file, ffmpeg = "ffmpeg", transcoding = true) {
|
||||
* @param file
|
||||
* @param ffmpeg
|
||||
*/
|
||||
async function getAudioTime (file, ffmpeg = "ffmpeg") {
|
||||
async function getAudioTime(file, ffmpeg = "ffmpeg") {
|
||||
return new Promise((resolve, _reject) => {
|
||||
(0, child_process.exec)(`${ffmpeg} -i "${file}"`, async (_error, _stdout, stderr) => {
|
||||
(0, child_process.exec)(`${ffmpeg} -i "${file}"`, async(_error, _stdout, stderr) => {
|
||||
try {
|
||||
let time = stderr.split("Duration:")[1]?.split(",")[0].trim()
|
||||
let arr = time?.split(":")
|
||||
@@ -208,10 +208,10 @@ async function getAudioTime (file, ffmpeg = "ffmpeg") {
|
||||
* @param file
|
||||
* @param ffmpeg
|
||||
*/
|
||||
async function audioTrans (file, ffmpeg = "ffmpeg") {
|
||||
async function audioTrans(file, ffmpeg = "ffmpeg") {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tmpfile = path.join(TMP_DIR, (0, uuid)());
|
||||
(0, child_process.exec)(`${ffmpeg} -y -i "${file}" -ac 1 -ar 8000 -f amr "${tmpfile}"`, async (_error, _stdout, _stderr) => {
|
||||
(0, child_process.exec)(`${ffmpeg} -y -i "${file}" -ac 1 -ar 8000 -f amr "${tmpfile}"`, async(_error, _stdout, _stderr) => {
|
||||
try {
|
||||
const amr = await fs.promises.readFile(tmpfile)
|
||||
resolve(amr)
|
||||
@@ -228,7 +228,7 @@ async function audioTrans (file, ffmpeg = "ffmpeg") {
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
async function read7Bytes (file) {
|
||||
async function read7Bytes(file) {
|
||||
const fd = await fs.promises.open(file, "r")
|
||||
const buf = (await fd.read(Buffer.alloc(7), 0, 7, 0)).buffer
|
||||
fd.close()
|
||||
@@ -238,7 +238,7 @@ async function read7Bytes (file) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function uuid () {
|
||||
function uuid() {
|
||||
let hex = crypto.randomBytes(16).toString("hex")
|
||||
return hex.substr(0, 8) + "-" + hex.substr(8, 4) + "-" + hex.substr(12, 4) + "-" + hex.substr(16, 4) + "-" + hex.substr(20)
|
||||
}
|
||||
@@ -247,7 +247,7 @@ function uuid () {
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
function int32ip2str (ip) {
|
||||
function int32ip2str(ip) {
|
||||
if (typeof ip === "string") { return ip }
|
||||
ip = ip & 0xffffffff
|
||||
return [
|
||||
@@ -273,7 +273,7 @@ const md5 = (data) => (0, crypto.createHash)("md5").update(data).digest()
|
||||
|
||||
errors.LoginErrorCode = errors.drop = errors.ErrorCode = void 0
|
||||
let ErrorCode;
|
||||
(function (ErrorCode) {
|
||||
(function(ErrorCode) {
|
||||
/** 客户端离线 */
|
||||
ErrorCode[ErrorCode.ClientNotOnline = -1] = "ClientNotOnline"
|
||||
/** 发包超时未收到服务器回应 */
|
||||
@@ -325,7 +325,7 @@ const ErrorMessage = {
|
||||
* @param code
|
||||
* @param message
|
||||
*/
|
||||
function drop (code, message) {
|
||||
function drop(code, message) {
|
||||
if (!message || !message.length) { message = ErrorMessage[code] }
|
||||
throw new core.ApiRejection(code, message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user