Commit 706fc120 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #364 from noplanman/implement_new_api_changes

Implement new api changes
parents 3204a0c0 9aa93286
...@@ -50,6 +50,7 @@ class CallbackqueryCommand extends SystemCommand ...@@ -50,6 +50,7 @@ class CallbackqueryCommand extends SystemCommand
'callback_query_id' => $callback_query_id, 'callback_query_id' => $callback_query_id,
'text' => 'Hello World!', 'text' => 'Hello World!',
'show_alert' => $callback_data === 'thumb up', 'show_alert' => $callback_data === 'thumb up',
'cache_time' => 5,
]; ];
return Request::answerCallbackQuery($data); return Request::answerCallbackQuery($data);
......
...@@ -409,16 +409,18 @@ class DB ...@@ -409,16 +409,18 @@ class DB
$chat_id = $chat->getId(); $chat_id = $chat->getId();
$chat_title = $chat->getTitle(); $chat_title = $chat->getTitle();
$chat_type = $chat->getType(); $chat_type = $chat->getType();
$chat_all_members_are_administrators = $chat->getAllMembersAreAdministrators();
try { try {
$sth = self::$pdo->prepare(' $sth = self::$pdo->prepare('
INSERT INTO `' . TB_CHAT . '` INSERT IGNORE INTO `' . TB_CHAT . '`
(`id`, `type`, `title`, `created_at` ,`updated_at`, `old_id`) (`id`, `type`, `title`, `all_members_are_administrators`, `created_at` ,`updated_at`, `old_id`)
VALUES VALUES
(:id, :type, :title, :date, :date, :oldid) (:id, :type, :title, :all_members_are_administrators, :date, :date, :oldid)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
`type` = :type, `type` = :type,
`title` = :title, `title` = :title,
`all_members_are_administrators` = :all_members_are_administrators,
`updated_at` = :date `updated_at` = :date
'); ');
...@@ -434,6 +436,7 @@ class DB ...@@ -434,6 +436,7 @@ class DB
$sth->bindParam(':type', $chat_type, PDO::PARAM_INT); $sth->bindParam(':type', $chat_type, PDO::PARAM_INT);
$sth->bindParam(':title', $chat_title, PDO::PARAM_STR, 255); $sth->bindParam(':title', $chat_title, PDO::PARAM_STR, 255);
$sth->bindParam(':all_members_are_administrators', $chat_all_members_are_administrators, PDO::PARAM_INT);
$sth->bindParam(':date', $date, PDO::PARAM_STR); $sth->bindParam(':date', $date, PDO::PARAM_STR);
return $sth->execute(); return $sth->execute();
...@@ -735,6 +738,7 @@ class DB ...@@ -735,6 +738,7 @@ class DB
$forward_from = $message->getForwardFrom(); $forward_from = $message->getForwardFrom();
$forward_from_chat = $message->getForwardFromChat(); $forward_from_chat = $message->getForwardFromChat();
$forward_from_message_id = $message->getForwardFromMessageId();
$photo = self::entitiesArrayToJson($message->getPhoto(), ''); $photo = self::entitiesArrayToJson($message->getPhoto(), '');
$entities = self::entitiesArrayToJson($message->getEntities(), null); $entities = self::entitiesArrayToJson($message->getEntities(), null);
$new_chat_member = $message->getNewChatMember(); $new_chat_member = $message->getNewChatMember();
...@@ -778,7 +782,7 @@ class DB ...@@ -778,7 +782,7 @@ class DB
$sth = self::$pdo->prepare(' $sth = self::$pdo->prepare('
INSERT IGNORE INTO `' . TB_MESSAGE . '` INSERT IGNORE INTO `' . TB_MESSAGE . '`
( (
`id`, `user_id`, `chat_id`, `date`, `forward_from`, `forward_from_chat`, `id`, `user_id`, `chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
`forward_date`, `reply_to_chat`, `reply_to_message`, `text`, `entities`, `audio`, `document`, `forward_date`, `reply_to_chat`, `reply_to_message`, `text`, `entities`, `audio`, `document`,
`photo`, `sticker`, `video`, `voice`, `caption`, `contact`, `photo`, `sticker`, `video`, `voice`, `caption`, `contact`,
`location`, `venue`, `new_chat_member`, `left_chat_member`, `location`, `venue`, `new_chat_member`, `left_chat_member`,
...@@ -786,7 +790,7 @@ class DB ...@@ -786,7 +790,7 @@ class DB
`supergroup_chat_created`, `channel_chat_created`, `supergroup_chat_created`, `channel_chat_created`,
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message` `migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`
) VALUES ( ) VALUES (
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
:forward_date, :reply_to_chat, :reply_to_message, :text, :entities, :audio, :document, :forward_date, :reply_to_chat, :reply_to_message, :text, :entities, :audio, :document,
:photo, :sticker, :video, :voice, :caption, :contact, :photo, :sticker, :video, :voice, :caption, :contact,
:location, :venue, :new_chat_member, :left_chat_member, :location, :venue, :new_chat_member, :left_chat_member,
...@@ -838,6 +842,7 @@ class DB ...@@ -838,6 +842,7 @@ class DB
$sth->bindParam(':date', $date, PDO::PARAM_STR); $sth->bindParam(':date', $date, PDO::PARAM_STR);
$sth->bindParam(':forward_from', $forward_from, PDO::PARAM_INT); $sth->bindParam(':forward_from', $forward_from, PDO::PARAM_INT);
$sth->bindParam(':forward_from_chat', $forward_from_chat, PDO::PARAM_INT); $sth->bindParam(':forward_from_chat', $forward_from_chat, PDO::PARAM_INT);
$sth->bindParam(':forward_from_message_id', $forward_from_message_id, PDO::PARAM_INT);
$sth->bindParam(':forward_date', $forward_date, PDO::PARAM_STR); $sth->bindParam(':forward_date', $forward_date, PDO::PARAM_STR);
$reply_to_chat_id = null; $reply_to_chat_id = null;
......
...@@ -21,12 +21,14 @@ namespace Longman\TelegramBot\Entities; ...@@ -21,12 +21,14 @@ namespace Longman\TelegramBot\Entities;
* @property string $username Optional. Username, for private chats, supergroups and channels if available * @property string $username Optional. Username, for private chats, supergroups and channels if available
* @property string $first_name Optional. First name of the other party in a private chat * @property string $first_name Optional. First name of the other party in a private chat
* @property string $last_name Optional. Last name of the other party in a private chat * @property string $last_name Optional. Last name of the other party in a private chat
* @property bool $all_members_are_administrators Optional. True if a group has ‘All Members Are Admins’ enabled.
* @method int getId() Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. * @method int getId() Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @method string getType() Type of chat, can be either "private ", "group", "supergroup" or "channel" * @method string getType() Type of chat, can be either "private ", "group", "supergroup" or "channel"
* @method string getTitle() Optional. Title, for channels and group chats * @method string getTitle() Optional. Title, for channels and group chats
* @method string getUsername() Optional. Username, for private chats, supergroups and channels if available * @method string getUsername() Optional. Username, for private chats, supergroups and channels if available
* @method string getFirstName() Optional. First name of the other party in a private chat * @method string getFirstName() Optional. First name of the other party in a private chat
* @method string getLastName() Optional. Last name of the other party in a private chat * @method string getLastName() Optional. Last name of the other party in a private chat
* @method bool getAllMembersAreAdministrators() Optional. True if a group has ‘All Members Are Admins’ enabled.
*/ */
class Chat extends Entity class Chat extends Entity
{ {
......
...@@ -23,6 +23,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -23,6 +23,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* 'id' => '', * 'id' => '',
* 'audio_url' => '', * 'audio_url' => '',
* 'title' => '', * 'title' => '',
* 'caption' => '',
* 'performer' => '', * 'performer' => '',
* 'audio_duration' => 123, * 'audio_duration' => 123,
* 'reply_markup' => <InlineKeyboard>, * 'reply_markup' => <InlineKeyboard>,
...@@ -34,6 +35,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -34,6 +35,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method string getId() Unique identifier for this result, 1-64 bytes * @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getAudioUrl() A valid URL for the audio file * @method string getAudioUrl() A valid URL for the audio file
* @method string getTitle() Title * @method string getTitle() Title
* @method string getCaption() Optional. Caption, 0-200 characters
* @method string getPerformer() Optional. Performer * @method string getPerformer() Optional. Performer
* @method int getAudioDuration() Optional. Audio duration in seconds * @method int getAudioDuration() Optional. Audio duration in seconds
* @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message * @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message
...@@ -42,6 +44,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -42,6 +44,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes * @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setAudioUrl(string $audio_url) A valid URL for the audio file * @method $this setAudioUrl(string $audio_url) A valid URL for the audio file
* @method $this setTitle(string $title) Title * @method $this setTitle(string $title) Title
* @method $this setCaption(string $caption) Optional. Caption, 0-200 characters
* @method $this setPerformer(string $performer) Optional. Performer * @method $this setPerformer(string $performer) Optional. Performer
* @method $this setAudioDuration(int $audio_duration) Optional. Audio duration in seconds * @method $this setAudioDuration(int $audio_duration) Optional. Audio duration in seconds
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message
......
...@@ -22,6 +22,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -22,6 +22,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* $data = [ * $data = [
* 'id' => '', * 'id' => '',
* 'audio_file_id' => '', * 'audio_file_id' => '',
* 'caption' => '',
* 'reply_markup' => <InlineKeyboard>, * 'reply_markup' => <InlineKeyboard>,
* 'input_message_content' => <InputMessageContent>, * 'input_message_content' => <InputMessageContent>,
* ]; * ];
...@@ -30,11 +31,13 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -30,11 +31,13 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method string getType() Type of the result, must be audio * @method string getType() Type of the result, must be audio
* @method string getId() Unique identifier for this result, 1-64 bytes * @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getAudioFileId() A valid file identifier for the audio file * @method string getAudioFileId() A valid file identifier for the audio file
* @method string getCaption() Optional. Caption, 0-200 characters
* @method InlineKeyboard getReplyMarkup() Optional. An Inline keyboard attached to the message * @method InlineKeyboard getReplyMarkup() Optional. An Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the audio * @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the audio
* *
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes * @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setAudioFileId(string $audio_file_id) A valid file identifier for the audio file * @method $this setAudioFileId(string $audio_file_id) A valid file identifier for the audio file
* @method $this setCaption(string $caption) Optional. Caption, 0-200 characters
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. An Inline keyboard attached to the message * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. An Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the audio * @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the audio
*/ */
......
...@@ -23,6 +23,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -23,6 +23,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* 'id' => '', * 'id' => '',
* 'voice_file_id' => '', * 'voice_file_id' => '',
* 'title' => '', * 'title' => '',
* 'caption' => '',
* 'reply_markup' => <InlineKeyboard>, * 'reply_markup' => <InlineKeyboard>,
* 'input_message_content' => <InputMessageContent>, * 'input_message_content' => <InputMessageContent>,
* ]; * ];
...@@ -32,12 +33,14 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -32,12 +33,14 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method string getId() Unique identifier for this result, 1-64 bytes * @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getVoiceFileId() A valid file identifier for the voice message * @method string getVoiceFileId() A valid file identifier for the voice message
* @method string getTitle() Voice message title * @method string getTitle() Voice message title
* @method string getCaption() Optional. Caption, 0-200 characters
* @method InlineKeyboard getReplyMarkup() Optional. An Inline keyboard attached to the message * @method InlineKeyboard getReplyMarkup() Optional. An Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the voice message * @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the voice message
* *
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes * @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setVoiceFileId(string $voice_file_id) A valid file identifier for the voice message * @method $this setVoiceFileId(string $voice_file_id) A valid file identifier for the voice message
* @method $this setTitle(string $title) Voice message title * @method $this setTitle(string $title) Voice message title
* @method $this setCaption(string $caption) Optional. Caption, 0-200 characters
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. An Inline keyboard attached to the message * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. An Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the voice message * @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the voice message
*/ */
......
...@@ -23,6 +23,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -23,6 +23,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* 'id' => '', * 'id' => '',
* 'voice_url' => '', * 'voice_url' => '',
* 'title' => '', * 'title' => '',
* 'caption' => '',
* 'voice_duration' => 123, * 'voice_duration' => 123,
* 'reply_markup' => <InlineKeyboard>, * 'reply_markup' => <InlineKeyboard>,
* 'input_message_content' => <InputMessageContent>, * 'input_message_content' => <InputMessageContent>,
...@@ -33,6 +34,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -33,6 +34,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method string getId() Unique identifier for this result, 1-64 bytes * @method string getId() Unique identifier for this result, 1-64 bytes
* @method string getVoiceUrl() A valid URL for the voice recording * @method string getVoiceUrl() A valid URL for the voice recording
* @method string getTitle() Recording title * @method string getTitle() Recording title
* @method string getCaption() Optional. Caption, 0-200 characters
* @method int getVoiceDuration() Optional. Recording duration in seconds * @method int getVoiceDuration() Optional. Recording duration in seconds
* @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message * @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the voice recording * @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the voice recording
...@@ -40,6 +42,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent; ...@@ -40,6 +42,7 @@ use Longman\TelegramBot\Entities\InputMessageContent\InputMessageContent;
* @method $this setId(string $id) Unique identifier for this result, 1-64 bytes * @method $this setId(string $id) Unique identifier for this result, 1-64 bytes
* @method $this setVoiceUrl(string $voice_url) A valid URL for the voice recording * @method $this setVoiceUrl(string $voice_url) A valid URL for the voice recording
* @method $this setTitle(string $title) Recording title * @method $this setTitle(string $title) Recording title
* @method $this setCaption(string $caption) Optional. Caption, 0-200 characters
* @method $this setVoiceDuration(int $voice_duration) Optional. Recording duration in seconds * @method $this setVoiceDuration(int $voice_duration) Optional. Recording duration in seconds
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message * @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the voice recording * @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the voice recording
......
...@@ -21,6 +21,7 @@ namespace Longman\TelegramBot\Entities; ...@@ -21,6 +21,7 @@ namespace Longman\TelegramBot\Entities;
* @method Chat getChat() Conversation the message belongs to * @method Chat getChat() Conversation the message belongs to
* @method User getForwardFrom() Optional. For forwarded messages, sender of the original message * @method User getForwardFrom() Optional. For forwarded messages, sender of the original message
* @method Chat getForwardFromChat() Optional. For messages forwarded from a channel, information about the original channel * @method Chat getForwardFromChat() Optional. For messages forwarded from a channel, information about the original channel
* @method int getForwardFromMessageId() Optional. For forwarded channel posts, identifier of the original message in the channel
* @method int getForwardDate() Optional. For forwarded messages, date the original message was sent in Unix time * @method int getForwardDate() Optional. For forwarded messages, date the original message was sent in Unix time
* @method Message getReplyToMessage() Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. * @method Message getReplyToMessage() Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
* @method int getEditDate() Optional. Date the message was last edited in Unix time * @method int getEditDate() Optional. Date the message was last edited in Unix time
......
...@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `chat` ( ...@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `chat` (
`id` bigint COMMENT 'Unique user or chat identifier', `id` bigint COMMENT 'Unique user or chat identifier',
`type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'Chat type, either private, group, supergroup or channel', `type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'Chat type, either private, group, supergroup or channel',
`title` CHAR(255) DEFAULT '' COMMENT 'Chat (group) title, is null if chat type is private', `title` CHAR(255) DEFAULT '' COMMENT 'Chat (group) title, is null if chat type is private',
`all_members_are_administrators` tinyint(1) DEFAULT 0 COMMENT 'True if a all members of this group are admins',
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update', `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update',
`old_id` bigint DEFAULT NULL COMMENT 'Unique chat identifier, this is filled when a group is converted to a supergroup', `old_id` bigint DEFAULT NULL COMMENT 'Unique chat identifier, this is filled when a group is converted to a supergroup',
...@@ -70,6 +71,7 @@ CREATE TABLE IF NOT EXISTS `message` ( ...@@ -70,6 +71,7 @@ CREATE TABLE IF NOT EXISTS `message` (
`date` timestamp NULL DEFAULT NULL COMMENT 'Date the message was sent in timestamp format', `date` timestamp NULL DEFAULT NULL COMMENT 'Date the message was sent in timestamp format',
`forward_from` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, sender of the original message', `forward_from` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, sender of the original message',
`forward_from_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier, chat the original message belongs to', `forward_from_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier, chat the original message belongs to',
`forward_from_message_id` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier of the original message in the channel',
`forward_date` timestamp NULL DEFAULT NULL COMMENT 'date the original message was sent in timestamp format', `forward_date` timestamp NULL DEFAULT NULL COMMENT 'date the original message was sent in timestamp format',
`reply_to_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier', `reply_to_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier',
`reply_to_message` bigint UNSIGNED DEFAULT NULL COMMENT 'Message that this message is reply to', `reply_to_message` bigint UNSIGNED DEFAULT NULL COMMENT 'Message that this message is reply to',
......
...@@ -48,6 +48,7 @@ class TestHelpers ...@@ -48,6 +48,7 @@ class TestHelpers
'last_name' => 'last', 'last_name' => 'last',
'username' => 'name', 'username' => 'name',
'type' => 'private', 'type' => 'private',
'all_members_are_administrators' => false,
]; ];
/** /**
......
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