From 54bc8a35cd122a6f7d05ed52dd7d0a98dc26d181 Mon Sep 17 00:00:00 2001 From: Tii Date: Fri, 18 Mar 2022 09:37:15 +0100 Subject: [PATCH 1/8] #1295 Make sure setCustomBotApiUri has an effect if Telegram object was already instantiated. --- src/Request.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Request.php b/src/Request.php index de663f41..599a437a 100644 --- a/src/Request.php +++ b/src/Request.php @@ -327,6 +327,10 @@ public static function setCustomBotApiUri(string $api_base_uri, string $api_base if ($api_base_download_uri !== '') { self::$api_base_download_uri = $api_base_download_uri; } + + if (self::$telegram) { + self::initialize(self::$telegram); + } } /** From dece5d2f4adc18e12ba0b52f4ce4a3c2f8e31274 Mon Sep 17 00:00:00 2001 From: Tii Date: Sun, 20 Mar 2022 16:46:41 +0100 Subject: [PATCH 2/8] Changed to an exception so it is at least understandable why it's not working. --- src/Request.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Request.php b/src/Request.php index 599a437a..6d90b614 100644 --- a/src/Request.php +++ b/src/Request.php @@ -323,14 +323,14 @@ public static function setClient(ClientInterface $client): void */ public static function setCustomBotApiUri(string $api_base_uri, string $api_base_download_uri = ''): void { + if (self::$client) { + throw new TelegramException('setCustomBotApiUri() needs to be called before the Telegram object gets instantiated.'); + } + self::$api_base_uri = $api_base_uri; if ($api_base_download_uri !== '') { self::$api_base_download_uri = $api_base_download_uri; } - - if (self::$telegram) { - self::initialize(self::$telegram); - } } /** From d5223f18e4b4e19cfa366324ede1b9319da436a6 Mon Sep 17 00:00:00 2001 From: Mikhail Solovev Date: Tue, 28 May 2024 01:00:07 +0300 Subject: [PATCH 3/8] FastFix to Critical Error. DB.php didn't work because old deprecated methods --- src/DB.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/DB.php b/src/DB.php index 487ea7ff..9bf2c4c9 100644 --- a/src/DB.php +++ b/src/DB.php @@ -1273,15 +1273,21 @@ public static function insertMessageRequest(Message $message): bool } // Insert the forwarded message user in users table - $forward_date = $message->getForwardDate() ? self::getTimestamp($message->getForwardDate()) : null; + $forward_date = $message->getForwardDate() ? self::getTimestamp($message->getForwardOrigin()->getDate()) : null; - if ($forward_from = $message->getForwardFrom()) { - self::insertUser($forward_from); - $forward_from = $forward_from->getId(); + $forward_origin = $message->getForwardOrigin(); + if($forward_origin instanceof MessageOriginUser){ + self::insertUser($forward_origin->getUser()); + $forward_from = $forward_origin->getUser()->getId(); } - if ($forward_from_chat = $message->getForwardFromChat()) { - self::insertChat($forward_from_chat); - $forward_from_chat = $forward_from_chat->getId(); + if($forward_origin instanceof MessageOriginChat){ + self::insertChat($forward_origin->getChat()); + $forward_from_chat = $forward_origin->getChat()->getId(); + } + if($forward_origin instanceof MessageOriginChannel){ + self::insertChat($forward_origin->getChat()); + $forward_from_chat = $forward_origin->getChat()->getId(); + } $via_bot_id = null; From 73250c24be35541ce4250d921a5bfae395aa2c94 Mon Sep 17 00:00:00 2001 From: Tii Date: Tue, 28 May 2024 08:52:25 +0200 Subject: [PATCH 4/8] Fixed bugs and added missing cases --- src/DB.php | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/DB.php b/src/DB.php index 9bf2c4c9..dd10b870 100644 --- a/src/DB.php +++ b/src/DB.php @@ -21,6 +21,10 @@ use Longman\TelegramBot\Entities\ChosenInlineResult; use Longman\TelegramBot\Entities\InlineQuery; use Longman\TelegramBot\Entities\Message; +use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginChannel; +use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginChat; +use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginHiddenUser; +use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginUser; use Longman\TelegramBot\Entities\MessageReactionCountUpdated; use Longman\TelegramBot\Entities\MessageReactionUpdated; use Longman\TelegramBot\Entities\Payments\PreCheckoutQuery; @@ -1273,21 +1277,31 @@ public static function insertMessageRequest(Message $message): bool } // Insert the forwarded message user in users table - $forward_date = $message->getForwardDate() ? self::getTimestamp($message->getForwardOrigin()->getDate()) : null; - - $forward_origin = $message->getForwardOrigin(); - if($forward_origin instanceof MessageOriginUser){ - self::insertUser($forward_origin->getUser()); - $forward_from = $forward_origin->getUser()->getId(); - } - if($forward_origin instanceof MessageOriginChat){ - self::insertChat($forward_origin->getChat()); - $forward_from_chat = $forward_origin->getChat()->getId(); - } - if($forward_origin instanceof MessageOriginChannel){ - self::insertChat($forward_origin->getChat()); - $forward_from_chat = $forward_origin->getChat()->getId(); - + $forward_from = null; + $forward_from_chat = null; + $forward_from_message_id = null; + $forward_signature = null; + $forward_sender_name = null; + $forward_date = null; + + if ($forward_origin = $message->getForwardOrigin()) { + $forward_date = self::getTimestamp($forward_origin->getDate()); + + if ($forward_origin instanceof MessageOriginUser) { + self::insertUser($forward_origin->getSenderUser()); + $forward_from = $forward_origin->getSenderUser()->getId(); + } elseif ($forward_origin instanceof MessageOriginHiddenUser) { + $forward_sender_name = $forward_origin->getSenderUserName(); + } elseif ($forward_origin instanceof MessageOriginChat) { + self::insertChat($forward_origin->getChat()); + $forward_from_chat = $forward_origin->getChat()->getId(); + $forward_signature = $forward_origin->getAuthorSignature(); + } elseif ($forward_origin instanceof MessageOriginChannel) { + self::insertChat($forward_origin->getChat()); + $forward_from_chat = $forward_origin->getChat()->getId(); + $forward_from_message_id = $forward_origin->getMessageId(); + $forward_signature = $forward_origin->getAuthorSignature(); + } } $via_bot_id = null; @@ -1365,9 +1379,9 @@ public static function insertMessageRequest(Message $message): bool $sth->bindValue(':date', $date); $sth->bindValue(':forward_from', $forward_from); $sth->bindValue(':forward_from_chat', $forward_from_chat); - $sth->bindValue(':forward_from_message_id', $message->getForwardFromMessageId()); - $sth->bindValue(':forward_signature', $message->getForwardSignature()); - $sth->bindValue(':forward_sender_name', $message->getForwardSenderName()); + $sth->bindValue(':forward_from_message_id', $forward_from_message_id); + $sth->bindValue(':forward_signature', $forward_signature); + $sth->bindValue(':forward_sender_name', $forward_sender_name); $sth->bindValue(':forward_date', $forward_date); $sth->bindValue(':is_topic_message', $message->getIsTopicMessage()); From efbbd53955ce655c4ffc701b9e80e3dc96f00230 Mon Sep 17 00:00:00 2001 From: Mikhail Solovev Date: Thu, 30 May 2024 05:40:27 +0300 Subject: [PATCH 5/8] Update 0.82.0-0.83.0.sql Forgot to update schema to work with Boosts properly --- utils/db-schema-update/0.82.0-0.83.0.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/db-schema-update/0.82.0-0.83.0.sql b/utils/db-schema-update/0.82.0-0.83.0.sql index 537307c7..6b9a7eac 100644 --- a/utils/db-schema-update/0.82.0-0.83.0.sql +++ b/utils/db-schema-update/0.82.0-0.83.0.sql @@ -69,3 +69,9 @@ ALTER TABLE `message` ALTER TABLE `telegram_update` ADD COLUMN `message_reaction_id` bigint UNSIGNED DEFAULT NULL COMMENT 'A reaction to a message was changed by a user' AFTER `edited_channel_post_id`, ADD COLUMN `message_reaction_count_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Reactions to a message with anonymous reactions were changed' AFTER `message_reaction_id`; + +ALTER TABLE `telegram_update` ADD COLUMN `chat_boost_updated_id` BIGINT UNSIGNED NULL COMMENT 'A boost update the chat has been sent'; +ALTER TABLE `telegram_update` ADD FOREIGN KEY (`chat_boost_updated_id`) REFERENCES `chat_boost_updated` (`id`); + +ALTER TABLE `telegram_update` ADD COLUMN `chat_boost_removed_id` BIGINT UNSIGNED NULL COMMENT 'A boost remove from the chat has been sent'; +ALTER TABLE `telegram_update` ADD FOREIGN KEY (`chat_boost_removed_id`) REFERENCES `chat_boost_removed` (`id`); From ca9eeb1c9e51c39a33070efeba01aac105ed9aa7 Mon Sep 17 00:00:00 2001 From: Tii Date: Thu, 30 May 2024 23:01:31 +0200 Subject: [PATCH 6/8] Added missing chat_boost_updated and chat_boost_removed references to structure.sql --- structure.sql | 6 +++++- utils/db-schema-update/0.82.0-0.83.0.sql | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/structure.sql b/structure.sql index 357501ec..d36af44f 100644 --- a/structure.sql +++ b/structure.sql @@ -378,6 +378,8 @@ CREATE TABLE IF NOT EXISTS `telegram_update` ( `my_chat_member_updated_id` BIGINT UNSIGNED NULL COMMENT 'The bot''s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.', `chat_member_updated_id` BIGINT UNSIGNED NULL COMMENT 'A chat member''s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates.', `chat_join_request_id` BIGINT UNSIGNED NULL COMMENT 'A request to join the chat has been sent', + `chat_boost_updated_id` BIGINT UNSIGNED NULL COMMENT 'A chat boost was added or changed.', + `chat_boost_removed_id` BIGINT UNSIGNED NULL COMMENT 'A boost was removed from a chat.', PRIMARY KEY (`id`), KEY `message_id` (`message_id`), @@ -409,7 +411,9 @@ CREATE TABLE IF NOT EXISTS `telegram_update` ( FOREIGN KEY (`poll_answer_poll_id`) REFERENCES `poll_answer` (`poll_id`), FOREIGN KEY (`my_chat_member_updated_id`) REFERENCES `chat_member_updated` (`id`), FOREIGN KEY (`chat_member_updated_id`) REFERENCES `chat_member_updated` (`id`), - FOREIGN KEY (`chat_join_request_id`) REFERENCES `chat_join_request` (`id`) + FOREIGN KEY (`chat_join_request_id`) REFERENCES `chat_join_request` (`id`), + FOREIGN KEY (`chat_boost_updated_id`) REFERENCES `chat_boost_updated` (`id`), + FOREIGN KEY (`chat_boost_removed_id`) REFERENCES `chat_boost_removed` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `conversation` ( diff --git a/utils/db-schema-update/0.82.0-0.83.0.sql b/utils/db-schema-update/0.82.0-0.83.0.sql index 6b9a7eac..72f35053 100644 --- a/utils/db-schema-update/0.82.0-0.83.0.sql +++ b/utils/db-schema-update/0.82.0-0.83.0.sql @@ -70,8 +70,8 @@ ALTER TABLE `telegram_update` ADD COLUMN `message_reaction_id` bigint UNSIGNED DEFAULT NULL COMMENT 'A reaction to a message was changed by a user' AFTER `edited_channel_post_id`, ADD COLUMN `message_reaction_count_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Reactions to a message with anonymous reactions were changed' AFTER `message_reaction_id`; -ALTER TABLE `telegram_update` ADD COLUMN `chat_boost_updated_id` BIGINT UNSIGNED NULL COMMENT 'A boost update the chat has been sent'; +ALTER TABLE `telegram_update` ADD COLUMN `chat_boost_updated_id` BIGINT UNSIGNED NULL COMMENT 'A chat boost was added or changed.'; ALTER TABLE `telegram_update` ADD FOREIGN KEY (`chat_boost_updated_id`) REFERENCES `chat_boost_updated` (`id`); -ALTER TABLE `telegram_update` ADD COLUMN `chat_boost_removed_id` BIGINT UNSIGNED NULL COMMENT 'A boost remove from the chat has been sent'; +ALTER TABLE `telegram_update` ADD COLUMN `chat_boost_removed_id` BIGINT UNSIGNED NULL COMMENT 'A boost was removed from a chat.'; ALTER TABLE `telegram_update` ADD FOREIGN KEY (`chat_boost_removed_id`) REFERENCES `chat_boost_removed` (`id`); From 5ff8c3dd5da361cbe1482116baf9d865c9bee87c Mon Sep 17 00:00:00 2001 From: Hitmare Date: Thu, 20 Mar 2025 16:47:18 +0100 Subject: [PATCH 7/8] Update README.md Update Readme to notify Users that the development of the project is currently stopped --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0a227de7..0cc4d245 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ + +

TThe development of the project is currently on hold until further notice. We will provide updates as soon as they become available.

PHP Telegram Bot

From 96bf360dbe65db72c5996f34a72e8af9a0ce1f43 Mon Sep 17 00:00:00 2001 From: Tii Date: Thu, 20 Mar 2025 17:07:18 +0100 Subject: [PATCH 8/8] README.md aktualisieren --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cc4d245..4301dc4a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -

TThe development of the project is currently on hold until further notice. We will provide updates as soon as they become available.

+

The development of the project is currently on hold until further notice. We will provide updates as soon as they become available.

PHP Telegram Bot