Commit 188b3ed8 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge branch 'develop' into custom_input_for_getUpdates

parents 27b7a8c0 408cbd42
......@@ -6,10 +6,17 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
## [Unreleased]
### Added
- Documents can be sent by providing its contents via Psr7 stream (as opposed to passing a file path).
- Allow setting a custom Guzzle HTTP Client for requests (#511).
- First implementations towards Bots API 3.0.
### Changed
- [:exclamation:][unreleased-bc-chats-params-array] `Request::sendToActiveChats` and `DB::selectChats` now accept parameters as an options array.
### Deprecated
### Removed
- [:exclamation:][unreleased-bc-up-download-directory] Upload and download directories are not set any more by default and must be set manually.
### Fixed
- ID fields are now typed with `PARAM_STR` PDO data type, to allow huge numbers.
- Message type data type for PDO corrected.
- Indexed table columns now have a fitting length.
- Take `custom_input` into account when using getUpdates method (mainly for testing).
### Security
......@@ -26,7 +33,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Removed
- All examples have been moved to a [dedicated repository](https://github.com/php-telegram-bot/example-bot).
### Fixed
- [:exclamation:](https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#0440) Format of Update content type using `$update->getUpdateContent()`.
- [:exclamation:][0.44.0-bc-update-content-type] Format of Update content type using `$update->getUpdateContent()`.
## [0.43.0] - 2017-04-17
### Added
......@@ -101,3 +108,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
- Logging improvements to Botan integration.
### Deprecated
- Move `hideKeyboard` to `removeKeyboard`.
[unreleased-bc-chats-params-array]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#unreleased
[unreleased-bc-up-download-directory]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#unreleased
[0.44.0-bc-update-content-type]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#update-getupdatecontent
......@@ -35,7 +35,7 @@ class ChatsCommand extends AdminCommand
/**
* @var string
*/
protected $version = '1.1.0';
protected $version = '1.2.0';
/**
* @var bool
......@@ -45,7 +45,7 @@ class ChatsCommand extends AdminCommand
/**
* Command execute method
*
* @return mixed
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
......@@ -55,19 +55,18 @@ class ChatsCommand extends AdminCommand
$chat_id = $message->getChat()->getId();
$text = trim($message->getText(true));
$results = DB::selectChats(
true, //Select groups (group chat)
true, //Select supergroups (super group chat)
true, //Select users (single chat)
null, //'yyyy-mm-dd hh:mm:ss' date range from
null, //'yyyy-mm-dd hh:mm:ss' date range to
null, //Specific chat_id to select
($text === '' || $text === '*') ? null : $text //Text to search in user/group name
);
$results = DB::selectChats([
'groups' => true,
'supergroups' => true,
'channels' => true,
'users' => true,
'text' => ($text === '' || $text === '*') ? null : $text //Text to search in user/group name
]);
$user_chats = 0;
$group_chats = 0;
$super_group_chats = 0;
$supergroup_chats = 0;
$channel_chats = 0;
if ($text === '') {
$text_back = '';
......@@ -100,24 +99,31 @@ class ChatsCommand extends AdminCommand
$text_back .= '- S ' . $chat->getTitle() . ' [' . $whois . ']' . PHP_EOL;
}
++$super_group_chats;
++$supergroup_chats;
} elseif ($chat->isGroupChat()) {
if ($text !== '') {
$text_back .= '- G ' . $chat->getTitle() . ' [' . $whois . ']' . PHP_EOL;
}
++$group_chats;
} elseif ($chat->isChannel()) {
if ($text !== '') {
$text_back .= '- C ' . $chat->getTitle() . ' [' . $whois . ']' . PHP_EOL;
}
++$channel_chats;
}
}
}
if (($user_chats + $group_chats + $super_group_chats) === 0) {
if (($user_chats + $group_chats + $supergroup_chats) === 0) {
$text_back = 'No chats found..';
} else {
$text_back .= PHP_EOL . 'Private Chats: ' . $user_chats;
$text_back .= PHP_EOL . 'Groups: ' . $group_chats;
$text_back .= PHP_EOL . 'Super Groups: ' . $super_group_chats;
$text_back .= PHP_EOL . 'Total: ' . ($user_chats + $group_chats + $super_group_chats);
$text_back .= PHP_EOL . 'Super Groups: ' . $supergroup_chats;
$text_back .= PHP_EOL . 'Channels: ' . $channel_chats;
$text_back .= PHP_EOL . 'Total: ' . ($user_chats + $group_chats + $supergroup_chats);
if ($text === '') {
$text_back .= PHP_EOL . PHP_EOL . 'List all chats: /' . $this->name . ' *' . PHP_EOL . 'Search for chats: /' . $this->name . ' <search string>';
......
......@@ -63,8 +63,8 @@ class DebugCommand extends AdminCommand
$debug_info = [];
$debug_info[] = sprintf('*TelegramBot version:* `%s`', $this->telegram->getVersion());
$debug_info[] = sprintf('*Download path:* `%s`', $this->telegram->getDownloadPath());
$debug_info[] = sprintf('*Upload path:* `%s`', $this->telegram->getUploadPath());
$debug_info[] = sprintf('*Download path:* `%s`', $this->telegram->getDownloadPath() ?: '`_Not set_`');
$debug_info[] = sprintf('*Upload path:* `%s`', $this->telegram->getUploadPath() ?: '`_Not set_`');
// Commands paths.
$debug_info[] = '*Commands paths:*';
......
......@@ -38,7 +38,7 @@ class SendtoallCommand extends AdminCommand
/**
* @var string
*/
protected $version = '1.3.0';
protected $version = '1.4.0';
/**
* @var bool
......@@ -48,7 +48,7 @@ class SendtoallCommand extends AdminCommand
/**
* Execute command
*
* @return boolean
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
......@@ -64,11 +64,12 @@ class SendtoallCommand extends AdminCommand
$results = Request::sendToActiveChats(
'sendMessage', //callback function to execute (see Request.php methods)
['text' => $text], //Param to evaluate the request
true, //Send to groups (group chat)
true, //Send to super groups chats (super group chat)
true, //Send to users (single chat)
null, //'yyyy-mm-dd hh:mm:ss' date range from
null //'yyyy-mm-dd hh:mm:ss' date range to
[
'groups' => true,
'supergroups' => true,
'channels' => false,
'users' => true,
]
);
$total = 0;
......
......@@ -42,7 +42,7 @@ class WhoisCommand extends AdminCommand
/**
* @var string
*/
protected $version = '1.2.0';
protected $version = '1.3.0';
/**
* @var bool
......@@ -52,7 +52,7 @@ class WhoisCommand extends AdminCommand
/**
* Command execute method
*
* @return mixed
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
......@@ -89,28 +89,25 @@ class WhoisCommand extends AdminCommand
$result = null;
if (is_numeric($text)) {
$results = DB::selectChats(
true, //Select groups (group chat)
true, //Select supergroups (super group chat)
true, //Select users (single chat)
null, //'yyyy-mm-dd hh:mm:ss' date range from
null, //'yyyy-mm-dd hh:mm:ss' date range to
$user_id //Specific chat_id to select
);
$results = DB::selectChats([
'groups' => true,
'supergroups' => true,
'channels' => true,
'users' => true,
'chat_id' => $user_id, //Specific chat_id to select
]);
if (!empty($results)) {
$result = reset($results);
}
} else {
$results = DB::selectChats(
true, //Select groups (group chat)
true, //Select supergroups (super group chat)
true, //Select users (single chat)
null, //'yyyy-mm-dd hh:mm:ss' date range from
null, //'yyyy-mm-dd hh:mm:ss' date range to
null, //Specific chat_id to select
$text //Text to search in user/group name
);
$results = DB::selectChats([
'groups' => true,
'supergroups' => true,
'channels' => true,
'users' => true,
'text' => $text //Text to search in user/group name
]);
if (is_array($results) && count($results) === 1) {
$result = reset($results);
......@@ -119,6 +116,7 @@ class WhoisCommand extends AdminCommand
if (is_array($result)) {
$result['id'] = $result['chat_id'];
$result['username'] = $result['chat_username'];
$chat = new Chat($result);
$user_id = $result['id'];
......
......@@ -11,22 +11,21 @@
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* New chat member command
* New chat members command
*/
class NewchatmemberCommand extends SystemCommand
class NewchatmembersCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Newchatmember';
protected $name = 'Newchatmembers';
/**
* @var string
*/
protected $description = 'New Chat Member';
protected $description = 'New Chat Member(s)';
/**
* @var string
......@@ -41,21 +40,9 @@ class NewchatmemberCommand extends SystemCommand
*/
public function execute()
{
$message = $this->getMessage();
//$message = $this->getMessage();
//$members = $message->getNewChatMembers();
$chat_id = $message->getChat()->getId();
$member = $message->getNewChatMember();
$text = 'Hi there!';
if (!$message->botAddedInChat()) {
$text = 'Hi ' . $member->tryMention() . '!';
}
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
return Request::sendMessage($data);
return parent::execute();
}
}
This diff is collapsed.
......@@ -37,6 +37,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method string getGifUrl() A valid URL for the GIF file. File size must not exceed 1MB
* @method int getGifWidth() Optional. Width of the GIF
* @method int getGifHeight() Optional. Height of the GIF
* @method int getGifDuration() Optional. Duration of the GIF
* @method string getThumbUrl() URL of the static thumbnail for the result (jpeg or gif)
* @method string getTitle() Optional. Title for the result
* @method string getCaption() Optional. Caption of the GIF file to be sent, 0-200 characters
......@@ -47,6 +48,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method $this setGifUrl(string $gif_url) A valid URL for the GIF file. File size must not exceed 1MB
* @method $this setGifWidth(int $gif_width) Optional. Width of the GIF
* @method $this setGifHeight(int $gif_height) Optional. Height of the GIF
* @method $this setGifDuration(int $gif_duration) Optional. Duration of the GIF
* @method $this setThumbUrl(string $thumb_url) URL of the static thumbnail for the result (jpeg or gif)
* @method $this setTitle(string $title) Optional. Title for the result
* @method $this setCaption(string $caption) Optional. Caption of the GIF file to be sent, 0-200 characters
......
......@@ -37,6 +37,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method string getMpeg4Url() A valid URL for the MP4 file. File size must not exceed 1MB
* @method int getMpeg4Width() Optional. Video width
* @method int getMpeg4Height() Optional. Video height
* @method int getMpeg4Duration() Optional. Video duration
* @method string getThumbUrl() URL of the static thumbnail (jpeg or gif) for the result
* @method string getTitle() Optional. Title for the result
* @method string getCaption() Optional. Caption of the MPEG-4 file to be sent, 0-200 characters
......@@ -47,6 +48,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method $this setMpeg4Url(string $mpeg4_url) A valid URL for the MP4 file. File size must not exceed 1MB
* @method $this setMpeg4Width(int $mpeg4_width) Optional. Video width
* @method $this setMpeg4Height(int $mpeg4_height) Optional. Video height
* @method $this setMpeg4Duration(int $mpeg4_duration) Optional. Video duration
* @method $this setThumbUrl(string $thumb_url) URL of the static thumbnail (jpeg or gif) for the result
* @method $this setTitle(string $title) Optional. Title for the result
* @method $this setCaption(string $caption) Optional. Caption of the MPEG-4 file to be sent, 0-200 characters
......
......@@ -30,11 +30,11 @@ namespace Longman\TelegramBot\Entities;
* @method Sticker getSticker() Optional. Message is a sticker, information about the sticker
* @method Video getVideo() Optional. Message is a video, information about the video
* @method Voice getVoice() Optional. Message is a voice message, information about the file
* @method Video Note getVideoNote() Optional. Message is a video note message, information about the video
* @method string getCaption() Optional. Caption for the document, photo or video, 0-200 characters
* @method Contact getContact() Optional. Message is a shared contact, information about the contact
* @method Location getLocation() Optional. Message is a shared location, information about the location
* @method Venue getVenue() Optional. Message is a venue, information about the venue
* @method User getNewChatMember() Optional. A new member was added to the group, information about them (this member may be the bot itself)
* @method User getLeftChatMember() Optional. A member was removed from the group, information about them (this member may be the bot itself)
* @method string getNewChatTitle() Optional. A chat title was changed to this value
* @method bool getDeleteChatPhoto() Optional. Service message: the chat photo was deleted
......@@ -65,10 +65,11 @@ class Message extends Entity
'sticker' => Sticker::class,
'video' => Video::class,
'voice' => Voice::class,
'video_note' => VideoNote::class,
'contact' => Contact::class,
'location' => Location::class,
'venue' => Venue::class,
'new_chat_member' => User::class,
'new_chat_members' => User::class,
'left_chat_member' => User::class,
'new_chat_photo' => PhotoSize::class,
'pinned_message' => Message::class,
......@@ -85,16 +86,6 @@ class Message extends Entity
*/
public function __construct(array $data, $bot_username = '')
{
//Retro-compatibility
if (isset($data['new_chat_participant'])) {
$data['new_chat_member'] = $data['new_chat_participant'];
unset($data['new_chat_participant']);
}
if (isset($data['left_chat_participant'])) {
$data['left_chat_member'] = $data['left_chat_participant'];
unset($data['left_chat_participant']);
}
parent::__construct($data, $bot_username);
}
......@@ -128,6 +119,21 @@ class Message extends Entity
return empty($pretty_array) ? null : $pretty_array;
}
/**
* Optional. A new member(s) was added to the group, information about them (one of this members may be the bot itself)
*
* This method overrides the default getNewChatMembers method
* and returns a nice array of User objects.
*
* @return null|User[]
*/
public function getNewChatMembers()
{
$pretty_array = $this->makePrettyObjectArray(User::class, 'new_chat_members');
return empty($pretty_array) ? null : $pretty_array;
}
/**
* Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
*
......@@ -221,12 +227,17 @@ class Message extends Entity
* Bot added in chat
*
* @return bool
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function botAddedInChat()
{
$member = $this->getNewChatMember();
foreach ($this->getNewChatMembers() as $member) {
if ($member instanceof User && $member->getUsername() === $this->getBotUsername()) {
return true;
}
}
return $member !== null && $member->getUsername() === $this->getBotUsername();
return false;
}
/**
......@@ -247,7 +258,7 @@ class Message extends Entity
'contact',
'location',
'venue',
'new_chat_member',
'new_chat_members',
'left_chat_member',
'new_chat_title',
'new_chat_photo',
......
......@@ -15,15 +15,11 @@ namespace Longman\TelegramBot\Entities;
*
* @link https://core.telegram.org/bots/api#user
*
* @property int $id Unique identifier for this user or bot
* @property string $first_name User's or bot’s first name
* @property string $last_name Optional. User's or bot’s last name
* @property string $username Optional. User's or bot’s username
*
* @method int getId() Unique identifier for this user or bot
* @method string getFirstName() User's or bot’s first name
* @method string getLastName() Optional. User's or bot’s last name
* @method string getUsername() Optional. User's or bot’s username
* @method string getLanguageCode() Optional. User's system language
*/
class User extends Entity
{
......
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
/**
* Class VideoNote
*
* @link https://core.telegram.org/bots/api#videonote
*
* @method string getFileId() Unique identifier for this file
* @method int getLength() Video width and height as defined by sender
* @method int getDuration() Duration of the audio in seconds as defined by sender
* @method PhotoSize getThumb() Optional. Video thumbnail as defined by sender
* @method int getFileSize() Optional. File size
*/
class VideoNote extends Entity
{
/**
* {@inheritdoc}
*/
protected function subEntities()
{
return [
'thumb' => PhotoSize::class,
];
}
}
......@@ -97,6 +97,7 @@ class Request
'editMessageCaption',
'editMessageReplyMarkup',
'getWebhookInfo',
'deleteMessage',
];
/**
......@@ -104,16 +105,32 @@ class Request
*
* @param \Longman\TelegramBot\Telegram $telegram
*
* @throws \Longman\TelegramBot\Exception\TelegramException
* @throws TelegramException
*/
public static function initialize(Telegram $telegram)
{
if (is_object($telegram)) {
if (!($telegram instanceof Telegram)) {
throw new TelegramException('Invalid Telegram pointer!');
}
self::$telegram = $telegram;
self::$client = new Client(['base_uri' => self::$api_base_uri]);
} else {
throw new TelegramException('Telegram pointer is empty!');
self::setClient(new Client(['base_uri' => self::$api_base_uri]));
}
/**
* Set a custom Guzzle HTTP Client object
*
* @param Client $client
*
* @throws TelegramException
*/
public static function setClient(Client $client)
{
if (!($client instanceof Client)) {
throw new TelegramException('Invalid GuzzleHttp\Client pointer!');
}
self::$client = $client;
}
/**
......@@ -262,8 +279,12 @@ class Request
*/
public static function downloadFile(File $file)
{
if (empty($download_path = self::$telegram->getDownloadPath())) {
throw new TelegramException('Download path not set!');
}
$tg_file_path = $file->getFilePath();
$file_path = self::$telegram->getDownloadPath() . '/' . $tg_file_path;
$file_path = $download_path . '/' . $tg_file_path;
$file_dir = dirname($file_path);
//For safety reasons, first try to create the directory, then check that it exists.
......@@ -943,36 +964,28 @@ class Request
*
* @param string $callback_function
* @param array $data
* @param boolean $send_groups
* @param boolean $send_super_groups
* @param boolean $send_users
* @param string $date_from
* @param string $date_to
* @param array $select_chats_params
*
* @return array
* @throws \Longman\TelegramBot\Exception\TelegramException
* @throws TelegramException
*/
public static function sendToActiveChats(
$callback_function,
array $data,
$send_groups = true,
$send_super_groups = true,
$send_users = true,
$date_from = null,
$date_to = null
array $select_chats_params
) {
$callback_path = __NAMESPACE__ . '\Request';
if (!method_exists($callback_path, $callback_function)) {
throw new TelegramException('Method "' . $callback_function . '" not found in class Request.');
}
$chats = DB::selectChats($send_groups, $send_super_groups, $send_users, $date_from, $date_to);
$chats = DB::selectChats($select_chats_params);
$results = [];
if (is_array($chats)) {
foreach ($chats as $row) {
$data['chat_id'] = $row['chat_id'];
$results[] = call_user_func_array($callback_path . '::' . $callback_function, [$data]);
$results[] = call_user_func($callback_path . '::' . $callback_function, $data);
}
}
......@@ -1078,4 +1091,39 @@ class Request
}
}
}
/**
* Use this method to delete either bot's messages or messages of other users if the bot is admin of the group.
*
* On success, true is returned.
*
* @link https://core.telegram.org/bots/api#deletemessage
*
* @param array $data
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public static function deleteMessage(array $data)
{
return self::send('deleteMessage', $data);
}
/**
* Use this method to send video notes. On success, the sent Message is returned.
*
* @link https://core.telegram.org/bots/api#sendvideonote
*
* @param array $data
* @param string $file
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public static function sendVideoNote(array $data, $file = null)
{
self::assignEncodedFile($data, 'video_note', $file);
return self::send('sendVideoNote', $data);
}
}
......@@ -161,10 +161,6 @@ class Telegram
$this->bot_username = $bot_username;
}
//Set default download and upload path
$this->setDownloadPath(BASE_PATH . '/../Download');
$this->setUploadPath(BASE_PATH . '/../Upload');
//Add default system commands path
$this->addCommandsPath(BASE_COMMANDS_PATH . '/SystemCommands');
......
CREATE TABLE IF NOT EXISTS `user` (
`id` bigint COMMENT 'Unique user identifier',
`first_name` CHAR(255) NOT NULL DEFAULT '' COMMENT 'User\'s first name',
`last_name` CHAR(255) DEFAULT NULL COMMENT 'User\'s last name',
`username` CHAR(255) DEFAULT NULL COMMENT 'User\'s username',
`first_name` CHAR(255) NOT NULL DEFAULT '' COMMENT 'User''s first name',
`last_name` CHAR(255) DEFAULT NULL COMMENT 'User''s last name',
`username` CHAR(191) DEFAULT NULL COMMENT 'User''s username',
`language_code` CHAR(10) DEFAULT NULL COMMENT 'User''s system language',
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update',
......@@ -30,10 +31,8 @@ CREATE TABLE IF NOT EXISTS `user_chat` (
PRIMARY KEY (`user_id`, `chat_id`),
FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`chat_id`) REFERENCES `chat` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`chat_id`) REFERENCES `chat` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE IF NOT EXISTS `inline_query` (
......@@ -54,7 +53,7 @@ CREATE TABLE IF NOT EXISTS `chosen_inline_result` (
`id` bigint UNSIGNED AUTO_INCREMENT COMMENT 'Unique identifier for this entry',
`result_id` CHAR(255) NOT NULL DEFAULT '' COMMENT 'Identifier for this result',
`user_id` bigint NULL COMMENT 'Unique user identifier',
`location` CHAR(255) NULL DEFAULT NULL COMMENT 'Location object, user\'s location',
`location` CHAR(255) NULL DEFAULT NULL COMMENT 'Location object, user''s location',
`inline_message_id` CHAR(255) NULL DEFAULT NULL COMMENT 'Identifier of the sent inline message',
`query` TEXT NOT NULL COMMENT 'The query that was used to obtain the result',
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
......@@ -84,19 +83,20 @@ CREATE TABLE IF NOT EXISTS `message` (
`sticker` TEXT COMMENT 'Sticker object. Message is a sticker, information about the sticker',
`video` TEXT COMMENT 'Video object. Message is a video, information about the video',
`voice` TEXT COMMENT 'Voice Object. Message is a Voice, information about the Voice',
`video_note` TEXT COMMENT 'VoiceNote Object. Message is a Video Note, information about the Video Note',
`contact` TEXT COMMENT 'Contact object. Message is a shared contact, information about the contact',
`location` TEXT COMMENT 'Location object. Message is a shared location, information about the location',
`venue` TEXT COMMENT 'Venue object. Message is a Venue, information about the Venue',
`caption` TEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption',
`new_chat_member` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, a new member was added to the group, information about them (this member may be bot itself)',
`left_chat_member` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, a member was removed from the group, information about them (this member may be bot itself)',
`new_chat_members` TEXT COMMENT 'List of unique user identifiers, new member(s) were added to the group, information about them (one of these members may be the bot itself)',
`left_chat_member` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, a member was removed from the group, information about them (this member may be the bot itself)',
`new_chat_title` CHAR(255) DEFAULT NULL COMMENT 'A chat title was changed to this value',
`new_chat_photo` TEXT COMMENT 'Array of PhotoSize objects. A chat photo was change to this value',
`delete_chat_photo` tinyint(1) DEFAULT 0 COMMENT 'Informs that the chat photo was deleted',
`group_chat_created` tinyint(1) DEFAULT 0 COMMENT 'Informs that the group has been created',
`supergroup_chat_created` tinyint(1) DEFAULT 0 COMMENT 'Informs that the supergroup has been created',
`channel_chat_created` tinyint(1) DEFAULT 0 COMMENT 'Informs that the channel chat has been created',
`migrate_to_chat_id` bigint NULL DEFAULT NULL COMMENT 'Migrate to chat identifier. The group has been migrated to a supergroup with the specified identifie',
`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',
`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',
`pinned_message` TEXT NULL COMMENT 'Message object. Specified message was pinned',
......@@ -106,7 +106,6 @@ CREATE TABLE IF NOT EXISTS `message` (
KEY `forward_from_chat` (`forward_from_chat`),
KEY `reply_to_chat` (`reply_to_chat`),
KEY `reply_to_message` (`reply_to_message`),
KEY `new_chat_member` (`new_chat_member`),
KEY `left_chat_member` (`left_chat_member`),
KEY `migrate_from_chat_id` (`migrate_from_chat_id`),
KEY `migrate_to_chat_id` (`migrate_to_chat_id`),
......@@ -117,7 +116,6 @@ CREATE TABLE IF NOT EXISTS `message` (
FOREIGN KEY (`forward_from_chat`) REFERENCES `chat` (`id`),
FOREIGN KEY (`reply_to_chat`, `reply_to_message`) REFERENCES `message` (`chat_id`, `id`),
FOREIGN KEY (`forward_from`) REFERENCES `user` (`id`),
FOREIGN KEY (`new_chat_member`) REFERENCES `user` (`id`),
FOREIGN KEY (`left_chat_member`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
......@@ -160,7 +158,7 @@ CREATE TABLE IF NOT EXISTS `edited_message` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
CREATE TABLE IF NOT EXISTS `telegram_update` (
`id` bigint UNSIGNED COMMENT 'Update\'s unique identifier',
`id` bigint UNSIGNED COMMENT 'Update''s unique identifier',
`chat_id` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier',
`message_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Unique message identifier',
`inline_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Unique inline query identifier',
......@@ -221,4 +219,4 @@ CREATE TABLE IF NOT EXISTS `request_limiter` (
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT charSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
ALTER TABLE `message` ADD COLUMN `new_chat_members` TEXT COMMENT 'List of unique user identifiers, new member(s) were added to the group, information about them (one of these members may be the bot itself)' AFTER `new_chat_member`;
UPDATE `message` SET `new_chat_members` = `new_chat_member`;
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