@@ -494,6 +494,51 @@ describe("resolveTelegramInboundBody", () => {
494494 expect ( result ?. effectiveWasMentioned ) . toBe ( true ) ;
495495 } ) ;
496496
497+ it ( "ignores leading commands addressed to another bot when mentions are optional" , async ( ) => {
498+ const logger = createLogger ( ) ;
499+ const command = "/status@other_bot" ;
500+ const result = await resolveGroup ( {
501+ logger,
502+ message : {
503+ text : command ,
504+ entities : [ { type : "bot_command" , offset : 0 , length : command . length } ] ,
505+ } ,
506+ overrides : {
507+ groupConfig : { requireMention : false } as never ,
508+ requireMention : false ,
509+ } ,
510+ } ) ;
511+
512+ expect ( result ) . toBeNull ( ) ;
513+ } ) ;
514+
515+ it ( "keeps this bot's leading command when a later command targets another bot" , async ( ) => {
516+ const logger = createLogger ( ) ;
517+ const ownCommand = "/inspect@bot" ;
518+ const otherCommand = "/weather@other_bot" ;
519+ const text = `${ ownCommand } ${ otherCommand } ` ;
520+ const result = await resolveGroup ( {
521+ logger,
522+ message : {
523+ text,
524+ entities : [
525+ { type : "bot_command" , offset : 0 , length : ownCommand . length } ,
526+ {
527+ type : "bot_command" ,
528+ offset : ownCommand . length + 1 ,
529+ length : otherCommand . length ,
530+ } ,
531+ ] ,
532+ } ,
533+ overrides : {
534+ groupConfig : { requireMention : false } as never ,
535+ requireMention : false ,
536+ } ,
537+ } ) ;
538+
539+ expect ( result ?. rawBody ) . toBe ( text ) ;
540+ } ) ;
541+
497542 it ( "does not transcribe group audio for unauthorized senders" , async ( ) => {
498543 transcribeFirstAudioMock . mockReset ( ) ;
499544 const logger = createLogger ( ) ;
0 commit comments