@@ -72,6 +72,7 @@ public function answerCallbackQuery(string $text = null): void
72
72
73
73
/**
74
74
* Edit message from telegram
75
+ * (Edit message text and reply markup)
75
76
*
76
77
* @param string|null $text
77
78
* @param array $options
@@ -80,24 +81,60 @@ public function answerCallbackQuery(string $text = null): void
80
81
public function editMessageText (?string $ text = null , array $ options = []): void
81
82
{
82
83
try {
83
- $ content = array (
84
- 'chat_id ' => $ this ->telegram ->Callback_ChatID (),
85
- 'message_id ' => $ this ->telegram ->MessageID (),
86
- 'disable_web_page_preview ' => true ,
87
- 'parse_mode ' => 'HTML ' ,
88
- );
89
-
90
- if (!empty ($ text )) {
91
- $ content ['text ' ] = $ text ;
92
- }
93
-
94
- if (!empty ($ options ) && isset ($ options ['reply_markup ' ])) {
95
- $ content ['reply_markup ' ] = $ this ->telegram ->buildInlineKeyBoard ($ options ['reply_markup ' ]);
96
- }
84
+ $ content = [
85
+ 'text ' => $ text ?? $ this ->Callback_Message_Text ()
86
+ ];
87
+ $ content = array_merge ($ content , $ this ->setContentEditMessage ($ options ));
97
88
98
89
$ this ->telegram ->editMessageText ($ content );
99
90
} catch (Exception $ e ) {
100
91
error_log ($ e ->getMessage ());
101
92
}
102
93
}
94
+
95
+ /**
96
+ * Edit message reply markup from a telegram
97
+ * (Edit message reply markup only)
98
+ *
99
+ * @param array $options
100
+ * @return void
101
+ */
102
+ public function editMessageReplyMarkup (array $ options = []): void
103
+ {
104
+ try {
105
+ $ this ->telegram ->editMessageReplyMarkup ($ this ->setContentEditMessage ($ options ));
106
+ } catch (Exception $ e ) {
107
+ error_log ($ e ->getMessage ());
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Get the text from callback message
113
+ *
114
+ * @return string
115
+ */
116
+ public function Callback_Message_Text (): string
117
+ {
118
+ return $ this ->telegram ->Callback_Message ()['text ' ];
119
+ }
120
+
121
+ /**
122
+ * @param array $options
123
+ * @return array
124
+ */
125
+ public function setContentEditMessage (array $ options = []): array
126
+ {
127
+ $ content = array (
128
+ 'chat_id ' => $ this ->telegram ->Callback_ChatID (),
129
+ 'message_id ' => $ this ->telegram ->MessageID (),
130
+ 'disable_web_page_preview ' => true ,
131
+ 'parse_mode ' => 'HTML ' ,
132
+ );
133
+
134
+ if (!empty ($ options ) && isset ($ options ['reply_markup ' ])) {
135
+ $ content ['reply_markup ' ] = $ this ->telegram ->buildInlineKeyBoard ($ options ['reply_markup ' ]);
136
+ }
137
+
138
+ return $ content ;
139
+ }
103
140
}
0 commit comments