Unverified Commit 49260a56 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #718 from noplanman/bot_api_3.5

Bot API 3.5
parents c712c82d 67d2ea60
......@@ -5,6 +5,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
## [Unreleased]
### Added
- Implemented new changes for Bot API 3.5 (InputMedia, MediaGroup).
### Changed
### Deprecated
### Removed
......
......@@ -830,7 +830,7 @@ class DB
INSERT IGNORE INTO `' . TB_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`, `media_group_id`, `text`, `entities`, `audio`, `document`,
`photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
`location`, `venue`, `new_chat_members`, `left_chat_member`,
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
......@@ -838,7 +838,7 @@ class DB
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`
) VALUES (
: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, :media_group_id, :text, :entities, :audio, :document,
:photo, :sticker, :video, :voice, :video_note, :caption, :contact,
:location, :venue, :new_chat_members, :left_chat_member,
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
......@@ -878,6 +878,7 @@ class DB
$sth->bindValue(':reply_to_chat', $reply_to_chat_id);
$sth->bindValue(':reply_to_message', $reply_to_message_id);
$sth->bindValue(':media_group_id', $message->getMediaGroupId());
$sth->bindValue(':text', $message->getText());
$sth->bindValue(':entities', $t = self::entitiesArrayToJson($message->getEntities(), null));
$sth->bindValue(':audio', $message->getAudio());
......
<?php
namespace Longman\TelegramBot\Entities\InputMedia;
interface InputMedia
{
}
<?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\InputMedia;
use Longman\TelegramBot\Entities\Entity;
/**
* Class InputMediaPhoto
*
* @link https://core.telegram.org/bots/api#inputmediaphoto
*
* <code>
* $data = [
* 'media' => '123abc',
* 'caption' => 'Photo caption',
* ];
* </code>
*
* @method string getType() Type of the result, must be photo
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
* @method string getCaption() Optional. Caption of the photo to be sent, 0-200 characters
*
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
* @method $this setCaption(string $caption) Optional. Caption of the photo to be sent, 0-200 characters
*/
class InputMediaPhoto extends Entity implements InputMedia
{
/**
* InputMediaPhoto constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'photo';
parent::__construct($data);
}
}
<?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\InputMedia;
use Longman\TelegramBot\Entities\Entity;
/**
* Class InputMediaVideo
*
* @link https://core.telegram.org/bots/api#inputmediavideo
*
* <code>
* $data = [
* 'media' => '123abc',
* 'caption' => 'Video caption',
* 'width' => 800,
* 'heidht' => 600,
* 'duration' => 42
* ];
* </code>
*
* @method string getType() Type of the result, must be video
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
* @method string getCaption() Optional. Caption of the video to be sent, 0-200 characters
* @method int getWidth() Optional. Video width
* @method int getHeight() Optional. Video height
* @method int getDuration() Optional. Video duration
*
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
* @method $this setCaption(string $caption) Optional. Caption of the video to be sent, 0-200 characters
* @method $this setWidth(int $width) Optional. Video width
* @method $this setHeight(int $height) Optional. Video height
* @method $this setDuration(int $duration) Optional. Video duration
*/
class InputMediaVideo extends Entity implements InputMedia
{
/**
* InputMediaVideo constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'video';
parent::__construct($data);
}
}
......@@ -29,6 +29,7 @@ use Longman\TelegramBot\Entities\Payments\SuccessfulPayment;
* @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 int getEditDate() Optional. Date the message was last edited in Unix time
* @method string getMediaGroupId() Optional. The unique identifier of a media message group this message belongs to
* @method string getAuthorSignature() Optional. Signature of the post author for messages in channels
* @method Audio getAudio() Optional. Message is an audio file, information about the file
* @method Document getDocument() Optional. Message is a general file, information about the file
......
......@@ -50,8 +50,8 @@ use Longman\TelegramBot\Exception\TelegramException;
* @method static ServerResponse deleteChatPhoto(array $data) Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse setChatTitle(array $data) Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse setChatDescription(array $data) Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse pinChatMessage(array $data) Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse unpinChatMessage(array $data) Use this method to unpin a message in a supergroup chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse pinChatMessage(array $data) Use this method to pin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
* @method static ServerResponse unpinChatMessage(array $data) Use this method to unpin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
* @method static ServerResponse leaveChat(array $data) Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
* @method static ServerResponse getChat(array $data) Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
* @method static ServerResponse getChatAdministrators(array $data) Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
......
......@@ -76,6 +76,7 @@ CREATE TABLE IF NOT EXISTS `message` (
`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_message` bigint UNSIGNED DEFAULT NULL COMMENT 'Message that this message is reply to',
`media_group_id` TEXT COMMENT 'The unique identifier of a media message group this message belongs to',
`text` TEXT COMMENT 'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8mb4',
`entities` TEXT COMMENT 'For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text',
`audio` TEXT COMMENT 'Audio object. Message is an audio file, information about the file',
......
ALTER TABLE `message` ADD COLUMN `media_group_id` TEXT COMMENT 'The unique identifier of a media message group this message belongs to' AFTER `reply_to_message`;
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