mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:54:30 +00:00
test: type telegram action mock passthrough args
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
import { Type } from "@sinclair/typebox";
|
import { Type } from "@sinclair/typebox";
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
|
||||||
import type { AnyAgentTool } from "./common.js";
|
|
||||||
import { BLUEBUBBLES_GROUP_ACTIONS } from "../../channels/plugins/bluebubbles-actions.js";
|
import { BLUEBUBBLES_GROUP_ACTIONS } from "../../channels/plugins/bluebubbles-actions.js";
|
||||||
import {
|
import {
|
||||||
listChannelMessageActions,
|
listChannelMessageActions,
|
||||||
@@ -13,6 +11,7 @@ import {
|
|||||||
CHANNEL_MESSAGE_ACTION_NAMES,
|
CHANNEL_MESSAGE_ACTION_NAMES,
|
||||||
type ChannelMessageActionName,
|
type ChannelMessageActionName,
|
||||||
} from "../../channels/plugins/types.js";
|
} from "../../channels/plugins/types.js";
|
||||||
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import { loadConfig } from "../../config/config.js";
|
import { loadConfig } from "../../config/config.js";
|
||||||
import { GATEWAY_CLIENT_IDS, GATEWAY_CLIENT_MODES } from "../../gateway/protocol/client-info.js";
|
import { GATEWAY_CLIENT_IDS, GATEWAY_CLIENT_MODES } from "../../gateway/protocol/client-info.js";
|
||||||
import { getToolResult, runMessageAction } from "../../infra/outbound/message-action-runner.js";
|
import { getToolResult, runMessageAction } from "../../infra/outbound/message-action-runner.js";
|
||||||
@@ -23,6 +22,7 @@ import { normalizeMessageChannel } from "../../utils/message-channel.js";
|
|||||||
import { resolveSessionAgentId } from "../agent-scope.js";
|
import { resolveSessionAgentId } from "../agent-scope.js";
|
||||||
import { listChannelSupportedActions } from "../channel-tools.js";
|
import { listChannelSupportedActions } from "../channel-tools.js";
|
||||||
import { channelTargetSchema, channelTargetsSchema, stringEnum } from "../schema/typebox.js";
|
import { channelTargetSchema, channelTargetsSchema, stringEnum } from "../schema/typebox.js";
|
||||||
|
import type { AnyAgentTool } from "./common.js";
|
||||||
import { jsonResult, readNumberParam, readStringParam } from "./common.js";
|
import { jsonResult, readNumberParam, readStringParam } from "./common.js";
|
||||||
import { resolveGatewayOptions } from "./gateway.js";
|
import { resolveGatewayOptions } from "./gateway.js";
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,14 @@ const deleteMessageTelegram = vi.fn(async () => ({ ok: true }));
|
|||||||
const originalToken = process.env.TELEGRAM_BOT_TOKEN;
|
const originalToken = process.env.TELEGRAM_BOT_TOKEN;
|
||||||
|
|
||||||
vi.mock("../../telegram/send.js", () => ({
|
vi.mock("../../telegram/send.js", () => ({
|
||||||
reactMessageTelegram: (...args: unknown[]) => reactMessageTelegram(...args),
|
reactMessageTelegram: (...args: Parameters<typeof reactMessageTelegram>) =>
|
||||||
sendMessageTelegram: (...args: unknown[]) => sendMessageTelegram(...args),
|
reactMessageTelegram(...args),
|
||||||
sendStickerTelegram: (...args: unknown[]) => sendStickerTelegram(...args),
|
sendMessageTelegram: (...args: Parameters<typeof sendMessageTelegram>) =>
|
||||||
deleteMessageTelegram: (...args: unknown[]) => deleteMessageTelegram(...args),
|
sendMessageTelegram(...args),
|
||||||
|
sendStickerTelegram: (...args: Parameters<typeof sendStickerTelegram>) =>
|
||||||
|
sendStickerTelegram(...args),
|
||||||
|
deleteMessageTelegram: (...args: Parameters<typeof deleteMessageTelegram>) =>
|
||||||
|
deleteMessageTelegram(...args),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("handleTelegramAction", () => {
|
describe("handleTelegramAction", () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import type { TelegramButtonStyle, TelegramInlineButtons } from "../../telegram/button-types.js";
|
|
||||||
import { createTelegramActionGate } from "../../telegram/accounts.js";
|
import { createTelegramActionGate } from "../../telegram/accounts.js";
|
||||||
|
import type { TelegramButtonStyle, TelegramInlineButtons } from "../../telegram/button-types.js";
|
||||||
import {
|
import {
|
||||||
resolveTelegramInlineButtonsScope,
|
resolveTelegramInlineButtonsScope,
|
||||||
resolveTelegramTargetChatType,
|
resolveTelegramTargetChatType,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import type { TelegramActionConfig } from "../../../config/types.telegram.js";
|
|
||||||
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
|
|
||||||
import {
|
import {
|
||||||
readNumberParam,
|
readNumberParam,
|
||||||
readStringArrayParam,
|
readStringArrayParam,
|
||||||
@@ -7,12 +5,14 @@ import {
|
|||||||
readStringParam,
|
readStringParam,
|
||||||
} from "../../../agents/tools/common.js";
|
} from "../../../agents/tools/common.js";
|
||||||
import { handleTelegramAction } from "../../../agents/tools/telegram-actions.js";
|
import { handleTelegramAction } from "../../../agents/tools/telegram-actions.js";
|
||||||
|
import type { TelegramActionConfig } from "../../../config/types.telegram.js";
|
||||||
import { extractToolSend } from "../../../plugin-sdk/tool-send.js";
|
import { extractToolSend } from "../../../plugin-sdk/tool-send.js";
|
||||||
import {
|
import {
|
||||||
createTelegramActionGate,
|
createTelegramActionGate,
|
||||||
listEnabledTelegramAccounts,
|
listEnabledTelegramAccounts,
|
||||||
} from "../../../telegram/accounts.js";
|
} from "../../../telegram/accounts.js";
|
||||||
import { isTelegramInlineButtonsEnabled } from "../../../telegram/inline-buttons.js";
|
import { isTelegramInlineButtonsEnabled } from "../../../telegram/inline-buttons.js";
|
||||||
|
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
|
||||||
|
|
||||||
const providerId = "telegram";
|
const providerId = "telegram";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import type { Message, ReactionTypeEmoji } from "@grammyjs/types";
|
import type { Message, ReactionTypeEmoji } from "@grammyjs/types";
|
||||||
import type { TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js";
|
|
||||||
import type { TelegramMediaRef } from "./bot-message-context.js";
|
|
||||||
import type { TelegramContext } from "./bot/types.js";
|
|
||||||
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
|
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||||
import { hasControlCommand } from "../auto-reply/command-detection.js";
|
import { hasControlCommand } from "../auto-reply/command-detection.js";
|
||||||
import {
|
import {
|
||||||
@@ -17,6 +14,7 @@ import { resolveChannelConfigWrites } from "../channels/plugins/config-writes.js
|
|||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
import { writeConfigFile } from "../config/io.js";
|
import { writeConfigFile } from "../config/io.js";
|
||||||
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
||||||
|
import type { TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js";
|
||||||
import { danger, logVerbose, warn } from "../globals.js";
|
import { danger, logVerbose, warn } from "../globals.js";
|
||||||
import { enqueueSystemEvent } from "../infra/system-events.js";
|
import { enqueueSystemEvent } from "../infra/system-events.js";
|
||||||
import { readChannelAllowFromStore } from "../pairing/pairing-store.js";
|
import { readChannelAllowFromStore } from "../pairing/pairing-store.js";
|
||||||
@@ -28,6 +26,7 @@ import {
|
|||||||
normalizeAllowFromWithStore,
|
normalizeAllowFromWithStore,
|
||||||
type NormalizedAllowFrom,
|
type NormalizedAllowFrom,
|
||||||
} from "./bot-access.js";
|
} from "./bot-access.js";
|
||||||
|
import type { TelegramMediaRef } from "./bot-message-context.js";
|
||||||
import { RegisterTelegramHandlerParams } from "./bot-native-commands.js";
|
import { RegisterTelegramHandlerParams } from "./bot-native-commands.js";
|
||||||
import { MEDIA_GROUP_TIMEOUT_MS, type MediaGroupEntry } from "./bot-updates.js";
|
import { MEDIA_GROUP_TIMEOUT_MS, type MediaGroupEntry } from "./bot-updates.js";
|
||||||
import { resolveMedia } from "./bot/delivery.js";
|
import { resolveMedia } from "./bot/delivery.js";
|
||||||
@@ -37,6 +36,7 @@ import {
|
|||||||
resolveTelegramForumThreadId,
|
resolveTelegramForumThreadId,
|
||||||
resolveTelegramGroupAllowFromContext,
|
resolveTelegramGroupAllowFromContext,
|
||||||
} from "./bot/helpers.js";
|
} from "./bot/helpers.js";
|
||||||
|
import type { TelegramContext } from "./bot/types.js";
|
||||||
import {
|
import {
|
||||||
evaluateTelegramGroupBaseAccess,
|
evaluateTelegramGroupBaseAccess,
|
||||||
evaluateTelegramGroupPolicyAccess,
|
evaluateTelegramGroupPolicyAccess,
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import type {
|
|||||||
ReactionTypeEmoji,
|
ReactionTypeEmoji,
|
||||||
} from "@grammyjs/types";
|
} from "@grammyjs/types";
|
||||||
import { type ApiClientOptions, Bot, HttpError, InputFile } from "grammy";
|
import { type ApiClientOptions, Bot, HttpError, InputFile } from "grammy";
|
||||||
import type { RetryConfig } from "../infra/retry.js";
|
|
||||||
import type { TelegramInlineButtons } from "./button-types.js";
|
|
||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
import { resolveMarkdownTableMode } from "../config/markdown-tables.js";
|
import { resolveMarkdownTableMode } from "../config/markdown-tables.js";
|
||||||
import { logVerbose } from "../globals.js";
|
import { logVerbose } from "../globals.js";
|
||||||
@@ -14,6 +12,7 @@ import { recordChannelActivity } from "../infra/channel-activity.js";
|
|||||||
import { isDiagnosticFlagEnabled } from "../infra/diagnostic-flags.js";
|
import { isDiagnosticFlagEnabled } from "../infra/diagnostic-flags.js";
|
||||||
import { formatErrorMessage, formatUncaughtError } from "../infra/errors.js";
|
import { formatErrorMessage, formatUncaughtError } from "../infra/errors.js";
|
||||||
import { createTelegramRetryRunner } from "../infra/retry-policy.js";
|
import { createTelegramRetryRunner } from "../infra/retry-policy.js";
|
||||||
|
import type { RetryConfig } from "../infra/retry.js";
|
||||||
import { redactSensitiveText } from "../logging/redact.js";
|
import { redactSensitiveText } from "../logging/redact.js";
|
||||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||||
import { mediaKindFromMime } from "../media/constants.js";
|
import { mediaKindFromMime } from "../media/constants.js";
|
||||||
@@ -23,6 +22,7 @@ import { loadWebMedia } from "../web/media.js";
|
|||||||
import { type ResolvedTelegramAccount, resolveTelegramAccount } from "./accounts.js";
|
import { type ResolvedTelegramAccount, resolveTelegramAccount } from "./accounts.js";
|
||||||
import { withTelegramApiErrorLogging } from "./api-logging.js";
|
import { withTelegramApiErrorLogging } from "./api-logging.js";
|
||||||
import { buildTelegramThreadParams } from "./bot/helpers.js";
|
import { buildTelegramThreadParams } from "./bot/helpers.js";
|
||||||
|
import type { TelegramInlineButtons } from "./button-types.js";
|
||||||
import { splitTelegramCaption } from "./caption.js";
|
import { splitTelegramCaption } from "./caption.js";
|
||||||
import { resolveTelegramFetch } from "./fetch.js";
|
import { resolveTelegramFetch } from "./fetch.js";
|
||||||
import { renderTelegramHtmlText } from "./format.js";
|
import { renderTelegramHtmlText } from "./format.js";
|
||||||
|
|||||||
Reference in New Issue
Block a user