2022-10-17 20:55:39 +08:00
|
|
|
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;
|
|
|
|
}
|
2022-11-18 22:53:26 +08:00
|
|
|
let url=`https://map.minigg.cn/map/get_map?resource_name=${msg}&is_cluster=false`
|
2022-10-17 20:55:39 +08:00
|
|
|
let res=await fetch(url,{method:'get'})
|
|
|
|
try{
|
|
|
|
res=await res.json()
|
|
|
|
if(res.retcode==-1){
|
2022-10-19 07:05:20 +08:00
|
|
|
await e.reply(`${res.message}`)
|
2022-10-17 20:55:39 +08:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|