mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:48:27 +00:00
fix: allow telegram prefixes/topics for inline buttons (#1072) — thanks @danielz1z
Co-authored-by: danielz1z <danielz1z@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import type { TelegramInlineButtonsScope } from "../config/types.telegram.js";
|
||||
import { listTelegramAccountIds, resolveTelegramAccount } from "./accounts.js";
|
||||
import { parseTelegramTarget } from "./targets.js";
|
||||
|
||||
const DEFAULT_INLINE_BUTTONS_SCOPE: TelegramInlineButtonsScope = "allowlist";
|
||||
|
||||
@@ -61,14 +62,12 @@ export function isTelegramInlineButtonsEnabled(params: {
|
||||
}
|
||||
|
||||
export function resolveTelegramTargetChatType(target: string): "direct" | "group" | "unknown" {
|
||||
let trimmed = target.trim();
|
||||
if (!trimmed) return "unknown";
|
||||
// Strip telegram: prefix added by normalizeTelegramMessagingTarget
|
||||
if (trimmed.toLowerCase().startsWith("telegram:")) {
|
||||
trimmed = trimmed.slice("telegram:".length).trim();
|
||||
}
|
||||
if (/^-?\d+$/.test(trimmed)) {
|
||||
return trimmed.startsWith("-") ? "group" : "direct";
|
||||
if (!target.trim()) return "unknown";
|
||||
const parsed = parseTelegramTarget(target);
|
||||
const chatId = parsed.chatId.trim();
|
||||
if (!chatId) return "unknown";
|
||||
if (/^-?\d+$/.test(chatId)) {
|
||||
return chatId.startsWith("-") ? "group" : "direct";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user