🌈 style: 代码美化,不做任何修改

This commit is contained in:
zhiyu1998 2023-03-07 13:27:00 +08:00
parent d774c811a1
commit 6abbc6154a
4 changed files with 174 additions and 160 deletions

View File

@ -1,6 +1,6 @@
import fetch from "node-fetch";
import { Group, segment } from "oicq";
import { autoTask } from "../utils/common.js"
import { autoTask } from "../utils/common.js";
// 指定定时发送的群号
const groupList = ["169721415"];
@ -60,7 +60,7 @@ export class daily extends plugin {
async function pushDailyWorld(e) {
// 每天60秒读懂世界接口地址
const url = await fetch("https://api.vvhan.com/api/60s?type=json").catch(err =>
console.error(err)
console.error(err),
);
const imgUrl = await url.json();
const res = await imgUrl.imgUrl;
@ -80,7 +80,7 @@ async function pushDailyWorld(e) {
async function pushTouchFish(e) {
const url = await fetch("https://api.vvhan.com/api/moyu?type=json").catch(err =>
console.error(err)
console.error(err),
);
const imgUrl = await url.json();
const res = await imgUrl.url;

View File

@ -139,7 +139,7 @@ export class query extends plugin {
return true;
}
e.reply(
`识别:${resp.data[0].name}\n烂番茄评分:${resp.imdbRating}\n豆瓣评分:${resp.doubanRating}\n评分:${resp.imdbRating}`
`识别:${resp.data[0].name}\n烂番茄评分:${resp.imdbRating}\n豆瓣评分:${resp.doubanRating}\n评分:${resp.imdbRating}`,
);
});
});
@ -151,7 +151,7 @@ export class query extends plugin {
let images = [];
let reqRes = [
...(await fetch(`https://shibe.online/api/cats?count=${numb}`).then(data =>
data.json()
data.json(),
)),
...(await fetch(`https://api.thecatapi.com/v1/images/search?limit=${numb}`)
.then(data => data.json())
@ -323,7 +323,7 @@ export class query extends plugin {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53",
},
}
},
)
.then(resp => {
// console.log(resp.data);
@ -482,7 +482,7 @@ export class query extends plugin {
});
await e.reply(await Bot.makeForwardMsg(bookMsg));
await e.reply(
"请选择一个你想要的ID、来源例如11918807 zlibrary只回复11918807默认zlibrary"
"请选择一个你想要的ID、来源例如11918807 zlibrary只回复11918807默认zlibrary",
);
thisBookMethod.setContext("searchBookContext");

View File

@ -91,7 +91,7 @@ export class tools extends plugin {
const language = languageReg.exec(msg);
if (!transMap.hasOwnProperty(language[1])) {
e.reply(
"输入格式有误!例子:翻中 China's policy has been consistent, but Japan chooses a path of mistrust, decoupling and military expansion"
"输入格式有误!例子:翻中 China's policy has been consistent, but Japan chooses a path of mistrust, decoupling and military expansion",
);
return;
}
@ -101,7 +101,7 @@ export class tools extends plugin {
let url = `http://api.fanyi.baidu.com/api/trans/vip/translate?from=auto&to=${
transMap[language[1]]
}&appid=${this.translateAppId}&salt=rconsole&sign=${md5(
this.translateAppId + place + "rconsole" + this.translateSecret
this.translateAppId + place + "rconsole" + this.translateSecret,
)}&q=${place}`;
// console.log(url)
await fetch(url)
@ -125,44 +125,51 @@ export class tools extends plugin {
// const url = `https://www.iesdouyin.com/aweme/v1/web/aweme/detail/?aweme_id=${ douId }&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`;
fetch("https://ttwid.bytedance.com/ttwid/union/register/", {
"method": "POST",
"mode": "cors",
"credentials": 'include',
method: "POST",
mode: "cors",
credentials: "include",
body: JSON.stringify({
"region": "cn",
"aid": 1768,
"needFid": false,
"service": "www.ixigua.com",
"migrate_info": {
"ticket": "",
"source": "node"
region: "cn",
aid: 1768,
needFid: false,
service: "www.ixigua.com",
migrate_info: {
ticket: "",
source: "node",
},
"cbUrlProtocol": "https",
"union": true
})
cbUrlProtocol: "https",
union: true,
}),
}).then(resp => {
const ttwid = resp.headers.get('set-cookie');
const odin_tt = 'a09d8eb0d95b7b9adb4b6fc6591918bfb996096967a7aa4305bd81b5150a8199d2e29ed21883cdd7709c5beaa2be3baa';
const ttwid = resp.headers.get("set-cookie");
const odin_tt =
"a09d8eb0d95b7b9adb4b6fc6591918bfb996096967a7aa4305bd81b5150a8199d2e29ed21883cdd7709c5beaa2be3baa";
const headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36',
'referer':'https://www.douyin.com/',
'Cookie': `ttwid=${ttwid};${odin_tt}`
}
const dyApi = 'https://www.douyin.com/aweme/v1/web/aweme/detail/?'
const params = `aweme_id=${ douId }&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`
"user-agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
referer: "https://www.douyin.com/",
Cookie: `ttwid=${ttwid};${odin_tt}`,
};
const dyApi = "https://www.douyin.com/aweme/v1/web/aweme/detail/?";
const params = `aweme_id=${douId}&aid=1128&version_name=23.5.0&device_platform=android&os_version=2333`;
// xg参数
axios.post(`http://47.115.200.238/xg/path?url=${params.replaceAll('&','%26')}`, {
axios
.post(`http://47.115.200.238/xg/path?url=${params.replaceAll("&", "%26")}`, {
headers: {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
"referer": "https://www.douyin.com/",
"cookie": ""
"user-agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
referer: "https://www.douyin.com/",
cookie: "",
},
}).then(resp => {
const param = resp.data.result[0].paramsencode
const resDyApi = `${dyApi}${param}`
axios.get(resDyApi, {
headers
}).then(async resp => {
})
.then(resp => {
const param = resp.data.result[0].paramsencode;
const resDyApi = `${dyApi}${param}`;
axios
.get(resDyApi, {
headers,
})
.then(async resp => {
const item = resp.data.aweme_detail;
e.reply(`识别:抖音, ${item.desc}`);
const urlTypeCode = item.aweme_type;
@ -172,8 +179,10 @@ export class tools extends plugin {
this.downloadVideo(url_2, false, headers).then(video => {
e.reply(
segment.video(
`${ this.defaultPath }${ this.e.group_id || this.e.user_id }/temp.mp4`
)
`${this.defaultPath}${
this.e.group_id || this.e.user_id
}/temp.mp4`,
),
);
});
} else if (urlType === "image") {
@ -193,11 +202,13 @@ export class tools extends plugin {
// e.reply(segment.image(i.url_list[0]));
}
// console.log(no_watermark_image_list)
await this.reply(await Bot.makeForwardMsg(no_watermark_image_list));
await this.reply(
await Bot.makeForwardMsg(no_watermark_image_list),
);
}
})
})
})
});
});
});
});
return true;
}
@ -260,8 +271,8 @@ export class tools extends plugin {
this.downloadVideo(data.video.play_addr.url_list[0], true).then(video => {
e.reply(
segment.video(
`${ this.defaultPath }${ this.e.group_id || this.e.user_id }/temp.mp4`
)
`${this.defaultPath}${this.e.group_id || this.e.user_id}/temp.mp4`,
),
);
});
});
@ -294,14 +305,14 @@ export class tools extends plugin {
getDynamic(dynamicId).then(async resp => {
if (resp.dynamicSrc.length > 0) {
e.reply(`识别:哔哩哔哩动态, ${resp.dynamicDesc}`);
let dynamicSrcMsg = []
let dynamicSrcMsg = [];
resp.dynamicSrc.forEach(item => {
dynamicSrcMsg.push({
message: segment.image(item),
nickname: e.sender.card || e.user_id,
user_id: e.user_id,
})
})
});
});
await this.reply(await Bot.makeForwardMsg(dynamicSrcMsg));
// resp.dynamicSrc.forEach(item => {
// e.reply(segment.image(item));
@ -326,7 +337,7 @@ export class tools extends plugin {
fetch(
videoId.startsWith("BV")
? `${baseVideoInfo}?bvid=${videoId}`
: `${ baseVideoInfo }?aid=${ videoId }`
: `${baseVideoInfo}?aid=${videoId}`,
)
.then(resp => resp.json())
.then(resp => {
@ -428,37 +439,39 @@ export class tools extends plugin {
mkdirsSync(downloadPath);
}
// 逐个遍历判断
let task = []
let task = [];
for (let item of resp.includes.media) {
if (item.type === "photo") {
// 图片
task.push(this.downloadImg(item.url, downloadPath))
task.push(this.downloadImg(item.url, downloadPath));
} else if (item.type === "video") {
// 视频
await this.downloadVideo(resp.includes.media[0].variants[0].url, true).then(_ => {
await this.downloadVideo(resp.includes.media[0].variants[0].url, true).then(
_ => {
e.reply(segment.video(`${downloadPath}/temp.mp4`));
});
},
);
}
}
let images = []
let path = []
let images = [];
let path = [];
// 获取所有图片的promise
await Promise.all(task).then(resp => {
// console.log(resp)
resp.forEach(item => {
path.push(item)
path.push(item);
images.push({
message: segment.image(fs.readFileSync(item)),
nickname: this.e.sender.card || this.e.user_id,
user_id: this.e.user_id,
});
})
})
await e.reply(await Bot.makeForwardMsg(images))
});
});
await e.reply(await Bot.makeForwardMsg(images));
// 清理文件
path.forEach(item => {
fs.unlinkSync(item);
})
});
});
return true;
}
@ -492,7 +505,7 @@ export class tools extends plugin {
// 小红书解析
async redbook(e) {
const msgUrl = /(http:|https:)\/\/(xhslink|xiaohongshu).com\/[A-Za-z\d._?%&+\-=\/#@]*/.exec(
e.msg
e.msg,
)[0];
const url = `https://dlpanda.com/zh-CN/xhs?url=${msgUrl}`;
@ -515,10 +528,11 @@ export class tools extends plugin {
if (!fs.existsSync(downloadPath)) {
mkdirsSync(downloadPath);
}
const res = resp.data.match(reg)
const res = resp.data.match(reg);
const imagesPath = res.map(item => {
const addr = `https:${item.split('"')[3]}`;
return axios.get(addr, {
return axios
.get(addr, {
headers: {
"User-Agent":
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
@ -533,24 +547,24 @@ export class tools extends plugin {
writer.on("finish", () => resolve(filepath));
writer.on("error", reject);
});
})
})
let path = []
});
});
let path = [];
const images = await Promise.all(imagesPath).then(paths => {
return paths.map(item => {
path.push(item)
path.push(item);
return {
message: segment.image(fs.readFileSync(item)),
nickname: e.sender.card || e.user_id,
user_id: e.user_id,
}
})
})
};
});
});
await this.reply(await Bot.makeForwardMsg(images));
// 清理文件
path.forEach(item => {
fs.unlinkSync(item);
})
});
});
return true;
@ -589,8 +603,8 @@ export class tools extends plugin {
type: "video",
data: value,
}),
1000
)
1000,
),
),
downloadBFile(
audioUrl,
@ -601,8 +615,8 @@ export class tools extends plugin {
type: "audio",
data: value,
}),
1000
)
1000,
),
),
]).then(data => {
return mergeFileToMp4(data[0].fullFileName, data[1].fullFileName, title + ".mp4");

View File

@ -151,7 +151,7 @@ export class update extends plugin {
await this.reply(
msg +
`存在冲突:\n${errMsg}\n` +
"请解决冲突后再更新,或者执行#强制更新,放弃本地修改"
"请解决冲突后再更新,或者执行#强制更新,放弃本地修改",
);
} else if (stdout.includes("CONFLICT")) {
await this.reply([