Skip to content

Commit 63c0ee3

Browse files
committed
Fix up initial code for the Bot API 5.1 implementation
1 parent ccb32d7 commit 63c0ee3

10 files changed

+124
-81
lines changed

src/Entities/ChatInviteLink.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ChatInviteLink extends Entity
3333
protected function subEntities(): array
3434
{
3535
return [
36-
'creator' => User::class
36+
'creator' => User::class,
3737
];
3838
}
3939
}

src/Entities/ChatMemberUpdated.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @link https://core.telegram.org/bots/api#chatmemberupdated
2020
*
2121
* @method Chat getChat() Chat the user belongs to
22-
* @method User getUser() Performer of the action, which resulted in the change
22+
* @method User getFrom() Performer of the action, which resulted in the change
2323
* @method int getDate() Date the change was done in Unix time
2424
* @method ChatMember getOldChatMember() Previous information about the chat member
2525
* @method ChatMember getNewChatMember() New information about the chat member
@@ -33,11 +33,11 @@ class ChatMemberUpdated extends Entity
3333
protected function subEntities(): array
3434
{
3535
return [
36-
'chat' => Chat::class,
37-
'from' => User::class,
38-
'old_chat_member' => ChatMember::class,
39-
'new_chat_member' => ChatMember::class,
40-
'invite_link' => ChatInviteLink::class,
36+
'chat' => Chat::class,
37+
'from' => User::class,
38+
'old_chat_member' => ChatMember::class,
39+
'new_chat_member' => ChatMember::class,
40+
'invite_link' => ChatInviteLink::class,
4141
];
4242
}
4343
}

src/Entities/Message.php

Lines changed: 59 additions & 55 deletions
Large diffs are not rendered by default.

src/Entities/MessageAutoDeleteTimerChanged.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
*/
2323
class MessageAutoDeleteTimerChanged extends Entity
2424
{
25+
2526
}

src/Entities/Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getUpdateType(): ?string
7878
/**
7979
* Get update content
8080
*
81-
* @return CallbackQuery|ChosenInlineResult|InlineQuery|Message
81+
* @return CallbackQuery|ChatMemberUpdated|ChosenInlineResult|InlineQuery|Message|PollAnswer|Poll|PreCheckoutQuery|ShippingQuery
8282
*/
8383
public function getUpdateContent()
8484
{

src/Entities/VoiceChatEnded.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
*/
2323
class VoiceChatEnded extends Entity
2424
{
25+
2526
}

src/Entities/VoiceChatParticipantsInvited.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class VoiceChatParticipantsInvited extends Entity
2828
protected function subEntities(): array
2929
{
3030
return [
31-
'users' => [User::class],
31+
'users' => [User::class],
3232
];
3333
}
3434
}

src/Entities/VoiceChatStarted.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
*/
2121
class VoiceChatStarted extends Entity
2222
{
23+
2324
}

structure.sql

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ CREATE TABLE IF NOT EXISTS `user_chat` (
3838
FOREIGN KEY (`chat_id`) REFERENCES `chat` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
3939
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
4040

41+
CREATE TABLE IF NOT EXISTS `chat_invite_link` (
42+
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry',
43+
`invite_link` VARCHAR(2083) CHARACTER SET 'ascii' COLLATE 'ascii_general_ci' NOT NULL COMMENT 'The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”',
44+
# IE7 has a 2083 character limit for HTTP GET operations: http://support.microsoft.com/kb/208427
45+
`creator_id` BIGINT NOT NULL COMMENT 'Creator of the link',
46+
`is_primary` BOOLEAN NOT NULL COMMENT 'True, if the link is primary',
47+
`is_revoked` BOOLEAN NOT NULL COMMENT 'True, if the link is revoked',
48+
`expire_date` TIMESTAMP NULL COMMENT 'Point in time (Unix TIMESTAMP) when the link will expire or has been expired',
49+
`member_limit` MEDIUMINT UNSIGNED NULL COMMENT 'Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999',
50+
51+
PRIMARY KEY (`id`),
52+
53+
FOREIGN KEY (`creator_id`) REFERENCES `user` (`id`)
54+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
55+
4156
CREATE TABLE IF NOT EXISTS `inline_query` (
4257
`id` bigint UNSIGNED COMMENT 'Unique identifier for this query',
4358
`user_id` bigint NULL COMMENT 'Unique user identifier',
@@ -111,6 +126,7 @@ CREATE TABLE IF NOT EXISTS `message` (
111126
`group_chat_created` tinyint(1) DEFAULT 0 COMMENT 'Informs that the group has been created',
112127
`supergroup_chat_created` tinyint(1) DEFAULT 0 COMMENT 'Informs that the supergroup has been created',
113128
`channel_chat_created` tinyint(1) DEFAULT 0 COMMENT 'Informs that the channel chat has been created',
129+
`message_auto_delete_timer_changed` TEXT COMMENT 'MessageAutoDeleteTimerChanged object. Message is a service message: auto-delete timer settings changed in the chat',
114130
`migrate_to_chat_id` bigint NULL DEFAULT NULL COMMENT 'Migrate to chat identifier. The group has been migrated to a supergroup with the specified identifier',
115131
`migrate_from_chat_id` bigint NULL DEFAULT NULL COMMENT 'Migrate from chat identifier. The supergroup has been migrated from a group with the specified identifier',
116132
`pinned_message` TEXT NULL COMMENT 'Message object. Specified message was pinned',
@@ -119,6 +135,9 @@ CREATE TABLE IF NOT EXISTS `message` (
119135
`connected_website` TEXT NULL COMMENT 'The domain name of the website on which the user has logged in.',
120136
`passport_data` TEXT NULL COMMENT 'Telegram Passport data',
121137
`proximity_alert_triggered` TEXT NULL COMMENT 'Service message. A user in the chat triggered another user''s proximity alert while sharing Live Location.',
138+
`voice_chat_started` TEXT COMMENT 'VoiceChatStarted object. Message is a service message: voice chat started',
139+
`voice_chat_ended` TEXT COMMENT 'VoiceChatEnded object. Message is a service message: voice chat ended',
140+
`voice_chat_participants_invited` TEXT COMMENT 'VoiceChatParticipantsInvited object. Message is a service message: new participants invited to a voice chat',
122141
`reply_markup` TEXT NULL COMMENT 'Inline keyboard attached to the message',
123142

124143
PRIMARY KEY (`chat_id`, `id`),
@@ -239,6 +258,21 @@ CREATE TABLE IF NOT EXISTS `poll_answer` (
239258
FOREIGN KEY (`poll_id`) REFERENCES `poll` (`id`)
240259
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
241260

261+
CREATE TABLE IF NOT EXISTS `chat_member_updated` (
262+
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry',
263+
`chat_id` BIGINT NOT NULL COMMENT 'Chat the user belongs to',
264+
`user_id` BIGINT NOT NULL COMMENT 'Performer of the action, which resulted in the change',
265+
`date` TIMESTAMP NOT NULL COMMENT 'Date the change was done in Unix time',
266+
`old_chat_member` TEXT NOT NULL COMMENT 'Previous information about the chat member',
267+
`new_chat_member` TEXT NOT NULL COMMENT 'New information about the chat member',
268+
`chat_invite_link_id` BIGINT UNSIGNED NULL COMMENT 'Chat invite link, which was used by the user to join the chat; for joining by invite link events only',
269+
270+
PRIMARY KEY (`id`),
271+
FOREIGN KEY (`chat_id`) REFERENCES `chat` (`id`),
272+
FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
273+
FOREIGN KEY (`chat_invite_link_id`) REFERENCES `chat_invite_link` (`id`)
274+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
275+
242276
CREATE TABLE IF NOT EXISTS `telegram_update` (
243277
`id` bigint UNSIGNED COMMENT 'Update''s unique identifier',
244278
`chat_id` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier',
@@ -253,6 +287,8 @@ CREATE TABLE IF NOT EXISTS `telegram_update` (
253287
`pre_checkout_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New incoming pre-checkout query. Contains full information about checkout',
254288
`poll_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New poll state. Bots receive only updates about polls, which are sent or stopped by the bot',
255289
`poll_answer_poll_id` bigint UNSIGNED DEFAULT NULL COMMENT 'A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.',
290+
`my_chat_member_update_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.',
291+
`chat_member_update_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.',
256292

257293
PRIMARY KEY (`id`),
258294
KEY `message_id` (`message_id`),
@@ -267,6 +303,8 @@ CREATE TABLE IF NOT EXISTS `telegram_update` (
267303
KEY `pre_checkout_query_id` (`pre_checkout_query_id`),
268304
KEY `poll_id` (`poll_id`),
269305
KEY `poll_answer_poll_id` (`poll_answer_poll_id`),
306+
KEY `my_chat_member_update_id` (`my_chat_member_update_id`),
307+
KEY `chat_member_update_id` (`chat_member_update_id`),
270308

271309
FOREIGN KEY (`chat_id`, `message_id`) REFERENCES `message` (`chat_id`, `id`),
272310
FOREIGN KEY (`edited_message_id`) REFERENCES `edited_message` (`id`),
@@ -278,7 +316,9 @@ CREATE TABLE IF NOT EXISTS `telegram_update` (
278316
FOREIGN KEY (`shipping_query_id`) REFERENCES `shipping_query` (`id`),
279317
FOREIGN KEY (`pre_checkout_query_id`) REFERENCES `pre_checkout_query` (`id`),
280318
FOREIGN KEY (`poll_id`) REFERENCES `poll` (`id`),
281-
FOREIGN KEY (`poll_answer_poll_id`) REFERENCES `poll_answer` (`poll_id`)
319+
FOREIGN KEY (`poll_answer_poll_id`) REFERENCES `poll_answer` (`poll_id`),
320+
FOREIGN KEY (`my_chat_member_update_id`) REFERENCES `chat_member_updated` (`id`),
321+
FOREIGN KEY (`chat_member_update_id`) REFERENCES `chat_member_updated` (`id`)
282322
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
283323

284324
CREATE TABLE IF NOT EXISTS `conversation` (
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Invite Links
22
CREATE TABLE IF NOT EXISTS `chat_invite_link` (
3-
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry'
4-
PRIMARY KEY,
3+
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry',
54
`invite_link` VARCHAR(2083) CHARACTER SET 'ascii' COLLATE 'ascii_general_ci' NOT NULL COMMENT 'The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”',
65
# IE7 has a 2083 character limit for HTTP GET operations: http://support.microsoft.com/kb/208427
76
`creator_id` BIGINT NOT NULL COMMENT 'Creator of the link',
@@ -10,39 +9,36 @@ CREATE TABLE IF NOT EXISTS `chat_invite_link` (
109
`expire_date` TIMESTAMP NULL COMMENT 'Point in time (Unix TIMESTAMP) when the link will expire or has been expired',
1110
`member_limit` MEDIUMINT UNSIGNED NULL COMMENT 'Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999',
1211

12+
PRIMARY KEY (`id`),
13+
1314
FOREIGN KEY (`creator_id`) REFERENCES `user` (`id`)
1415
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
1516

1617
# New update type
1718
CREATE TABLE IF NOT EXISTS `chat_member_updated` (
18-
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry'
19-
PRIMARY KEY,
19+
`id` BIGINT UNSIGNED COMMENT 'Unique identifier for this entry',
2020
`chat_id` BIGINT NOT NULL COMMENT 'Chat the user belongs to',
2121
`user_id` BIGINT NOT NULL COMMENT 'Performer of the action, which resulted in the change',
2222
`date` TIMESTAMP NOT NULL COMMENT 'Date the change was done in Unix time',
2323
`old_chat_member` TEXT NOT NULL COMMENT 'Previous information about the chat member',
2424
`new_chat_member` TEXT NOT NULL COMMENT 'New information about the chat member',
2525
`chat_invite_link_id` BIGINT UNSIGNED NULL COMMENT 'Chat invite link, which was used by the user to join the chat; for joining by invite link events only',
2626

27+
PRIMARY KEY (`id`),
28+
2729
FOREIGN KEY (`chat_id`) REFERENCES `chat` (`id`),
2830
FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
2931
FOREIGN KEY (`chat_invite_link_id`) REFERENCES `chat_invite_link` (`id`)
3032
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
3133

3234
# Updates about member status changes in chats
33-
ALTER TABLE `telegram_update` ADD COLUMN `my_chat_member_update_id`
34-
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.';
35+
ALTER TABLE `telegram_update` ADD COLUMN `my_chat_member_update_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.';
3536
ALTER TABLE `telegram_update` ADD FOREIGN KEY (`my_chat_member_update_id`) REFERENCES `chat_member_updated` (`id`);
36-
ALTER TABLE `telegram_update` ADD COLUMN `chat_member_update_id`
37-
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.';
37+
ALTER TABLE `telegram_update` ADD COLUMN `chat_member_update_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.';
3838
ALTER TABLE `telegram_update` ADD FOREIGN KEY (`chat_member_update_id`) REFERENCES `chat_member_updated` (`id`);
3939

4040
# New service messages
41-
ALTER TABLE `message` ADD COLUMN `message_auto_delete_timer_changed`
42-
TEXT COMMENT 'MessageAutoDeleteTimerChanged object. Message is a service message: auto-delete timer settings changed in the chat' AFTER `channel_chat_created`;
43-
ALTER TABLE `message` ADD COLUMN `voice_chat_started`
44-
TEXT COMMENT 'VoiceChatStarted object. Message is a service message: voice chat started' AFTER `proximity_alert_triggered`;
45-
ALTER TABLE `message` ADD COLUMN `voice_chat_ended`
46-
TEXT COMMENT 'VoiceChatEnded object. Message is a service message: voice chat ended' AFTER `voice_chat_started`;
47-
ALTER TABLE `message` ADD COLUMN `voice_chat_participants_invited`
48-
TEXT COMMENT 'VoiceChatParticipantsInvited object. Message is a service message: new participants invited to a voice chat' AFTER `voice_chat_ended`;
41+
ALTER TABLE `message` ADD COLUMN `message_auto_delete_timer_changed` TEXT COMMENT 'MessageAutoDeleteTimerChanged object. Message is a service message: auto-delete timer settings changed in the chat' AFTER `channel_chat_created`;
42+
ALTER TABLE `message` ADD COLUMN `voice_chat_started` TEXT COMMENT 'VoiceChatStarted object. Message is a service message: voice chat started' AFTER `proximity_alert_triggered`;
43+
ALTER TABLE `message` ADD COLUMN `voice_chat_ended` TEXT COMMENT 'VoiceChatEnded object. Message is a service message: voice chat ended' AFTER `voice_chat_started`;
44+
ALTER TABLE `message` ADD COLUMN `voice_chat_participants_invited` TEXT COMMENT 'VoiceChatParticipantsInvited object. Message is a service message: new participants invited to a voice chat' AFTER `voice_chat_ended`;

0 commit comments

Comments
 (0)