@@ -45,6 +45,8 @@ export default class TelegramExecutionContext {
4545 return 'callback' ;
4646 } else if ( this . update . business_message ) {
4747 return 'business_message' ;
48+ } else if ( this . update . guest_message ) {
49+ return 'guest_message' ;
4850 }
4951 return '' ;
5052 }
@@ -58,6 +60,8 @@ export default class TelegramExecutionContext {
5860 return this . update . message . chat . id . toString ( ) ;
5961 } else if ( this . update . business_message ?. chat . id ) {
6062 return this . update . business_message . chat . id . toString ( ) ;
63+ } else if ( this . update . guest_message ?. chat . id ) {
64+ return this . update . guest_message . chat . id . toString ( ) ;
6165 }
6266 return '' ;
6367 }
@@ -67,7 +71,12 @@ export default class TelegramExecutionContext {
6771 * @returns The message ID as a string or empty string if not available
6872 */
6973 private getMessageId ( ) : string {
70- return this . update . message ?. message_id . toString ( ) ?? '' ;
74+ if ( this . update . message ?. message_id ) {
75+ return this . update . message . message_id . toString ( ) ;
76+ } else if ( this . update . guest_message ?. message_id ) {
77+ return this . update . guest_message . message_id . toString ( ) ;
78+ }
79+ return '' ;
7180 }
7281
7382 /**
@@ -79,6 +88,7 @@ export default class TelegramExecutionContext {
7988 async replyVideo ( video : string , options : Record < string , number | string | boolean > = { } ) {
8089 switch ( this . update_type ) {
8190 case 'message' :
91+ case 'guest_message' :
8292 return await this . api . sendVideo ( this . bot . api . toString ( ) , {
8393 ...options ,
8494 chat_id : this . getChatId ( ) ,
@@ -117,6 +127,7 @@ export default class TelegramExecutionContext {
117127 switch ( this . update_type ) {
118128 case 'photo' :
119129 case 'message' :
130+ case 'guest_message' :
120131 return await this . api . sendPhoto ( this . bot . api . toString ( ) , {
121132 ...options ,
122133 chat_id : this . getChatId ( ) ,
@@ -144,6 +155,7 @@ export default class TelegramExecutionContext {
144155 case 'message' :
145156 case 'photo' :
146157 case 'document' :
158+ case 'guest_message' :
147159 return await this . api . sendChatAction ( this . bot . api . toString ( ) , {
148160 chat_id : this . getChatId ( ) ,
149161 action : 'typing' ,
@@ -176,6 +188,19 @@ export default class TelegramExecutionContext {
176188 return null ;
177189 }
178190
191+ /**
192+ * Answer a guest query
193+ * @param message - text to reply with
194+ * @param parse_mode - one of HTML, MarkdownV2, Markdown, or an empty string for ascii
195+ * @returns Promise with the API response
196+ */
197+ async answerGuestQuery ( message : string , parse_mode = '' ) {
198+ return await this . api . answerGuestQuery ( this . bot . api . toString ( ) , {
199+ guest_query_id : this . update . guest_message ?. guest_query_id ?? '' ,
200+ result : new TelegramInlineQueryResultArticle ( { content : message , title : 'Response' , parse_mode } ) ,
201+ } ) ;
202+ }
203+
179204
180205 /**
181206 * Reply to the last message with a stream of text
@@ -206,6 +231,10 @@ export default class TelegramExecutionContext {
206231 case 'message' :
207232 case 'photo' :
208233 case 'document' :
234+ case 'guest_message' :
235+ if ( this . update_type === 'guest_message' ) {
236+ return await this . answerGuestQuery ( message , parse_mode ) ;
237+ }
209238 if ( reply ) {
210239 return await this . api . sendMessage ( this . bot . api . toString ( ) , {
211240 ...options ,
0 commit comments