@@ -48,6 +48,7 @@ function toTelegramButtonStyle(
4848function toTelegramInlineButton (
4949 button : MessagePresentationButton ,
5050 optionIndex : number ,
51+ options ?: { allowWebAppButtons ?: boolean } ,
5152) : TelegramInlineButton | undefined {
5253 const style = toTelegramButtonStyle ( button . style ) ;
5354 const action = resolveMessagePresentationButtonAction ( button ) ;
@@ -58,7 +59,9 @@ function toTelegramInlineButton(
5859 return { text : button . label , url : action . url , style } ;
5960 }
6061 if ( action . type === "web-app" ) {
61- return action . url ? { text : button . label , web_app : { url : action . url } , style } : undefined ;
62+ return options ?. allowWebAppButtons === true && action . url
63+ ? { text : button . label , web_app : { url : action . url } , style }
64+ : undefined ;
6265 }
6366 if ( action . type === "approval" ) {
6467 const callbackData = buildTelegramApprovalCallbackData ( action ) ;
@@ -99,12 +102,13 @@ function toTelegramInlineButton(
99102function chunkInteractiveButtons (
100103 buttons : readonly MessagePresentationButton [ ] ,
101104 rows : TelegramInlineButton [ ] [ ] ,
105+ options ?: { allowWebAppButtons ?: boolean } ,
102106) {
103107 // Index is position in the question's options; core emits one buttons block in option order.
104108 for ( let i = 0 ; i < buttons . length ; i += TELEGRAM_INTERACTIVE_ROW_SIZE ) {
105109 const row = buttons
106110 . slice ( i , i + TELEGRAM_INTERACTIVE_ROW_SIZE )
107- . map ( ( button , offset ) => toTelegramInlineButton ( button , i + offset ) )
111+ . map ( ( button , offset ) => toTelegramInlineButton ( button , i + offset , options ) )
108112 . filter ( ( button ) : button is TelegramInlineButton => Boolean ( button ) ) ;
109113 if ( row . length > 0 ) {
110114 rows . push ( row ) ;
@@ -145,14 +149,15 @@ function buildTelegramInteractiveButtons(
145149/** Convert portable presentation controls to Telegram inline keyboard rows. */
146150export function buildTelegramPresentationButtons (
147151 presentation ?: MessagePresentation ,
152+ options ?: { allowWebAppButtons ?: boolean } ,
148153) : TelegramInlineButtons | undefined {
149154 const rows : TelegramInlineButton [ ] [ ] = [ ] ;
150155 for ( const block of presentation ?. blocks ?? [ ] ) {
151156 if ( ! isMessagePresentationInteractiveBlock ( block ) ) {
152157 continue ;
153158 }
154159 if ( block . type === "buttons" ) {
155- chunkInteractiveButtons ( block . buttons , rows ) ;
160+ chunkInteractiveButtons ( block . buttons , rows , options ) ;
156161 continue ;
157162 }
158163 chunkInteractiveButtons (
0 commit comments