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-08-04 23:13:05 +08:00 committed by leiyilu
parent e072452cd4
commit 2b11c4fecf
5 changed files with 524 additions and 408 deletions

View File

@ -1,8 +1,14 @@
# 1.1.6
* 初步实现云原神签到 以及查询时间
* 通过发送token以及devId给机器人实现绑定
* 格式支持`ai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********`
* 新增指令`#云原神签到`可进行云原神签到
* 新增指令`#云原神查询`可查询当前绑定token的剩余时间
# 1.1.5
* 体力模板列表更改为转发形式更具体呈现效果
* 新增自动签到配置
*可在`xiaoyao-cvs-plugin/config/config.yaml`中修改是否启用自动签到
# 1.1.3~1.1.4
# 1.1.2~1.1.4
* 新增指令`#米游币全部签到`
*为所有存在的stoken进行社区米游币签到
* 新增指令`#米社全部签到`
@ -10,8 +16,6 @@
* 新增自动签到默认**00:02**开始执行签到
*具体时间修改在`./config/config.yaml`
* 米游社米游币获取功能需要绑定`cookies`来跑非信任的bot请勿发送cookies
* 实现米游社多模块签到
* 实现米游社米游币获取
* 新增指令`cookies帮助`
* 新增指令`#米游社原神签到`
* 用于获取米游社米游币
@ -19,13 +23,12 @@
* 用于签到不同的社区模块
* 具体有`原神、崩坏3、崩坏2、未定事件簿`
* `大别野、崩坏星穹铁道、绝区零` 并未提供签到入口待定,后续概率补充
# 1.1.2
* 初步实现米游社签到米游币以及社区签到
* 需要引入包文件`cnpm i promise-retry `跟`cnpm i superagent`
* V3版本引入文件`pnpm i promise-retry `跟`pnpm i superagent`
* 如果出现了安装其中一个包导致另外的包出问题的请群里询问
* 具体获取cookie教程后续会完善 敬情期待~
* 需要完整的cookie内容要包含`login_ticket`跟`login_uid`不然是无法实现米游社签到的
* 需要完整的cookie内容要包含`login_ticket`不然是无法实现米游社签到的
* 获取到的cookies发送bot后请触发一次`#mys原神签到`指令以保存`stoken`实现自动签到**触发指令后无需多次获取cookies**
* `stoken`文件数据在**xiaoyao-cvs-plugin/data/yaml/**目录下
# 1.1.0
* 增加`#图鉴帮助`用于查看帮助命令

View File

@ -317,6 +317,9 @@ export async function DailyNoteTask() {
let sendResin = 120;
//推送cd12小时一次
let sendCD = 12 * 3600;
if(isV3){
return true;
}
//获取需要推送的用户
for (let [user_id, cookie] of Object.entries(NoteCookie)) {
user_id = cookie.qq || user_id;
@ -340,7 +343,7 @@ export async function DailyNoteTask() {
e.reply = (msg) => {
Bot.pickUser(user_id * 1).sendMsg(msg).catch((err) => {
logger.mark(err)
Bot.logger.mark(err)
})
// common.relpyPrivate(user_id, msg);
};
@ -388,8 +391,9 @@ export async function Note_appoint(e) {
let mstList = [];
let sumCount=(urlType.length/80).toFixed(0);
xlmsg=sumCount-xlmsg>-1?xlmsg:sumCount;
urlType.unshift(`模板列表共,第${xlmsg}页,共${urlType.length}张,请选择序号~~\n当前支持选择的模板有:`)
urlType.unshift(`模板列表共,第${xlmsg}页,共${urlType.length}张,\n您可通过【#体力模板设置1】来绑定你需要的体力模板~\n请选择序号~~\n当前支持选择的模板有:`)
let xxmsg=(xlmsg-1)==0?0:80*(xlmsg-1)
let count=0;
for (let [index, item] of urlType.entries()) {
let msg_pass = [];
let imgurl;
@ -404,6 +408,7 @@ export async function Note_appoint(e) {
}
item = index + "." + item
}
count++;
if(Object.keys(mstList).length==80){
break;
}
@ -420,13 +425,17 @@ export async function Note_appoint(e) {
user_id: Bot.uin
})
}
if(xxmsg<urlType.length-1){
mstList.push({
message: `更多内容请翻页查看\n如:#体力模板列表2`,
nickname: nickname,
user_id: Bot.uin
})
let endMsg="";
if(count<urlType.length-1){
endMsg= `更多内容请翻页查看\n如:#体力模板列表2`
}else{
endMsg= `已经到底了~~`
}
mstList.push({
message: endMsg,
nickname: nickname,
user_id: Bot.uin
})
e.reply(await Bot.makeForwardMsg(mstList));
return true;
}

View File

@ -28,7 +28,7 @@ import {
mysSign,
cookiesDocHelp,
signlist,
allMysSign,
allMysSign,yunSign,sendyunTime,yuntoken,
allSign
} from "./sign.js"
export {
@ -38,7 +38,7 @@ export {
sign,
versionInfo,
Note_appoint,
pokeNote,
pokeNote,yunSign,sendyunTime,yuntoken,
cookiesDocHelp,
sysCfg,
help,

View File

@ -12,6 +12,7 @@ import {
} from '../components/Changelog.js';
import gsCfg from '../model/gsCfg.js';
import fs from "fs";
import YAML from 'yaml'
export const rule = {
mysSign: {
reg: "^#*(米游社|mys|社区)(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零|全部)签到$",
@ -25,14 +26,18 @@ export const rule = {
reg: "^#(米游币|米社)全部签到$",
describe: "米游币全部签到"
},
// allMysSign: {
// reg: "^#米游币全部签到$",
// describe: "米游币全部签到"
// },
// allSign: {
// reg: "^#米社全部签到$",
// describe: "米社全部签到"
// },
sendyunTime: {
reg: "^#*云原神(时间|剩余时间|剩余|还有多久|还剩多少分钟|查询)$",
describe: "米游币全部签到"
},
yunSign: {
reg: "^#*云原神签到$",
describe: "云原神签到"
},
yuntoken:{
reg: "^(.*)ct(.*)$",
describe: "云原神签到"
},
cookiesDocHelp: {
reg: "^#*(米游社|cookies|米游币)帮助$",
describe: "cookies获取帮助"
@ -382,3 +387,66 @@ export async function signlist(e) {
isbool = false;
return true;
}
let yunpath=`${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/`;
init()
function init() {
Data.createDir("",yunpath , false);
}
export async function yunSign(e){
if(!(await getyunToken(e))){
e.reply("尚未绑定云原神token")
return true;
}
let miHoYoApi = new MihoYoApi(e);
e.reply((await miHoYoApi.yunGenshen()).sendMSg)
return;
}
const getyunToken=async function(e){
let file = `${yunpath}/${e.user_id}.yaml`
try {
let ck = fs.readFileSync(file, 'utf-8')
ck = YAML.parse(ck)
e.devId=ck.devId; e.yuntoken=ck.yuntoken;
return ck
} catch (error) {
return ""
}
}
export async function sendyunTime(e){
if(!(await getyunToken(e))){
e.reply("尚未绑定云原神token")
return true;
}
let miHoYoApi = new MihoYoApi(e);
e.reply((await miHoYoApi.logyunGenshen()).log_msg)
return;
}
export async function yuntoken(e){
console.log(e)
if (["ct","si","devId"].includes(e.msg)) {
e.reply(`格式支持\nai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********`)
return false;
}
let msg=e.msg.split("devId")
let devId=msg[1].replace(/=/,"")
let yuntoken=msg[0];
e.devId=devId;
e.yuntoken=yuntoken;
let miHoYoApi = new MihoYoApi(e);
let objData=(await miHoYoApi.logyunGenshen()) //校验token是否有效
if(objData.retcode!=0){
e.reply(objData.message)
return true;
}
let datalist = {
devId: devId,
yuntoken: yuntoken,
qq: e.user_id,
uid: e.uid,
sign: true
}
let yamlStr = YAML.stringify(datalist);
fs.writeFileSync(`${yunpath}${e.user_id}.yaml`, yamlStr, 'utf8');
e.reply("云原神cookie保存成功~\n您后续可发送【#云原神查询】获取使用时间~")
return true;
}

View File

@ -84,6 +84,8 @@ export default class MihoYoApi {
this.e = e
this.cookie = e.cookie
this.userId = String(e.user_id)
this.yuntoken=e.yuntoken
this.devId=e.devId
// //初始化配置文件
let data = this.getStoken(this.e.user_id);
if (data) {
@ -209,11 +211,45 @@ export default class MihoYoApi {
}
async yunGenshen() {
const url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/login`;
let url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/login`;
let res = await superagent.post(url).set(this.getyunHeader()).timeout(10000);
url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/wallet/wallet/get`;
let sendMSg = "";
let log_msg=(await this.logyunGenshen()).log_msg
sendMSg += log_msg
Bot.logger.info(log_msg)
url =
`https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/listNotifications?status=NotificationStatusUnread&type=NotificationTypePopup&is_sort=true`;
res = await superagent.get(url).set(this.getyunHeader()).timeout(10000);
let resObj = JSON.parse(res.text);
let list = resObj.data.list;
if(Object.keys(list).length==0){
resObj.sendMSg="您今天的奖励已经领取了啦~";
return resObj;
}
for (let item of list) {
let reward_id = item.id;
let reward_msg = item.msg;
url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/ackNotification`;
res = await superagent.post(url).set(this.getyunHeader()).send({"id": reward_id}).timeout(10000);
let log_msg=`\n领取奖励,ID:${reward_id},Msg:${reward_msg}`;
Bot.logger.info(log_msg)
sendMSg+=log_msg
}
log_msg="\n\n"+(await this.logyunGenshen()).log_msg
sendMSg += log_msg
resObj.sendMSg=sendMSg;
Bot.logger.info(log_msg)
return resObj;
}
async logyunGenshen(){
let url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/wallet/wallet/get`;
let res = await superagent.get(url).set(this.getyunHeader()).timeout(10000);
let resObj = JSON.parse(res.text);
let data = resObj.data
let log_msg=`米云币:${data?.coin?.coin_num},免费时长:${data?.free_time?.free_time}分钟,总时长:${data.total_time}分钟`;
resObj.log_msg=log_msg
return resObj
}
async stoken(cookie, e) {
@ -312,12 +348,12 @@ export default class MihoYoApi {
//云原神签到头
getyunHeader() {
return {
"x-rpc-combo_token": token, //这里填你的ck
"x-rpc-combo_token": this.yuntoken, //这里填你的ck
"x-rpc-client_type": "2",
"x-rpc-app_version": "1.3.0",
"x-rpc-sys_version": "11",
"x-rpc-channel": "mihoyo",
"x-rpc-device_id": device_id, //这里填获取到的设备Id
"x-rpc-device_id": this.devId, //这里填获取到的设备Id
"x-rpc-device_name": "Xiaomi Mi 10 Pro",
"x-rpc-device_model": "Mi 10 Pro",
"x-rpc-app_id": "1953439974",
@ -387,7 +423,7 @@ export default class MihoYoApi {
url = `${web_api}/event/luna/sign`
}
url += `?region=${region}&act_id=${board.actid}&uid=${game_uid}`
let res= await superagent.post(url).set(this.getpubHeaders(board)).timeout(10000);
let res = await superagent.post(url).set(this.getpubHeaders(board)).timeout(10000);
let resObj = JSON.parse(res.text);
return resObj
}