koishi-plugin-bcjh-logs 0.0.8 → 0.0.9
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 +10 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -31,11 +31,11 @@ var Config = import_koishi.Schema.object({});
|
|
|
31
31
|
function apply(ctx) {
|
|
32
32
|
const logger = ctx.logger("bcjh-logs");
|
|
33
33
|
ctx.middleware(async (session, next) => {
|
|
34
|
+
const isPrivate = !session.guildId;
|
|
34
35
|
let atSelf = false;
|
|
35
|
-
const botId = session.bot
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
atSelf = mentioned;
|
|
36
|
+
const botId = session.bot.selfId;
|
|
37
|
+
if (typeof session.mentioned === "boolean") {
|
|
38
|
+
atSelf = session.mentioned;
|
|
39
39
|
} else {
|
|
40
40
|
const elements = session.elements || [];
|
|
41
41
|
for (const el of elements) {
|
|
@@ -56,7 +56,12 @@ function apply(ctx) {
|
|
|
56
56
|
const green = "\x1B[32m";
|
|
57
57
|
const yellow = "\x1B[33m";
|
|
58
58
|
const reset = "\x1B[0m";
|
|
59
|
-
|
|
59
|
+
let logMessage;
|
|
60
|
+
if (isPrivate) {
|
|
61
|
+
logMessage = `{atSelf:${yellow}${atSelf}${reset},content:‘${green}${content}${reset}’,用户:${yellow}${userId}${reset},频道:${yellow}${channelId}${reset},群组:${yellow}${guildId}${reset},平台:${yellow}${platform}${reset}}`;
|
|
62
|
+
} else {
|
|
63
|
+
logMessage = `{atSelf:${yellow}${atSelf}${reset},content:‘${green}${content}${reset}’,昵称:${yellow}${username}${reset},用户:${yellow}${userId}${reset},频道:${yellow}${channelId}${reset},群组:${yellow}${guildId}${reset},平台:${yellow}${platform}${reset}}`;
|
|
64
|
+
}
|
|
60
65
|
logger.info(logMessage);
|
|
61
66
|
return next();
|
|
62
67
|
}, true);
|