Skip to content

Commit

Permalink
更新,实现对商城表情的外显修改,使用表情包外显。
Browse files Browse the repository at this point in the history
  • Loading branch information
WJZ-P committed Oct 10, 2024
1 parent 5d2332e commit f8ccab1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "修改图片概要",
"slug": "change_summary",
"description": "修改图片/表情包外显消息(未进入群聊时在外部看见的简略文本)(^∀^)",
"version": "1.1.0",
"version": "1.1.1",
"icon": "./src/assests/icon.svg",
"thumb": "./src/assests/icon.svg",
"authors": [
Expand All @@ -27,8 +27,8 @@
"repo": "WJZ-P/LiteLoaderQQNT-Change-Summary",
"branch": "main",
"release": {
"tag": "v1.1.0",
"file": "Change-Summary-1.1.0.zip"
"tag": "v1.1.1",
"file": "Change-Summary-1.1.1.zip"
}
}
}
25 changes: 19 additions & 6 deletions src/utils/ipcUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {Config} = require("../Config.js")
const {Config} = require("../Config.js")
const {pluginLog} = require("./backendLogUtils.js");

const config = Config.config
Expand Down Expand Up @@ -34,7 +34,7 @@ function ipcModifyer(ipcProxy, window) {

async function ipcMsgModify(args) {
// 获取随机文本辅助函数
const getRandomText = async() => {
const getRandomText = async () => {
const response = await fetch(config.randomTextApi);
return await response.json();
}
Expand All @@ -52,16 +52,15 @@ async function ipcMsgModify(args) {
//说明消息内容是图片类,则修改图片外显
else if (item.elementType === 2) {
pluginLog('尝试修改图片外显')

try {
const subtype = item.picElement.picSubType;
const subtype = item.picElement.picSubType;//subType 1是表情包,0是图片
const useRandom = subtype === 1 ? config.isMemeOTuseRandom : config.isPicOTuseRandom;
const outsideText = subtype === 1 ? config.memeOutsideText : config.picOutsideText;

if(useRandom)
if (useRandom)
item.picElement.summary = (await getRandomText())[config.randomTextApiKey];
else item.picElement.summary = outsideText;
} catch(e) {
} catch (e) {
console.error(`获取随机文本或设置外显文字时发生错误: ${e}`);
}

Expand All @@ -70,6 +69,20 @@ async function ipcMsgModify(args) {
// for (let item of args[3][1][1].msgElements) {
// console.log(item)
// }
} else if (item.elementType === 11) {//11是marketFaceElement,是商城表情,用表情包的外显或者随机外显吧
try {
pluginLog('尝试修改商城表情外显')

const useRandom = config.isMemeOTuseRandom
const outsideText = config.memeOutsideText

if (useRandom)
item.marketFaceElement.faceName = (await getRandomText())[config.randomTextApiKey];
else item.marketFaceElement.faceName = outsideText;

} catch (e) {
pluginLog(`获取随机文本或设置外显文字时发生错误: ${e}`);
}
}
}

Expand Down

0 comments on commit f8ccab1

Please sign in to comment.