Commit aa4792ab authored by MBoretto's avatar MBoretto

Chat type is now enum

parent e867ff3d
...@@ -249,7 +249,7 @@ class DB ...@@ -249,7 +249,7 @@ class DB
$sth2 = self::$pdo->prepare('INSERT INTO `'.TB_CHATS.'` $sth2 = self::$pdo->prepare('INSERT INTO `'.TB_CHATS.'`
(`id`, `type`, `title`, `created_at` ,`updated_at`, `old_id`) (`id`, `type`, `title`, `created_at` ,`updated_at`, `old_id`)
VALUES (:id, :type, :title, :date, :date, :oldid) VALUES (:id, :type, :title, :date, :date, :oldid)
ON DUPLICATE KEY UPDATE `title`=:title, `updated_at`=:date'); ON DUPLICATE KEY UPDATE `type`=:type, `title`=:title, `updated_at`=:date');
$chat_title = $chat->getTitle(); $chat_title = $chat->getTitle();
$type = $chat->getType(); $type = $chat->getType();
...@@ -319,7 +319,13 @@ class DB ...@@ -319,7 +319,13 @@ class DB
$update_id = $update->getUpdateId(); $update_id = $update->getUpdateId();
$message_id = $message->getMessageId(); $message_id = $message->getMessageId();
$from_id = $from->getId(); $from_id = $from->getId();
$reply_to_message = $message->getReplyToMessage()->getMessageId();
$reply_to_message = $message->getReplyToMessage();
$reply_to_message_id = null;
if (is_object($reply_to_message)) {
$reply_to_message_id = $reply_to_message->getMessageId();
}
$text = $message->getText(); $text = $message->getText();
$audio = $message->getAudio(); $audio = $message->getAudio();
$document = $message->getDocument(); $document = $message->getDocument();
......
CREATE TABLE `messages` ( CREATE TABLE `messages` (
`update_id` bigint UNSIGNED COMMENT 'The update\'s unique identifier.', `update_id` bigint UNSIGNED COMMENT 'The update\'s unique identifier.',
`message_id` bigint COMMENT 'Unique message identifier', `message_id` bigint UNSIGNED COMMENT 'Unique message identifier',
`user_id` bigint COMMENT 'User identifier', `user_id` bigint COMMENT 'User identifier',
`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Date the message was sent in timestamp format', `date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Date the message was sent in timestamp format',
`chat_id` bigint NOT NULL DEFAULT '0' COMMENT 'Chat identifier.', `chat_id` bigint NOT NULL DEFAULT '0' COMMENT 'Chat identifier.',
`forward_from` bigint NOT NULL DEFAULT '0' COMMENT 'User id. For forwarded messages, sender of the original message', `forward_from` bigint NOT NULL DEFAULT '0' COMMENT 'User id. For forwarded messages, sender of the original message',
`forward_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'For forwarded messages, date the original message was sent in Unix time', `forward_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'For forwarded messages, date the original message was sent in Unix time',
`reply_to_message` bigint COMMENT 'Message is a reply to another message already stored.', `reply_to_message` bigint UNSIGNED DEFAULT NULL COMMENT 'Message is a reply to another message already stored.',
`text` LONGTEXT COMMENT 'For text messages, the actual UTF-8 text of the message', `text` TEXT COMMENT 'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8',
`audio` TEXT DEFAULT '' COMMENT 'Audio object. Message is an audio file, information about the file', `audio` TEXT DEFAULT '' COMMENT 'Audio object. Message is an audio file, information about the file',
`document` TEXT DEFAULT '' COMMENT 'Document object. Message is a general file, information about the file', `document` TEXT DEFAULT '' COMMENT 'Document object. Message is a general file, information about the file',
`photo` TEXT DEFAULT '' COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo', `photo` TEXT DEFAULT '' COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo',
`sticker` TEXT DEFAULT '' COMMENT 'Sticker object. Message is a sticker, information about the sticker', `sticker` TEXT DEFAULT '' COMMENT 'Sticker object. Message is a sticker, information about the sticker',
`video` TEXT DEFAULT '' COMMENT 'Video object. Message is a video, information about the video', `video` TEXT DEFAULT '' COMMENT 'Video object. Message is a video, information about the video',
`voice` TEXT DEFAULT '' COMMENT 'Voice Object. Message is a Voice, information about the Voice', `voice` TEXT DEFAULT '' COMMENT 'Voice Object. Message is a Voice, information about the Voice',
`caption` LONGTEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption', `caption` TEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption',
`contact` TEXT DEFAULT '' COMMENT 'Contact object. Message is a shared contact, information about the contact', `contact` TEXT DEFAULT '' COMMENT 'Contact object. Message is a shared contact, information about the contact',
`location` TEXT DEFAULT '' COMMENT 'Location object. Message is a shared location, information about the location', `location` TEXT DEFAULT '' COMMENT 'Location object. Message is a shared location, information about the location',
`new_chat_participant` bigint NOT NULL DEFAULT '0' COMMENT 'User id. A new member was added to the group, information about them (this member may be bot itself)', `new_chat_participant` bigint NOT NULL DEFAULT '0' COMMENT 'User id. A new member was added to the group, information about them (this member may be bot itself)',
...@@ -45,7 +45,7 @@ CREATE TABLE `users` ( ...@@ -45,7 +45,7 @@ CREATE TABLE `users` (
CREATE TABLE `chats` ( CREATE TABLE `chats` (
`id` bigint NOT NULL DEFAULT '0' COMMENT 'Unique user or chat identifier', `id` bigint NOT NULL DEFAULT '0' COMMENT 'Unique user or chat identifier',
`type` CHAR(10) DEFAULT '' COMMENT 'chat type private, group, supergroup or channel', `type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'chat type private, group, supergroup or channel',
`title` CHAR(255) DEFAULT '' COMMENT 'chat title null if case of single chat with the bot', `title` CHAR(255) DEFAULT '' COMMENT 'chat title null if case of single chat with the bot',
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Entry date creation', `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Entry date creation',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Entry date update', `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Entry date update',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment