1414
1515use  Longman \TelegramBot \Entities \CallbackQuery ;
1616use  Longman \TelegramBot \Entities \Chat ;
17+ use  Longman \TelegramBot \Entities \ChatBoostRemoved ;
18+ use  Longman \TelegramBot \Entities \ChatBoostUpdated ;
1719use  Longman \TelegramBot \Entities \ChatJoinRequest ;
1820use  Longman \TelegramBot \Entities \ChatMemberUpdated ;
1921use  Longman \TelegramBot \Entities \ChosenInlineResult ;
@@ -149,6 +151,8 @@ protected static function defineTables(): void
149151        $ tables  = [
150152            'callback_query ' ,
151153            'chat ' ,
154+             'chat_boost_updated ' ,
155+             'chat_boost_removed ' ,
152156            'chat_join_request ' ,
153157            'chat_member_updated ' ,
154158            'chosen_inline_result ' ,
@@ -340,10 +344,12 @@ protected static function insertTelegramUpdate(
340344        ?string  $ poll_answer_poll_id  = null ,
341345        ?string  $ my_chat_member_updated_id  = null ,
342346        ?string  $ chat_member_updated_id  = null ,
343-         ?string  $ chat_join_request_id  = null 
347+         ?string  $ chat_join_request_id  = null ,
348+         ?string  $ chat_boost_updated_id  = null ,
349+         ?string  $ chat_boost_removed_id  = null 
344350    ): ?bool  {
345-         if  ($ message_id  === null  && $ edited_message_id  === null  && $ channel_post_id  === null  && $ edited_channel_post_id  === null  && $ message_reaction_id  === null  && $ message_reaction_count_id  === null  && $ inline_query_id  === null  && $ chosen_inline_result_id  === null  && $ callback_query_id  === null  && $ shipping_query_id  === null  && $ pre_checkout_query_id  === null  && $ poll_id  === null  && $ poll_answer_poll_id  === null  && $ my_chat_member_updated_id  === null  && $ chat_member_updated_id  === null  && $ chat_join_request_id  === null ) {
346-             throw  new  TelegramException ('message_id, edited_message_id, channel_post_id, edited_channel_post_id, message_reaction_id, message_reaction_count_id, inline_query_id, chosen_inline_result_id, callback_query_id, shipping_query_id, pre_checkout_query_id, poll_id, poll_answer_poll_id, my_chat_member_updated_id, chat_member_updated_id are all null ' );
351+         if  ($ message_id  === null  && $ edited_message_id  === null  && $ channel_post_id  === null  && $ edited_channel_post_id  === null  && $ message_reaction_id  === null  && $ message_reaction_count_id  === null  && $ inline_query_id  === null  && $ chosen_inline_result_id  === null  && $ callback_query_id  === null  && $ shipping_query_id  === null  && $ pre_checkout_query_id  === null  && $ poll_id  === null  && $ poll_answer_poll_id  === null  && $ my_chat_member_updated_id  === null  && $ chat_member_updated_id  === null  && $ chat_join_request_id  === null  &&  $ chat_boost_updated_id  ===  null  &&  $ chat_boost_removed_id  ===  null ) {
352+             throw  new  TelegramException ('message_id, edited_message_id, channel_post_id, edited_channel_post_id, message_reaction_id, message_reaction_count_id, inline_query_id, chosen_inline_result_id, callback_query_id, shipping_query_id, pre_checkout_query_id, poll_id, poll_answer_poll_id, my_chat_member_updated_id, chat_member_updated_id, chat_join_request_id, chat_boost_updated_id, chat_boost_removed_id  are all null ' );
347353        }
348354
349355        if  (!self ::isDbConnected ()) {
@@ -359,14 +365,14 @@ protected static function insertTelegramUpdate(
359365                    `inline_query_id`, `chosen_inline_result_id`, 
360366                    `callback_query_id`, `shipping_query_id`, `pre_checkout_query_id`, 
361367                    `poll_id`, `poll_answer_poll_id`, `my_chat_member_updated_id`, `chat_member_updated_id`, 
362-                     `chat_join_request_id` 
368+                     `chat_join_request_id`, `chat_boost_updated_id`, `chat_boost_removed_id`  
363369                ) VALUES ( 
364370                    :id, :chat_id, :message_id, :edited_message_id, 
365371                    :channel_post_id, :edited_channel_post_id, :message_reaction_id, :message_reaction_count_id, 
366372                    :inline_query_id, :chosen_inline_result_id, 
367373                    :callback_query_id, :shipping_query_id, :pre_checkout_query_id, 
368374                    :poll_id, :poll_answer_poll_id, :my_chat_member_updated_id, :chat_member_updated_id, 
369-                     :chat_join_request_id 
375+                     :chat_join_request_id, :chat_boost_updated_id, :chat_boost_removed_id  
370376                ) 
371377             ' );
372378
@@ -388,6 +394,8 @@ protected static function insertTelegramUpdate(
388394            $ sth ->bindValue (':my_chat_member_updated_id ' , $ my_chat_member_updated_id );
389395            $ sth ->bindValue (':chat_member_updated_id ' , $ chat_member_updated_id );
390396            $ sth ->bindValue (':chat_join_request_id ' , $ chat_join_request_id );
397+             $ sth ->bindValue (':chat_boost_updated_id ' , $ chat_boost_updated_id );
398+             $ sth ->bindValue (':chat_boost_removed_id ' , $ chat_boost_removed_id );
391399
392400            return  $ sth ->execute ();
393401        } catch  (PDOException   $ e ) {
@@ -561,6 +569,8 @@ public static function insertRequest(Update $update): bool
561569        $ my_chat_member_updated_id  = null ;
562570        $ chat_member_updated_id     = null ;
563571        $ chat_join_request_id       = null ;
572+         $ chat_boost_updated_id      = null ;
573+         $ chat_boost_removed_id      = null ;
564574
565575        if  (($ message  = $ update ->getMessage ()) && self ::insertMessageRequest ($ message )) {
566576            $ chat_id     = $ message ->getChat ()->getId ();
@@ -602,6 +612,10 @@ public static function insertRequest(Update $update): bool
602612            $ chat_member_updated_id  = self ::$ pdo ->lastInsertId ();
603613        } elseif  (($ chat_join_request  = $ update ->getChatJoinRequest ()) && self ::insertChatJoinRequestRequest ($ chat_join_request )) {
604614            $ chat_join_request_id  = self ::$ pdo ->lastInsertId ();
615+         } elseif  (($ chat_boost_updated  = $ update ->getChatBoost ()) && self ::insertChatBoostUpdatedRequest ($ chat_boost_updated )) {
616+             $ chat_boost_updated_id  = self ::$ pdo ->lastInsertId ();
617+         } elseif  (($ chat_boost_removed  = $ update ->getRemovedChatBoost ()) && self ::insertChatBoostRemovedRequest ($ chat_boost_removed )) {
618+             $ chat_boost_removed_id  = self ::$ pdo ->lastInsertId ();
605619        } else  {
606620            return  false ;
607621        }
@@ -624,7 +638,9 @@ public static function insertRequest(Update $update): bool
624638            $ poll_answer_poll_id ,
625639            $ my_chat_member_updated_id ,
626640            $ chat_member_updated_id ,
627-             $ chat_join_request_id
641+             $ chat_join_request_id ,
642+             $ chat_boost_updated_id ,
643+             $ chat_boost_removed_id
628644        );
629645    }
630646
@@ -1143,6 +1159,88 @@ public static function insertChatJoinRequestRequest(ChatJoinRequest $chat_join_r
11431159        }
11441160    }
11451161
1162+     /** 
1163+      * Insert chat boost updated into database 
1164+      * 
1165+      * @param ChatBoostUpdated $chat_boost_updated 
1166+      * 
1167+      * @return bool If the insert was successful 
1168+      * @throws TelegramException 
1169+      */ 
1170+     public  static  function  insertChatBoostUpdatedRequest (ChatBoostUpdated   $ chat_boost_updated ): bool 
1171+     {
1172+         if  (!self ::isDbConnected ()) {
1173+             return  false ;
1174+         }
1175+ 
1176+         try  {
1177+             $ sth  = self ::$ pdo ->prepare (' 
1178+                 INSERT INTO ` '  . TB_CHAT_BOOST_UPDATED  . '`  
1179+                 (`chat_id`, `boost`, `created_at`) 
1180+                 VALUES 
1181+                 (:chat_id, :boost, :created_at) 
1182+              ' );
1183+ 
1184+             $ date     = self ::getTimestamp ();
1185+             $ chat_id  = null ;
1186+ 
1187+             if  ($ chat  = $ chat_boost_updated ->getChat ()) {
1188+                 $ chat_id  = $ chat ->getId ();
1189+                 self ::insertChat ($ chat , $ date );
1190+             }
1191+ 
1192+             $ sth ->bindValue (':chat_id ' , $ chat_id );
1193+             $ sth ->bindValue (':boost ' , $ chat_boost_updated ->getBoost ());
1194+             $ sth ->bindValue (':created_at ' , $ date );
1195+ 
1196+             return  $ sth ->execute ();
1197+         } catch  (PDOException   $ e ) {
1198+             throw  new  TelegramException ($ e ->getMessage ());
1199+         }
1200+     }
1201+ 
1202+     /** 
1203+      * Insert chat boost removed into database 
1204+      * 
1205+      * @param ChatBoostRemoved $chat_boost_removed 
1206+      * 
1207+      * @return bool If the insert was successful 
1208+      * @throws TelegramException 
1209+      */ 
1210+     public  static  function  insertChatBoostRemovedRequest (ChatBoostRemoved   $ chat_boost_removed ): bool 
1211+     {
1212+         if  (!self ::isDbConnected ()) {
1213+             return  false ;
1214+         }
1215+ 
1216+         try  {
1217+             $ sth  = self ::$ pdo ->prepare (' 
1218+                 INSERT INTO ` '  . TB_CHAT_BOOST_REMOVED  . '`  
1219+                 (`chat_id`, `boost_id`, `remove_date`, `source`, `created_at`) 
1220+                 VALUES 
1221+                 (:chat_id, :boost_id, :remove_date, :source, :created_at) 
1222+              ' );
1223+ 
1224+             $ date     = self ::getTimestamp ();
1225+             $ chat_id  = null ;
1226+ 
1227+             if  ($ chat  = $ chat_boost_removed ->getChat ()) {
1228+                 $ chat_id  = $ chat ->getId ();
1229+                 self ::insertChat ($ chat , $ date );
1230+             }
1231+ 
1232+             $ sth ->bindValue (':chat_id ' , $ chat_id );
1233+             $ sth ->bindValue (':boost_id ' , $ chat_boost_removed ->getBoostId ());
1234+             $ sth ->bindValue (':remove_date ' , self ::getTimestamp ($ chat_boost_removed ->getRemoveDate ()));
1235+             $ sth ->bindValue (':source ' , $ chat_boost_removed ->getSource ());
1236+             $ sth ->bindValue (':created_at ' , $ date );
1237+ 
1238+             return  $ sth ->execute ();
1239+         } catch  (PDOException   $ e ) {
1240+             throw  new  TelegramException ($ e ->getMessage ());
1241+         }
1242+     }
1243+ 
11461244    /** 
11471245     * Insert Message request in db 
11481246     * 
0 commit comments