openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
29 lines (28 loc) • 1.43 kB
JavaScript
//#region extensions/telegram/src/bot-info.ts
function normalizeBoolean(value) {
return typeof value === "boolean" ? value : null;
}
function normalizeTelegramBotInfo(value) {
if (!value || typeof value !== "object") return;
const bot = value;
if (typeof bot.id !== "number" || bot.is_bot !== true || typeof bot.first_name !== "string" || typeof bot.username !== "string") return;
return {
id: bot.id,
is_bot: true,
first_name: bot.first_name,
username: bot.username,
...typeof bot.last_name === "string" ? { last_name: bot.last_name } : {},
...typeof bot.language_code === "string" ? { language_code: bot.language_code } : {},
can_join_groups: normalizeBoolean(bot.can_join_groups) ?? false,
can_read_all_group_messages: normalizeBoolean(bot.can_read_all_group_messages) ?? false,
can_manage_bots: normalizeBoolean(bot.can_manage_bots) ?? false,
supports_inline_queries: normalizeBoolean(bot.supports_inline_queries) ?? false,
supports_join_request_queries: normalizeBoolean(bot.supports_join_request_queries) ?? false,
can_connect_to_business: normalizeBoolean(bot.can_connect_to_business) ?? false,
has_main_web_app: normalizeBoolean(bot.has_main_web_app) ?? false,
has_topics_enabled: normalizeBoolean(bot.has_topics_enabled) ?? false,
allows_users_to_create_topics: normalizeBoolean(bot.allows_users_to_create_topics) ?? false
};
}
//#endregion
export { normalizeTelegramBotInfo as t };