🔥 删除一些功能

This commit is contained in:
yeyang
2024-04-04 15:24:15 +08:00
parent cff04722e7
commit 456e314924
7 changed files with 142 additions and 249 deletions

View File

@@ -1,5 +1,4 @@
import _ from "lodash"
import fetch from "node-fetch"
import { Config } from "../components/index.js"
import { heisiType, pandadiuType, xiurenTypeId } from "../constants/fun.js"
import { common, funApi, uploadRecord } from "../model/index.js"
@@ -17,8 +16,6 @@ _.forIn(picApis, (values, key) => {
picApiKeys.push(key)
})
const apiReg = new RegExp(`(${picApiKeys.join("|")}|^jktj$|^接口统计$)`)
export class Fun extends plugin {
constructor (e) {
super({
@@ -38,10 +35,6 @@ export class Fun extends plugin {
reg: "^#(([\u4e00-\u9fa5]{2,6})-)?([\u4e00-\u9fa5]{2,6})?翻译(.*)$",
fnc: "youdao"
},
{
reg: "^#?((我要|给我)?(资料卡)?(点赞)?(赞|超|操|草|抄|吵|炒)我)$|((赞|超|操|草|抄|吵|炒)(他|她|它|TA|ta|Ta))$",
fnc: "thumbUp"
},
{
reg: "github.com/[a-zA-Z0-9-]{1,39}/[a-zA-Z0-9_-]{1,100}",
fnc: "GH"
@@ -50,18 +43,6 @@ export class Fun extends plugin {
reg: "^#?coser$",
fnc: "coser"
},
// {
// reg: '^#?铃声搜索',
// fnc: 'lingsheng'
// },
{
reg: apiReg,
fnc: "picture"
},
// {
// reg: '^#?来点神秘图(\\d+|s.*)?$',
// fnc: 'mengdui'
// },
{
reg: `^#(${Object.keys(pandadiuType).join("|")})?acg`,
fnc: "acg"
@@ -125,14 +106,6 @@ export class Fun extends plugin {
e.reply(results, true)
}
/**
* 点赞
* @param e
*/
async thumbUp (e) {
await funApi.thumbUp(e)
}
// github
async GH (e) {
const api = "https://opengraph.githubassets.com"
@@ -203,73 +176,6 @@ export class Fun extends plugin {
.catch(err => common.handleException(e, err))
}
// 铃声多多
// async lingsheng (e) {
// let msg = e.msg.replace(/#|铃声搜索/g, '')
// let num = Math.ceil(Math.random() * 15)
// if (num == 0) num = 1
// let api = `http://xiaobai.klizi.cn/API/music/lingsheng.php?msg=${msg}&n=${num}`
// let res = await fetch(api).then(res => res.json()).catch(err => logger.error(err))
// if (!res) return e.reply(API_ERROR)
// if (res.title == null && res.author == null) return e.reply('❎ 没有找到相关的歌曲哦~', true)
// await e.reply([
// `标题:${res.title}\n`,
// `作者:${res.author}`
// ])
// await e.reply(await uploadRecord(res.aac, 0, false))
// }
// api大集合
async picture (e) {
let { sese, sesepro } = Config.getGroup(e.group_id)
if (!sese && !sesepro && !e.isMaster) return false
let key = "yenai:apiAggregate:CD"
if (await redis.get(key)) return false
if (/jktj|接口统计/.test(e.msg)) {
let msg = ["现接口数量如下"]
for (let i in picApis) {
if (i == "mode") continue
let urls = picApis[i].url || picApis[i]
msg.push(`\n${i} => ${Array.isArray(urls) ? urls.length : 1}`)
}
return e.reply(msg)
}
// 解析消息中的类型
let regRet = apiReg.exec(e.msg)
if (regRet[1] == "mode") return false
let picObj = picApis[_.sample(Object.keys(picApis).filter(item => new RegExp(item).test(regRet[1])))]
if (Array.isArray(picObj)) picObj = _.sample(picObj)
let urlReg = /^https?:\/\/(([a-zA-Z0-9_-])+(\.)?)*(:\d+)?(\/((\.)?(\?)?=?&?[a-zA-Z0-9_-](\?)?)*)*$/i
if (!picObj.url && !urlReg.test(encodeURI(picObj)) && !Array.isArray(picObj)) {
return logger.error(`${e.logFnc}未找到url`)
}
if (picObj.type !== "image" && picObj.type !== "text" && picObj.type !== "json" && picObj.type) {
return logger.error(`${e.logFnc}类型不正确`)
}
let url = picObj.url || picObj
// 数组随机取或指定
if (Array.isArray(url)) url = _.sample(url)
url = encodeURI(url)
if (picObj.type == "text") {
url = await fetch(url).then(res => res.text()).catch(err => logger.error(err))
} else if (picObj.type == "json") {
if (!picObj.path) return logger.error(`${e.logFnc}json未指定路径`)
let res = await fetch(url).then(res => res.json()).catch(err => logger.error(err))
url = _.get(res, picObj.path)
}
if (!url) return logger.error(`${e.logFnc}未获取到图片链接`)
logger.debug(`${e.logFnc}使用接口:${url}`)
common.recallsendMsg(e, segment.image(url))
redis.set(key, "cd", { EX: 2 })
}
// 查看头像
async LookAvatar () {
const id = this.e.msg.replace(/^#?((查?看头像)|取头像)/, "").trim() || this.e.at ||

View File

@@ -13,8 +13,6 @@ const TimeUnitReg = Object.keys(Time_unit).join("|")
/** 清理多久没发言的人正则 */
const noactivereg = new RegExp(`^#(查看|清理|确认清理|获取)(${Numreg})个?(${TimeUnitReg})没发言的人(第(${Numreg})页)?$`)
/** 我要自闭正则 */
const Autisticreg = new RegExp(`^#?我要(自闭|禅定)(${Numreg})?个?(${TimeUnitReg})?$`, "i")
// 获取定时任务
const redisTask = await Ga.getRedisMuteTask() || false
export class GroupAdmin extends plugin {
@@ -132,10 +130,6 @@ export class GroupAdmin extends plugin {
reg: "^#今日打卡$",
fnc: "DaySigned"
},
{
reg: Autisticreg, // 我要自闭
fnc: "Autistic"
},
{
reg: "^#((今|昨|前|明|后)天|\\d{4}-\\d{1,2}-\\d{1,2})谁生日$",
fnc: "groupBirthday"
@@ -213,23 +207,6 @@ export class GroupAdmin extends plugin {
.catch(err => common.handleException(e, err))
}
// 我要自闭
async Autistic (e) {
// 判断是否有管理
if (!e.group.is_admin && !e.group.is_owner) return
if (e.isMaster) return e.reply("别自闭啦~~", true)
if (e.member.is_admin && !e.group.is_owner) return e.reply("别自闭啦~~", true)
// 解析正则
let regRet = Autisticreg.exec(e.msg)
// 获取数字
let TabooTime = translateChinaNum(regRet[2] || 5)
let Company = Time_unit[_.toUpper(regRet[3]) || "分"]
await e.group.muteMember(e.user_id, TabooTime * Company)
e.reply("那我就不手下留情了~", true)
}
// 设置管理
async SetAdmin (e) {
if (!common.checkPermission(e, "master", "owner")) return

89
apps/thumbUp.js Normal file
View File

@@ -0,0 +1,89 @@
import { funApi, common, memes } from "../model/index.js"
import _ from "lodash"
import { Config } from "../components/index.js"
import { successImgs, faildsImgs } from "../constants/fun.js"
export class ThumbUp extends plugin {
constructor () {
super({
name: "椰奶点赞",
event: "message",
priority: 500,
rule: [
{
reg: "^#?((我要|给我)?(资料卡)?(点赞)?(赞|超|操|草|抄|吵|炒)我)$|((赞|超|操|草|抄|吵|炒)(他|她|它|TA|ta|Ta))$",
fnc: "thumbUp"
}
]
})
}
/**
* 点赞
* @param e
*/
async thumbUp (e) {
let _do = "赞"
let userId = e.user_id
let isSelf = true
if (e.msg.includes("超", "操", "草", "抄", "吵", "炒")) {
_do = "超"
}
if (e.at && e.msg.includes("他", "她", "它", "TA", "ta", "Ta")) {
userId = e.at
isSelf = false
}
/** 判断是否为好友 */
let isFriend = await (e.bot ?? Bot).fl.get(userId)
let allowLikeByStrangers = Config.whole.Strangers_love
if (!isFriend && !allowLikeByStrangers) { return (e.message?.[0]?.text == "#全部赞我") ? false : e.reply(`不加好友不${_do}🙄`, true) }
/** 执行点赞 */
let n = 0
let failsMsg = `今天已经${_do}过了,还搁这讨${_do}呢!!!`
for (let i = 0; i < 10; i++) {
let res = null
try {
res = await new funApi.ThumbUpApi(e).thumbUp(userId, 10)
} catch (error) {
logger.error(error)
return common.handleException(e, error)
}
logger.debug(`${e.logFnc}${userId}点赞`, res)
if (res.code) {
if (res.code == 1) {
failsMsg = `${_do}失败,请检查是否开启陌生人点赞或添加好友`
} else {
if (_do == "超") {
failsMsg = res.msg.replace(/点赞/g, "超").replace("给", "超").replace("点", "").replace("个赞", "下")
} else {
failsMsg = res.msg
}
}
break
} else {
n += 10
}
}
let successMsg = `${isSelf ? "你" : userId}${_do}${n}下哦,记得回我~ ${isFriend ? "" : `(如${_do}失败请添加好友)`}`
const avatar = `https://q1.qlogo.cn/g?b=qq&s=100&nk=${userId}`
const successFn = _.sample(["ganyu", "zan"])
/** 判断点赞是否成功 */
let msg = n > 0
? [
`\n${successMsg}`,
segment.image((await memes[successFn](avatar)) ||
_.sample(successImgs) + userId)
]
: (e.message?.[0]?.text == "#全部赞我")
? []
: [
`\n${failsMsg}`,
segment.image((await memes.crawl(avatar)) ||
_.sample(faildsImgs) + userId)
]
/** 回复 */
if (msg.length) { return e.reply(msg, true, { at: userId }) }
}
}

View File

@@ -117,11 +117,6 @@ export const helpList = [{
desc: "处理本群的全部加群申请",
icon: 3
},
{
title: "#我要自闭 <时间>",
desc: "自闭一会",
icon: 20
},
{
title: "#加|移精",
desc: "回复消息进行加/移精",

View File

@@ -2,11 +2,11 @@ import bgg from "./funApi/bgg.js"
import youdao from "./funApi/youdao.js"
import * as pageCrawling from "./funApi/pageCrawling.js"
import randomSinging from "./funApi/randomSinging.js"
import thumbUp from "./funApi/thumbUp.js"
import ThumbUpApi from "./funApi/thumbUpApi.js"
export default {
bgg,
youdao,
thumbUp,
ThumbUpApi,
randomSinging,
...pageCrawling
}

View File

@@ -1,125 +0,0 @@
import _ from "lodash"
import { memes, common } from "../../index.js"
import { Config } from "../../../components/index.js"
import { successImgs, faildsImgs } from "../../../constants/fun.js"
/**
*
* @param e
*/
export default async function thumbUp (e) {
let _do = "赞"
let userId = e.user_id
let isSelf = true
if (e.msg.includes("超", "操", "草", "抄", "吵", "炒")) {
_do = "超"
}
if (e.at && e.msg.includes("他", "她", "它", "TA", "ta", "Ta")) {
userId = e.at
isSelf = false
}
/** 判断是否为好友 */
let isFriend = await (e.bot ?? Bot).fl.get(userId)
let allowLikeByStrangers = Config.whole.Strangers_love
if (!isFriend && !allowLikeByStrangers) { return (e.message?.[0]?.text == "#全部赞我") ? false : e.reply(`不加好友不${_do}🙄`, true) }
/** 执行点赞 */
let n = 0
let failsMsg = `今天已经${_do}过了,还搁这讨${_do}呢!!!`
for (let i = 0; i < 10; i++) {
let res = null
try {
res = await new ThumbUpApi(e).thumbUp(userId, 10)
} catch (error) {
logger.error(error)
return common.handleException(e, error)
}
logger.debug(`${e.logFnc}${userId}点赞`, res)
if (res.code) {
if (res.code == 1) {
failsMsg = `${_do}失败,请检查是否开启陌生人点赞或添加好友`
} else {
if (_do == "超") {
failsMsg = res.msg.replace(/点赞/g, "超").replace("给", "超").replace("点", "").replace("个赞", "下")
} else {
failsMsg = res.msg
}
}
break
} else {
n += 10
}
}
let successMsg = `${isSelf ? "你" : userId}${_do}${n}下哦,记得回我~ ${isFriend ? "" : `(如${_do}失败请添加好友)`}`
const avatar = `https://q1.qlogo.cn/g?b=qq&s=100&nk=${userId}`
const successFn = _.sample(["ganyu", "zan"])
/** 判断点赞是否成功 */
let msg = n > 0
? [
`\n${successMsg}`,
segment.image((await memes[successFn](avatar)) ||
_.sample(successImgs) + userId)
]
: (e.message?.[0]?.text == "#全部赞我")
? []
: [
`\n${failsMsg}`,
segment.image((await memes.crawl(avatar)) ||
_.sample(faildsImgs) + userId)
]
/** 回复 */
if (msg.length) { return e.reply(msg, true, { at: userId }) }
}
class ThumbUpApi {
constructor (e) {
this.e = e
this.Bot = e.bot ?? Bot
}
/**
* 陌生人点赞
* @param {number} uid QQ号
* @param {number} times 数量
* @returns {object}
*/
async thumbUp (uid, times = 1) {
try {
let core = this.Bot.icqq?.core
if (!core) core = (await import("icqq")).core
if (times > 20) { times = 20 }
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")
]),
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")
]),
uid, 0, 5, Number(times)
])
}
const body = core.jce.encodeWrapper({ ReqFavorite }, "VisitorSvc", "ReqFavorite", this.Bot.sig.seq + 1)
const payload = await this.Bot.sendUni("VisitorSvc.ReqFavorite", body)
let result = core.jce.decodeWrapper(payload)[0]
return { code: result[3], msg: result[4] }
} catch (error) {
return this.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) }
if (res.retcode && !res.code) { res.code = res.retcode }
if (res.message && !res.msg) { res.msg = res.message }
return res
}
}

View File

@@ -0,0 +1,51 @@
export default class ThumbUpApi {
constructor (e) {
this.e = e
this.Bot = e.bot ?? Bot
}
/**
* 陌生人点赞
* @param {number} uid QQ号
* @param {number} times 数量
* @returns {object}
*/
async thumbUp (uid, times = 1) {
try {
let core = this.Bot.icqq?.core
if (!core) core = (await import("icqq")).core
if (times > 20) { times = 20 }
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")
]),
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")
]),
uid, 0, 5, Number(times)
])
}
const body = core.jce.encodeWrapper({ ReqFavorite }, "VisitorSvc", "ReqFavorite", this.Bot.sig.seq + 1)
const payload = await this.Bot.sendUni("VisitorSvc.ReqFavorite", body)
let result = core.jce.decodeWrapper(payload)[0]
return { code: result[3], msg: result[4] }
} catch (error) {
return this.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) }
if (res.retcode && !res.code) { res.code = res.retcode }
if (res.message && !res.msg) { res.msg = res.message }
return res
}
}