mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 23:14:31 +00:00
refactor: unify inbound debounce policy and split gateway/models helpers
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { Message, ReactionTypeEmoji } from "@grammyjs/types";
|
||||
import { resolveAgentDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||
import { hasControlCommand } from "../auto-reply/command-detection.js";
|
||||
import {
|
||||
createInboundDebouncer,
|
||||
resolveInboundDebounceMs,
|
||||
@@ -13,6 +12,7 @@ import {
|
||||
import { resolveStoredModelOverride } from "../auto-reply/reply/model-selection.js";
|
||||
import { listSkillCommandsForAgents } from "../auto-reply/skill-commands.js";
|
||||
import { buildCommandsMessagePaginated } from "../auto-reply/status.js";
|
||||
import { shouldDebounceTextInbound } from "../channels/inbound-debounce-policy.js";
|
||||
import { resolveChannelConfigWrites } from "../channels/plugins/config-writes.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { writeConfigFile } from "../config/io.js";
|
||||
@@ -206,14 +206,18 @@ export const registerTelegramHandlers = ({
|
||||
buildKey: (entry) => entry.debounceKey,
|
||||
shouldDebounce: (entry) => {
|
||||
const text = entry.msg.text ?? entry.msg.caption ?? "";
|
||||
const hasText = text.trim().length > 0;
|
||||
if (hasText && hasControlCommand(text, cfg, { botUsername: entry.botUsername })) {
|
||||
const hasDebounceableText = shouldDebounceTextInbound({
|
||||
text,
|
||||
cfg,
|
||||
commandOptions: { botUsername: entry.botUsername },
|
||||
});
|
||||
if (!hasDebounceableText) {
|
||||
return false;
|
||||
}
|
||||
if (entry.debounceLane === "forward") {
|
||||
return true;
|
||||
}
|
||||
return entry.allMedia.length === 0 && hasText;
|
||||
return entry.allMedia.length === 0;
|
||||
},
|
||||
onFlush: async (entries) => {
|
||||
const last = entries.at(-1);
|
||||
|
||||
Reference in New Issue
Block a user