Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support api 7.2 #489

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All Notable changes to `PHP Telegram Bot Api` will be documented in this file

## 3.0.0 - YYYY-MM-DD
- Add `\TelegramBot\Api\BotApi::replaceStickerInSet` api method
- Add Added the parameter `business_connection_id` to `\TelegramBot\Api\BotApi` send methods
- Add `\TelegramBot\Api\BotApi::getBusinessConnection` api method
- Add `\TelegramBot\Api\Types\Update::$deletedBusinessMessages` field
- Add `\TelegramBot\Api\Types\Update::$editedBusinessMessage` field
- Add `\TelegramBot\Api\Types\Update::$businessMessage` field
- Add `\TelegramBot\Api\Types\Update::$businessConnection` field
- Add `\TelegramBot\Api\Types\Update::$myChatMember` field
- Add `\TelegramBot\Api\Types\Update::$chatMember` field
- Add `\TelegramBot\Api\Types\Update::$chatJoinRequest` field
Expand Down
157 changes: 126 additions & 31 deletions src/BotApi.php

Large diffs are not rendered by default.

164 changes: 164 additions & 0 deletions src/Types/InputSticker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?php

declare(strict_types=1);

namespace TelegramBot\Api\Types;

use TelegramBot\Api\BaseType;
use TelegramBot\Api\TypeInterface;

/**
* Class InputSticker.
* This object describes a sticker to be added to a sticker set.
*
* @author bernard-ng <[email protected]>
*/
class InputSticker extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
protected static $requiredParams = ['sticker', 'format', 'emoji_list'];

/**
* {@inheritdoc}
*
* @var array
*/
protected static $map = [
'sticker' => true,
'format' => true,
'emoji_list' => true,
'mask_position' => MaskPosition::class,
'keywords' => true,
];

/**
* The added sticker.
* Pass a file_id as a String to send a file that already exists on the Telegram servers,
* pass an HTTP URL as a String for Telegram to get a file from the Internet,
* upload a new one using multipart/form-data, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
* Animated and video stickers can't be uploaded via HTTP URL.
*
* @var string
* @see https://core.telegram.org/bots/api#sending-files
*/
protected string $sticker;

/**
* Format of the added sticker, must be one of “static”
* for a .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video
*
* @var string
*/
protected string $format;

/**
* List of 1-20 emoji associated with the sticker
*
* @var string[]
*/
protected array $emojiList;

/**
* Optional. Position where the mask should be placed on faces. For “mask” stickers only.
*
* @var MaskPosition|null
*/
protected $maskPosition;

/**
* Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters.
* For “regular” and “custom_emoji” stickers only.
*
* @var string[]
*/
protected $keywords;

/**
* @return string
*/
public function getSticker()
{
return $this->sticker;
}

/**
* @param string $sticker
* @return void
*/
public function setSticker(string $sticker)
{
$this->sticker = $sticker;
}

/**
* @return string
*/
public function getFormat()
{
return $this->format;
}

/**
* @param string $format
* @return void
*/
public function setFormat(string $format)
{
$this->format = $format;
}

/**
* @return string[]
*/
public function getEmojiList()
{
return $this->emojiList;
}

/**
* @param string[] $emojiList
* @return void
*/
public function setEmojiList(array $emojiList)
{
$this->emojiList = $emojiList;
}

/**
* @return MaskPosition|null
*/
public function getMaskPosition()
{
return $this->maskPosition;
}

/**
* @param MaskPosition|null $maskPosition
* @return void
*/
public function setMaskPosition($maskPosition)
{
$this->maskPosition = $maskPosition;
}

/**
* @return string[]
*/
public function getKeywords()
{
return $this->keywords;
}

/**
* @param string[] $keywords
* @return void
*/
public function setKeywords(array $keywords)
{
$this->keywords = $keywords;
}
}
101 changes: 101 additions & 0 deletions src/Types/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class Update extends BaseType implements TypeInterface
'message_reaction_count' => MessageReactionCountUpdated::class,
'chat_boost' => ChatBoostUpdated::class,
'chat_boost_removed' => ChatBoostRemoved::class,
'business_connection' => BusinessConnection::class,
'business_message' => Message::class,
'edited_business_message' => Message::class,
'deleted_business_messages' => BusinessMessagesDeleted::class
];

/**
Expand Down Expand Up @@ -198,6 +202,35 @@ class Update extends BaseType implements TypeInterface
*/
protected $chatBoostRemoved;

/**
* Optional. The bot was connected to or disconnected from a business account,
* or a user edited an existing connection with the bot
*
* @var BusinessConnection|null
*/
protected $businessConnection;

/**
* Optional. New message from a connected business account
*
* @var Message|null
*/
protected $businessMessage;

/**
* Optional. New version of a message from a connected business account
*
* @var Message|null
*/
protected $editedBusinessMessage;

/**
* Optional. Messages were deleted from a connected business account
*
* @var BusinessMessagesDeleted|null
*/
protected $deletedBusinessMessages;

/**
* @return int
*/
Expand Down Expand Up @@ -540,4 +573,72 @@ public function setChatBoostRemoved($chatBoostRemoved)
{
$this->chatBoostRemoved = $chatBoostRemoved;
}

/**
* @return BusinessConnection|null
*/
public function getBusinessConnection()
{
return $this->businessConnection;
}

/**
* @param BusinessConnection|null $businessConnection
* @return void
*/
public function setBusinessConnection($businessConnection)
{
$this->businessConnection = $businessConnection;
}

/**
* @return Message|null
*/
public function getBusinessMessage()
{
return $this->businessMessage;
}

/**
* @param Message|null $businessMessage
* @return void
*/
public function setBusinessMessage($businessMessage)
{
$this->businessMessage = $businessMessage;
}

/**
* @return Message|null
*/
public function getEditedBusinessMessage()
{
return $this->editedBusinessMessage;
}

/**
* @param Message|null $editedBusinessMessage
* @return void
*/
public function setEditedBusinessMessage($editedBusinessMessage)
{
$this->editedBusinessMessage = $editedBusinessMessage;
}

/**
* @return BusinessMessagesDeleted|null
*/
public function getDeletedBusinessMessages()
{
return $this->deletedBusinessMessages;
}

/**
* @param BusinessMessagesDeleted|null $deletedBusinessMessages
* @return void
*/
public function setDeletedBusinessMessages($deletedBusinessMessages)
{
$this->deletedBusinessMessages = $deletedBusinessMessages;
}
}
58 changes: 58 additions & 0 deletions tests/Types/BusinessConnectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace TelegramBot\Api\Test\Types;

use TelegramBot\Api\Test\AbstractTypeTest;
use TelegramBot\Api\Types\BusinessConnection;

class BusinessConnectionTest extends AbstractTypeTest
{
protected static function getType()
{
return BusinessConnection::class;
}

public static function getMinResponse()
{
return [
'id' => 1,
'user' => UserTest::getMinResponse(),
'user_chat_id' => 1,
'date' => 1682343643,
'can_reply' => true,
'is_enabled' => true
];
}

public static function getFullResponse()
{
return [
'id' => 1,
'user' => UserTest::getMinResponse(),
'user_chat_id' => 1,
'date' => 1682343643,
'can_reply' => true,
'is_enabled' => true
];
}

protected function assertMinItem($item)
{
$this->assertEquals(1, $item->getId());
$this->assertEquals(UserTest::createMinInstance(), $item->getUser());
$this->assertEquals(1, $item->getUserChatId());
$this->assertEquals(1682343643, $item->getDate());
$this->assertTrue($item->getCanReply());
$this->assertTrue($item->getIsEnabled());
}

protected function assertFullItem($item)
{
$this->assertEquals(1, $item->getId());
$this->assertEquals(UserTest::createMinInstance(), $item->getUser());
$this->assertEquals(1, $item->getUserChatId());
$this->assertEquals(1682343643, $item->getDate());
$this->assertTrue($item->getCanReply());
$this->assertTrue($item->getIsEnabled());
}
}
Loading
Loading