@ascegu/teamily 1.0.13 → 1.0.14
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/package.json +1 -1
- package/src/channel.ts +12 -4
- package/src/monitor.ts +2 -2
- package/src/types.ts +6 -0
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { normalizeTeamilyTarget, normalizeTeamilyAllowEntry } from "./normalize.
|
|
|
26
26
|
import { probeTeamily } from "./probe.js";
|
|
27
27
|
import { getTeamilyRuntime } from "./runtime.js";
|
|
28
28
|
import type { ResolvedTeamilyAccount } from "./types.js";
|
|
29
|
-
import {
|
|
29
|
+
import { isGroupSession } from "./types.js";
|
|
30
30
|
|
|
31
31
|
const meta = {
|
|
32
32
|
id: "teamily",
|
|
@@ -243,11 +243,17 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
|
|
|
243
243
|
const rt = getTeamilyRuntime();
|
|
244
244
|
const currentCfg = rt.config.loadConfig();
|
|
245
245
|
|
|
246
|
-
const isGroup = message.sessionType
|
|
246
|
+
const isGroup = isGroupSession(message.sessionType);
|
|
247
247
|
const from = message.sendID;
|
|
248
248
|
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
log?.info?.(
|
|
250
|
+
`[${accountId}] Incoming message: sessionType=${message.sessionType}, isGroup=${isGroup}, ` +
|
|
251
|
+
`from=${from}, recvID=${message.recvID}, isAtSelf=${message.isAtSelf ?? false}`,
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
// In group chats, all messages are dispatched to the agent for context,
|
|
255
|
+
// but only @-mentioned messages trigger a reply.
|
|
256
|
+
const shouldReply = !isGroup || !!message.isAtSelf;
|
|
251
257
|
|
|
252
258
|
const text = message.content?.text || "";
|
|
253
259
|
const sessionKey = isGroup ? `teamily:group:${message.recvID}` : `teamily:${from}`;
|
|
@@ -300,11 +306,13 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
|
|
|
300
306
|
cfg: currentCfg,
|
|
301
307
|
dispatcherOptions: {
|
|
302
308
|
deliver: async (payload: { text?: string; body?: string }) => {
|
|
309
|
+
if (!shouldReply) return;
|
|
303
310
|
const replyText = payload?.text ?? payload?.body;
|
|
304
311
|
if (replyText) {
|
|
305
312
|
const monitor = getTeamilyMonitor(accountId);
|
|
306
313
|
if (!monitor) throw new Error(`Teamily monitor not running for account ${accountId}`);
|
|
307
314
|
const replyTo = isGroup ? `group:${message.recvID}` : from;
|
|
315
|
+
log?.info?.(`[${accountId}] Sending reply to: ${replyTo} (isGroup=${isGroup})`);
|
|
308
316
|
const target = normalizeTeamilyTarget(replyTo);
|
|
309
317
|
await monitor.sendText(target, replyText);
|
|
310
318
|
}
|
package/src/monitor.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
TeamilyVideoContent,
|
|
7
7
|
TeamilyAudioContent,
|
|
8
8
|
} from "./types.js";
|
|
9
|
-
import { CONTENT_TYPES, SESSION_TYPES } from "./types.js";
|
|
9
|
+
import { CONTENT_TYPES, SESSION_TYPES, isGroupSession } from "./types.js";
|
|
10
10
|
|
|
11
11
|
export type TeamilyMessageHandler = (message: TeamilyMessage) => Promise<void> | void;
|
|
12
12
|
export type TeamilyConnectionState = "connecting" | "connected" | "disconnected" | "error";
|
|
@@ -241,7 +241,7 @@ function convertSdkMessage(msg: MessageItem, selfUserID: string): TeamilyMessage
|
|
|
241
241
|
return {
|
|
242
242
|
serverMsgID: msg.serverMsgID || msg.clientMsgID || `${Date.now()}_${Math.random()}`,
|
|
243
243
|
sendID: msg.sendID || "unknown",
|
|
244
|
-
recvID: sessionType
|
|
244
|
+
recvID: isGroupSession(sessionType) ? (msg.groupID || "") : (msg.recvID || selfUserID),
|
|
245
245
|
content,
|
|
246
246
|
contentType,
|
|
247
247
|
sessionType,
|
package/src/types.ts
CHANGED
|
@@ -121,6 +121,12 @@ export const CONTENT_TYPES = {
|
|
|
121
121
|
// Session type constants
|
|
122
122
|
export const SESSION_TYPES = {
|
|
123
123
|
SINGLE: 1,
|
|
124
|
+
SUPER_GROUP: 2,
|
|
124
125
|
GROUP: 3,
|
|
125
126
|
NOTIFICATION: 4,
|
|
126
127
|
} as const;
|
|
128
|
+
|
|
129
|
+
/** Returns true when the session type represents any kind of group chat. */
|
|
130
|
+
export function isGroupSession(sessionType: number): boolean {
|
|
131
|
+
return sessionType === SESSION_TYPES.GROUP || sessionType === SESSION_TYPES.SUPER_GROUP;
|
|
132
|
+
}
|