@@ -56,6 +56,7 @@ type TelegramQaScenarioRun = {
5656 input : string ;
5757 expectedTextIncludes ?: string [ ] ;
5858 matchText ?: string ;
59+ replyToLatestSutMessage ?: boolean ;
5960} ;
6061
6162type TelegramQaScenarioDefinition = LiveTransportScenarioDefinition < TelegramQaScenarioId > & {
@@ -276,6 +277,7 @@ const TELEGRAM_QA_SCENARIOS: TelegramQaScenarioDefinition[] = [
276277 allowAnySutReply : true ,
277278 expectReply : true ,
278279 input : `@${ sutUsername } Telegram QA mention routing check. Reply with a short acknowledgement.` ,
280+ replyToLatestSutMessage : true ,
279281 } ) ,
280282 } ,
281283 {
@@ -613,11 +615,24 @@ async function flushTelegramUpdates(token: string) {
613615 throw new Error ( "timed out after 15000ms draining Telegram updates" ) ;
614616}
615617
616- async function sendGroupMessage ( token : string , groupId : string , text : string ) {
618+ async function sendGroupMessage (
619+ token : string ,
620+ groupId : string ,
621+ text : string ,
622+ opts : { replyToMessageId ?: number } = { } ,
623+ ) {
617624 return await callTelegramApi < TelegramSendMessageResult > ( token , "sendMessage" , {
618625 chat_id : groupId ,
619626 text,
620627 disable_notification : true ,
628+ ...( opts . replyToMessageId !== undefined
629+ ? {
630+ reply_parameters : {
631+ message_id : opts . replyToMessageId ,
632+ allow_sending_without_reply : true ,
633+ } ,
634+ }
635+ : { } ) ,
621636 } ) ;
622637}
623638
@@ -1228,6 +1243,7 @@ export async function runTelegramQaLive(params: {
12281243 try {
12291244 await waitForTelegramChannelRunning ( gatewayHarness . gateway , sutAccountId ) ;
12301245 assertLeaseHealthy ( ) ;
1246+ let latestSutMessageId : number | undefined ;
12311247 try {
12321248 writeTelegramQaProgress ( progressEnabled , "canary start" ) ;
12331249 const canaryTiming = await runCanary ( {
@@ -1238,6 +1254,7 @@ export async function runTelegramQaLive(params: {
12381254 timeoutMs : resolveTelegramQaCanaryTimeoutMs ( ) ,
12391255 observedMessages,
12401256 } ) ;
1257+ latestSutMessageId = canaryTiming . responseMessageId ;
12411258 scenarioResults . push ( {
12421259 id : "telegram-canary" ,
12431260 title : "Telegram canary" ,
@@ -1291,6 +1308,9 @@ export async function runTelegramQaLive(params: {
12911308 runtimeEnv . driverToken ,
12921309 runtimeEnv . groupId ,
12931310 scenarioRun . input ,
1311+ scenarioRun . replyToLatestSutMessage
1312+ ? { replyToMessageId : latestSutMessageId }
1313+ : undefined ,
12941314 ) ;
12951315 const requestStartedAt = new Date ( requestStartedAtMs ) . toISOString ( ) ;
12961316 const matched = await waitForObservedMessage ( {
@@ -1333,6 +1353,7 @@ export async function runTelegramQaLive(params: {
13331353 responseMessageId : redactPublicMetadata ? undefined : matched . message . messageId ,
13341354 } satisfies TelegramQaScenarioResult ;
13351355 scenarioResults . push ( result ) ;
1356+ latestSutMessageId = matched . message . messageId ;
13361357 writeTelegramQaProgress (
13371358 progressEnabled ,
13381359 `scenario pass ${ scenarioIndexLabel } : ${ scenarioIdForLog } ` ,
0 commit comments