Telegram: use Grammy types directly, add typed Probe/Audit to plugin interface (#8403)

* Telegram: replace duplicated types with Grammy imports, add Probe/Audit generics to plugin interface

* Telegram: remove legacy forward metadata (deprecated in Bot API 7.0), simplify required-field checks

* Telegram: clean up remaining legacy references and unnecessary casts

* Telegram: keep RequestInit parameter type in proxy fetch (addresses review feedback)

* Telegram: add exhaustiveness guard to resolveForwardOrigin switch
This commit is contained in:
Christian Klotz
2026-02-04 10:09:28 +00:00
committed by GitHub
parent 6341819d74
commit da6de49815
12 changed files with 110 additions and 270 deletions

View File

@@ -1,6 +1,6 @@
import type { TelegramMessage } from "./bot/types.js";
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
// @ts-nocheck
import type { Message } from "@grammyjs/types";
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
import { hasControlCommand } from "../auto-reply/command-detection.js";
import {
createInboundDebouncer,
@@ -63,7 +63,7 @@ export const registerTelegramHandlers = ({
type TextFragmentEntry = {
key: string;
messages: Array<{ msg: TelegramMessage; ctx: unknown; receivedAtMs: number }>;
messages: Array<{ msg: Message; ctx: unknown; receivedAtMs: number }>;
timer: ReturnType<typeof setTimeout>;
};
const textFragmentBuffer = new Map<string, TextFragmentEntry>();
@@ -72,7 +72,7 @@ export const registerTelegramHandlers = ({
const debounceMs = resolveInboundDebounceMs({ cfg, channel: "telegram" });
type TelegramDebounceEntry = {
ctx: unknown;
msg: TelegramMessage;
msg: Message;
allMedia: Array<{ path: string; contentType?: string }>;
storeAllowFrom: string[];
debounceKey: string | null;
@@ -111,7 +111,7 @@ export const registerTelegramHandlers = ({
const baseCtx = first.ctx as { me?: unknown; getFile?: unknown } & Record<string, unknown>;
const getFile =
typeof baseCtx.getFile === "function" ? baseCtx.getFile.bind(baseCtx) : async () => ({});
const syntheticMessage: TelegramMessage = {
const syntheticMessage: Message = {
...first.msg,
text: combinedText,
caption: undefined,
@@ -231,7 +231,7 @@ export const registerTelegramHandlers = ({
return;
}
const syntheticMessage: TelegramMessage = {
const syntheticMessage: Message = {
...first.msg,
text: combinedText,
caption: undefined,
@@ -557,7 +557,7 @@ export const registerTelegramHandlers = ({
if (modelCallback.type === "select") {
const { provider, model } = modelCallback;
// Process model selection as a synthetic message with /model command
const syntheticMessage: TelegramMessage = {
const syntheticMessage: Message = {
...callbackMessage,
from: callback.from,
text: `/model ${provider}/${model}`,
@@ -582,7 +582,7 @@ export const registerTelegramHandlers = ({
return;
}
const syntheticMessage: TelegramMessage = {
const syntheticMessage: Message = {
...callbackMessage,
from: callback.from,
text: data,