Skip to content

Commit 29a3cd8

Browse files
committed
Added new animation related properties and methods.
1 parent 6f3745d commit 29a3cd8

File tree

7 files changed

+17
-6
lines changed

7 files changed

+17
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ $result = Request::sendPhoto([
364364
]);
365365
```
366366

367-
*sendAudio*, *sendDocument*, *sendSticker*, *sendVideo*, *sendVoice* and *sendVideoNote* all work in the same way, just check the [API documentation](https://core.telegram.org/bots/api#sendphoto) for the exact usage.
367+
*sendAudio*, *sendDocument*, *sendAnimation*, *sendSticker*, *sendVideo*, *sendVoice* and *sendVideoNote* all work in the same way, just check the [API documentation](https://core.telegram.org/bots/api#sendphoto) for the exact usage.
368368
See the [*ImageCommand.php*][ImageCommand.php] for a full example.
369369

370370
#### Send Chat Action

src/DB.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,15 @@ public static function insertMessageRequest(Message $message)
829829
(
830830
`id`, `user_id`, `chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
831831
`forward_date`, `reply_to_chat`, `reply_to_message`, `media_group_id`, `text`, `entities`, `audio`, `document`,
832-
`game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
832+
`animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
833833
`location`, `venue`, `new_chat_members`, `left_chat_member`,
834834
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
835835
`supergroup_chat_created`, `channel_chat_created`,
836836
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`, `connected_website`
837837
) VALUES (
838838
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
839839
:forward_date, :reply_to_chat, :reply_to_message, :media_group_id, :text, :entities, :audio, :document,
840-
:game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
840+
:animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
841841
:location, :venue, :new_chat_members, :left_chat_member,
842842
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
843843
:supergroup_chat_created, :channel_chat_created,
@@ -881,6 +881,7 @@ public static function insertMessageRequest(Message $message)
881881
$sth->bindValue(':entities', $t = self::entitiesArrayToJson($message->getEntities(), null));
882882
$sth->bindValue(':audio', $message->getAudio());
883883
$sth->bindValue(':document', $message->getDocument());
884+
$sth->bindValue(':animation', $message->getAnimation());
884885
$sth->bindValue(':game', $message->getGame());
885886
$sth->bindValue(':photo', $t = self::entitiesArrayToJson($message->getPhoto(), null));
886887
$sth->bindValue(':sticker', $message->getSticker());
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace Longman\TelegramBot\Entities\Games;
12-
13-
use Longman\TelegramBot\Entities\Entity;
11+
namespace Longman\TelegramBot\Entities;
1412

1513
/**
1614
* Class Animation
@@ -20,6 +18,9 @@
2018
* @link https://core.telegram.org/bots/api#animation
2119
*
2220
* @method string getFileId() Unique file identifier
21+
* @method int getWidth() Video width as defined by sender
22+
* @method int getHeight() Video height as defined by sender
23+
* @method int getDuration() Duration of the video in seconds as defined by sender
2324
* @method PhotoSize getThumb() Optional. Animation thumbnail as defined by sender
2425
* @method string getFileName() Optional. Original animation filename as defined by sender
2526
* @method string getMimeType() Optional. MIME type of the file as defined by sender

src/Entities/Message.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* @method string getAuthorSignature() Optional. Signature of the post author for messages in channels
3535
* @method Audio getAudio() Optional. Message is an audio file, information about the file
3636
* @method Document getDocument() Optional. Message is a general file, information about the file
37+
* @method Animation getAnimation() Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set
3738
* @method Game getGame() Optional. Message is a game, information about the game.
3839
* @method Sticker getSticker() Optional. Message is a sticker, information about the sticker
3940
* @method Video getVideo() Optional. Message is a video, information about the video
@@ -73,6 +74,7 @@ protected function subEntities()
7374
'caption_entities' => MessageEntity::class,
7475
'audio' => Audio::class,
7576
'document' => Document::class,
77+
'animation' => Animation::class,
7678
'game' => Game::class,
7779
'photo' => PhotoSize::class,
7880
'sticker' => Sticker::class,
@@ -280,6 +282,8 @@ public function getType()
280282
'text',
281283
'audio',
282284
'document',
285+
'animation',
286+
'game',
283287
'photo',
284288
'sticker',
285289
'video',

src/Request.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @method static ServerResponse sendDocument(array $data) Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
3232
* @method static ServerResponse sendSticker(array $data) Use this method to send .webp stickers. On success, the sent Message is returned.
3333
* @method static ServerResponse sendVideo(array $data) Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
34+
* @method static ServerResponse sendAnimation(array $data) Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
3435
* @method static ServerResponse sendVoice(array $data) Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
3536
* @method static ServerResponse sendVideoNote(array $data) Use this method to send video messages. On success, the sent Message is returned.
3637
* @method static ServerResponse sendMediaGroup(array $data) Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned.
@@ -145,6 +146,7 @@ class Request
145146
'sendDocument',
146147
'sendSticker',
147148
'sendVideo',
149+
'sendAnimation',
148150
'sendVoice',
149151
'sendVideoNote',
150152
'sendMediaGroup',
@@ -668,6 +670,7 @@ private static function limitTelegramRequests($action, array $data = [])
668670
'sendDocument',
669671
'sendSticker',
670672
'sendVideo',
673+
'sendAnimation',
671674
'sendVoice',
672675
'sendVideoNote',
673676
'sendMediaGroup',

structure.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ CREATE TABLE IF NOT EXISTS `message` (
8181
`entities` TEXT COMMENT 'For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text',
8282
`audio` TEXT COMMENT 'Audio object. Message is an audio file, information about the file',
8383
`document` TEXT COMMENT 'Document object. Message is a general file, information about the file',
84+
`animation` TEXT COMMENT 'Optional. Message is an animation, information about the animation',
8485
`game` TEXT COMMENT 'Game object. Message is a game, information about the game',
8586
`photo` TEXT COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo',
8687
`sticker` TEXT COMMENT 'Sticker object. Message is a sticker, information about the sticker',
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `message` ADD COLUMN `animation` TEXT NULL COMMENT 'Optional. Message is an animation, information about the animation' AFTER `document`;

0 commit comments

Comments
 (0)