@@ -33,22 +33,16 @@ public function sendMessage(string $message = '', array $options = [], string $s
3333 'parse_mode ' => 'HTML '
3434 );
3535
36- try {
37- if ($ sendType === 'Message ' ) {
38- $ content ['text ' ] = $ message ;
39- } elseif ($ sendType === 'Photo ' && !empty ($ options )) {
40- $ content ['photo ' ] = $ options ['photo ' ];
41- $ content ['caption ' ] = $ message ;
42- }
43-
44- if (!empty ($ options ) && isset ($ options ['reply_markup ' ])) {
45- $ content ['reply_markup ' ] = $ this ->telegram ->buildInlineKeyBoard ($ options ['reply_markup ' ]);
46- }
47-
48- $ this ->telegram ->{'send ' . $ sendType }($ content );
49- } catch (Exception $ e ) {
50- error_log ($ e ->getMessage ());
36+ if ($ sendType === 'Message ' ) {
37+ $ content ['text ' ] = $ message ;
38+ } elseif ($ sendType === 'Photo ' ) {
39+ $ content ['photo ' ] = $ options ['photo ' ] ?? null ;
40+ $ content ['caption ' ] = $ message ;
5141 }
42+
43+ $ content ['reply_markup ' ] = $ options ['reply_markup ' ] ? $ this ->telegram ->buildInlineKeyBoard ($ options ['reply_markup ' ]) : null ;
44+
45+ $ this ->telegram ->{'send ' . $ sendType }($ content );
5246 }
5347
5448 /**
@@ -81,10 +75,9 @@ public function answerCallbackQuery(string $text = null): void
8175 public function editMessageText (?string $ text = null , array $ options = []): void
8276 {
8377 try {
84- $ content = [
78+ $ content = array_merge ( [
8579 'text ' => $ text ?? $ this ->Callback_Message_Text ()
86- ];
87- $ content = array_merge ($ content , $ this ->setContentEditMessage ($ options ));
80+ ], $ this ->setCallbackContentMessage ($ options ));
8881
8982 $ this ->telegram ->editMessageText ($ content );
9083 } catch (Exception $ e ) {
@@ -102,7 +95,7 @@ public function editMessageText(?string $text = null, array $options = []): void
10295 public function editMessageReplyMarkup (array $ options = []): void
10396 {
10497 try {
105- $ this ->telegram ->editMessageReplyMarkup ($ this ->setContentEditMessage ($ options ));
98+ $ this ->telegram ->editMessageReplyMarkup ($ this ->setCallbackContentMessage ($ options ));
10699 } catch (Exception $ e ) {
107100 error_log ($ e ->getMessage ());
108101 }
@@ -119,10 +112,12 @@ public function Callback_Message_Text(): string
119112 }
120113
121114 /**
115+ * Create content for a callback message
116+ *
122117 * @param array $options
123118 * @return array
124119 */
125- public function setContentEditMessage (array $ options = []): array
120+ public function setCallbackContentMessage (array $ options = []): array
126121 {
127122 $ content = array (
128123 'chat_id ' => $ this ->telegram ->Callback_ChatID (),
@@ -131,10 +126,25 @@ public function setContentEditMessage(array $options = []): array
131126 'parse_mode ' => 'HTML ' ,
132127 );
133128
134- if (!empty ($ options ) && isset ($ options ['reply_markup ' ])) {
135- $ content ['reply_markup ' ] = $ this ->telegram ->buildInlineKeyBoard ($ options ['reply_markup ' ]);
136- }
129+ $ content ['reply_markup ' ] = $ options ['reply_markup ' ] ? $ this ->telegram ->buildInlineKeyBoard ($ options ['reply_markup ' ]) : null ;
137130
138131 return $ content ;
139132 }
133+
134+ /**
135+ * Generate menu markup
136+ *
137+ * @return array[]
138+ */
139+ public function menuMarkup (): array
140+ {
141+ return [
142+ [
143+ $ this ->telegram ->buildInlineKeyBoardButton ("📰 About " , "" , "about " , "" ),
144+ $ this ->telegram ->buildInlineKeyBoardButton ("📞 Contact " , config ('author.contact ' ))
145+ ], [
146+ $ this ->telegram ->buildInlineKeyBoardButton ("💠 Source Code " , config ('author.source_code ' ))
147+ ]
148+ ];
149+ }
140150}
0 commit comments