feat: add group chat activation mode
This commit is contained in:
@@ -73,7 +73,10 @@ export type TelegramConfig = {
|
||||
webhookPath?: string;
|
||||
};
|
||||
|
||||
export type GroupChatActivationMode = "mention" | "always";
|
||||
|
||||
export type GroupChatConfig = {
|
||||
activation?: GroupChatActivationMode;
|
||||
requireMention?: boolean;
|
||||
mentionPatterns?: string[];
|
||||
historyLimit?: number;
|
||||
@@ -289,6 +292,9 @@ const ClawdisSchema = z.object({
|
||||
timestampPrefix: z.union([z.boolean(), z.string()]).optional(),
|
||||
groupChat: z
|
||||
.object({
|
||||
activation: z
|
||||
.union([z.literal("mention"), z.literal("always")])
|
||||
.optional(),
|
||||
requireMention: z.boolean().optional(),
|
||||
mentionPatterns: z.array(z.string()).optional(),
|
||||
historyLimit: z.number().int().positive().optional(),
|
||||
|
||||
11
src/config/group-chat.ts
Normal file
11
src/config/group-chat.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { ClawdisConfig, GroupChatActivationMode } from "./config.js";
|
||||
|
||||
export function resolveGroupChatActivation(
|
||||
cfg?: ClawdisConfig,
|
||||
): GroupChatActivationMode {
|
||||
const groupChat = cfg?.inbound?.groupChat;
|
||||
if (groupChat?.activation === "always") return "always";
|
||||
if (groupChat?.activation === "mention") return "mention";
|
||||
if (groupChat?.requireMention === false) return "always";
|
||||
return "mention";
|
||||
}
|
||||
Reference in New Issue
Block a user