mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 11:21:07 +00:00
18 lines
609 B
TypeScript
18 lines
609 B
TypeScript
import { parseTelegramTarget } from "./targets.js";
|
|
|
|
export function resolveTelegramAutoThreadId(params: {
|
|
to: string;
|
|
toolContext?: { currentThreadTs?: string; currentChannelId?: string };
|
|
}): string | undefined {
|
|
const context = params.toolContext;
|
|
if (!context?.currentThreadTs || !context.currentChannelId) {
|
|
return undefined;
|
|
}
|
|
const parsedTo = parseTelegramTarget(params.to);
|
|
const parsedChannel = parseTelegramTarget(context.currentChannelId);
|
|
if (parsedTo.chatId.toLowerCase() !== parsedChannel.chatId.toLowerCase()) {
|
|
return undefined;
|
|
}
|
|
return context.currentThreadTs;
|
|
}
|