feat: unify group mention defaults
This commit is contained in:
@@ -995,8 +995,8 @@ export async function getReplyFromConfig(
|
||||
const webAuthAgeMs = getWebAuthAgeMs();
|
||||
const heartbeatSeconds = resolveHeartbeatSeconds(cfg, undefined);
|
||||
const groupActivation = isGroup
|
||||
? normalizeGroupActivation(sessionEntry?.groupActivation) ??
|
||||
defaultGroupActivation()
|
||||
? (normalizeGroupActivation(sessionEntry?.groupActivation) ??
|
||||
defaultGroupActivation())
|
||||
: undefined;
|
||||
const statusText = buildStatusMessage({
|
||||
agent: {
|
||||
|
||||
@@ -1235,7 +1235,7 @@ const LEGACY_CONFIG_RULES: LegacyConfigRule[] = [
|
||||
{
|
||||
path: ["telegram", "requireMention"],
|
||||
message:
|
||||
"telegram.requireMention was removed; use telegram.groups.\"*\".requireMention instead (run `clawdis doctor` to migrate).",
|
||||
'telegram.requireMention was removed; use telegram.groups."*".requireMention instead (run `clawdis doctor` to migrate).',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1280,8 +1280,10 @@ const LEGACY_CONFIG_MIGRATIONS: LegacyConfigMigration[] = [
|
||||
const groupChat =
|
||||
(routing as Record<string, unknown>).groupChat &&
|
||||
typeof (routing as Record<string, unknown>).groupChat === "object"
|
||||
? ((routing as Record<string, unknown>)
|
||||
.groupChat as Record<string, unknown>)
|
||||
? ((routing as Record<string, unknown>).groupChat as Record<
|
||||
string,
|
||||
unknown
|
||||
>)
|
||||
: null;
|
||||
if (!groupChat) return;
|
||||
const requireMention = groupChat.requireMention;
|
||||
@@ -1331,18 +1333,22 @@ const LEGACY_CONFIG_MIGRATIONS: LegacyConfigMigration[] = [
|
||||
},
|
||||
{
|
||||
id: "telegram.requireMention->telegram.groups.*.requireMention",
|
||||
describe: "Move telegram.requireMention to telegram.groups.*.requireMention",
|
||||
describe:
|
||||
"Move telegram.requireMention to telegram.groups.*.requireMention",
|
||||
apply: (raw, changes) => {
|
||||
const telegram = raw.telegram;
|
||||
if (!telegram || typeof telegram !== "object") return;
|
||||
const requireMention = (telegram as Record<string, unknown>).requireMention;
|
||||
const requireMention = (telegram as Record<string, unknown>)
|
||||
.requireMention;
|
||||
if (requireMention === undefined) return;
|
||||
|
||||
const groups =
|
||||
(telegram as Record<string, unknown>).groups &&
|
||||
typeof (telegram as Record<string, unknown>).groups === "object"
|
||||
? ((telegram as Record<string, unknown>)
|
||||
.groups as Record<string, unknown>)
|
||||
? ((telegram as Record<string, unknown>).groups as Record<
|
||||
string,
|
||||
unknown
|
||||
>)
|
||||
: {};
|
||||
const defaultKey = "*";
|
||||
const entry =
|
||||
|
||||
@@ -2,7 +2,9 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as replyModule from "../auto-reply/reply.js";
|
||||
import { createTelegramBot } from "./bot.js";
|
||||
|
||||
const loadConfig = vi.fn(() => ({}));
|
||||
const { loadConfig } = vi.hoisted(() => ({
|
||||
loadConfig: vi.fn(() => ({})),
|
||||
}));
|
||||
vi.mock("../config/config.js", () => ({
|
||||
loadConfig,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user