11import type { ReactionType , ReactionTypeEmoji } from "grammy/types" ;
2- import type { RetryConfig } from "openclaw/plugin-sdk/retry-runtime" ;
32import { logVerbose } from "openclaw/plugin-sdk/runtime-env" ;
43import { formatErrorMessage } from "openclaw/plugin-sdk/ssrf-runtime" ;
54import { buildTypingThreadParams } from "./bot/helpers.js" ;
@@ -12,32 +11,21 @@ import {
1211 withTelegramApiContextLease ,
1312 type TelegramApi ,
1413 type TelegramApiContext ,
15- type TelegramApiOverride ,
1614} from "./send-context.js" ;
15+ import type {
16+ TelegramApiCallOpts ,
17+ TelegramMessageActionOpts ,
18+ TelegramSendOpts ,
19+ } from "./send-message-types.js" ;
1720import { prepareTelegramOutbound } from "./send-outbound.js" ;
18- import type { OpenClawConfig } from "./send.runtime.js" ;
1921import { parseTelegramTarget } from "./targets.js" ;
2022
21- type TelegramReactionOpts = {
22- cfg : OpenClawConfig ;
23- token ?: string ;
24- accountId ?: string ;
25- api ?: TelegramApiOverride ;
23+ type TelegramReactionOpts = TelegramApiCallOpts & {
2624 remove ?: boolean ;
27- verbose ?: boolean ;
28- retry ?: RetryConfig ;
29- gatewayClientScopes ?: readonly string [ ] ;
3025} ;
3126
32- type TelegramTypingOpts = {
33- cfg : OpenClawConfig ;
34- token ?: string ;
35- accountId ?: string ;
36- verbose ?: boolean ;
37- api ?: TelegramApiOverride ;
38- retry ?: RetryConfig ;
39- messageThreadId ?: number ;
40- } ;
27+ type TelegramTypingOpts = Omit < TelegramApiCallOpts , "gatewayClientScopes" > &
28+ Pick < TelegramSendOpts , "messageThreadId" > ;
4129
4230export async function sendTypingTelegram (
4331 to : string ,
@@ -135,21 +123,10 @@ async function reactMessageTelegramWithContext(
135123 return { ok : true } ;
136124}
137125
138- type TelegramDeleteOpts = {
139- cfg : OpenClawConfig ;
140- token ?: string ;
141- accountId ?: string ;
142- notify ?: boolean ;
143- verbose ?: boolean ;
144- api ?: TelegramApiOverride ;
145- retry ?: RetryConfig ;
146- gatewayClientScopes ?: readonly string [ ] ;
147- } ;
148-
149126export async function deleteMessageTelegram (
150127 chatIdInput : string | number ,
151128 messageIdInput : string | number ,
152- opts : TelegramDeleteOpts ,
129+ opts : TelegramMessageActionOpts ,
153130) : Promise < { ok : true } | { ok : false ; warning : string } > {
154131 const context = resolveTelegramApiContext ( opts ) ;
155132 return withTelegramApiContextLease (
@@ -161,7 +138,7 @@ export async function deleteMessageTelegram(
161138async function deleteMessageTelegramWithContext (
162139 chatIdInput : string | number ,
163140 messageIdInput : string | number ,
164- opts : TelegramDeleteOpts ,
141+ opts : TelegramMessageActionOpts ,
165142 context : TelegramApiContext ,
166143) : Promise < { ok : true } | { ok : false ; warning : string } > {
167144 const { api } = context ;
@@ -197,7 +174,7 @@ async function deleteMessageTelegramWithContext(
197174export async function pinMessageTelegram (
198175 chatIdInput : string | number ,
199176 messageIdInput : string | number ,
200- opts : TelegramDeleteOpts ,
177+ opts : TelegramMessageActionOpts ,
201178) : Promise < { ok : true ; messageId : string ; chatId : string } > {
202179 const context = resolveTelegramApiContext ( opts ) ;
203180 return withTelegramApiContextLease (
@@ -209,7 +186,7 @@ export async function pinMessageTelegram(
209186async function pinMessageTelegramWithContext (
210187 chatIdInput : string | number ,
211188 messageIdInput : string | number ,
212- opts : TelegramDeleteOpts ,
189+ opts : TelegramMessageActionOpts ,
213190 context : TelegramApiContext ,
214191) : Promise < { ok : true ; messageId : string ; chatId : string } > {
215192 const { api } = context ;
@@ -234,7 +211,7 @@ async function pinMessageTelegramWithContext(
234211export async function unpinMessageTelegram (
235212 chatIdInput : string | number ,
236213 messageIdInput : string | number | undefined ,
237- opts : TelegramDeleteOpts ,
214+ opts : TelegramMessageActionOpts ,
238215) : Promise < { ok : true ; chatId : string ; messageId ?: string } > {
239216 const context = resolveTelegramApiContext ( opts ) ;
240217 return withTelegramApiContextLease (
@@ -246,7 +223,7 @@ export async function unpinMessageTelegram(
246223async function unpinMessageTelegramWithContext (
247224 chatIdInput : string | number ,
248225 messageIdInput : string | number | undefined ,
249- opts : TelegramDeleteOpts ,
226+ opts : TelegramMessageActionOpts ,
250227 context : TelegramApiContext ,
251228) : Promise < { ok : true ; chatId : string ; messageId ?: string } > {
252229 const { api } = context ;
0 commit comments