Telegram: remove @ts-nocheck from bot-message.ts (#9180)
* Telegram: remove @ts-nocheck from bot-message.ts, type deps via Omit<BuildTelegramMessageContextParams> * Telegram: widen allMedia to TelegramMediaRef[] so stickerMetadata flows through * Telegram: remove @ts-nocheck from bot-message.ts (#9180)main
parent
4434cae565
commit
90b4e54354
|
|
@ -6,6 +6,7 @@ Docs: https://docs.openclaw.ai
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
- Telegram: remove `@ts-nocheck` from `bot-message.ts`, type deps via `Omit<BuildTelegramMessageContextParams>`, widen `allMedia` to `TelegramMediaRef[]`. (#9180)
|
||||||
- Telegram: remove `@ts-nocheck` from `bot.ts`, fix duplicate `bot.catch` error handler (Grammy overrides), remove dead reaction `message_thread_id` routing, harden sticker cache guard. (#9077)
|
- Telegram: remove `@ts-nocheck` from `bot.ts`, fix duplicate `bot.catch` error handler (Grammy overrides), remove dead reaction `message_thread_id` routing, harden sticker cache guard. (#9077)
|
||||||
- Onboarding: add Cloudflare AI Gateway provider setup and docs. (#7914) Thanks @roerohan.
|
- Onboarding: add Cloudflare AI Gateway provider setup and docs. (#7914) Thanks @roerohan.
|
||||||
- Onboarding: add Moonshot (.cn) auth choice and keep the China base URL when preserving defaults. (#7180) Thanks @waynelwz.
|
- Onboarding: add Moonshot (.cn) auth choice and keep the China base URL when preserving defaults. (#7180) Thanks @waynelwz.
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ import {
|
||||||
resolveTelegramThreadSpec,
|
resolveTelegramThreadSpec,
|
||||||
} from "./bot/helpers.js";
|
} from "./bot/helpers.js";
|
||||||
|
|
||||||
type TelegramMediaRef = {
|
export type TelegramMediaRef = {
|
||||||
path: string;
|
path: string;
|
||||||
contentType?: string;
|
contentType?: string;
|
||||||
stickerMetadata?: {
|
stickerMetadata?: {
|
||||||
|
|
@ -89,7 +89,7 @@ type ResolveGroupActivation = (params: {
|
||||||
|
|
||||||
type ResolveGroupRequireMention = (chatId: string | number) => boolean;
|
type ResolveGroupRequireMention = (chatId: string | number) => boolean;
|
||||||
|
|
||||||
type BuildTelegramMessageContextParams = {
|
export type BuildTelegramMessageContextParams = {
|
||||||
primaryCtx: TelegramContext;
|
primaryCtx: TelegramContext;
|
||||||
allMedia: TelegramMediaRef[];
|
allMedia: TelegramMediaRef[];
|
||||||
storeAllowFrom: string[];
|
storeAllowFrom: string[];
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,30 @@
|
||||||
// @ts-nocheck
|
import type { ReplyToMode } from "../config/config.js";
|
||||||
import { buildTelegramMessageContext } from "./bot-message-context.js";
|
import type { TelegramAccountConfig } from "../config/types.telegram.js";
|
||||||
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
|
import type { TelegramBotOptions } from "./bot.js";
|
||||||
|
import type { TelegramContext, TelegramStreamMode } from "./bot/types.js";
|
||||||
|
import {
|
||||||
|
buildTelegramMessageContext,
|
||||||
|
type BuildTelegramMessageContextParams,
|
||||||
|
type TelegramMediaRef,
|
||||||
|
} from "./bot-message-context.js";
|
||||||
import { dispatchTelegramMessage } from "./bot-message-dispatch.js";
|
import { dispatchTelegramMessage } from "./bot-message-dispatch.js";
|
||||||
|
|
||||||
export const createTelegramMessageProcessor = (deps) => {
|
/** Dependencies injected once when creating the message processor. */
|
||||||
|
type TelegramMessageProcessorDeps = Omit<
|
||||||
|
BuildTelegramMessageContextParams,
|
||||||
|
"primaryCtx" | "allMedia" | "storeAllowFrom" | "options"
|
||||||
|
> & {
|
||||||
|
telegramCfg: TelegramAccountConfig;
|
||||||
|
runtime: RuntimeEnv;
|
||||||
|
replyToMode: ReplyToMode;
|
||||||
|
streamMode: TelegramStreamMode;
|
||||||
|
textLimit: number;
|
||||||
|
opts: Pick<TelegramBotOptions, "token">;
|
||||||
|
resolveBotTopicsEnabled: (ctx: TelegramContext) => boolean | Promise<boolean>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createTelegramMessageProcessor = (deps: TelegramMessageProcessorDeps) => {
|
||||||
const {
|
const {
|
||||||
bot,
|
bot,
|
||||||
cfg,
|
cfg,
|
||||||
|
|
@ -26,7 +48,12 @@ export const createTelegramMessageProcessor = (deps) => {
|
||||||
resolveBotTopicsEnabled,
|
resolveBotTopicsEnabled,
|
||||||
} = deps;
|
} = deps;
|
||||||
|
|
||||||
return async (primaryCtx, allMedia, storeAllowFrom, options) => {
|
return async (
|
||||||
|
primaryCtx: TelegramContext,
|
||||||
|
allMedia: TelegramMediaRef[],
|
||||||
|
storeAllowFrom: string[],
|
||||||
|
options?: { messageIdOverride?: string; forceWasMentioned?: boolean },
|
||||||
|
) => {
|
||||||
const context = await buildTelegramMessageContext({
|
const context = await buildTelegramMessageContext({
|
||||||
primaryCtx,
|
primaryCtx,
|
||||||
allMedia,
|
allMedia,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue