File size: 5,405 Bytes
2b65ba8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
import plugin from '../../../lib/plugins/plugin.js'
import fs from "fs";
import lodash from "lodash";
import { Config } from '../components/index.js'
import { YamlReader, puppeteer, common } from '../model/index.js';
import fetch from "node-fetch";
export class example extends plugin {
constructor() {
super({
name: "小月签到",
event: "message",
priority: 500,
rule: [
{
reg: '^#?(小月)?签到$',
fnc: 'sign',
},
{
reg: '^#?(小月)?(积分排行|积分排名)$',
fnc: 'rankIntegral',
},
{
reg: '^#?(小月)?(积分查询|查询积分)',
fnc: 'queryRank',
}
],
});
}
async sign(e) {
let res = await fetch(`https://yxyapi.sesepic.top/sign?user=${e.user_id}`).catch((err) => logger.error(err))
if (!res?.ok) return e.reply('接口请求失败')
res = await res.json()
let keyres = await fetch(`https://yxyapi.sesepic.top/keys?user=${e.user_id}`).catch(err => { })
if (keyres?.ok) keyres = await keyres.text()
if (keyres == 'true')
keyres = '已激活'
else
keyres = '未激活'
let tgres = await fetch('https://ovooa.com/API/tgrj/api.php?type=json').catch((err) => { })
if (tgres?.ok) tgres = await tgres.json()
let ylres = await fetch('https://v1.hitokoto.cn/?c=a').catch((err) => { })
if (ylres?.ok) ylres = await ylres.json()
let xzName = ['白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座', '水瓶座', '双鱼座']
let num = Math.floor(Math.random() * xzName.length)
let xz = await fetch(`https://xiaoapi.cn/API/xzys.php?msg=${encodeURI(xzName[num])}`).catch((err) => { })
if (xz?.ok) {
xz = await xz.text()
xz = xz.split('\n')
}
if (res.data.endExperience >= 99999) res.data.endExperience = 99999
let { dj, ex } = await getExperience(res.data.endExperience)
let name = e.sender.card || e.sender.nickname
name = name.substring(0, 12)
//签到数据
let signdata = {
//头像
tx: `https://q1.qlogo.cn/g?b=qq&s=0&nk=${e.user_id}`,
//名字
name,
//等级
dj,
//经验
ex,
//密钥激活状态
keyres,
//签到状态
msg: res.msg,
//积分
integral: res.data.integral,
//经验
experience: res.data.experience,
//积分排名
rank: res.data.rank,
//累计签到次数
time: res.data.time,
//最后签到时间
endTime: res.data.endTime,
//总积分
endIntegral: res.data.endIntegral,
//总经验
endExperience: res.data.endExperience,
//舔狗文案
tg: tgres?.text ?? '我给你打了几通电话,你终于接了。听到了你发出啊啊啊啊的声音,你说你肚子痛,我想你一定是很难受吧。电话还有个男的对你说“来换个姿势”,一定是在做理疗了。期待你早日康复,我好担心。',
//动漫语录
yl: ylres?.hitokoto ?? '只要轻唤你的名字,我们的羁绊就永远不会消逝',
//出自动漫
ylfrom: ylres?.from ?? '紫罗兰永恒花园',
//星座运势
xz_xz: xz?.[0] ?? '水瓶座',
xz_sz: xz?.[3] ?? '9',
xz_color: xz?.[4] ?? '玛瑙黑',
xz_zt: xz?.[5] ?? '今天适合约恋人到欧式风味的餐厅喝咖啡,咖啡的香浓能让两人之间弥漫着浪漫的气味;花点钱施舍给需要帮助的人,可提升你的财运;谦和的态度才能更好的树立你在客户心中的形象,对你今天的洽谈工作非常有利。 ',
//随机底图
bg: await rodom()
}
await puppeteer.render('sign/index', {
...signdata
}, {
e,
scale: 2.0,
})
}
async rankIntegral(e) {
let res = await fetch(`https://yxyapi.sesepic.top/signrank`).catch(err => { })
if (res?.ok) res = await res.json()
for (let i = 0; i < 100; i++) {
res.rank[i].tx = `https://q1.qlogo.cn/g?b=qq&s=0&nk=${res.rank[i].qq}`
}
let arrQQ = []
let arrTx = []
let arrJf = []
for (let i of res.rank) {
arrQQ.push(i.qq)
arrTx.push(i.tx)
arrJf.push(i.value)
}
arrQQ = arrQQ.toString()
arrTx = arrTx.toString()
let data = {
arrQQ,
arrTx,
arrJf,
bg: await rodom()
}
await puppeteer.render('sign/rank', {
...data
}, {
e,
scale: 2.0
})
}
async queryRank(e) {
let res = await fetch(`https://test-1.peterliangaaa.repl.co/signrank`).catch(err => { })
if (res?.ok) res = await res.json()
if (!res) return e.reply('接口失效')
let qq = e.at ?? e.msg.match(/\d+/)?.[0]
if (!qq) return e.reply('未在消息内找到查询者QQ')
for (let i = 0; i < res.rank.length; i++) {
if (res.rank[i].qq == qq) {
return e.reply(`QQ:${qq}\n积分:${res.rank[i].value}\n排名:${i+1}\n总人数:${res.rank.length}`,true)
}
}
e.reply('未在积分榜上查询到此玩家')
}
}
//随机底图
const rodom = async function () {
var image = fs.readdirSync(`./plugins/xiaoyue-plugin/resources/sign/imgs`);
var list_img = [];
for (let val of image) {
list_img.push(val)
}
var imgs = list_img.length == 1 ? list_img[0] : list_img[lodash.random(0, list_img.length - 1)];
return imgs;
}
//返回等级,经验
const getExperience = async function (experience) {
let dj = {}
let res = {}
for (let i = 1; i <= 100; i++) {
dj['LV' + i] = 1000 * i
}
dj['LV100'] = 99999
for (let ex in dj) {
if (dj[ex] >= experience) {
res = { "dj": ex, "ex": `${experience}/${dj[ex]}` }
return res
}
}
} |