Skip to content

Commit bbc0f16

Browse files
author
eldarQa
committed
Update sendVoice & sendDice methods
1 parent dafad7c commit bbc0f16

File tree

2 files changed

+54
-12
lines changed

2 files changed

+54
-12
lines changed

src/BotApi.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,17 @@ public function sendAnimation(
812812
* On success, the sent Message is returned.
813813
* Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
814814
*
815-
* @param int|string $chatId chat_id or @channel_name
815+
* @param int|string $chatId chat_id or @channel_name
816816
* @param \CURLFile|string $voice
817-
* @param int|null $duration
818-
* @param int|null $replyToMessageId
817+
* @param string $caption Voice message caption, 0-1024 characters after entities parsing
818+
* @param int|null $duration
819+
* @param int|null $replyToMessageId
819820
* @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply|
820821
* Types\ReplyKeyboardRemove|null $replyMarkup
821-
* @param bool $disableNotification
822-
* @param string|null $parseMode
822+
* @param bool $disableNotification
823+
* @param bool $allowSendingWithoutReply Pass True, if the message should be sent even if the specified
824+
* replied-to message is not found
825+
* @param string|null $parseMode
823826
*
824827
* @return \TelegramBot\Api\Types\Message
825828
* @throws \TelegramBot\Api\InvalidArgumentException
@@ -828,19 +831,23 @@ public function sendAnimation(
828831
public function sendVoice(
829832
$chatId,
830833
$voice,
834+
$caption = null,
831835
$duration = null,
832836
$replyToMessageId = null,
833837
$replyMarkup = null,
834838
$disableNotification = false,
839+
$allowSendingWithoutReply = false,
835840
$parseMode = null
836841
) {
837842
return Message::fromResponse($this->call('sendVoice', [
838843
'chat_id' => $chatId,
839844
'voice' => $voice,
845+
'caption' => $caption,
840846
'duration' => $duration,
841847
'reply_to_message_id' => $replyToMessageId,
842848
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(),
843849
'disable_notification' => (bool)$disableNotification,
850+
'allow_sending_without_reply' => $allowSendingWithoutReply,
844851
'parse_mode' => $parseMode
845852
]));
846853
}
@@ -1943,28 +1950,38 @@ public function sendPoll(
19431950
* On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die.
19441951
* But it's awkward, and we decided to help it change. One dice at a time!)
19451952
*
1946-
* @param $chatId string|int Unique identifier for the target chat or username of the target channel
1953+
* @param $chatId string|int Unique identifier for the target chat or username of the target channel
19471954
* (in the format @channelusername)
1955+
* @param $emoji string Emoji on which the dice throw animation is based. Currently, must be one of “🎲”,
1956+
* “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and
1957+
* values 1-64 for “🎰”. Defaults to “🎲
19481958
* @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound.
19491959
* @param null $replyToMessageId If the message is a reply, ID of the original message
1960+
* @param bool $$allowSendingWithoutReply Pass True, if the message should be sent even if the specified replied-to
1961+
* message is not found,
19501962
* @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard,
19511963
* custom reply keyboard, instructions to remove reply
19521964
* keyboard or to force a reply from the user.
1965+
*
19531966
* @return bool|Message
19541967
* @throws Exception
19551968
* @throws HttpException
19561969
* @throws InvalidJsonException
19571970
*/
19581971
public function sendDice(
19591972
$chatId,
1973+
$emoji,
19601974
$disableNotification = false,
19611975
$replyToMessageId = null,
1976+
$allowSendingWithoutReply = false,
19621977
$replyMarkup = null
19631978
) {
19641979
return Message::fromResponse($this->call('sendDice', [
19651980
'chat_id' => $chatId,
1981+
'emoji' => $emoji,
19661982
'disable_notification' => (bool) $disableNotification,
19671983
'reply_to_message_id' => (int) $replyToMessageId,
1984+
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply,
19681985
'reply_markup' => $replyMarkup === null ? $replyMarkup : $replyMarkup->toJson(),
19691986
]));
19701987
}

src/Types/Voice.php

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,36 @@ class Voice extends BaseType implements TypeInterface
1919
*
2020
* @var array
2121
*/
22-
static protected $requiredParams = ['file_id', 'duration'];
22+
static protected $requiredParams = ['file_id', 'file_unique_id', 'duration'];
2323

2424
/**
2525
* {@inheritdoc}
2626
*
2727
* @var array
2828
*/
2929
static protected $map = [
30-
'file_id' => true,
31-
'duration' => true,
32-
'mime_type' => true,
33-
'file_size' => true
30+
'file_id' => true,
31+
'file_unique_id' => true,
32+
'duration' => true,
33+
'mime_type' => true,
34+
'file_size' => true,
3435
];
3536

3637
/**
37-
* Unique identifier for this file
38+
* Identifier for this file, which can be used to download or reuse the file
3839
*
3940
* @var string
4041
*/
4142
protected $fileId;
4243

44+
/**
45+
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be
46+
* used to download or reuse the file.
47+
*
48+
* @var string
49+
*/
50+
protected $fileUniqueId;
51+
4352
/**
4453
* Duration of the audio in seconds as defined by sender
4554
*
@@ -77,6 +86,22 @@ public function setFileId($fileId)
7786
$this->fileId = $fileId;
7887
}
7988

89+
/**
90+
* @return string
91+
*/
92+
public function getFileUniqueId()
93+
{
94+
return $this->fileUniqueId;
95+
}
96+
97+
/**
98+
* @param string $fileUniqueId
99+
*/
100+
public function setFileUniqueId($fileUniqueId)
101+
{
102+
$this->fileUniqueId = $fileUniqueId;
103+
}
104+
80105
/**
81106
* @return int
82107
*/

0 commit comments

Comments
 (0)