mioku-plugin-chat 2.1.1 → 2.1.2
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/index.ts +10 -6
- package/package.json +1 -1
- package/utils/index.ts +0 -1
- package/utils/message.ts +4 -10
package/index.ts
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
getQuotedContent,
|
|
16
16
|
isGroupAllowed,
|
|
17
17
|
isQuotingBot,
|
|
18
|
-
safeText,
|
|
19
18
|
shouldTrigger,
|
|
20
19
|
} from "./utils";
|
|
21
20
|
import { BASE_CONFIG } from "./configs/base";
|
|
@@ -613,9 +612,12 @@ const chatPlugin = definePlugin({
|
|
|
613
612
|
if (overrideContent?.trim()) {
|
|
614
613
|
return overrideContent.trim();
|
|
615
614
|
}
|
|
616
|
-
//
|
|
617
|
-
//
|
|
618
|
-
|
|
615
|
+
// If no event or event has no message property (synthetic event like group_member_increase),
|
|
616
|
+
// return the default prompt
|
|
617
|
+
if (!event || !event.message || !Array.isArray(event.message)) {
|
|
618
|
+
return "[No new user message in this turn. Reply naturally based on the runtime instruction and recent context.]";
|
|
619
|
+
}
|
|
620
|
+
const text = ctx.text(event)?.trim() || "";
|
|
619
621
|
if (text) {
|
|
620
622
|
return text;
|
|
621
623
|
}
|
|
@@ -1037,7 +1039,9 @@ const chatPlugin = definePlugin({
|
|
|
1037
1039
|
const cfg = await getConfig();
|
|
1038
1040
|
if (!cfg.apiKey) return;
|
|
1039
1041
|
|
|
1040
|
-
|
|
1042
|
+
if (!e?.message || !Array.isArray(e.message)) return;
|
|
1043
|
+
|
|
1044
|
+
const text = ctx.text(e) || "";
|
|
1041
1045
|
const isGroup = e.message_type === "group";
|
|
1042
1046
|
const groupId: number | undefined = isGroup ? e.group_id : undefined;
|
|
1043
1047
|
const userId: number = e.user_id || e.sender?.user_id;
|
|
@@ -1681,7 +1685,7 @@ async function processChat(
|
|
|
1681
1685
|
}
|
|
1682
1686
|
if (quotedInfo?.imageUrl) imageUrls.push(quotedInfo.imageUrl);
|
|
1683
1687
|
|
|
1684
|
-
let messageContent =
|
|
1688
|
+
let messageContent = ctx.text(e) || "";
|
|
1685
1689
|
let extraContext = "";
|
|
1686
1690
|
if (quotedInfo) {
|
|
1687
1691
|
const parts = [
|
package/package.json
CHANGED
package/utils/index.ts
CHANGED
package/utils/message.ts
CHANGED
|
@@ -11,15 +11,6 @@ import { getImageTag } from "../core/media/image-analyzer";
|
|
|
11
11
|
|
|
12
12
|
const HISTORY_MEDIA_CONCURRENCY = 8;
|
|
13
13
|
|
|
14
|
-
export function safeText(ctx: MiokiContext, e: any): string {
|
|
15
|
-
if (!e || !Array.isArray(e.message)) return "";
|
|
16
|
-
try {
|
|
17
|
-
return ctx.text(e) || "";
|
|
18
|
-
} catch {
|
|
19
|
-
return "";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
export function shouldTrigger(
|
|
24
15
|
e: any,
|
|
25
16
|
text: string,
|
|
@@ -124,7 +115,10 @@ export function extractContent(
|
|
|
124
115
|
cfg: ChatConfig,
|
|
125
116
|
ctx: MiokiContext,
|
|
126
117
|
): { text: string; multimodal: any[] | null } {
|
|
127
|
-
let text =
|
|
118
|
+
let text = "";
|
|
119
|
+
try {
|
|
120
|
+
text = ctx.text(e) || "";
|
|
121
|
+
} catch {}
|
|
128
122
|
|
|
129
123
|
// If text is empty but user @'d the bot, describe the action
|
|
130
124
|
if (!text.trim() && e.message) {
|