koishi-plugin-forward-hime 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +21 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -122,6 +122,20 @@ function cqJsonTranslator(content, elem) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
__name(cqJsonTranslator, "cqJsonTranslator");
|
|
125
|
+
var IdNameCache = /* @__PURE__ */ new Map();
|
|
126
|
+
function getNameFromQQat(elem) {
|
|
127
|
+
const name2 = elem.attrs.name;
|
|
128
|
+
if (name2) {
|
|
129
|
+
return name2;
|
|
130
|
+
}
|
|
131
|
+
const id = elem.attrs.id;
|
|
132
|
+
if (IdNameCache.has(id)) {
|
|
133
|
+
return IdNameCache.get(id);
|
|
134
|
+
} else {
|
|
135
|
+
return id;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
__name(getNameFromQQat, "getNameFromQQat");
|
|
125
139
|
function Middleware(session) {
|
|
126
140
|
const platform = guessPlatform(session);
|
|
127
141
|
let newContent = [];
|
|
@@ -132,8 +146,14 @@ function Middleware(session) {
|
|
|
132
146
|
(0, import_koishi4.h)("span", `:`)
|
|
133
147
|
];
|
|
134
148
|
if (platform === "QQ") {
|
|
149
|
+
IdNameCache.set(session.userId, session.username);
|
|
135
150
|
for (const key in session.elements) {
|
|
136
151
|
switch (session.elements[key].type) {
|
|
152
|
+
case "at":
|
|
153
|
+
newContent.push(
|
|
154
|
+
(0, import_koishi4.h)("span", `@${getNameFromQQat(session.elements[key])}`)
|
|
155
|
+
);
|
|
156
|
+
break;
|
|
137
157
|
case "forward":
|
|
138
158
|
newContent.push((0, import_koishi4.h)("span", `[CQ:转发消息]`));
|
|
139
159
|
break;
|
|
@@ -329,7 +349,7 @@ async function MsgDecoratorFallback(session, node) {
|
|
|
329
349
|
return defaultDecoratorFallback(elems);
|
|
330
350
|
}
|
|
331
351
|
__name(MsgDecoratorFallback, "MsgDecoratorFallback");
|
|
332
|
-
async function atTranslator(session,
|
|
352
|
+
async function atTranslator(session, _, { head, content }) {
|
|
333
353
|
const newMsg = await new Promise((resolve, reject) => {
|
|
334
354
|
let newContent = [];
|
|
335
355
|
for (const key in content) {
|