mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
新增地图资源查询功能
This commit is contained in:
parent
f8f9df6761
commit
9afdd7858c
@ -1,3 +1,7 @@
|
|||||||
|
# 1.2.3
|
||||||
|
* 新增地图资源查询功能
|
||||||
|
* `#月莲在哪里` 指令类似 `某某物品在哪里`
|
||||||
|
* 感谢 **@小灰灰** 提供的webAPI接口服务
|
||||||
# 1.2.2
|
# 1.2.2
|
||||||
* 重写接口文件去除`promise-retry`跟 `superagent`依赖
|
* 重写接口文件去除`promise-retry`跟 `superagent`依赖
|
||||||
* 自动签到增加推送签到信息以及成功信息
|
* 自动签到增加推送签到信息以及成功信息
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
versionInfo,
|
versionInfo,
|
||||||
help
|
help
|
||||||
} from "./help.js";
|
} from "./help.js";
|
||||||
|
import {genShenMap} from './map.js'
|
||||||
import {
|
import {
|
||||||
Note,
|
Note,
|
||||||
DailyNoteTask,
|
DailyNoteTask,
|
||||||
@ -38,7 +39,7 @@ export {
|
|||||||
sign,
|
sign,
|
||||||
versionInfo,cloudToken,
|
versionInfo,cloudToken,
|
||||||
Note_appoint,signTask,
|
Note_appoint,signTask,
|
||||||
pokeNote,
|
pokeNote,genShenMap,
|
||||||
cookiesDocHelp,
|
cookiesDocHelp,
|
||||||
sysCfg,
|
sysCfg,
|
||||||
help,updCookie,
|
help,updCookie,
|
||||||
@ -47,6 +48,7 @@ export {
|
|||||||
Note,
|
Note,
|
||||||
};
|
};
|
||||||
import gsCfg from '../model/gsCfg.js';
|
import gsCfg from '../model/gsCfg.js';
|
||||||
|
import Data from "../components/Data.js";
|
||||||
const _path = process.cwd();
|
const _path = process.cwd();
|
||||||
|
|
||||||
let rule = {
|
let rule = {
|
||||||
@ -66,6 +68,10 @@ let rule = {
|
|||||||
reg: "^#*(体力|树脂|查询体力|便笺|便签)$",
|
reg: "^#*(体力|树脂|查询体力|便笺|便签)$",
|
||||||
describe: "体力",
|
describe: "体力",
|
||||||
},
|
},
|
||||||
|
genShenMap:{
|
||||||
|
reg: "^#*(.*)(在(哪|那)里)$",
|
||||||
|
describe: "地图资源查询 #**在哪里",
|
||||||
|
},
|
||||||
Note_appoint: {
|
Note_appoint: {
|
||||||
reg: "^#体力模板(设置(.*)|列表(.*))$",
|
reg: "^#体力模板(设置(.*)|列表(.*))$",
|
||||||
describe: "体力模板设置",
|
describe: "体力模板设置",
|
||||||
@ -87,6 +93,7 @@ lodash.forEach(rule, (r) => {
|
|||||||
task();
|
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() {
|
||||||
@ -105,6 +112,7 @@ async function task() {
|
|||||||
signTask('cloud')
|
signTask('cloud')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
42
apps/map.js
Normal file
42
apps/map.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import {
|
||||||
|
Cfg,
|
||||||
|
Data
|
||||||
|
} from "../components/index.js";
|
||||||
|
import fs from "fs";
|
||||||
|
import fetch from "node-fetch";
|
||||||
|
import utils from "../model/mys/utils.js";
|
||||||
|
import {
|
||||||
|
segment
|
||||||
|
} from "oicq";
|
||||||
|
let path = './data/map'
|
||||||
|
|
||||||
|
export async function genShenMap(e){
|
||||||
|
let msg= e.msg.replace(/#|(哪|那)|里|在/g,"")
|
||||||
|
var urlFile = fs.readdirSync(`./data/map/`);
|
||||||
|
let msgPath=`${path}/${msg}.jpg`
|
||||||
|
if(urlFile.includes(`${msg}.jpg`)){
|
||||||
|
await e.reply(segment.image(`file://${msgPath}`))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let url=`https://map.minigg.cn/map/get_map?resource_name=${msg}&map_id=2&is_cluster=false`
|
||||||
|
let res=await fetch(url,{method:'get'})
|
||||||
|
try{
|
||||||
|
res=await res.json()
|
||||||
|
if(res.retcode==-1){
|
||||||
|
await e.reply(`${msg}:${res.message}`)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}catch(ex){
|
||||||
|
await Data.downFile(url,msgPath)
|
||||||
|
await e.reply(segment.image(`file://${msgPath}`))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
init()
|
||||||
|
/** 初始化创建配置文件 */
|
||||||
|
function init () {
|
||||||
|
if (!fs.existsSync(path)) {
|
||||||
|
fs.mkdirSync(path)
|
||||||
|
}
|
||||||
|
}
|
@ -211,7 +211,7 @@ export async function cloudToken(e) {
|
|||||||
e.yuntoken = yuntoken;
|
e.yuntoken = yuntoken;
|
||||||
let res=await user.cloudSeach()
|
let res=await user.cloudSeach()
|
||||||
if (res.retcode != 0) {
|
if (res.retcode != 0) {
|
||||||
e.reply(objData.message)
|
e.reply(res.message)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let datalist = {
|
let datalist = {
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import lodash from "lodash";
|
import lodash from "lodash";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
import { pipeline } from 'stream'
|
||||||
|
import { promisify } from 'util'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
|
import path from 'node:path'
|
||||||
const _path = process.cwd()
|
const _path = process.cwd()
|
||||||
|
|
||||||
let Data = {
|
let Data = {
|
||||||
@ -38,7 +42,34 @@ let Data = {
|
|||||||
}
|
}
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
|
mkdirs (dirname) {
|
||||||
|
if (fs.existsSync(dirname)) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
if (Data.mkdirs(path.dirname(dirname))) {
|
||||||
|
fs.mkdirSync(dirname)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 下载保存文件
|
||||||
|
* @param fileUrl 下载地址
|
||||||
|
* @param savePath 保存路径
|
||||||
|
*/
|
||||||
|
async downFile(fileUrl, savePath, param = {}) {
|
||||||
|
try {
|
||||||
|
Data.mkdirs(path.dirname(savePath))
|
||||||
|
Bot.logger.mark(`[下载文件] ${fileUrl}`)
|
||||||
|
const response = await fetch(fileUrl, param)
|
||||||
|
const streamPipeline = promisify(pipeline)
|
||||||
|
await streamPipeline(response.body, fs.createWriteStream(savePath))
|
||||||
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
Bot.logger.error(`下载文件错误:${err}`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
/*
|
/*
|
||||||
* 写JSON
|
* 写JSON
|
||||||
* */
|
* */
|
||||||
|
@ -10,7 +10,7 @@ export async function sleepAsync(sleepms) {
|
|||||||
|
|
||||||
|
|
||||||
export async function randomSleepAsync(end) {
|
export async function randomSleepAsync(end) {
|
||||||
let sleep = 3 * 1000 + _.random((end || 5) * 1000);
|
let sleep = 4 * 1000 + _.random((end || 5) * 1000);
|
||||||
await sleepAsync(sleep);
|
await sleepAsync(sleep);
|
||||||
}
|
}
|
||||||
export function randomString(length, os = false) {
|
export function randomString(length, os = false) {
|
||||||
@ -35,6 +35,7 @@ export async function redisSet(userId="all", type = 'bbs', data, time=0) {
|
|||||||
EX: parseInt(new_date)
|
EX: parseInt(new_date)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送私聊消息,仅给好友发送
|
* 发送私聊消息,仅给好友发送
|
||||||
* @param user_id qq号
|
* @param user_id qq号
|
||||||
|
@ -109,7 +109,7 @@ export default class user {
|
|||||||
let data = Object.assign({}, forum, item)
|
let data = Object.assign({}, forum, item)
|
||||||
item.is_sign = true;
|
item.is_sign = true;
|
||||||
item.upName = forum.name
|
item.upName = forum.name
|
||||||
res = await this.getData("isSign", data)
|
res = await this.getData("isSign", data,false)
|
||||||
await utils.sleepAsync(500)
|
await utils.sleepAsync(500)
|
||||||
item.total_sign_day = res?.data?.total_sign_day
|
item.total_sign_day = res?.data?.total_sign_day
|
||||||
if (res?.data?.is_sign) {
|
if (res?.data?.is_sign) {
|
||||||
@ -123,7 +123,7 @@ export default class user {
|
|||||||
if (signTime) {
|
if (signTime) {
|
||||||
//有数据的时候不得行必须出去
|
//有数据的时候不得行必须出去
|
||||||
if (!mysTask) {
|
if (!mysTask) {
|
||||||
message += "${item.nickname}-${item.game_uid}:验证码失败请等待6分钟后重试或者手动上米游社签到~";
|
message += `${item.nickname}-${item.game_uid}:验证码失败请等待6分钟后重试或者手动上米游社签到~`;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
await utils.sleepAsync(60000 * 6) //等6分钟再说
|
await utils.sleepAsync(60000 * 6) //等6分钟再说
|
||||||
@ -131,7 +131,7 @@ export default class user {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await utils.sleepAsync(2000)
|
await utils.sleepAsync(2000)
|
||||||
res = await this.getData("sign", data)
|
res = await this.getData("sign", data,false)
|
||||||
if (res?.data?.gt) { //进行3次验证码访问签到加高通过概率
|
if (res?.data?.gt) { //进行3次验证码访问签到加高通过概率
|
||||||
let validate = await this.geetest(res.data)
|
let validate = await this.geetest(res.data)
|
||||||
if (validate) {
|
if (validate) {
|
||||||
@ -140,7 +140,7 @@ export default class user {
|
|||||||
header["x-rpc-validate"] = validate
|
header["x-rpc-validate"] = validate
|
||||||
header["x-rpc-seccode"] = `${validate}|jordan`
|
header["x-rpc-seccode"] = `${validate}|jordan`
|
||||||
data.headers = header
|
data.headers = header
|
||||||
res = await this.getData("sign", data)
|
res = await this.getData("sign", data,false)
|
||||||
if (!res?.data?.gt) {
|
if (!res?.data?.gt) {
|
||||||
if(this.allSign){
|
if(this.allSign){
|
||||||
this.allSign[forum.name].sign++;
|
this.allSign[forum.name].sign++;
|
||||||
@ -166,10 +166,9 @@ export default class user {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await utils.sleepAsync(2000)
|
|
||||||
}
|
}
|
||||||
//获取签到信息和奖励信息
|
//获取签到信息和奖励信息
|
||||||
const SignInfo = await this.getData("home", data)
|
const SignInfo = await this.getData("home", data,false)
|
||||||
if (SignInfo) {
|
if (SignInfo) {
|
||||||
let awards = SignInfo.data.awards[item.total_sign_day - 1];
|
let awards = SignInfo.data.awards[item.total_sign_day - 1];
|
||||||
item.awards = awards?.name + "*" + awards?.cnt
|
item.awards = awards?.name + "*" + awards?.cnt
|
||||||
@ -256,7 +255,7 @@ export default class user {
|
|||||||
let Share = 0;
|
let Share = 0;
|
||||||
let sumcount = 0;
|
let sumcount = 0;
|
||||||
message += `\n**${forum.name}**\n`
|
message += `\n**${forum.name}**\n`
|
||||||
res = await this.getData("bbsSign", forum)
|
res = await this.getData("bbsSign", forum,false)
|
||||||
if (res?.retcode == 1034) {
|
if (res?.retcode == 1034) {
|
||||||
message += `社区签到: 验证码失败\n`;
|
message += `社区签到: 验证码失败\n`;
|
||||||
challenge = await this.bbsGeetest()
|
challenge = await this.bbsGeetest()
|
||||||
@ -264,14 +263,14 @@ export default class user {
|
|||||||
forum["headers"] = {
|
forum["headers"] = {
|
||||||
"x-rpc-challenge": challenge
|
"x-rpc-challenge": challenge
|
||||||
}
|
}
|
||||||
await this.getData("bbsSign", forum)
|
await this.getData("bbsSign", forum,false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message += `社区签到: ${res.message}\n`;
|
message += `社区签到: ${res.message}\n`;
|
||||||
}
|
}
|
||||||
Bot.logger.mark(`${this.e.user_id}:${this.e.uid}:${forum.name} 社区签到结果: [${res.message}]`);
|
Bot.logger.mark(`${this.e.user_id}:${this.e.uid}:${forum.name} 社区签到结果: [${res.message}]`);
|
||||||
await utils.randomSleepAsync();
|
await utils.randomSleepAsync();
|
||||||
res = await this.getData("bbsPostList", forum)
|
res = await this.getData("bbsPostList", forum,false)
|
||||||
sumcount++;
|
sumcount++;
|
||||||
let postList = res.data.list;
|
let postList = res.data.list;
|
||||||
let postId
|
let postId
|
||||||
@ -293,13 +292,13 @@ export default class user {
|
|||||||
"x-rpc-challenge": challenge,
|
"x-rpc-challenge": challenge,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.getData("bbsPostFull", data)
|
await this.getData("bbsPostFull", data,false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await utils.randomSleepAsync(10);
|
await utils.randomSleepAsync(10);
|
||||||
res = await this.getData("bbsVotePost", {
|
res = await this.getData("bbsVotePost", {
|
||||||
postId
|
postId
|
||||||
})
|
},false)
|
||||||
if (res?.message && res?.retcode == 0) {
|
if (res?.message && res?.retcode == 0) {
|
||||||
Vote++;
|
Vote++;
|
||||||
}
|
}
|
||||||
@ -312,7 +311,7 @@ export default class user {
|
|||||||
"x-rpc-challenge": challenge,
|
"x-rpc-challenge": challenge,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.getData("bbsVotePost", data)
|
await this.getData("bbsVotePost", data,false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await utils.randomSleepAsync(2);
|
await utils.randomSleepAsync(2);
|
||||||
@ -320,7 +319,7 @@ export default class user {
|
|||||||
let sharePost = postList[0].post;
|
let sharePost = postList[0].post;
|
||||||
res = await this.getData("bbsShareConf", {
|
res = await this.getData("bbsShareConf", {
|
||||||
postId
|
postId
|
||||||
})
|
},false)
|
||||||
if (res?.message && res?.retcode == 0) {
|
if (res?.message && res?.retcode == 0) {
|
||||||
Share++;
|
Share++;
|
||||||
}
|
}
|
||||||
@ -358,7 +357,7 @@ export default class user {
|
|||||||
mysTask = true;
|
mysTask = true;
|
||||||
|
|
||||||
let tips = ['开始米社签到任务']
|
let tips = ['开始米社签到任务']
|
||||||
let time = userIdList.length * 25 + 5
|
let time = userIdList.length * 25 + 5+ (userIdList.length/3 * 60)
|
||||||
let finishTime = moment().add(time, 's').format('MM-DD HH:mm:ss')
|
let finishTime = moment().add(time, 's').format('MM-DD HH:mm:ss')
|
||||||
tips.push(`\n签到用户:${userIdList.length}个`)
|
tips.push(`\n签到用户:${userIdList.length}个`)
|
||||||
tips.push(`\n预计需要:${this.countTime(time)}`)
|
tips.push(`\n预计需要:${this.countTime(time)}`)
|
||||||
@ -580,7 +579,8 @@ export default class user {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.e = e;
|
this.e = e;
|
||||||
await this.getbbsSign(this.ForumData);
|
let res= await this.getbbsSign(this.ForumData);
|
||||||
|
e.reply(res.message)
|
||||||
await utils.sleepAsync(10000);
|
await utils.sleepAsync(10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user