2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

新增七圣召唤动态指令 例:#七圣刻晴动态

This commit is contained in:
Ctrlcvs 2022-12-17 18:29:18 +08:00
parent 16d9f7d19c
commit b998e12a68
2 changed files with 83 additions and 31 deletions

View File

@ -1,7 +1,7 @@
import lodash from "lodash"; import lodash from "lodash";
import schedule from "node-schedule"; import schedule from "node-schedule";
import { import {
AtlasAlias AtlasAlias,getBasicVoide
} from "./xiaoyao_image.js"; } from "./xiaoyao_image.js";
import { import {
versionInfo, versionInfo,
@ -20,7 +20,7 @@ import {
import { import {
rule as adminRule, rule as adminRule,
updateRes, updateRes,
sysCfg,updateTemp, sysCfg, updateTemp,
updateMiaoPlugin updateMiaoPlugin
} from "./admin.js"; } from "./admin.js";
import { import {
@ -29,8 +29,8 @@ import {
updCookie, updCookie,
userInfo, userInfo,
gclog, gclog,
mytoken,gcPaylog, mytoken, gcPaylog,
bindStoken,bindLogin_ticket, bindStoken, bindLogin_ticket,
cloudToken cloudToken
} from "./user.js" } from "./user.js"
import { import {
@ -44,13 +44,13 @@ import {
} from "./sign.js" } from "./sign.js"
export { export {
updateRes,updateTemp, updateRes, updateTemp,
delSign,gcPaylog, delSign, gcPaylog,
cloudSign, cloudSign,
seach,bindLogin_ticket, seach, bindLogin_ticket,
bbsSign, bbsSign,
gclog, gclog,
mytoken, mytoken, getBasicVoide,
bindStoken, bindStoken,
updateMiaoPlugin, updateMiaoPlugin,
userInfo, userInfo,
@ -106,6 +106,10 @@ let rule = {
reg: "#poke#", reg: "#poke#",
describe: "体力", describe: "体力",
}, },
getBasicVoide: {
reg: '#?(动态)',
describe: "动态",
},
...userRule, ...userRule,
...signRule, ...signRule,
...adminRule ...adminRule
@ -121,22 +125,22 @@ task();
async function task() { async function task() {
if (typeof test != "undefined") return; if (typeof test != "undefined") return;
let set = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config") let set = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config")
schedule.scheduleJob(set.mysBbsTime, function() { schedule.scheduleJob(set.mysBbsTime, function () {
if (set.ismysSign) { if (set.ismysSign) {
signTask('bbs') signTask('bbs')
} }
}); });
schedule.scheduleJob(set.allSignTime, function() { schedule.scheduleJob(set.allSignTime, function () {
if (set.isSign) { if (set.isSign) {
signTask('mys') signTask('mys')
} }
}); });
schedule.scheduleJob(set.cloudSignTime, function() { schedule.scheduleJob(set.cloudSignTime, function () {
if (set.isCloudSign) { if (set.isCloudSign) {
signTask('cloud') signTask('cloud')
} }
}); });
schedule.scheduleJob(set.noteTask, function() { schedule.scheduleJob(set.noteTask, function () {
if (set.isNoteTask) { if (set.isNoteTask) {
DailyNoteTask() DailyNoteTask()
} }

View File

@ -34,9 +34,49 @@ export async function AtlasAlias(e) {
return send_Msg(e, "all", ""); return send_Msg(e, "all", "");
} }
/** 获取角色卡片的原图 */
export async function getBasicVoide(e) {
if (!e.hasReply && !e.source) {
return true
}
// 引用的消息不是自己的消息
if (e.source.user_id !== e.self_id) {
return true
}
// 引用的消息不是纯图片
if (!/^\[图片]$/.test(e.source.message)) {
return true
}
// 获取原消息
let source
if (e.isGroup) {
source = (await e.group.getChatHistory(e.source.seq, 1)).pop()
} else {
source = (await e.friend.getChatHistory(e.source.time, 1)).pop()
}
if (source) {
let imgPath = await redis.get(`xiaoyao:basic:${source.message_id}`)
console.log(imgPath)
if (imgPath) {
e.reply([segment.video(`file:///${imgPath}`)])
return true
}
if (source.time) {
let time = new Date()
// 对at错图像的增加嘲讽...
if (time / 1000 - source.time < 3600) {
e.reply([segment.image(process.cwd() + '/plugins/miao-plugin/resources/common/face/what.jpg')])
return true
}
}
}
e.reply('消息太过久远了,俺也忘了动态是啥了,下次早点来吧~')
return true
}
export async function roleInfo(e) { export async function roleInfo(e) {
let msg = e.msg.replace(/#||信息|图鉴|命座|天赋|原牌|七圣/g, ""); let msg = e.msg.replace(/#||信息|图鉴|命座|天赋|原牌|七圣|动态/g, "");
let Botcfg,id,type='juese_tujian'; let Botcfg, id, type = 'juese_tujian';
if (isV3) { if (isV3) {
Botcfg = (await import(`file://${_path}/plugins/genshin/model/gsCfg.js`)).default; Botcfg = (await import(`file://${_path}/plugins/genshin/model/gsCfg.js`)).default;
id = Botcfg.roleNameToID(msg) id = Botcfg.roleNameToID(msg)
@ -54,27 +94,27 @@ export async function roleInfo(e) {
} else { } else {
name = Botcfg.roleIdToName(id, true); name = Botcfg.roleIdToName(id, true);
} }
if(/原牌|七圣/.test(e.msg)) { if (/原牌|七圣/.test(e.msg)) {
if(!name){ if (!name) {
let list = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`,'yuanmo_tujian') let list = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`, 'yuanmo_tujian')
name= info_img(e,list,msg) name = info_img(e, list, msg)
} }
type=`basicInfo_tujian/role/${name}` type = `basicInfo_tujian/role/${name}`
} }
if (!name) return false; if (!name) return false;
send_Msg(e, type, name) send_Msg(e, type, name)
return true; return true;
} }
const filePath = async function(e) { const filePath = async function (e) {
let data = list; let data = list;
data.push("juese_tujian") data.push("juese_tujian")
for (let [index, val] of data.entries()) { for (let [index, val] of data.entries()) {
let msg=e.msg; let msg = e.msg;
if(index!=data.length-1){ if (index != data.length - 1) {
msg=e.msg.replace(new RegExp(reglist[index], "g"), ""); msg = e.msg.replace(new RegExp(reglist[index], "g"), "");
}else { } else {
msg=e.msg.replace(/#||信息|图鉴|命座|天赋/g, ""); msg = e.msg.replace(/#||信息|图鉴|命座|天赋/g, "");
} }
let path = `${pathPlus}${val}/${msg}.png` let path = `${pathPlus}${val}/${msg}.png`
if (fs.existsSync(path)) { if (fs.existsSync(path)) {
@ -84,12 +124,12 @@ const filePath = async function(e) {
} }
} }
const send_Msg = function(e, type, name) { const send_Msg = async function (e, type, name) {
let path; let path;
if (type == "all") { if (type == "all") {
for (let [index, val] of list.entries()) { for (let [index, val] of list.entries()) {
name = e.msg.replace(new RegExp(reglist[index], "g"), ""); name = e.msg.replace(new RegExp(reglist[index], "g"), "");
if(val.includes('juese_tujian')) continue; if (val.includes('juese_tujian')) continue;
let new_name = info_img(e, gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`, let new_name = info_img(e, gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`,
val), name) val), name)
if (new_name) { if (new_name) {
@ -103,17 +143,25 @@ const send_Msg = function(e, type, name) {
if (!fs.existsSync(path)) { if (!fs.existsSync(path)) {
return false; return false;
} }
e.reply(segment.image(`file:///${path}`)); let msg = segment.image(`file:///${path}`)
try {
if (/动态/.test(e.msg)) msg = segment.video(`file:///${path.replace(/\.png|\.jpg/, '.mp4')}`)
} catch (error) {
Bot.logger.error(`发送七圣动态数据失败:` + error)
// error
}
let { message_id } = await e.reply(msg);
await redis.set(`xiaoyao:basic:${message_id}`, path.replace(/\.png|\.jpg/, '.mp4'), 10800); //三小时
return true; return true;
} }
export async function Atlas_list(e) { export async function Atlas_list(e) {
let list = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`,'Atlas_list') let list = gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/resources/Atlas_alias/`, 'Atlas_list')
let name = e.msg.replace(/#|井/g, "") let name = e.msg.replace(/#|井/g, "")
for (let i in list) { for (let i in list) {
let title = i.split("|"); let title = i.split("|");
for (let j = 0; j < title.length; j++) { for (let j = 0; j < title.length; j++) {
if (title[j] == name) { if (title[j] == name) {
await utils.replyMake(e, [`当前选择【${name}`,"请选择:\n" + list[i].join("\n")], 0) await utils.replyMake(e, [`当前选择【${name}`, "请选择:\n" + list[i].join("\n")], 0)
return true; return true;
} }
} }
@ -121,7 +169,7 @@ export async function Atlas_list(e) {
return false; return false;
} }
const info_img = function(e, list, name) { const info_img = function (e, list, name) {
for (let i in list) { for (let i in list) {
for (let val of list[i]) { for (let val of list[i]) {
if (val == name || i == name) { if (val == name || i == name) {