🐞 fix: 解决tiktok解析问题

This commit is contained in:
zhiyu1998 2022-12-29 22:28:39 +08:00
parent 9908d0e213
commit 0d0d67d881
2 changed files with 29 additions and 20 deletions

View File

@ -56,48 +56,56 @@ export class mystery extends plugin {
this.mysteryConfig = config.getConfig('mystery')
}
// 接受到消息都会先执行一次
async accept () {
let oldReply = this.e.reply
/** 接受到消息都会先执行一次 */
async accept() {
if (this.e.isGroup) {
let group = this.e.group;
if (!group.is_owner && (group.is_admin && group.mute_left > 0)) return;
if (!(group.is_owner || group.is_admin) && (group.all_muted || group.mute_left > 0)) return;
}
let old_reply = this.e.reply;
this.e.reply = async function (msgs, quote, data) {
if (!msgs) return false
if (!Array.isArray(msgs)) msgs = [ msgs ]
let result = await oldReply(msgs, quote, data)
if (!msgs) return false;
if (!Array.isArray(msgs)) msgs = [msgs];
let result = await old_reply(msgs, quote, data);
if (!result || !result.message_id) {
let isxml = false
let isxml = false;
for (let msg of msgs) {
if (msg && msg?.type == 'xml' && msg?.data) {
msg.data = msg.data.replace(/^<\?xml.*update=.*?>/g, '<?xml update="1.0" encoding="utf-8" ?>')
isxml = true
msg.data = msg.data.replace(/^<\?xml.*version=.*?>/g, '<?xml version="1.0" encoding="utf-8" ?>');
isxml = true;
}
}
if (isxml) {
result = await oldReply(msgs, quote, data)
result = await old_reply(msgs, quote, data);
} else {
let MsgList = [ {
message: msgs, nickname: Bot.nickname, user_id: Bot.user_id
} ]
let MsgList = [{
message: msgs,
nickname: Bot.nickname,
user_id: Bot.uin
}];
let forwardMsg = await Bot.makeForwardMsg(MsgList)
let forwardMsg = await Bot.makeForwardMsg(MsgList);
forwardMsg.data = forwardMsg.data
.replace('<?xml update="1.0" encoding="utf-8"?>', '<?xml update="1.0" encoding="utf-8" ?>')
.replace('<?xml version="1.0" encoding="utf-8"?>', '<?xml version="1.0" encoding="utf-8" ?>')
.replace(/\n/g, '')
.replace(/<title color="#777777" size="26">(.+?)<\/title>/g, '___')
.replace(/___+/, '<title color="#777777" size="26">请点击查看内容</title>')
msgs = forwardMsg
result = await oldReply(msgs, quote, data)
.replace(/___+/, '<title color="#777777" size="26">请点击查看内容</title>');
msgs = forwardMsg;
result = await old_reply(msgs, quote, data);
}
if (!result || !result.message_id) {
logger.error('风控消息处理失败请登录手机QQ查看是否可手动解除风控')
logger.error('风控消息处理失败请登录手机QQ查看是否可手动解除风控');
}
}
return result
return result;
}
}

View File

@ -129,6 +129,7 @@ export class tools extends plugin {
"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",
"Content-Type": "application/json",
"Accept-Encoding": "gzip,deflate,compress"
},
timeout: 10000,
proxy: false,