mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-12-05 18:01:56 +00:00
🔧 chore: 医药查询轻量化
This commit is contained in:
parent
4376b42f2f
commit
52f95bc1ad
@ -70,19 +70,29 @@ export class query extends plugin {
|
|||||||
const res = await fetch(url)
|
const res = await fetch(url)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(resp => resp.list);
|
.then(resp => resp.list);
|
||||||
const promises = res.map(async element => {
|
let msg = [];
|
||||||
|
for (let element of res) {
|
||||||
const title = this.removeTag(element.title);
|
const title = this.removeTag(element.title);
|
||||||
const template = `${ title }\n标签:${ element.secondTitle }\n介绍:${ element.introduction }`;
|
const thumbnail = element?.thumbnail || element?.auditDoctor?.thumbnail;
|
||||||
return {
|
const doctor = `\n\n👨⚕️ 医生信息:${ element?.auditDoctor?.name } - ${ element?.auditDoctor?.clinicProfessional } - ${ element?.auditDoctor?.eduProfessional } - ${ element?.auditDoctor?.institutionName } - ${ element?.auditDoctor?.institutionLevel } - ${ element?.auditDoctor?.departmentName }`
|
||||||
|
const template = `📌 ${ title } - ${ element.secondTitle }${element?.auditDoctor ? doctor : ''}\n\n📝 简介:${ element.introduction }`;
|
||||||
|
if (thumbnail) {
|
||||||
|
msg.push({
|
||||||
|
message: [segment.image(thumbnail), { type: "text", text: template, }],
|
||||||
|
nickname: e.sender.card || e.user_id,
|
||||||
|
user_id: e.user_id,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
msg.push({
|
||||||
message: {
|
message: {
|
||||||
type: "text",
|
type: "text",
|
||||||
text: template,
|
text: template,
|
||||||
},
|
},
|
||||||
nickname: Bot.nickname,
|
nickname: e.sender.card || e.user_id,
|
||||||
user_id: Bot.user_id,
|
user_id: e.user_id,
|
||||||
};
|
})
|
||||||
});
|
}
|
||||||
const msg = await Promise.all(promises);
|
}
|
||||||
e.reply(await Bot.makeForwardMsg(msg));
|
e.reply(await Bot.makeForwardMsg(msg));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
@ -329,6 +339,7 @@ export class query extends plugin {
|
|||||||
|
|
||||||
return parsedData;
|
return parsedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除标签
|
// 删除标签
|
||||||
removeTag(title) {
|
removeTag(title) {
|
||||||
const titleRex = /<[^>]+>/g;
|
const titleRex = /<[^>]+>/g;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user