优化
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js';
|
||||
import { segment } from "oicq";
|
||||
import { Cfg, QQInterface, common } from '../model/index.js';
|
||||
import { common, QQInterface } from '../model/index.js';
|
||||
import lodash from 'lodash'
|
||||
import moment from 'moment'
|
||||
|
||||
@@ -428,7 +428,7 @@ export class example extends plugin {
|
||||
await Bot.pickGroup(i).sendMsg(e.message)
|
||||
.then(() => e.reply("✅ " + i + " 群聊消息已送达"))
|
||||
.catch((err) => e.reply(`❎ ${i} 发送失败\n错误信息为:${err.message}`))
|
||||
await Cfg.sleep(5000)
|
||||
await common.sleep(5000)
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -527,7 +527,7 @@ export class example extends plugin {
|
||||
for (let i of img) {
|
||||
msg.push([segment.image(i), "直链:", i])
|
||||
}
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
await e.reply([segment.image(img[0]), "直链:", img[0]])
|
||||
}
|
||||
@@ -571,7 +571,7 @@ export class example extends plugin {
|
||||
})
|
||||
|
||||
if (res.length >= 2) {
|
||||
Cfg.getforwardMsg(e, res)
|
||||
common.getforwardMsg(e, res)
|
||||
} else {
|
||||
e.reply(res[0])
|
||||
}
|
||||
@@ -700,7 +700,7 @@ export class example extends plugin {
|
||||
]
|
||||
}
|
||||
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
|
||||
}
|
||||
|
||||
@@ -730,7 +730,7 @@ export class example extends plugin {
|
||||
//撤回消息
|
||||
await target.recallMsg(source.message_id);
|
||||
|
||||
await Cfg.sleep(300);
|
||||
await common.sleep(300);
|
||||
let recallcheck = await Bot.getMsg(source.message_id)
|
||||
if (recallcheck && recallcheck.message_id == source.message_id) {
|
||||
let msg;
|
||||
|
||||
14
apps/fun.js
14
apps/fun.js
@@ -3,7 +3,7 @@ import fetch from 'node-fetch'
|
||||
import { segment } from "oicq"
|
||||
import lodash from 'lodash'
|
||||
import { Config } from '../components/index.js'
|
||||
import { Cfg, uploadRecord, common, Interface } from '../model/index.js'
|
||||
import { common, uploadRecord, QQInterface, Interface } from '../model/index.js'
|
||||
|
||||
const heisitype = {
|
||||
"白丝": "baisi",
|
||||
@@ -156,7 +156,7 @@ export class example extends plugin {
|
||||
} else break;
|
||||
} else {
|
||||
//陌生人点赞
|
||||
let res = await common.thumbUp(e.user_id, 10)
|
||||
let res = await QQInterface.thumbUp(e.user_id, 10)
|
||||
logger.debug("[椰奶陌生人点赞]", res)
|
||||
if (res.code != 0) {
|
||||
if (res.code == 1) {
|
||||
@@ -223,7 +223,7 @@ export class example extends plugin {
|
||||
item++
|
||||
}
|
||||
}
|
||||
Cfg.getRecallsendMsg(e, msg, false)
|
||||
common.getRecallsendMsg(e, msg, false)
|
||||
return true
|
||||
}
|
||||
//cos/acg搜索
|
||||
@@ -256,7 +256,7 @@ export class example extends plugin {
|
||||
?.map(item => (!/www.pandadiu.com/.test(item) ? domain : "") + (item.match(/<img src="(.*?)".*/)[1]))
|
||||
?.map(item => segment.image(item)) || false
|
||||
if (!imglist) return e.reply(API_ERROR)
|
||||
Cfg.getRecallsendMsg(e, imglist, false)
|
||||
common.getRecallsendMsg(e, imglist, false)
|
||||
}
|
||||
|
||||
//黑丝
|
||||
@@ -288,7 +288,7 @@ export class example extends plugin {
|
||||
return item
|
||||
})
|
||||
//发送消息
|
||||
Cfg.getRecallsendMsg(e, lodash.take(imglist, 20), false)
|
||||
common.getRecallsendMsg(e, lodash.take(imglist, 20), false)
|
||||
}
|
||||
//萌堆
|
||||
async mengdui(e) {
|
||||
@@ -341,7 +341,7 @@ export class example extends plugin {
|
||||
}
|
||||
let msg = list.map(item => segment.image(item.match(/https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*/i)[0]))
|
||||
msg = lodash.take(msg, 30)
|
||||
Cfg.getRecallsendMsg(e, msg, false)
|
||||
common.getRecallsendMsg(e, msg, false)
|
||||
}
|
||||
|
||||
//铃声多多
|
||||
@@ -372,7 +372,7 @@ export class example extends plugin {
|
||||
msg.push(i.image.map(item => segment.image(item)))
|
||||
}
|
||||
if (lodash.isEmpty(msg)) return this.bcy_topic(e)
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
}
|
||||
|
||||
//api大集合
|
||||
|
||||
@@ -2,7 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import lodash from 'lodash'
|
||||
import { Config } from '../components/index.js'
|
||||
import { Cfg, Gpadmin, common, QQInterface, Browser } from '../model/index.js'
|
||||
import { Gpadmin, common, QQInterface, Browser } from '../model/index.js'
|
||||
import moment from 'moment'
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ export class Basics extends plugin {
|
||||
|
||||
if (!(/\d{5,}/.test(qq))) return e.reply("❎ 请输入正确的QQ号");
|
||||
//判断是否为主人
|
||||
if (Cfg.masterQQ?.includes(Number(qq))) {
|
||||
if (Config.masterQQ?.includes(Number(qq))) {
|
||||
return e.reply("居然调戏主人!!!哼,坏蛋(ノ`⊿´)ノ");
|
||||
}
|
||||
let Memberinfo = e.group.pickMember(Number(qq)).info
|
||||
@@ -310,7 +310,7 @@ export class Basics extends plugin {
|
||||
}
|
||||
if (!qq || !(/\d{5,}/.test(qq))) return e.reply("❎ 请输入正确的QQ号");
|
||||
//判断是否为主人
|
||||
if (Cfg.masterQQ?.includes(Number(qq))) {
|
||||
if (Config.masterQQ?.includes(Number(qq))) {
|
||||
return e.reply("居然调戏主人!!!哼,坏蛋(ノ`⊿´)ノ");
|
||||
}
|
||||
let Memberinfo = e.group.pickMember(Number(qq)).info
|
||||
@@ -579,10 +579,10 @@ export class Basics extends plugin {
|
||||
`\n昵称:${info.card || info.nickname}\n`,
|
||||
`QQ:${info.user_id}\n`,
|
||||
`群身份:${common.ROLE_MAP[info.role]}\n`,
|
||||
`禁言剩余时间:${Cfg.getsecondformat(Member.mute_left)}`
|
||||
`禁言剩余时间:${common.getsecondformat(Member.mute_left)}`
|
||||
])
|
||||
}
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
}
|
||||
|
||||
//解除全部禁言
|
||||
@@ -595,7 +595,7 @@ export class Basics extends plugin {
|
||||
if (!mutelist) return e.reply("都没有人被禁言我怎么解的辣\(`Δ’)/")
|
||||
for (let i of mutelist) {
|
||||
await e.group.muteMember(i, 0)
|
||||
await Cfg.sleep(2000)
|
||||
await common.sleep(2000)
|
||||
}
|
||||
e.reply("已经把全部的禁言解除辣╮( •́ω•̀ )╭")
|
||||
}
|
||||
@@ -625,7 +625,7 @@ export class Basics extends plugin {
|
||||
|
||||
e.reply(`本此共需清理「${list.length}」人,防止误触发\n请发送:#确认清理${Reg[2]}${Reg[3]}没发言的人`)
|
||||
}
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
}
|
||||
|
||||
//查看和清理从未发言的人
|
||||
@@ -640,7 +640,7 @@ export class Basics extends plugin {
|
||||
}
|
||||
let removelist = list.map(item => item.user_id)
|
||||
let msg = await Gpadmin.getkickMember(e, removelist)
|
||||
return Cfg.getforwardMsg(e, msg)
|
||||
return common.getforwardMsg(e, msg)
|
||||
}
|
||||
//清理
|
||||
if (/^#?清理/.test(e.msg)) {
|
||||
@@ -653,7 +653,8 @@ export class Basics extends plugin {
|
||||
let num = e.msg.match(new RegExp(Numreg))
|
||||
num = num ? common.translateChinaNum(num[0]) : 1
|
||||
let listinfo = await Gpadmin.getneverspeakinfo(e, num)
|
||||
Cfg.getforwardMsg(e, listinfo)
|
||||
if (!listinfo) return false;
|
||||
common.getforwardMsg(e, listinfo)
|
||||
}
|
||||
|
||||
//查看不活跃排行榜和入群记录
|
||||
@@ -666,7 +667,7 @@ export class Basics extends plugin {
|
||||
} else {
|
||||
msg = await Gpadmin.getRecentlyJoined(e, num)
|
||||
}
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
}
|
||||
//发送通知
|
||||
async Send_notice(e) {
|
||||
@@ -692,7 +693,7 @@ export class Basics extends plugin {
|
||||
let data = JSON.parse(await redis.get(task[i]))
|
||||
msglist.push(`${i + 1}.\n群号:${data.groupNumber}\n禁言时间:${data.muteTime}\n解禁时间:${data.remTime}`)
|
||||
}
|
||||
Cfg.getforwardMsg(e, msglist)
|
||||
common.getforwardMsg(e, msglist)
|
||||
return true
|
||||
}
|
||||
if (/取消/.test(e.msg)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from "oicq";
|
||||
import { Config } from "../components/index.js"
|
||||
import { YamlReader, Cfg } from '../model/index.js'
|
||||
import { YamlReader, common } from '../model/index.js'
|
||||
//全局
|
||||
let temp = {};
|
||||
const ops = ["+", "-"];
|
||||
@@ -65,7 +65,7 @@ export class NEWCMD extends plugin {
|
||||
|
||||
if (qq == Bot.uin) return
|
||||
|
||||
if (Cfg.masterQQ.includes(qq)) return e.reply("❎ 该命令对机器人管理员无效");
|
||||
if (Config.masterQQ.includes(qq)) return e.reply("❎ 该命令对机器人管理员无效");
|
||||
|
||||
if (temp[qq + e.group_id]) return e.reply("❎ 目标群成员处于验证状态");
|
||||
|
||||
@@ -156,7 +156,7 @@ Bot.on("notice.group.increase", async (e) => {
|
||||
|
||||
if (e.user_id == Bot.uin) return
|
||||
|
||||
if (Cfg.masterQQ.includes(e.user_id)) return
|
||||
if (Config.masterQQ.includes(e.user_id)) return
|
||||
|
||||
if (e?.group?.mute_left > 0) return
|
||||
|
||||
@@ -270,7 +270,7 @@ async function verify(user_id, group_id, e) {
|
||||
|
||||
const msg = ` 欢迎,请在「${verifycfg.time}」秒内发送「${m}${operator}${n}」的运算结果,否则将会被移出群聊`;
|
||||
|
||||
await Cfg.sleep(600);
|
||||
await common.sleep(600);
|
||||
//消息发送成功才写入
|
||||
if (await e.reply([segment.at(user_id), msg])) {
|
||||
temp[user_id + group_id] = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import lodash from 'lodash'
|
||||
import { segment } from 'oicq'
|
||||
import Cfg from '../model/Config.js';
|
||||
import { common } from '../model/index.js';
|
||||
import moment from 'moment';
|
||||
const ROLE_MAP = {
|
||||
"admin": '群管理',
|
||||
@@ -99,7 +99,7 @@ export class anotice extends plugin {
|
||||
`可用"#同意好友申请<QQ>"或"#拒绝好友申请<QQ>"进行处理`,
|
||||
...FriendAdd
|
||||
];
|
||||
return Cfg.getforwardMsg(e, msg)
|
||||
return common.getforwardMsg(e, msg)
|
||||
} else if (/全部/.test(e.msg)) {
|
||||
//同意全部好友申请
|
||||
await e.reply("好哒,我开始处理辣٩(๑•ㅂ•)۶")
|
||||
@@ -112,7 +112,7 @@ export class anotice extends plugin {
|
||||
} else {
|
||||
fail.push(`${fail.length + 1}、${i.user_id}`)
|
||||
}
|
||||
await Cfg.sleep(2000)
|
||||
await common.sleep(2000)
|
||||
}
|
||||
let msg = [
|
||||
`本次共${yes ? '同意' : '拒绝'}${FriendAdd.length}条好友申请\n成功:${success.length}\n失败:${fail.length}`
|
||||
@@ -120,7 +120,7 @@ export class anotice extends plugin {
|
||||
if (!lodash.isEmpty(success)) msg.push([`以下为成功的名单:\n`, success.join("\n")])
|
||||
if (!lodash.isEmpty(fail)) msg.push([`以下为失败的名单:\n`, fail.join("\n")])
|
||||
|
||||
return Cfg.getforwardMsg(e, msg)
|
||||
return common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
//处理单个好友申请
|
||||
let qq = e.message[0].text.replace(/#|(同意|拒绝)好友申请/g, '').trim()
|
||||
@@ -288,7 +288,7 @@ export class anotice extends plugin {
|
||||
`可使用 "#(同意|拒绝)加群申请xxx"\n或 "#(同意|拒绝)全部加群申请"`,
|
||||
...SystemMsg
|
||||
]
|
||||
return Cfg.getforwardMsg(e, msg)
|
||||
return common.getforwardMsg(e, msg)
|
||||
}
|
||||
if (!e.isMaster && !e.member.is_owner && !e.member.is_admin) {
|
||||
return e.reply("❎ 该命令仅限管理员可用", true);
|
||||
@@ -307,7 +307,7 @@ export class anotice extends plugin {
|
||||
fail.push(`${fail.length + 1}、${i.user_id}`)
|
||||
}
|
||||
}
|
||||
await Cfg.sleep(1000)
|
||||
await common.sleep(1000)
|
||||
}
|
||||
let msg = [
|
||||
`本次共处理${SystemMsg.length}条群申请\n成功:${success.length}\n失败:${fail.length}\n风险:${risk.length}`
|
||||
@@ -315,7 +315,7 @@ export class anotice extends plugin {
|
||||
if (!lodash.isEmpty(success)) msg.push([`以下为成功的名单:\n`, success.join("\n")])
|
||||
if (!lodash.isEmpty(fail)) msg.push([`以下为失败的名单:\n`, fail.join("\n")])
|
||||
if (!lodash.isEmpty(risk)) msg.push([`以下为风险账号名单:\n`, risk.join("\n")])
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
let qq = e.msg.replace(/#(同意|拒绝)(加|入)群申请/g, "").trim()
|
||||
|
||||
@@ -356,7 +356,7 @@ export class anotice extends plugin {
|
||||
`可使用 "#(同意|拒绝)群邀请xxx"\n或 "#(同意|拒绝)全部群邀请"`,
|
||||
...SystemMsg
|
||||
]
|
||||
return Cfg.getforwardMsg(e, msg)
|
||||
return common.getforwardMsg(e, msg)
|
||||
}
|
||||
|
||||
await e.reply("好哒,我开始处理辣٩(๑•ㅂ•)۶")
|
||||
@@ -369,12 +369,12 @@ export class anotice extends plugin {
|
||||
} else {
|
||||
fail.push(`${fail.length + 1}、${i.user_id}`)
|
||||
}
|
||||
await Cfg.sleep(1000)
|
||||
await common.sleep(1000)
|
||||
}
|
||||
let msg = [`本次共处理${SystemMsg.length}条群邀请\n成功:${success.length}\n失败:${fail.length}`]
|
||||
if (!lodash.isEmpty(success)) msg.push([`以下为成功的名单:\n`, success.join("\n")])
|
||||
if (!lodash.isEmpty(fail)) msg.push([`以下为失败的名单:\n`, fail.join("\n")])
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
} else {
|
||||
let groupid = e.msg.replace(/#(同意|拒绝)群邀请/g, "").trim()
|
||||
|
||||
@@ -421,6 +421,6 @@ export class anotice extends plugin {
|
||||
}
|
||||
if (lodash.isEmpty(msg)) return e.reply("好耶!!一条请求都没有哦o( ❛ᴗ❛ )o", true)
|
||||
msg.unshift("以下为暂未处理的请求")
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import Cfg from '../model/Config.js'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export class Friends extends plugin {
|
||||
|
||||
if (e.user_id == Bot.uin) return false;
|
||||
|
||||
if (Cfg.masterQQ.includes(e.user_id)) return false
|
||||
if (Config.masterQQ.includes(e.user_id)) return false
|
||||
logger.mark("[椰奶]好友撤回")
|
||||
// 读取
|
||||
let res = JSON.parse(
|
||||
@@ -94,10 +94,8 @@ export class Friends extends plugin {
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
await Cfg.getSend(msg)
|
||||
if (forwardMsg) {
|
||||
await Cfg.getSend(forwardMsg)
|
||||
}
|
||||
await common.sendMasterMsg(msg)
|
||||
if (forwardMsg) await common.sendMasterMsg(forwardMsg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import Cfg from '../model/Config.js'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
import moment from 'moment'
|
||||
|
||||
@@ -164,7 +164,7 @@ export class newgroups extends plugin {
|
||||
}
|
||||
// 禁言 (这里仅处理机器人被禁言)
|
||||
case 'ban': {
|
||||
let Forbiddentime = Cfg.getsecondformat(e.duration)
|
||||
let Forbiddentime = common.getsecondformat(e.duration)
|
||||
|
||||
if (!Config.getGroup(e.group_id).botBeenBanned) return false;
|
||||
|
||||
@@ -220,7 +220,7 @@ export class newgroups extends plugin {
|
||||
// 是否为机器人撤回
|
||||
if (e.user_id == Bot.uin) return false;
|
||||
// 是否为主人撤回
|
||||
if (Cfg.masterQQ.includes(e.user_id)) return false;
|
||||
if (Config.masterQQ.includes(e.user_id)) return false;
|
||||
// 读取
|
||||
let res = JSON.parse(
|
||||
await redis.get(`notice:messageGroup:${e.message_id}`)
|
||||
@@ -253,7 +253,7 @@ export class newgroups extends plugin {
|
||||
special = '[合并消息]'
|
||||
} else {
|
||||
// 正常处理
|
||||
forwardMsg = await Bot.pickFriend(Cfg.masterQQ[0]).makeForwardMsg([
|
||||
forwardMsg = await Bot.pickFriend(Config.masterQQ[0]).makeForwardMsg([
|
||||
{
|
||||
message: res,
|
||||
nickname: e.group.pickMember(e.user_id).card,
|
||||
@@ -287,10 +287,8 @@ export class newgroups extends plugin {
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
await Cfg.getSend(msg)
|
||||
if (forwardMsg) {
|
||||
await Cfg.getSend(forwardMsg)
|
||||
}
|
||||
await common.sendMasterMsg(msg)
|
||||
if (forwardMsg) await common.sendMasterMsg(forwardMsg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import Cfg from '../model/Config.js'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
|
||||
export class anotice extends plugin {
|
||||
@@ -18,7 +18,7 @@ Bot.on("message", async (e) => {
|
||||
// 判断是否为机器人消息
|
||||
if (e.user_id == Bot.uin) return false;
|
||||
// 判断是否主人消息
|
||||
if (Cfg.masterQQ.includes(e.user_id)) return false;
|
||||
if (Config.masterQQ.includes(e.user_id)) return false;
|
||||
//删除缓存时间
|
||||
let deltime = Config.Notice.deltime
|
||||
// 判断群聊还是私聊
|
||||
@@ -183,10 +183,9 @@ Bot.on("message", async (e) => {
|
||||
]
|
||||
}
|
||||
// 发送消息
|
||||
await Cfg.getSend(msg)
|
||||
if (forwardMsg) {
|
||||
await Cfg.getSend(forwardMsg)
|
||||
}
|
||||
await common.sendMasterMsg(msg)
|
||||
if (forwardMsg) await common.sendMasterMsg(forwardMsg)
|
||||
|
||||
})
|
||||
|
||||
// 特殊消息处理
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import { segment } from 'oicq'
|
||||
import cfg from '../../../lib/config/config.js'
|
||||
import xcfg from '../model/Config.js'
|
||||
import { common } from '../model/index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
const ROLE_MAP = {
|
||||
admin: '群管理',
|
||||
@@ -79,6 +79,6 @@ export class invitation extends plugin {
|
||||
}
|
||||
break;
|
||||
}
|
||||
await xcfg.getSend(msg)
|
||||
await common.sendMasterMsg(msg)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import moment from 'moment';
|
||||
import { Config } from '../components/index.js'
|
||||
import { Cfg, Pixiv, common, setu } from '../model/index.js'
|
||||
import { Pixiv, common, setu } from '../model/index.js'
|
||||
|
||||
//文案
|
||||
const SWITCH_ERROR = "主人没有开放这个功能哦(*/ω\*)"
|
||||
@@ -75,7 +75,7 @@ export class example extends plugin {
|
||||
|
||||
await e.reply(msg)
|
||||
|
||||
img.length == 1 || /R-18/.test(msg[4]) ? Cfg.recallsendMsg(e, img) : Cfg.getRecallsendMsg(e, img, false)
|
||||
img.length == 1 || /R-18/.test(msg[4]) ? common.recallsendMsg(e, img) : common.getRecallsendMsg(e, img, false)
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ export class example extends plugin {
|
||||
|
||||
if (!res) return
|
||||
|
||||
Cfg.getRecallsendMsg(e, res, false)
|
||||
common.getRecallsendMsg(e, res, false)
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ export class example extends plugin {
|
||||
res = await new Pixiv(e).searchTags(tag, page)
|
||||
}
|
||||
if (!res) return
|
||||
Cfg.getRecallsendMsg(e, res, false)
|
||||
common.getRecallsendMsg(e, res, false)
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ export class example extends plugin {
|
||||
|
||||
if (!res) return
|
||||
|
||||
Cfg.getRecallsendMsg(e, res, false)
|
||||
common.getRecallsendMsg(e, res, false)
|
||||
}
|
||||
|
||||
/**以uid搜图**/
|
||||
@@ -179,7 +179,7 @@ export class example extends plugin {
|
||||
|
||||
if (!res) return
|
||||
|
||||
Cfg.getRecallsendMsg(e, res, false)
|
||||
common.getRecallsendMsg(e, res, false)
|
||||
}
|
||||
|
||||
//随机原创插画
|
||||
@@ -200,7 +200,7 @@ export class example extends plugin {
|
||||
|
||||
if (!res) return
|
||||
|
||||
Cfg.getRecallsendMsg(e, res, false)
|
||||
common.getRecallsendMsg(e, res, false)
|
||||
}
|
||||
|
||||
//相关作品
|
||||
@@ -211,7 +211,7 @@ export class example extends plugin {
|
||||
let regRet = relatedReg.exec(e.msg)
|
||||
let msg = await new Pixiv(e).getrelated_works(regRet[1])
|
||||
if (!msg) return
|
||||
Cfg.getRecallsendMsg(e, msg, false)
|
||||
common.getRecallsendMsg(e, msg, false)
|
||||
}
|
||||
|
||||
//p站单图
|
||||
@@ -222,6 +222,6 @@ export class example extends plugin {
|
||||
if ((!sese && !sesepro || !sesepro && ispro) && !e.isMaster) return e.reply(SWITCH_ERROR)
|
||||
|
||||
let msg = await new Pixiv(e).getPximg(ispro)
|
||||
ispro ? Cfg.getRecallsendMsg(e, [msg], false) : Cfg.recallsendMsg(e, msg)
|
||||
ispro ? common.getRecallsendMsg(e, [msg], false) : common.recallsendMsg(e, msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ export class NewConfig extends plugin {
|
||||
}
|
||||
//查看涩涩设置
|
||||
async View_Settings(e) {
|
||||
let set = setu.getConfig(e)
|
||||
let set = setu.getSeSeConfig(e)
|
||||
let data = Config.Notice
|
||||
e.reply([
|
||||
`sese:${data.sese ? "✅" : "❎"}\n`,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import plugin from '../../../lib/plugins/plugin.js'
|
||||
import os from 'os';
|
||||
import { render, Config } from '../components/index.js'
|
||||
import { CPU, Cfg, common } from '../model/index.js'
|
||||
import { CPU, common } from '../model/index.js'
|
||||
import moment from 'moment';
|
||||
// import si from 'systeminformation'
|
||||
let si = await redis.get('yenai:node_modules') ? await import("systeminformation") : false
|
||||
@@ -106,7 +106,7 @@ export class example extends plugin {
|
||||
* @return {String} 天:?时:分:秒
|
||||
*/
|
||||
function Formatting(time, repair) {
|
||||
let times = Cfg.getsecond(time, repair)
|
||||
let times = common.getsecond(time, repair)
|
||||
|
||||
let { second, minute, hour, day } = times
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import YAML from 'yaml'
|
||||
import chokidar from 'chokidar'
|
||||
import fs from 'node:fs'
|
||||
import YamlReader from '../model/YamlReader.js'
|
||||
import cfg from '../../../lib/config/config.js'
|
||||
|
||||
const Path = process.cwd();
|
||||
const Plugin_Name = 'yenai-plugin'
|
||||
@@ -38,7 +39,10 @@ class Config {
|
||||
}
|
||||
return { ...defCfg, ...config }
|
||||
}
|
||||
|
||||
/**主人QQ */
|
||||
get masterQQ() {
|
||||
return cfg.masterQQ
|
||||
}
|
||||
//获取全局设置
|
||||
get Notice() {
|
||||
return this.getNotice()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import puppeteer from 'puppeteer'
|
||||
import { segment } from 'oicq'
|
||||
class Browser {
|
||||
export default new class Browser {
|
||||
/**
|
||||
* @description:返回网页截图
|
||||
* @param {String} url 网页链接
|
||||
@@ -90,7 +90,4 @@ class Browser {
|
||||
await browser.close();
|
||||
return segment.image(res)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default new Browser();
|
||||
}
|
||||
@@ -5,7 +5,8 @@ import fs from 'fs'
|
||||
import { common } from './index.js'
|
||||
import { Config } from '../components/index.js'
|
||||
let si = await redis.get('yenai:node_modules') ? await import("systeminformation") : false
|
||||
class OSUtils {
|
||||
|
||||
export default new class OSUtils {
|
||||
constructor() {
|
||||
this.cpuUsageMSDefault = 1000; // CPU 利用率默认时间段
|
||||
this.isGPU = false;
|
||||
@@ -253,5 +254,4 @@ class OSUtils {
|
||||
js: fs.readdirSync("./plugins/example")?.length || 0
|
||||
}
|
||||
}
|
||||
}
|
||||
export default new OSUtils();
|
||||
}
|
||||
271
model/Config.js
271
model/Config.js
@@ -1,271 +0,0 @@
|
||||
import cfg from '../../../lib/config/config.js'
|
||||
import common from '../../../lib/common/common.js'
|
||||
import fs from 'fs'
|
||||
import Config from '../components/Config.js'
|
||||
|
||||
class newConfig {
|
||||
|
||||
/**主人QQ */
|
||||
get masterQQ() {
|
||||
return cfg.masterQQ
|
||||
}
|
||||
/**
|
||||
* @description: 延时函数
|
||||
* @param {*} ms 时间(毫秒)
|
||||
*/
|
||||
sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
/** 读取文件 */
|
||||
getJson(path) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(path, 'utf8'))
|
||||
} catch (err) {
|
||||
logger.error('读取失败')
|
||||
logger.error(err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** 写入json文件 */
|
||||
setJson(path, cot = {}) {
|
||||
try {
|
||||
fs.writeFileSync(path, JSON.stringify(cot, '', '\t'))
|
||||
return true
|
||||
} catch (error) {
|
||||
logger.error('写入失败')
|
||||
logger.error(err)
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** 发消息 */
|
||||
async getSend(msg) {
|
||||
if (Config.Notice.notificationsAll) {
|
||||
// 发送全部管理
|
||||
for (let index of cfg.masterQQ) {
|
||||
await common.relpyPrivate(index, msg)
|
||||
await this.sleep(5000)
|
||||
}
|
||||
} else {
|
||||
// 发给第一个管理
|
||||
await common.relpyPrivate(cfg.masterQQ[0], msg)
|
||||
await common.sleep(200)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 秒转换返回对象
|
||||
* @param {Number} time 秒数
|
||||
* @param {boolean} repair 是否需要补零
|
||||
* @return {object} 包含天,时,分,秒
|
||||
*/
|
||||
getsecond(time, repair) {
|
||||
let second = parseInt(time)
|
||||
let minute = 0
|
||||
let hour = 0
|
||||
let day = 0
|
||||
if (second > 60) {
|
||||
minute = parseInt(second / 60)
|
||||
second = parseInt(second % 60)
|
||||
}
|
||||
if (minute > 60) {
|
||||
hour = parseInt(minute / 60)
|
||||
minute = parseInt(minute % 60)
|
||||
}
|
||||
if (hour > 23) {
|
||||
day = parseInt(hour / 24)
|
||||
hour = parseInt(hour % 24)
|
||||
}
|
||||
if (repair) {
|
||||
hour = hour < 10 ? "0" + hour : hour
|
||||
minute = minute < 10 ? "0" + minute : minute
|
||||
second = second < 10 ? "0" + second : second
|
||||
}
|
||||
return {
|
||||
day,
|
||||
hour,
|
||||
minute,
|
||||
second
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: //发送转发消息
|
||||
* @param {*} e oicq
|
||||
* @param {Array} message 发送的消息
|
||||
* @param {Number} time 撤回时间
|
||||
* @param {Boolean} isBot 转发信息是否以bot信息发送
|
||||
* @param {Boolean} isfk 是否发送默认风控消息
|
||||
* @return {Boolean}
|
||||
*/
|
||||
async getforwardMsg(e, message, time = 0, isBot = true, isfk = true) {
|
||||
let forwardMsg = []
|
||||
for (let i of message) {
|
||||
forwardMsg.push(
|
||||
{
|
||||
message: i,
|
||||
nickname: isBot ? Bot.nickname : e.sender.card || e.sender.nickname,
|
||||
user_id: isBot ? Bot.uin : e.sender.user_id
|
||||
}
|
||||
)
|
||||
}
|
||||
//发送
|
||||
if (e.isGroup) {
|
||||
forwardMsg = await e.group.makeForwardMsg(forwardMsg)
|
||||
} else {
|
||||
forwardMsg = await e.friend.makeForwardMsg(forwardMsg)
|
||||
}
|
||||
//处理转发卡片
|
||||
forwardMsg.data = forwardMsg.data
|
||||
.replace('<?xml version="1.0" encoding="utf-8"?>', '<?xml version="1.0" encoding="utf-8" ?>')
|
||||
.replace(/\n/g, '')
|
||||
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
|
||||
.replace(/___+/, '<title color="#777777" size="26">涩批(//// ^ ////)</title>');
|
||||
//发送消息
|
||||
let res = await e.reply(forwardMsg, false, { recallMsg: time })
|
||||
if (!res) {
|
||||
if (isfk) {
|
||||
await e.reply("消息发送失败,可能被风控")
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 发送普通消息并根据指定时间撤回群消息
|
||||
* @param {*} e oicq
|
||||
* @param {*} msg 消息
|
||||
* @param {Number} time 撤回时间
|
||||
* @param {Boolean} isfk 是否发送默认风控消息
|
||||
* @return {*}
|
||||
*/
|
||||
async recallsendMsg(e, msg, time = 0, isfk = true) {
|
||||
time = time || this.getRecallTime(e)
|
||||
|
||||
//发送消息
|
||||
let res = await e.reply(msg, false, { recallMsg: time })
|
||||
if (!res) {
|
||||
if (isfk) {
|
||||
await e.reply("消息发送失败,可能被风控")
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取配置的撤回时间发送转发消息
|
||||
* @param {*} e oicq
|
||||
* @param {Array} msg 发送的消息
|
||||
* @param {Boolean} isBot 转发信息是否以bot信息发送
|
||||
* @param {Boolean} isfk 是否发送默认风控消息
|
||||
* @return {Boolean}
|
||||
*/
|
||||
async getRecallsendMsg(e, msg, isBot = true, isfk = true) {
|
||||
let time = this.getRecallTime(e)
|
||||
|
||||
let res = await this.getforwardMsg(e, msg, time, isBot, isfk)
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取群的撤回时间
|
||||
* @param {*} e oicq
|
||||
* @return {Number}
|
||||
*/
|
||||
getRecallTime(e) {
|
||||
if (!e.isGroup) return 0;
|
||||
let path = "./plugins/yenai-plugin/config/setu/setu.json"
|
||||
//获取撤回时间
|
||||
let cfgs = {};
|
||||
let time = 120;
|
||||
if (fs.existsSync(path)) {
|
||||
cfgs = this.getJson(path)
|
||||
}
|
||||
|
||||
if (cfgs[e.group_id]) {
|
||||
time = cfgs[e.group_id].recall
|
||||
}
|
||||
return time
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 取cookie
|
||||
* @param {String} data 如:qun.qq.com
|
||||
* @return {Object}
|
||||
*/
|
||||
getck(data) {
|
||||
let cookie = Bot.cookies[data]
|
||||
let ck = cookie.replace(/=/g, `":"`).replace(/;/g, `","`).replace(/ /g, "").trim()
|
||||
ck = ck.substring(0, ck.length - 2)
|
||||
ck = `{"`.concat(ck).concat("}")
|
||||
return JSON.parse(ck)
|
||||
}
|
||||
|
||||
/**默认秒转换格式 */
|
||||
getsecondformat(value) {
|
||||
let time = this.getsecond(value)
|
||||
|
||||
let { second, minute, hour, day } = time
|
||||
// 处理返回消息
|
||||
let result = ''
|
||||
if (second != 0) {
|
||||
result = parseInt(second) + '秒'
|
||||
}
|
||||
if (minute > 0) {
|
||||
result = parseInt(minute) + '分' + result
|
||||
}
|
||||
if (hour > 0) {
|
||||
result = parseInt(hour) + '小时' + result
|
||||
}
|
||||
if (day > 0) {
|
||||
result = parseInt(day) + '天' + result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** 将数组进行分页,返回新的分页数组
|
||||
* @param {Object} pageSize 每页大小
|
||||
* @param {Object} arr 数组
|
||||
*/
|
||||
returnAllPageFunc(pageSize, arr) {
|
||||
let pageNum = 1
|
||||
let pageObj = {
|
||||
pageNum: 1,
|
||||
list: []
|
||||
}
|
||||
let pageResult = []
|
||||
|
||||
let newArr = JSON.parse(JSON.stringify(arr))
|
||||
let totalPage = newArr.length ? Math.ceil(arr.length / pageSize) : 0 // 计算总页数
|
||||
|
||||
for (let i = 1; i <= totalPage; i++) {
|
||||
if (totalPage == 1) {
|
||||
pageNum += 1
|
||||
pageObj.list = newArr.splice(0, arr.length)
|
||||
} else if (i <= totalPage) {
|
||||
pageNum += 1
|
||||
pageObj.list = newArr.splice(0, pageSize)
|
||||
} else {
|
||||
pageObj.list = newArr.splice(0, arr.length % pageSize)
|
||||
}
|
||||
pageResult.push(pageObj)
|
||||
pageObj = {
|
||||
pageNum: pageNum,
|
||||
list: []
|
||||
}
|
||||
}
|
||||
return pageResult
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default new newConfig();
|
||||
@@ -1,4 +1,4 @@
|
||||
import Cfg from './Config.js';
|
||||
import { common } from './index.js';
|
||||
import lodash from 'lodash';
|
||||
import moment from 'moment'
|
||||
import { segment } from 'oicq'
|
||||
@@ -41,19 +41,18 @@ class Group_admin {
|
||||
`最后发言时间:${moment(item.last_sent_time * 1000).format("YYYY-MM-DD HH:mm:ss")}`
|
||||
]
|
||||
})
|
||||
let Page = Cfg.returnAllPageFunc(30, msg)
|
||||
let Page = lodash.chunk(msg, 30)
|
||||
if (num > Page.length) {
|
||||
e.reply("哪有那么多人辣o(´^`)o")
|
||||
return false
|
||||
}
|
||||
let msgs = Page[num - 1]
|
||||
let res = msgs.list
|
||||
res.unshift(`当前为第${msgs.pageNum}页,共${Page.length}页,本页共${res.length}人,总共${msg.length}人`)
|
||||
res.unshift(`以下为${times}${unit}没发言过的坏淫`)
|
||||
msgs.unshift(`当前为第${num}页,共${Page.length}页,本页共${msgs.length}人,总共${msg.length}人`)
|
||||
msgs.unshift(`以下为${times}${unit}没发言过的坏淫`)
|
||||
if (num < Page.length) {
|
||||
res.splice(2, 0, `可用 "#查看${times}${unit}没发言过的人第${msgs.pageNum + 1}页" 翻页`)
|
||||
msgs.splice(2, 0, `可用 "#查看${times}${unit}没发言过的人第${num + 1}页" 翻页`)
|
||||
}
|
||||
return res
|
||||
return msgs
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +67,7 @@ class Group_admin {
|
||||
if (!list) return false
|
||||
list = list.map(item => item.user_id)
|
||||
let msg = await this.getkickMember(e, list)
|
||||
Cfg.getforwardMsg(e, msg)
|
||||
common.getforwardMsg(e, msg)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -133,19 +132,18 @@ class Group_admin {
|
||||
`进群时间:${moment(item.join_time * 1000).format("YYYY-MM-DD HH:mm:ss")}`
|
||||
]
|
||||
})
|
||||
let Page = Cfg.returnAllPageFunc(30, msg)
|
||||
let Page = lodash.chunk(msg, 30)
|
||||
if (num > Page.length) {
|
||||
e.reply("哪有那么多人辣o(´^`)o")
|
||||
return false
|
||||
}
|
||||
let msgs = Page[num - 1]
|
||||
let res = msgs.list
|
||||
res.unshift(`当前为第${msgs.pageNum}页,共${Page.length}页,本页共${res.length}人,总共${msg.length}人`)
|
||||
res.unshift(`以下为进群后从未发言过的坏淫`)
|
||||
msgs.unshift(`当前为第${num}页,共${Page.length}页,本页共${msgs.length}人,总共${msg.length}人`)
|
||||
msgs.unshift(`以下为进群后从未发言过的坏淫`)
|
||||
if (num < Page.length) {
|
||||
res.splice(2, 0, `可用 "#查看从未发言过的人第${msgs.pageNum + 1}页" 翻页`)
|
||||
msgs.splice(2, 0, `可用 "#查看从未发言过的人第${num + 1}页" 翻页`)
|
||||
}
|
||||
return res
|
||||
return msgs
|
||||
}
|
||||
/**
|
||||
* @description: 批量踢出群成员
|
||||
@@ -162,7 +160,7 @@ class Group_admin {
|
||||
} else {
|
||||
fail.push(i)
|
||||
}
|
||||
await Cfg.sleep(5000)
|
||||
await common.sleep(5000)
|
||||
}
|
||||
let msg = [
|
||||
[`本次共清理${arr.length}人\n`,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import fetch from "node-fetch"
|
||||
import { Cfg } from './index.js';
|
||||
import { common } from './index.js';
|
||||
import lodash from 'lodash'
|
||||
import moment from 'moment'
|
||||
import { core } from "oicq";
|
||||
import { segment } from "oicq";
|
||||
/**获取gtk */
|
||||
const gtk = function (t) {
|
||||
@@ -64,7 +65,7 @@ export default new class assistant {
|
||||
}
|
||||
/**发送说说 */
|
||||
async setQzone(con, img) {
|
||||
let ck = Cfg.getck('qzone.qq.com')
|
||||
let ck = common.getck('qzone.qq.com')
|
||||
|
||||
if (img) {
|
||||
let url = `http://xiaobai.klizi.cn/API/qqgn/ss_sendimg.php?uin=${Bot.uin}&skey=${ck.skey}&pskey=${ck.p_skey}&url=${img[0]}&msg=${con}`
|
||||
@@ -287,7 +288,7 @@ export default new class assistant {
|
||||
|
||||
/**今日打卡 */
|
||||
async signInToday(groupId) {
|
||||
let ck = Cfg.getck('qun.qq.com')
|
||||
let ck = common.getck('qun.qq.com')
|
||||
let body = JSON.stringify({
|
||||
"dayYmd": moment().format("YYYYMMDD"),
|
||||
"offset": 0,
|
||||
@@ -385,4 +386,37 @@ export default new class assistant {
|
||||
body,
|
||||
}).then(res => res.json()).catch(err => console.error(err));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 陌生人点赞
|
||||
* @param {Number} uid QQ号
|
||||
* @param {Number} times 数量
|
||||
* @return {Object}
|
||||
*/
|
||||
async thumbUp(uid, times = 1) {
|
||||
if (times > 20)
|
||||
times = 20;
|
||||
let ReqFavorite;
|
||||
if (Bot.fl.get(uid)) {
|
||||
ReqFavorite = core.jce.encodeStruct([
|
||||
core.jce.encodeNested([
|
||||
Bot.uin, 1, Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160131", "hex")
|
||||
]),
|
||||
uid, 0, 1, Number(times)
|
||||
]);
|
||||
}
|
||||
else {
|
||||
ReqFavorite = core.jce.encodeStruct([
|
||||
core.jce.encodeNested([
|
||||
Bot.uin, 1, Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160135", "hex")
|
||||
]),
|
||||
uid, 0, 5, Number(times)
|
||||
]);
|
||||
}
|
||||
const body = core.jce.encodeWrapper({ ReqFavorite }, "VisitorSvc", "ReqFavorite", Bot.sig.seq + 1);
|
||||
const payload = await Bot.sendUni("VisitorSvc.ReqFavorite", body);
|
||||
let result = core.jce.decodeWrapper(payload)[0];
|
||||
return { code: result[3], msg: result[4] };
|
||||
}
|
||||
}
|
||||
268
model/common.js
268
model/common.js
@@ -1,7 +1,233 @@
|
||||
import { core } from "oicq";
|
||||
import common from '../../../lib/common/common.js'
|
||||
import fs from 'fs'
|
||||
import Config from '../components/Config.js'
|
||||
import child_process from 'child_process'
|
||||
|
||||
export default new class common {
|
||||
|
||||
export default new class newCommon {
|
||||
/**
|
||||
* @description: 延时函数
|
||||
* @param {*} ms 时间(毫秒)
|
||||
*/
|
||||
sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
/** 读取文件 */
|
||||
getJson(path) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(path, 'utf8'))
|
||||
} catch (err) {
|
||||
logger.error('读取失败')
|
||||
logger.error(err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** 写入json文件 */
|
||||
setJson(path, cot = {}) {
|
||||
try {
|
||||
fs.writeFileSync(path, JSON.stringify(cot, '', '\t'))
|
||||
return true
|
||||
} catch (error) {
|
||||
logger.error('写入失败')
|
||||
logger.error(err)
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** 发消息 */
|
||||
async sendMasterMsg(msg) {
|
||||
if (Config.Notice.notificationsAll) {
|
||||
// 发送全部管理
|
||||
for (let index of Config.masterQQ) {
|
||||
await common.relpyPrivate(index, msg)
|
||||
await this.sleep(5000)
|
||||
}
|
||||
} else {
|
||||
// 发给第一个管理
|
||||
await common.relpyPrivate(Config.masterQQ[0], msg)
|
||||
await common.sleep(200)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 秒转换返回对象
|
||||
* @param {Number} time 秒数
|
||||
* @param {boolean} repair 是否需要补零
|
||||
* @return {object} 包含天,时,分,秒
|
||||
*/
|
||||
getsecond(time, repair) {
|
||||
let second = parseInt(time)
|
||||
let minute = 0
|
||||
let hour = 0
|
||||
let day = 0
|
||||
if (second > 60) {
|
||||
minute = parseInt(second / 60)
|
||||
second = parseInt(second % 60)
|
||||
}
|
||||
if (minute > 60) {
|
||||
hour = parseInt(minute / 60)
|
||||
minute = parseInt(minute % 60)
|
||||
}
|
||||
if (hour > 23) {
|
||||
day = parseInt(hour / 24)
|
||||
hour = parseInt(hour % 24)
|
||||
}
|
||||
if (repair) {
|
||||
hour = hour < 10 ? "0" + hour : hour
|
||||
minute = minute < 10 ? "0" + minute : minute
|
||||
second = second < 10 ? "0" + second : second
|
||||
}
|
||||
return {
|
||||
day,
|
||||
hour,
|
||||
minute,
|
||||
second
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: //发送转发消息
|
||||
* @param {*} e oicq
|
||||
* @param {Array} message 发送的消息
|
||||
* @param {Number} time 撤回时间
|
||||
* @param {Boolean} isBot 转发信息是否以bot信息发送
|
||||
* @param {Boolean} isfk 是否发送默认风控消息
|
||||
* @return {Boolean}
|
||||
*/
|
||||
async getforwardMsg(e, message, time = 0, isBot = true, isfk = true) {
|
||||
let forwardMsg = []
|
||||
for (let i of message) {
|
||||
forwardMsg.push(
|
||||
{
|
||||
message: i,
|
||||
nickname: isBot ? Bot.nickname : e.sender.card || e.sender.nickname,
|
||||
user_id: isBot ? Bot.uin : e.sender.user_id
|
||||
}
|
||||
)
|
||||
}
|
||||
//发送
|
||||
if (e.isGroup) {
|
||||
forwardMsg = await e.group.makeForwardMsg(forwardMsg)
|
||||
} else {
|
||||
forwardMsg = await e.friend.makeForwardMsg(forwardMsg)
|
||||
}
|
||||
//处理转发卡片
|
||||
forwardMsg.data = forwardMsg.data
|
||||
.replace('<?xml version="1.0" encoding="utf-8"?>', '<?xml version="1.0" encoding="utf-8" ?>')
|
||||
.replace(/\n/g, '')
|
||||
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
|
||||
.replace(/___+/, '<title color="#777777" size="26">涩批(//// ^ ////)</title>');
|
||||
//发送消息
|
||||
let res = await e.reply(forwardMsg, false, { recallMsg: time })
|
||||
if (!res) {
|
||||
if (isfk) {
|
||||
await e.reply("消息发送失败,可能被风控")
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 发送普通消息并根据指定时间撤回群消息
|
||||
* @param {*} e oicq
|
||||
* @param {*} msg 消息
|
||||
* @param {Number} time 撤回时间
|
||||
* @param {Boolean} isfk 是否发送默认风控消息
|
||||
* @return {*}
|
||||
*/
|
||||
async recallsendMsg(e, msg, time = 0, isfk = true) {
|
||||
time = time || this.getRecallTime(e.group_id);
|
||||
|
||||
//发送消息
|
||||
let res = await e.reply(msg, false, { recallMsg: time })
|
||||
if (!res) {
|
||||
if (isfk) {
|
||||
await e.reply("消息发送失败,可能被风控")
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取配置的撤回时间发送转发消息
|
||||
* @param {*} e oicq
|
||||
* @param {Array} msg 发送的消息
|
||||
* @param {Boolean} isBot 转发信息是否以bot信息发送
|
||||
* @param {Boolean} isfk 是否发送默认风控消息
|
||||
* @return {Boolean}
|
||||
*/
|
||||
async getRecallsendMsg(e, msg, isBot = true, isfk = true) {
|
||||
let time = this.getRecallTime(e.group_id)
|
||||
|
||||
let res = await this.getforwardMsg(e, msg, time, isBot, isfk)
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取群的撤回时间
|
||||
* @param {*} e oicq
|
||||
* @return {Number}
|
||||
*/
|
||||
getRecallTime(groupId) {
|
||||
if (!groupId) return 0;
|
||||
let path = "./plugins/yenai-plugin/config/setu/setu.json"
|
||||
//获取撤回时间
|
||||
let cfgs = {};
|
||||
let time = 120;
|
||||
if (fs.existsSync(path)) {
|
||||
cfgs = this.getJson(path)
|
||||
}
|
||||
|
||||
if (cfgs[groupId]) {
|
||||
time = cfgs[groupId].recall
|
||||
}
|
||||
return time
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 取cookie
|
||||
* @param {String} data 如:qun.qq.com
|
||||
* @return {Object}
|
||||
*/
|
||||
getck(data) {
|
||||
let cookie = Bot.cookies[data]
|
||||
let ck = cookie.replace(/=/g, `":"`).replace(/;/g, `","`).replace(/ /g, "").trim()
|
||||
ck = ck.substring(0, ck.length - 2)
|
||||
ck = `{"`.concat(ck).concat("}")
|
||||
return JSON.parse(ck)
|
||||
}
|
||||
|
||||
/**默认秒转换格式 */
|
||||
getsecondformat(value) {
|
||||
let time = this.getsecond(value)
|
||||
|
||||
let { second, minute, hour, day } = time
|
||||
// 处理返回消息
|
||||
let result = ''
|
||||
if (second != 0) {
|
||||
result = parseInt(second) + '秒'
|
||||
}
|
||||
if (minute > 0) {
|
||||
result = parseInt(minute) + '分' + result
|
||||
}
|
||||
if (hour > 0) {
|
||||
result = parseInt(hour) + '小时' + result
|
||||
}
|
||||
if (day > 0) {
|
||||
result = parseInt(day) + '天' + result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 使用JS将数字从汉字形式转化为阿拉伯形式
|
||||
* @param {string} s_123
|
||||
@@ -10,7 +236,7 @@ export default new class common {
|
||||
translateChinaNum(s_123) {
|
||||
//如果是纯数字直接返回
|
||||
if (/^\d+$/.test(s_123)) return Number(s_123)
|
||||
// -------------------------------------------------- 字典,甚至可以使用繁体 --------------------------------------------------
|
||||
//字典
|
||||
let map = new Map()
|
||||
map.set('一', 1)
|
||||
map.set('壹', 1) // 特殊
|
||||
@@ -23,8 +249,7 @@ export default new class common {
|
||||
map.set('七', 7)
|
||||
map.set('八', 8)
|
||||
map.set('九', 9)
|
||||
|
||||
// -------------------------------------------------- 按照亿、万为分割将字符串划分为三部分 --------------------------------------------------
|
||||
//按照亿、万为分割将字符串划分为三部分
|
||||
let split = ''
|
||||
split = s_123.split('亿')
|
||||
let s_1_23 = split.length > 1 ? split : ['', s_123]
|
||||
@@ -69,37 +294,10 @@ export default new class common {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 陌生人点赞
|
||||
* @param {Number} uid QQ号
|
||||
* @param {Number} times 数量
|
||||
* @return {Object}
|
||||
* @description: Promise执行exec
|
||||
* @param {String} cmd
|
||||
* @return {*}
|
||||
*/
|
||||
async thumbUp(uid, times = 1) {
|
||||
if (times > 20)
|
||||
times = 20;
|
||||
let ReqFavorite;
|
||||
if (Bot.fl.get(uid)) {
|
||||
ReqFavorite = core.jce.encodeStruct([
|
||||
core.jce.encodeNested([
|
||||
Bot.uin, 1, Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160131", "hex")
|
||||
]),
|
||||
uid, 0, 1, Number(times)
|
||||
]);
|
||||
}
|
||||
else {
|
||||
ReqFavorite = core.jce.encodeStruct([
|
||||
core.jce.encodeNested([
|
||||
Bot.uin, 1, Bot.sig.seq + 1, 1, 0, Buffer.from("0C180001060131160135", "hex")
|
||||
]),
|
||||
uid, 0, 5, Number(times)
|
||||
]);
|
||||
}
|
||||
const body = core.jce.encodeWrapper({ ReqFavorite }, "VisitorSvc", "ReqFavorite", Bot.sig.seq + 1);
|
||||
const payload = await Bot.sendUni("VisitorSvc.ReqFavorite", body);
|
||||
let result = core.jce.decodeWrapper(payload)[0];
|
||||
return { code: result[3], msg: result[4] };
|
||||
}
|
||||
|
||||
async execSync(cmd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
child_process.exec(cmd, (error, stdout, stderr) => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import Browser from "./Browser.js";
|
||||
import common from "./common.js";
|
||||
import Cfg from "./Config.js";
|
||||
import CPU from "./CPU.js";
|
||||
import Pixiv from "./Pixiv.js";
|
||||
import setu from "./setu.js";
|
||||
@@ -9,4 +8,4 @@ import YamlReader from "./YamlReader.js";
|
||||
import Gpadmin from "./Group_admin.js";
|
||||
import QQInterface from "./QQInterface.js";
|
||||
import Interface from './Interface.js'
|
||||
export { Browser, common, Cfg, CPU, Pixiv, setu, uploadRecord, YamlReader, Gpadmin, QQInterface, Interface }
|
||||
export { Browser, common, CPU, Pixiv, setu, uploadRecord, YamlReader, Gpadmin, QQInterface, Interface }
|
||||
@@ -1,7 +1,7 @@
|
||||
import { segment } from "oicq";
|
||||
import fetch from 'node-fetch'
|
||||
import fs from 'fs'
|
||||
import Cfg from './Config.js';
|
||||
import { common } from './index.js';
|
||||
import lodash from "lodash";
|
||||
|
||||
export default new class setu {
|
||||
@@ -40,7 +40,7 @@ export default new class setu {
|
||||
async setuapi(e, r18, num = 1, tag = "") {
|
||||
let api = "https://api.lolicon.app/setu/v2";
|
||||
if (fs.existsSync(this.apicfg)) {
|
||||
let apicfg = Cfg.getJson(this.apicfg)
|
||||
let apicfg = common.getJson(this.apicfg)
|
||||
if (apicfg.api) api = apicfg.api
|
||||
}
|
||||
let size = "original"
|
||||
@@ -93,11 +93,11 @@ export default new class setu {
|
||||
let present = parseInt(new Date().getTime() / 1000)
|
||||
|
||||
//发送消息
|
||||
let res = await Cfg.getRecallsendMsg(e, msg, false)
|
||||
let res = await common.getRecallsendMsg(e, msg, false)
|
||||
if (e.isGroup) {
|
||||
//获取CD
|
||||
if (fs.existsSync(this.path)) {
|
||||
let groupCD = Cfg.getJson(this.path)
|
||||
let groupCD = common.getJson(this.path)
|
||||
if (groupCD[e.group_id]) cd = groupCD[e.group_id].cd
|
||||
}
|
||||
if (!e.isMaster && res) {
|
||||
@@ -112,7 +112,7 @@ export default new class setu {
|
||||
} else {
|
||||
//私聊
|
||||
if (fs.existsSync(this.path_s)) {
|
||||
let friendCD = Cfg.getJson(this.path_s)
|
||||
let friendCD = common.getJson(this.path_s)
|
||||
if (friendCD[e.user_id]) cd = friendCD[e.user_id]
|
||||
}
|
||||
if (!e.isMaster && res) {
|
||||
@@ -166,14 +166,14 @@ export default new class setu {
|
||||
if (e.isGroup) {
|
||||
//获取配置
|
||||
if (fs.existsSync(this.path)) {
|
||||
cfgs = Cfg.getJson(this.path)
|
||||
cfgs = common.getJson(this.path)
|
||||
if (cfgs[e.group_id]) {
|
||||
return cfgs[e.group_id].r18
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (fs.existsSync(this.path_s)) {
|
||||
cfgs = Cfg.getJson(this.path_s)
|
||||
cfgs = common.getJson(this.path_s)
|
||||
if (cfgs.friendr18 !== undefined) {
|
||||
return cfgs.friendr18
|
||||
}
|
||||
@@ -191,13 +191,13 @@ export default new class setu {
|
||||
setGroupRecallTimeAndCd(e, num, yes = true) {
|
||||
let res = {};
|
||||
|
||||
if (fs.existsSync(this.path)) res = Cfg.getJson(this.path)
|
||||
if (fs.existsSync(this.path)) res = common.getJson(this.path)
|
||||
|
||||
if (!res[e.group_id]) res[e.group_id] = lodash.cloneDeep(this.def)
|
||||
|
||||
yes ? res[e.group_id].recall = Number(num) : res[e.group_id].cd = Number(num)
|
||||
|
||||
return Cfg.setJson(this.path, res) ? true : false
|
||||
return common.setJson(this.path, res) ? true : false
|
||||
}
|
||||
/**
|
||||
* @description: 设置CD
|
||||
@@ -208,10 +208,10 @@ export default new class setu {
|
||||
setUserCd(e, qq, cd) {
|
||||
let res = {};
|
||||
if (fs.existsSync(this.path_s)) {
|
||||
res = Cfg.getJson(this.path_s)
|
||||
res = common.getJson(this.path_s)
|
||||
}
|
||||
res[qq] = Number(cd)
|
||||
if (Cfg.setJson(this.path_s, res)) {
|
||||
if (common.setJson(this.path_s, res)) {
|
||||
e.reply(`✅ 设置用户${qq}的cd成功,cd时间为${cd}秒`)
|
||||
delete this.temp[qq]
|
||||
return true
|
||||
@@ -230,7 +230,7 @@ export default new class setu {
|
||||
let res = {};
|
||||
if (group) {
|
||||
if (fs.existsSync(this.path)) {
|
||||
res = Cfg.getJson(this.path)
|
||||
res = common.getJson(this.path)
|
||||
}
|
||||
|
||||
if (!res[e.group_id]) res[e.group_id] = lodash.cloneDeep(this.def)
|
||||
@@ -238,7 +238,7 @@ export default new class setu {
|
||||
|
||||
res[e.group_id].r18 = yes ? 1 : 0
|
||||
|
||||
if (Cfg.setJson(this.path, res)) {
|
||||
if (common.setJson(this.path, res)) {
|
||||
e.reply(`✅ 已${yes ? "开启" : "关闭"}${e.group_id}的涩涩模式~`)
|
||||
return true
|
||||
} else {
|
||||
@@ -247,12 +247,12 @@ export default new class setu {
|
||||
}
|
||||
} else {
|
||||
if (fs.existsSync(this.path_s)) {
|
||||
res = Cfg.getJson(this.path_s)
|
||||
res = common.getJson(this.path_s)
|
||||
}
|
||||
|
||||
res.friendr18 = yes ? 1 : 0
|
||||
|
||||
if (Cfg.setJson(this.path_s, res)) {
|
||||
if (common.setJson(this.path_s, res)) {
|
||||
e.reply(`✅ 已${yes ? "开启" : "关闭"}私聊涩涩功能~`)
|
||||
return true
|
||||
} else {
|
||||
@@ -267,19 +267,19 @@ export default new class setu {
|
||||
* @param {*} e oicq
|
||||
* @return {*}
|
||||
*/
|
||||
getConfig(e) {
|
||||
getSeSeConfig(e) {
|
||||
let set = lodash.cloneDeep(this.def)
|
||||
if (e.isGroup) {
|
||||
//获取群聊单独cd
|
||||
if (fs.existsSync(this.path)) {
|
||||
let groupCD = Cfg.getJson(this.path)
|
||||
let groupCD = common.getJson(this.path)
|
||||
if (groupCD[e.group_id]) set.cd = groupCD[e.group_id].cd
|
||||
}
|
||||
set.recall = Cfg.getRecallTime(e)
|
||||
set.recall = common.getRecallTime(e.group_id)
|
||||
} else {
|
||||
//获取私聊单独cd
|
||||
if (fs.existsSync(this.path_s)) {
|
||||
let friendCD = Cfg.getJson(this.path_s)
|
||||
let friendCD = common.getJson(this.path_s)
|
||||
if (friendCD[e.user_id]) set.cd = friendCD[e.user_id]
|
||||
}
|
||||
delete set.recall
|
||||
@@ -293,7 +293,7 @@ export default new class setu {
|
||||
* @return {String}
|
||||
*/
|
||||
Secondformat(value) {
|
||||
let time = Cfg.getsecond(value)
|
||||
let time = common.getsecond(value)
|
||||
|
||||
let { second, minute, hour, day } = time
|
||||
// 处理返回消息
|
||||
|
||||
Reference in New Issue
Block a user