diff --git a/src/Client.php b/src/Client.php index 81f5d99..5573fdd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -11,7 +11,7 @@ abstract class Client { * @param array $parameters * @return mixed */ - abstract public function _rawApiCall(string $method, array $parameters); + abstract public function _apiCall(string $method, array $parameters); /** @@ -36,7 +36,7 @@ abstract public function _rawApiCall(string $method, array $parameters); * @param string[] $allowedUpdates * A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, * “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available - * update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the + * update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the * previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the * getUpdates, so unwanted updates may be received for a short period of time. * @@ -56,7 +56,7 @@ public function getUpdates( 'allowed_updates' => $allowedUpdates, ]; - return $this->_rawApiCall('getUpdates', $requestParameters); + return $this->_apiCall('getUpdates', $requestParameters); } /** @@ -75,6 +75,9 @@ public function getUpdates( * Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide * for details. * + * @param string $ipAddress + * The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS + * * @param int $maxConnections * Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults * to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput. @@ -82,50 +85,62 @@ public function getUpdates( * @param string[] $allowedUpdates * A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, * “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available - * update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the + * update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the * previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the * setWebhook, so unwanted updates may be received for a short period of time. * + * @param bool $dropPendingUpdates + * Pass True to drop all pending updates + * * @return mixed */ public function setWebhook( string $url, Type\AbstractInputFile $certificate = null, + string $ipAddress = null, int $maxConnections = null, - array $allowedUpdates = null + array $allowedUpdates = null, + bool $dropPendingUpdates = null ) { $requestParameters = [ 'url' => $url, 'certificate' => $certificate, + 'ip_address' => $ipAddress, 'max_connections' => $maxConnections, 'allowed_updates' => $allowedUpdates, + 'drop_pending_updates' => $dropPendingUpdates, ]; - return $this->_rawApiCall('setWebhook', $requestParameters); + return $this->_apiCall('setWebhook', $requestParameters); } /** * https://core.telegram.org/bots/api#deletewebhook * - * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. Requires no parameters. + * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. + * + * @param bool $dropPendingUpdates + * Pass True to drop all pending updates * * @return mixed */ public function deleteWebhook( + bool $dropPendingUpdates = null ) { $requestParameters = [ + 'drop_pending_updates' => $dropPendingUpdates, ]; - return $this->_rawApiCall('deleteWebhook', $requestParameters); + return $this->_apiCall('deleteWebhook', $requestParameters); } /** * https://core.telegram.org/bots/api#getwebhookinfo * - * Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will - * return an object with the url field empty. + * Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url + * field empty. * * @return mixed */ @@ -135,7 +150,7 @@ public function getWebhookInfo( $requestParameters = [ ]; - return $this->_rawApiCall('getWebhookInfo', $requestParameters); + return $this->_apiCall('getWebhookInfo', $requestParameters); } /** @@ -152,7 +167,44 @@ public function getMe( $requestParameters = [ ]; - return $this->_rawApiCall('getMe', $requestParameters); + return $this->_apiCall('getMe', $requestParameters); + } + + /** + * https://core.telegram.org/bots/api#logout + * + * Use this method to log out from the cloud Bot API server before launching the bot locally. You must + * log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a + * successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 + * minutes. Returns True on success. Requires no parameters. + * + * @return mixed + */ + public function logOut( + ) + { + $requestParameters = [ + ]; + + return $this->_apiCall('logOut', $requestParameters); + } + + /** + * https://core.telegram.org/bots/api#close + * + * Use this method to close the bot instance before moving it from one local server to another. You need to delete the + * webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return + * error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters. + * + * @return mixed + */ + public function close( + ) + { + $requestParameters = [ + ]; + + return $this->_apiCall('close', $requestParameters); } /** @@ -169,6 +221,9 @@ public function getMe( * @param string $parseMode * Mode for parsing entities in the message text. See formatting options for more details. * + * @param Type\MessageEntity[] $entities + * List of special entities that appear in message text, which can be specified instead of parse_mode + * * @param bool $disableWebPagePreview * Disables link previews for links in this message * @@ -178,6 +233,9 @@ public function getMe( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -188,9 +246,11 @@ public function sendMessage( $chatId, string $text, string $parseMode = null, + array $entities = null, bool $disableWebPagePreview = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -198,19 +258,21 @@ public function sendMessage( 'chat_id' => $chatId, 'text' => $text, 'parse_mode' => $parseMode, + 'entities' => $entities, 'disable_web_page_preview' => $disableWebPagePreview, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendMessage', $requestParameters); + return $this->_apiCall('sendMessage', $requestParameters); } /** * https://core.telegram.org/bots/api#forwardmessage * - * Use this method to forward messages of any kind. On success, the sent Message is returned. + * Use this method to forward messages of any kind. Service messages can't be forwarded. On success, the sent Message is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -241,7 +303,78 @@ public function forwardMessage( 'message_id' => $messageId, ]; - return $this->_rawApiCall('forwardMessage', $requestParameters); + return $this->_apiCall('forwardMessage', $requestParameters); + } + + /** + * https://core.telegram.org/bots/api#copymessage + * + * Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. The method is + * analogous to the method forwardMessage, but the copied message doesn't have a link to the + * original message. Returns the MessageId of the sent message on success. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @param int|string $fromChatId + * Unique identifier for the chat where the original message was sent (or channel username in the format + * @|channelusername) + * + * @param int $messageId + * Message identifier in the chat specified in from_chat_id + * + * @param string $caption + * New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is + * kept + * + * @param string $parseMode + * Mode for parsing entities in the new caption. See formatting options for more details. + * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the new caption, which can be specified instead of parse_mode + * + * @param bool $disableNotification + * Sends the message silently. Users will receive a notification with no sound. + * + * @param int $replyToMessageId + * If the message is a reply, ID of the original message + * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * + * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup + * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, + * instructions to remove reply keyboard or to force a reply from the user. + * + * @return mixed + */ + public function copyMessage( + $chatId, + $fromChatId, + int $messageId, + string $caption = null, + string $parseMode = null, + array $captionEntities = null, + bool $disableNotification = null, + int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, + $replyMarkup = null + ) + { + $requestParameters = [ + 'chat_id' => $chatId, + 'from_chat_id' => $fromChatId, + 'message_id' => $messageId, + 'caption' => $caption, + 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, + 'disable_notification' => $disableNotification, + 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, + 'reply_markup' => $replyMarkup, + ]; + + return $this->_apiCall('copyMessage', $requestParameters); } /** @@ -255,7 +388,8 @@ public function forwardMessage( * @param Type\AbstractInputFile|string $photo * Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an * HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. - * More info on Sending Files » + * The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height + * ratio must be at most 20. More info on Sending Files » * * @param string $caption * Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing @@ -263,12 +397,18 @@ public function forwardMessage( * @param string $parseMode * Mode for parsing entities in the photo caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -280,8 +420,10 @@ public function sendPhoto( $photo, string $caption = null, string $parseMode = null, + array $captionEntities = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -290,21 +432,22 @@ public function sendPhoto( 'photo' => $photo, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendPhoto', $requestParameters); + return $this->_apiCall('sendPhoto', $requestParameters); } /** * https://core.telegram.org/bots/api#sendaudio * * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must - * be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For - * sending voice messages, use the sendVoice method - * instead. + * be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently + * send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the sendVoice method instead. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -320,6 +463,9 @@ public function sendPhoto( * @param string $parseMode * Mode for parsing entities in the audio caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param int $duration * Duration of the audio in seconds * @@ -342,6 +488,9 @@ public function sendPhoto( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -353,12 +502,14 @@ public function sendAudio( $audio, string $caption = null, string $parseMode = null, + array $captionEntities = null, int $duration = null, string $performer = null, string $title = null, $thumb = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -367,22 +518,25 @@ public function sendAudio( 'audio' => $audio, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'duration' => $duration, 'performer' => $performer, 'title' => $title, 'thumb' => $thumb, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendAudio', $requestParameters); + return $this->_apiCall('sendAudio', $requestParameters); } /** * https://core.telegram.org/bots/api#senddocument * - * 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. + * 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. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -406,12 +560,21 @@ public function sendAudio( * @param string $parseMode * Mode for parsing entities in the document caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @param bool $disableContentTypeDetection + * Disables automatic server-side content type detection for files uploaded using multipart/form-data + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -424,8 +587,11 @@ public function sendDocument( $thumb = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, + bool $disableContentTypeDetection = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -435,19 +601,22 @@ public function sendDocument( 'thumb' => $thumb, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, + 'disable_content_type_detection' => $disableContentTypeDetection, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendDocument', $requestParameters); + return $this->_apiCall('sendDocument', $requestParameters); } /** * https://core.telegram.org/bots/api#sendvideo * - * 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. + * 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. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -479,6 +648,9 @@ public function sendDocument( * @param string $parseMode * Mode for parsing entities in the video caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param bool $supportsStreaming * Pass True, if the uploaded video is suitable for streaming * @@ -488,6 +660,9 @@ public function sendDocument( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -503,9 +678,11 @@ public function sendVideo( $thumb = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, bool $supportsStreaming = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -518,13 +695,15 @@ public function sendVideo( 'thumb' => $thumb, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'supports_streaming' => $supportsStreaming, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendVideo', $requestParameters); + return $this->_apiCall('sendVideo', $requestParameters); } /** @@ -563,12 +742,18 @@ public function sendVideo( * @param string $parseMode * Mode for parsing entities in the animation caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -584,8 +769,10 @@ public function sendAnimation( $thumb = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -598,19 +785,23 @@ public function sendAnimation( 'thumb' => $thumb, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendAnimation', $requestParameters); + return $this->_apiCall('sendAnimation', $requestParameters); } /** * https://core.telegram.org/bots/api#sendvoice * * 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. + * 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. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -626,6 +817,9 @@ public function sendAnimation( * @param string $parseMode * Mode for parsing entities in the voice message caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param int $duration * Duration of the voice message in seconds * @@ -635,6 +829,9 @@ public function sendAnimation( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -646,9 +843,11 @@ public function sendVoice( $voice, string $caption = null, string $parseMode = null, + array $captionEntities = null, int $duration = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -657,13 +856,15 @@ public function sendVoice( 'voice' => $voice, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'duration' => $duration, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendVoice', $requestParameters); + return $this->_apiCall('sendVoice', $requestParameters); } /** @@ -699,6 +900,9 @@ public function sendVoice( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -713,6 +917,7 @@ public function sendVideoNote( $thumb = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -724,36 +929,43 @@ public function sendVideoNote( 'thumb' => $thumb, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendVideoNote', $requestParameters); + return $this->_apiCall('sendVideoNote', $requestParameters); } /** * https://core.telegram.org/bots/api#sendmediagroup * - * Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned. + * Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be + * only grouped in an album with messages of the same type. On success, an array of Messages that + * were sent is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * - * @param Type\InputMediaPhoto[]|Type\InputMediaVideo[] $media - * A JSON-serialized array describing photos and videos to be sent, must include 2-10 items + * @param Type\InputMediaAudio[]|Type\InputMediaDocument[]|Type\InputMediaPhoto[]|Type\InputMediaVideo[] $media + * A JSON-serialized array describing messages to be sent, must include 2-10 items * * @param bool $disableNotification - * Sends the messages silently. Users will receive a notification with no sound. + * Sends messages silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the messages are a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @return mixed */ public function sendMediaGroup( $chatId, $media, bool $disableNotification = null, - int $replyToMessageId = null + int $replyToMessageId = null, + bool $allowSendingWithoutReply = null ) { $requestParameters = [ @@ -761,9 +973,10 @@ public function sendMediaGroup( 'media' => $media, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, ]; - return $this->_rawApiCall('sendMediaGroup', $requestParameters); + return $this->_apiCall('sendMediaGroup', $requestParameters); } /** @@ -780,15 +993,28 @@ public function sendMediaGroup( * @param float $longitude * Longitude of the location * + * @param float $horizontalAccuracy + * The radius of uncertainty for the location, measured in meters; 0-1500 + * * @param int $livePeriod * Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400. * + * @param int $heading + * For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. + * + * @param int $proximityAlertRadius + * For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. + * Must be between 1 and 100000 if specified. + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -799,9 +1025,13 @@ public function sendLocation( $chatId, float $latitude, float $longitude, + float $horizontalAccuracy = null, int $livePeriod = null, + int $heading = null, + int $proximityAlertRadius = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -809,20 +1039,26 @@ public function sendLocation( 'chat_id' => $chatId, 'latitude' => $latitude, 'longitude' => $longitude, + 'horizontal_accuracy' => $horizontalAccuracy, 'live_period' => $livePeriod, + 'heading' => $heading, + 'proximity_alert_radius' => $proximityAlertRadius, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendLocation', $requestParameters); + return $this->_apiCall('sendLocation', $requestParameters); } /** * https://core.telegram.org/bots/api#editmessagelivelocation * * Use this method to edit live location messages. A location can be edited until its live_period expires or - * editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned. + * editing is explicitly disabled by a call to stopMessageLiveLocation. On + * success, if the edited message is not an inline message, the edited Message is returned, otherwise + * True is returned. * * @param float $latitude * Latitude of new location @@ -840,6 +1076,16 @@ public function sendLocation( * @param string $inlineMessageId * Required if chat_id and message_id are not specified. Identifier of the inline message * + * @param float $horizontalAccuracy + * The radius of uncertainty for the location, measured in meters; 0-1500 + * + * @param int $heading + * Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. + * + * @param int $proximityAlertRadius + * Maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and + * 100000 if specified. + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for a new inline keyboard. * @@ -851,6 +1097,9 @@ public function editMessageLiveLocation( $chatId = null, int $messageId = null, string $inlineMessageId = null, + float $horizontalAccuracy = null, + int $heading = null, + int $proximityAlertRadius = null, Type\InlineKeyboardMarkup $replyMarkup = null ) { @@ -860,18 +1109,20 @@ public function editMessageLiveLocation( 'inline_message_id' => $inlineMessageId, 'latitude' => $latitude, 'longitude' => $longitude, + 'horizontal_accuracy' => $horizontalAccuracy, + 'heading' => $heading, + 'proximity_alert_radius' => $proximityAlertRadius, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('editMessageLiveLocation', $requestParameters); + return $this->_apiCall('editMessageLiveLocation', $requestParameters); } /** * https://core.telegram.org/bots/api#stopmessagelivelocation * * Use this method to stop updating a live location message before live_period expires. On success, if the - * message was sent by the bot, the sent Message is returned, - * otherwise True is returned. + * message was sent by the bot, the sent Message is returned, otherwise True is returned. * * @param int|string $chatId * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the @@ -902,13 +1153,14 @@ public function stopMessageLiveLocation( 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('stopMessageLiveLocation', $requestParameters); + return $this->_apiCall('stopMessageLiveLocation', $requestParameters); } /** * https://core.telegram.org/bots/api#sendvenue * - * Use this method to send information about a venue. On success, the sent Message is returned. + * Use this method to send information about a venue. On success, the sent Message is + * returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -932,12 +1184,21 @@ public function stopMessageLiveLocation( * Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, * “arts_entertainment/aquarium” or “food/icecream”.) * + * @param string $googlePlaceId + * Google Places identifier of the venue + * + * @param string $googlePlaceType + * Google Places type of the venue. (See supported types.) + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -952,8 +1213,11 @@ public function sendVenue( string $address, string $foursquareId = null, string $foursquareType = null, + string $googlePlaceId = null, + string $googlePlaceType = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -965,12 +1229,15 @@ public function sendVenue( 'address' => $address, 'foursquare_id' => $foursquareId, 'foursquare_type' => $foursquareType, + 'google_place_id' => $googlePlaceId, + 'google_place_type' => $googlePlaceType, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendVenue', $requestParameters); + return $this->_apiCall('sendVenue', $requestParameters); } /** @@ -999,6 +1266,9 @@ public function sendVenue( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove keyboard or to force a reply from the user. @@ -1013,6 +1283,7 @@ public function sendContact( string $vcard = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -1024,10 +1295,11 @@ public function sendContact( 'vcard' => $vcard, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendContact', $requestParameters); + return $this->_apiCall('sendContact', $requestParameters); } /** @@ -1038,46 +1310,52 @@ public function sendContact( * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * - * @param string $question - * Poll question, 1-255 characters - * * @param string[] $options * A JSON-serialized list of answer options, 2-10 strings 1-100 characters each * - * @param bool $isAnonymous - * True, if the poll needs to be anonymous, defaults to True + * @param string $question + * Poll question, 1-300 characters * - * @param string $type - * Poll type, “quiz” or “regular”, defaults to “regular” + * @param int $openPeriod + * Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date. * - * @param bool $allowsMultipleAnswers - * True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found * - * @param int $correctOptionId - * 0-based identifier of the correct answer option, required for polls in quiz mode - * - * @param string $explanation - * Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 - * characters with at most 2 line feeds after entities parsing + * @param int $replyToMessageId + * If the message is a reply, ID of the original message * - * @param string $explanationParseMode - * Mode for parsing entities in the explanation. See formatting options for more details. + * @param bool $disableNotification + * Sends the message silently. Users will receive a notification with no sound. * - * @param int $openPeriod - * Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date. + * @param bool $isClosed + * Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. * * @param int $closeDate * Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 * seconds in the future. Can't be used together with open_period. * - * @param bool $isClosed - * Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. + * @param string $explanationParseMode + * Mode for parsing entities in the explanation. See formatting options for more details. * - * @param bool $disableNotification - * Sends the message silently. Users will receive a notification with no sound. + * @param Type\MessageEntity[] $explanationEntities + * List of special entities that appear in the poll explanation, which can be specified instead of parse_mode * - * @param int $replyToMessageId - * If the message is a reply, ID of the original message + * @param string $explanation + * Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 + * characters with at most 2 line feeds after entities parsing + * + * @param int $correctOptionId + * 0-based identifier of the correct answer option, required for polls in quiz mode + * + * @param bool $allowsMultipleAnswers + * True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False + * + * @param string $type + * Poll type, “quiz” or “regular”, defaults to “regular” + * + * @param bool $isAnonymous + * True, if the poll needs to be anonymous, defaults to True * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, @@ -1087,19 +1365,21 @@ public function sendContact( */ public function sendPoll( $chatId, - string $question, array $options, - bool $isAnonymous = null, - string $type = null, - bool $allowsMultipleAnswers = null, - int $correctOptionId = null, - string $explanation = null, - string $explanationParseMode = null, + string $question, int $openPeriod = null, - int $closeDate = null, - bool $isClosed = null, - bool $disableNotification = null, + bool $allowSendingWithoutReply = null, int $replyToMessageId = null, + bool $disableNotification = null, + bool $isClosed = null, + int $closeDate = null, + string $explanationParseMode = null, + array $explanationEntities = null, + string $explanation = null, + int $correctOptionId = null, + bool $allowsMultipleAnswers = null, + string $type = null, + bool $isAnonymous = null, $replyMarkup = null ) { @@ -1113,15 +1393,17 @@ public function sendPoll( 'correct_option_id' => $correctOptionId, 'explanation' => $explanation, 'explanation_parse_mode' => $explanationParseMode, + 'explanation_entities' => $explanationEntities, 'open_period' => $openPeriod, 'close_date' => $closeDate, 'is_closed' => $isClosed, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendPoll', $requestParameters); + return $this->_apiCall('sendPoll', $requestParameters); } /** @@ -1133,8 +1415,9 @@ public function sendPoll( * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * * @param string $emoji - * Emoji on which the dice throw animation is based. Currently, must be one of “”, “”, or “”. Dice can - * have values 1-6 for “” and “”, and values 1-5 for “”. Defaults to “” + * Emoji on which the dice throw animation is based. Currently, must be one of “”, “”, “”, “”, + * “”, or “”. Dice can have values 1-6 for “”, “” and “”, values 1-5 for “” and “”, and values + * 1-64 for “”. Defaults to “” * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. @@ -1142,6 +1425,9 @@ public function sendPoll( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -1153,6 +1439,7 @@ public function sendDice( string $emoji = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -1161,10 +1448,11 @@ public function sendDice( 'emoji' => $emoji, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendDice', $requestParameters); + return $this->_apiCall('sendDice', $requestParameters); } /** @@ -1180,8 +1468,8 @@ public function sendDice( * * @param string $action * Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text - * messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio - * files, upload_document for general files, find_location for location data, record_video_note or + * messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice + * notes, upload_document for general files, find_location for location data, record_video_note or * upload_video_note for video notes. * * @return mixed @@ -1196,7 +1484,7 @@ public function sendChatAction( 'action' => $action, ]; - return $this->_rawApiCall('sendChatAction', $requestParameters); + return $this->_apiCall('sendChatAction', $requestParameters); } /** @@ -1227,17 +1515,17 @@ public function getUserProfilePhotos( 'limit' => $limit, ]; - return $this->_rawApiCall('getUserProfilePhotos', $requestParameters); + return $this->_apiCall('getUserProfilePhotos', $requestParameters); } /** * https://core.telegram.org/bots/api#getfile * * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files - * of up to 20MB in size. On success, a File object is - * returned. The file can then be downloaded via the link - * https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for - * at least 1 hour. When the link expires, a new one can be requested by calling getFile again. + * of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the + * link https://api.telegram.org/file/bot<token>/<file_path>, where + * <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new + * one can be requested by calling getFile again. * * @param string $fileId * File identifier to get info about @@ -1252,14 +1540,14 @@ public function getFile( 'file_id' => $fileId, ]; - return $this->_rawApiCall('getFile', $requestParameters); + return $this->_apiCall('getFile', $requestParameters); } /** * https://core.telegram.org/bots/api#kickchatmember * * Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user - * will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. + * will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. * Returns True on success. * * @param int|string $chatId @@ -1271,23 +1559,29 @@ public function getFile( * * @param int $untilDate * Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from - * the current time they are considered to be banned forever + * the current time they are considered to be banned forever. Applied for supergroups and channels only. + * + * @param bool $revokeMessages + * Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to + * see messages in the group that were sent before the user was removed. Always True for supergroups and channels. * * @return mixed */ public function kickChatMember( $chatId, int $userId, - int $untilDate = null + int $untilDate = null, + bool $revokeMessages = null ) { $requestParameters = [ 'chat_id' => $chatId, 'user_id' => $userId, 'until_date' => $untilDate, + 'revoke_messages' => $revokeMessages, ]; - return $this->_rawApiCall('kickChatMember', $requestParameters); + return $this->_apiCall('kickChatMember', $requestParameters); } /** @@ -1295,7 +1589,9 @@ public function kickChatMember( * * Use this method to unban a previously kicked user in a supergroup or channel. The user will not * return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this - * to work. Returns True on success. + * to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to + * join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want + * this, use the parameter only_if_banned. Returns True on success. * * @param int|string $chatId * Unique identifier for the target group or username of the target supergroup or channel (in the format @@ -1304,19 +1600,24 @@ public function kickChatMember( * @param int $userId * Unique identifier of the target user * + * @param bool $onlyIfBanned + * Do nothing if the user is not banned + * * @return mixed */ public function unbanChatMember( $chatId, - int $userId + int $userId, + bool $onlyIfBanned = null ) { $requestParameters = [ 'chat_id' => $chatId, 'user_id' => $userId, + 'only_if_banned' => $onlyIfBanned, ]; - return $this->_rawApiCall('unbanChatMember', $requestParameters); + return $this->_apiCall('unbanChatMember', $requestParameters); } /** @@ -1356,7 +1657,7 @@ public function restrictChatMember( 'until_date' => $untilDate, ]; - return $this->_rawApiCall('restrictChatMember', $requestParameters); + return $this->_apiCall('restrictChatMember', $requestParameters); } /** @@ -1372,8 +1673,13 @@ public function restrictChatMember( * @param int $userId * Unique identifier of the target user * - * @param bool $canChangeInfo - * Pass True, if the administrator can change chat title, photo and other settings + * @param bool $isAnonymous + * Pass True, if the administrator's presence in the chat is hidden + * + * @param bool $canManageChat + * Pass True, if the administrator can access the chat event log, chat statistics, message statistics in + * channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other + * administrator privilege * * @param bool $canPostMessages * Pass True, if the administrator can create channel posts, channels only @@ -1384,48 +1690,60 @@ public function restrictChatMember( * @param bool $canDeleteMessages * Pass True, if the administrator can delete messages of other users * - * @param bool $canInviteUsers - * Pass True, if the administrator can invite new users to the chat + * @param bool $canManageVoiceChats + * Pass True, if the administrator can manage voice chats * * @param bool $canRestrictMembers * Pass True, if the administrator can restrict, ban or unban chat members * - * @param bool $canPinMessages - * Pass True, if the administrator can pin messages, supergroups only - * * @param bool $canPromoteMembers * Pass True, if the administrator can add new administrators with a subset of their own privileges or demote * administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) * + * @param bool $canChangeInfo + * Pass True, if the administrator can change chat title, photo and other settings + * + * @param bool $canInviteUsers + * Pass True, if the administrator can invite new users to the chat + * + * @param bool $canPinMessages + * Pass True, if the administrator can pin messages, supergroups only + * * @return mixed */ public function promoteChatMember( $chatId, int $userId, - bool $canChangeInfo = null, + bool $isAnonymous = null, + bool $canManageChat = null, bool $canPostMessages = null, bool $canEditMessages = null, bool $canDeleteMessages = null, - bool $canInviteUsers = null, + bool $canManageVoiceChats = null, bool $canRestrictMembers = null, - bool $canPinMessages = null, - bool $canPromoteMembers = null + bool $canPromoteMembers = null, + bool $canChangeInfo = null, + bool $canInviteUsers = null, + bool $canPinMessages = null ) { $requestParameters = [ 'chat_id' => $chatId, 'user_id' => $userId, - 'can_change_info' => $canChangeInfo, + 'is_anonymous' => $isAnonymous, + 'can_manage_chat' => $canManageChat, 'can_post_messages' => $canPostMessages, 'can_edit_messages' => $canEditMessages, 'can_delete_messages' => $canDeleteMessages, - 'can_invite_users' => $canInviteUsers, + 'can_manage_voice_chats' => $canManageVoiceChats, 'can_restrict_members' => $canRestrictMembers, - 'can_pin_messages' => $canPinMessages, 'can_promote_members' => $canPromoteMembers, + 'can_change_info' => $canChangeInfo, + 'can_invite_users' => $canInviteUsers, + 'can_pin_messages' => $canPinMessages, ]; - return $this->_rawApiCall('promoteChatMember', $requestParameters); + return $this->_apiCall('promoteChatMember', $requestParameters); } /** @@ -1458,7 +1776,7 @@ public function setChatAdministratorCustomTitle( 'custom_title' => $customTitle, ]; - return $this->_rawApiCall('setChatAdministratorCustomTitle', $requestParameters); + return $this->_apiCall('setChatAdministratorCustomTitle', $requestParameters); } /** @@ -1486,15 +1804,15 @@ public function setChatPermissions( 'permissions' => $permissions, ]; - return $this->_rawApiCall('setChatPermissions', $requestParameters); + return $this->_apiCall('setChatPermissions', $requestParameters); } /** * https://core.telegram.org/bots/api#exportchatinvitelink * - * Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an - * administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as - * String on success. + * Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. + * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new + * invite link as String on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -1509,7 +1827,106 @@ public function exportChatInviteLink( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('exportChatInviteLink', $requestParameters); + return $this->_apiCall('exportChatInviteLink', $requestParameters); + } + + /** + * https://core.telegram.org/bots/api#createchatinvitelink + * + * Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to + * work and must have the appropriate admin rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @param int $expireDate + * Point in time (Unix timestamp) when the link will expire + * + * @param int $memberLimit + * Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite + * link; 1-99999 + * + * @return mixed + */ + public function createChatInviteLink( + $chatId, + int $expireDate = null, + int $memberLimit = null + ) + { + $requestParameters = [ + 'chat_id' => $chatId, + 'expire_date' => $expireDate, + 'member_limit' => $memberLimit, + ]; + + return $this->_apiCall('createChatInviteLink', $requestParameters); + } + + /** + * https://core.telegram.org/bots/api#editchatinvitelink + * + * Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for + * this to work and must have the appropriate admin rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @param string $inviteLink + * The invite link to edit + * + * @param int $expireDate + * Point in time (Unix timestamp) when the link will expire + * + * @param int $memberLimit + * Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite + * link; 1-99999 + * + * @return mixed + */ + public function editChatInviteLink( + $chatId, + string $inviteLink, + int $expireDate = null, + int $memberLimit = null + ) + { + $requestParameters = [ + 'chat_id' => $chatId, + 'invite_link' => $inviteLink, + 'expire_date' => $expireDate, + 'member_limit' => $memberLimit, + ]; + + return $this->_apiCall('editChatInviteLink', $requestParameters); + } + + /** + * https://core.telegram.org/bots/api#revokechatinvitelink + * + * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically + * generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the + * revoked invite link as ChatInviteLink object. + * + * @param int|string $chatId + * Unique identifier of the target chat or username of the target channel (in the format @|channelusername) + * + * @param string $inviteLink + * The invite link to revoke + * + * @return mixed + */ + public function revokeChatInviteLink( + $chatId, + string $inviteLink + ) + { + $requestParameters = [ + 'chat_id' => $chatId, + 'invite_link' => $inviteLink, + ]; + + return $this->_apiCall('revokeChatInviteLink', $requestParameters); } /** @@ -1536,7 +1953,7 @@ public function setChatPhoto( 'photo' => $photo, ]; - return $this->_rawApiCall('setChatPhoto', $requestParameters); + return $this->_apiCall('setChatPhoto', $requestParameters); } /** @@ -1558,7 +1975,7 @@ public function deleteChatPhoto( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('deleteChatPhoto', $requestParameters); + return $this->_apiCall('deleteChatPhoto', $requestParameters); } /** @@ -1585,7 +2002,7 @@ public function setChatTitle( 'title' => $title, ]; - return $this->_rawApiCall('setChatTitle', $requestParameters); + return $this->_apiCall('setChatTitle', $requestParameters); } /** @@ -1612,15 +2029,15 @@ public function setChatDescription( 'description' => $description, ]; - return $this->_rawApiCall('setChatDescription', $requestParameters); + return $this->_apiCall('setChatDescription', $requestParameters); } /** * https://core.telegram.org/bots/api#pinchatmessage * - * Use this method to pin a message in a group, 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. + * Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be + * an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or + * 'can_edit_messages' admin right in a channel. Returns True on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -1630,7 +2047,7 @@ public function setChatDescription( * * @param bool $disableNotification * Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. - * Notifications are always disabled in channels. + * Notifications are always disabled in channels and private chats. * * @return mixed */ @@ -1646,22 +2063,51 @@ public function pinChatMessage( 'disable_notification' => $disableNotification, ]; - return $this->_rawApiCall('pinChatMessage', $requestParameters); + return $this->_apiCall('pinChatMessage', $requestParameters); } /** * https://core.telegram.org/bots/api#unpinchatmessage * - * Use this method to unpin a message in a group, 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. + * Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot + * must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or + * 'can_edit_messages' admin right in a channel. Returns True on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * + * @param int $messageId + * Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be + * unpinned. + * * @return mixed */ public function unpinChatMessage( + $chatId, + int $messageId = null + ) + { + $requestParameters = [ + 'chat_id' => $chatId, + 'message_id' => $messageId, + ]; + + return $this->_apiCall('unpinChatMessage', $requestParameters); + } + + /** + * https://core.telegram.org/bots/api#unpinallchatmessages + * + * Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an + * administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' + * admin right in a channel. Returns True on success. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @return mixed + */ + public function unpinAllChatMessages( $chatId ) { @@ -1669,7 +2115,7 @@ public function unpinChatMessage( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('unpinChatMessage', $requestParameters); + return $this->_apiCall('unpinAllChatMessages', $requestParameters); } /** @@ -1691,7 +2137,7 @@ public function leaveChat( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('leaveChat', $requestParameters); + return $this->_apiCall('leaveChat', $requestParameters); } /** @@ -1714,7 +2160,7 @@ public function getChat( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('getChat', $requestParameters); + return $this->_apiCall('getChat', $requestParameters); } /** @@ -1737,7 +2183,7 @@ public function getChatAdministrators( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('getChatAdministrators', $requestParameters); + return $this->_apiCall('getChatAdministrators', $requestParameters); } /** @@ -1759,13 +2205,14 @@ public function getChatMembersCount( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('getChatMembersCount', $requestParameters); + return $this->_apiCall('getChatMembersCount', $requestParameters); } /** * https://core.telegram.org/bots/api#getchatmember * - * Use this method to get information about a member of a chat. Returns a ChatMember object on success. + * Use this method to get information about a member of a chat. Returns a ChatMember object + * on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target supergroup or channel (in the format @@ -1786,7 +2233,7 @@ public function getChatMember( 'user_id' => $userId, ]; - return $this->_rawApiCall('getChatMember', $requestParameters); + return $this->_apiCall('getChatMember', $requestParameters); } /** @@ -1814,7 +2261,7 @@ public function setChatStickerSet( 'sticker_set_name' => $stickerSetName, ]; - return $this->_rawApiCall('setChatStickerSet', $requestParameters); + return $this->_apiCall('setChatStickerSet', $requestParameters); } /** @@ -1837,7 +2284,7 @@ public function deleteChatStickerSet( 'chat_id' => $chatId, ]; - return $this->_rawApiCall('deleteChatStickerSet', $requestParameters); + return $this->_apiCall('deleteChatStickerSet', $requestParameters); } /** @@ -1883,7 +2330,7 @@ public function answerCallbackQuery( 'cache_time' => $cacheTime, ]; - return $this->_rawApiCall('answerCallbackQuery', $requestParameters); + return $this->_apiCall('answerCallbackQuery', $requestParameters); } /** @@ -1905,7 +2352,7 @@ public function setMyCommands( 'commands' => $commands, ]; - return $this->_rawApiCall('setMyCommands', $requestParameters); + return $this->_apiCall('setMyCommands', $requestParameters); } /** @@ -1921,14 +2368,14 @@ public function getMyCommands( $requestParameters = [ ]; - return $this->_rawApiCall('getMyCommands', $requestParameters); + return $this->_apiCall('getMyCommands', $requestParameters); } /** * https://core.telegram.org/bots/api#editmessagetext * - * Use this method to edit text and game messages. On - * success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. + * Use this method to edit text and game messages. On success, if the edited message is not an + * inline message, the edited Message is returned, otherwise True is returned. * * @param string $text * New text of the message, 1-4096 characters after entities parsing @@ -1946,6 +2393,9 @@ public function getMyCommands( * @param string $parseMode * Mode for parsing entities in the message text. See formatting options for more details. * + * @param Type\MessageEntity[] $entities + * List of special entities that appear in message text, which can be specified instead of parse_mode + * * @param bool $disableWebPagePreview * Disables link previews for links in this message * @@ -1960,6 +2410,7 @@ public function editMessageText( int $messageId = null, string $inlineMessageId = null, string $parseMode = null, + array $entities = null, bool $disableWebPagePreview = null, Type\InlineKeyboardMarkup $replyMarkup = null ) @@ -1970,17 +2421,18 @@ public function editMessageText( 'inline_message_id' => $inlineMessageId, 'text' => $text, 'parse_mode' => $parseMode, + 'entities' => $entities, 'disable_web_page_preview' => $disableWebPagePreview, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('editMessageText', $requestParameters); + return $this->_apiCall('editMessageText', $requestParameters); } /** * https://core.telegram.org/bots/api#editmessagecaption * - * Use this method to edit captions of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. + * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. * * @param int|string $chatId * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the @@ -1998,6 +2450,9 @@ public function editMessageText( * @param string $parseMode * Mode for parsing entities in the message caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for an inline keyboard. * @@ -2009,6 +2464,7 @@ public function editMessageCaption( string $inlineMessageId = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, Type\InlineKeyboardMarkup $replyMarkup = null ) { @@ -2018,21 +2474,23 @@ public function editMessageCaption( 'inline_message_id' => $inlineMessageId, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('editMessageCaption', $requestParameters); + return $this->_apiCall('editMessageCaption', $requestParameters); } /** * https://core.telegram.org/bots/api#editmessagemedia * - * Use this method to edit animation, audio, document, photo, or video messages. If a message is a part of a message - * album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline - * message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, if - * the edited message was sent by the bot, the edited Message is returned, otherwise True is returned. + * Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, + * then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video + * otherwise. When an inline message is edited, a new file can't be uploaded. Use a previously uploaded file via its file_id or + * specify a URL. On success, if the edited message was sent by the bot, the edited Message is returned, + * otherwise True is returned. * - * @param Type\InputMediaAnimation|Type\InputMediaDocument|Type\InputMediaAudio|Type\InputMediaPhoto|Type\InputMediaVideo $media + * @param Type\AbstractInputMedia $media * A JSON-serialized object for a new media content of the message * * @param int|string $chatId @@ -2051,7 +2509,7 @@ public function editMessageCaption( * @return mixed */ public function editMessageMedia( - $media, + Type\AbstractInputMedia $media, $chatId = null, int $messageId = null, string $inlineMessageId = null, @@ -2066,15 +2524,14 @@ public function editMessageMedia( 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('editMessageMedia', $requestParameters); + return $this->_apiCall('editMessageMedia', $requestParameters); } /** * https://core.telegram.org/bots/api#editmessagereplymarkup * - * Use this method to edit only the reply markup of messages. On success, if edited message is sent by the bot, the edited - * Message is returned, otherwise True is - * returned. + * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, + * the edited Message is returned, otherwise True is returned. * * @param int|string $chatId * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the @@ -2105,13 +2562,14 @@ public function editMessageReplyMarkup( 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('editMessageReplyMarkup', $requestParameters); + return $this->_apiCall('editMessageReplyMarkup', $requestParameters); } /** * https://core.telegram.org/bots/api#stoppoll * - * Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned. + * Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the + * final results is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -2136,7 +2594,7 @@ public function stopPoll( 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('stopPoll', $requestParameters); + return $this->_apiCall('stopPoll', $requestParameters); } /** @@ -2168,15 +2626,14 @@ public function deleteMessage( 'message_id' => $messageId, ]; - return $this->_rawApiCall('deleteMessage', $requestParameters); + return $this->_apiCall('deleteMessage', $requestParameters); } /** * https://core.telegram.org/bots/api#sendsticker * * Use this method to send static .WEBP or animated - * .TGS stickers. On success, the sent Message is - * returned. + * .TGS stickers. On success, the sent Message is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -2192,6 +2649,9 @@ public function deleteMessage( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -2203,6 +2663,7 @@ public function sendSticker( $sticker, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ) { @@ -2211,10 +2672,11 @@ public function sendSticker( 'sticker' => $sticker, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendSticker', $requestParameters); + return $this->_apiCall('sendSticker', $requestParameters); } /** @@ -2235,7 +2697,7 @@ public function getStickerSet( 'name' => $name, ]; - return $this->_rawApiCall('getStickerSet', $requestParameters); + return $this->_apiCall('getStickerSet', $requestParameters); } /** @@ -2263,7 +2725,7 @@ public function uploadStickerFile( 'png_sticker' => $pngSticker, ]; - return $this->_rawApiCall('uploadStickerFile', $requestParameters); + return $this->_apiCall('uploadStickerFile', $requestParameters); } /** @@ -2326,7 +2788,7 @@ public function createNewStickerSet( 'mask_position' => $maskPosition, ]; - return $this->_rawApiCall('createNewStickerSet', $requestParameters); + return $this->_apiCall('createNewStickerSet', $requestParameters); } /** @@ -2379,7 +2841,7 @@ public function addStickerToSet( 'mask_position' => $maskPosition, ]; - return $this->_rawApiCall('addStickerToSet', $requestParameters); + return $this->_apiCall('addStickerToSet', $requestParameters); } /** @@ -2405,7 +2867,7 @@ public function setStickerPositionInSet( 'position' => $position, ]; - return $this->_rawApiCall('setStickerPositionInSet', $requestParameters); + return $this->_apiCall('setStickerPositionInSet', $requestParameters); } /** @@ -2426,7 +2888,7 @@ public function deleteStickerFromSet( 'sticker' => $sticker, ]; - return $this->_rawApiCall('deleteStickerFromSet', $requestParameters); + return $this->_apiCall('deleteStickerFromSet', $requestParameters); } /** @@ -2462,7 +2924,7 @@ public function setStickerSetThumb( 'thumb' => $thumb, ]; - return $this->_rawApiCall('setStickerSetThumb', $requestParameters); + return $this->_apiCall('setStickerSetThumb', $requestParameters); } /** @@ -2524,7 +2986,7 @@ public function answerInlineQuery( 'switch_pm_parameter' => $switchPmParameter, ]; - return $this->_rawApiCall('answerInlineQuery', $requestParameters); + return $this->_apiCall('answerInlineQuery', $requestParameters); } /** @@ -2532,8 +2994,8 @@ public function answerInlineQuery( * * Use this method to send invoices. On success, the sent Message is returned. * - * @param int $chatId - * Unique identifier for the target private chat + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * * @param string $description * Product description, 1-255 characters @@ -2545,9 +3007,6 @@ public function answerInlineQuery( * @param string $providerToken * Payments provider token, obtained via Botfather * - * @param string $startParameter - * Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter - * * @param string $currency * Three-letter ISO 4217 currency code, see more on currencies * @@ -2558,8 +3017,11 @@ public function answerInlineQuery( * @param string $title * Product name, 1-32 characters * - * @param bool $needShippingAddress - * Pass True, if you require the user's shipping address to complete the order + * @param bool $needEmail + * Pass True, if you require the user's email address to complete the order + * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found * * @param int $replyToMessageId * If the message is a reply, ID of the original message @@ -2576,12 +3038,12 @@ public function answerInlineQuery( * @param bool $sendPhoneNumberToProvider * Pass True, if user's phone number should be sent to provider * + * @param bool $needShippingAddress + * Pass True, if you require the user's shipping address to complete the order + * * @param int $photoWidth * Photo width * - * @param bool $needEmail - * Pass True, if you require the user's email address to complete the order - * * @param bool $needPhoneNumber * Pass True, if you require the user's phone number to complete the order * @@ -2602,6 +3064,22 @@ public function answerInlineQuery( * A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed * description of required fields should be provided by the payment provider. * + * @param string $startParameter + * Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, + * allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded + * copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used + * as the start parameter + * + * @param int[] $suggestedTipAmounts + * A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not + * float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a + * strictly increased order and must not exceed max_tip_amount. + * + * @param int $maxTipAmount + * The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For + * example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the + * number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not * empty, the first button must be a Pay button. @@ -2609,28 +3087,31 @@ public function answerInlineQuery( * @return mixed */ public function sendInvoice( - int $chatId, + $chatId, string $description, string $payload, string $providerToken, - string $startParameter, string $currency, array $prices, string $title, - bool $needShippingAddress = null, + bool $needEmail = null, + bool $allowSendingWithoutReply = null, int $replyToMessageId = null, bool $disableNotification = null, bool $isFlexible = null, bool $sendEmailToProvider = null, bool $sendPhoneNumberToProvider = null, + bool $needShippingAddress = null, int $photoWidth = null, - bool $needEmail = null, bool $needPhoneNumber = null, bool $needName = null, int $photoHeight = null, int $photoSize = null, string $photoUrl = null, string $providerData = null, + string $startParameter = null, + array $suggestedTipAmounts = null, + int $maxTipAmount = null, Type\InlineKeyboardMarkup $replyMarkup = null ) { @@ -2640,9 +3121,11 @@ public function sendInvoice( 'description' => $description, 'payload' => $payload, 'provider_token' => $providerToken, - 'start_parameter' => $startParameter, 'currency' => $currency, 'prices' => $prices, + 'max_tip_amount' => $maxTipAmount, + 'suggested_tip_amounts' => $suggestedTipAmounts, + 'start_parameter' => $startParameter, 'provider_data' => $providerData, 'photo_url' => $photoUrl, 'photo_size' => $photoSize, @@ -2657,18 +3140,19 @@ public function sendInvoice( 'is_flexible' => $isFlexible, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendInvoice', $requestParameters); + return $this->_apiCall('sendInvoice', $requestParameters); } /** * https://core.telegram.org/bots/api#answershippingquery * * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot - * API will send an Update with a - * shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * API will send an Update with a shipping_query field to the bot. Use this method to + * reply to shipping queries. On success, True is returned. * * @param string $shippingQueryId * Unique identifier for the query to be answered @@ -2701,16 +3185,16 @@ public function answerShippingQuery( 'error_message' => $errorMessage, ]; - return $this->_rawApiCall('answerShippingQuery', $requestParameters); + return $this->_apiCall('answerShippingQuery', $requestParameters); } /** * https://core.telegram.org/bots/api#answerprecheckoutquery * * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form - * of an Update with the field - * pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The - * Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * of an Update with the field pre_checkout_query. Use this method to respond to such + * pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds + * after the pre-checkout query was sent. * * @param string $preCheckoutQueryId * Unique identifier for the query to be answered @@ -2739,7 +3223,7 @@ public function answerPreCheckoutQuery( 'error_message' => $errorMessage, ]; - return $this->_rawApiCall('answerPreCheckoutQuery', $requestParameters); + return $this->_apiCall('answerPreCheckoutQuery', $requestParameters); } /** @@ -2754,14 +3238,14 @@ public function answerPreCheckoutQuery( * @param int $userId * User identifier * - * @param Type\PassportElementErrorDataField[]|Type\PassportElementErrorFrontSide[]|Type\PassportElementErrorReverseSide[]|Type\PassportElementErrorSelfie[]|Type\PassportElementErrorFile[]|Type\PassportElementErrorFiles[]|Type\PassportElementErrorTranslationFile[]|Type\PassportElementErrorTranslationFiles[]|Type\PassportElementErrorUnspecified[] $errors + * @param Type\AbstractPassportElementError[] $errors * A JSON-serialized array describing the errors * * @return mixed */ public function setPassportDataErrors( int $userId, - $errors + array $errors ) { $requestParameters = [ @@ -2769,7 +3253,7 @@ public function setPassportDataErrors( 'errors' => $errors, ]; - return $this->_rawApiCall('setPassportDataErrors', $requestParameters); + return $this->_apiCall('setPassportDataErrors', $requestParameters); } /** @@ -2789,6 +3273,9 @@ public function setPassportDataErrors( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not * empty, the first button must launch the game. @@ -2800,6 +3287,7 @@ public function sendGame( string $gameShortName, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, Type\InlineKeyboardMarkup $replyMarkup = null ) { @@ -2808,19 +3296,19 @@ public function sendGame( 'game_short_name' => $gameShortName, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; - return $this->_rawApiCall('sendGame', $requestParameters); + return $this->_apiCall('sendGame', $requestParameters); } /** * https://core.telegram.org/bots/api#setgamescore * * Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns - * the edited Message, otherwise returns - * True. Returns an error, if the new score is not greater than the user's current score in the chat and force is - * False. + * the edited Message, otherwise returns True. Returns an error, if the new score is + * not greater than the user's current score in the chat and force is False. * * @param int $userId * User identifier @@ -2865,7 +3353,7 @@ public function setGameScore( 'inline_message_id' => $inlineMessageId, ]; - return $this->_rawApiCall('setGameScore', $requestParameters); + return $this->_apiCall('setGameScore', $requestParameters); } /** @@ -2902,6 +3390,6 @@ public function getGameHighScores( 'inline_message_id' => $inlineMessageId, ]; - return $this->_rawApiCall('getGameHighScores', $requestParameters); + return $this->_apiCall('getGameHighScores', $requestParameters); } } \ No newline at end of file diff --git a/src/Type/AbstractInlineQueryResult.php b/src/Type/AbstractInlineQueryResult.php index 275505d..9b04c4d 100644 --- a/src/Type/AbstractInlineQueryResult.php +++ b/src/Type/AbstractInlineQueryResult.php @@ -2,4 +2,4 @@ namespace MadmagesTelegram\Types\Type; -abstract class AbstractInlineQueryResult {} \ No newline at end of file +abstract class AbstractInlineQueryResult extends AbstractType {} \ No newline at end of file diff --git a/src/Type/AbstractInputMedia.php b/src/Type/AbstractInputMedia.php index 3a0a367..86c94f0 100644 --- a/src/Type/AbstractInputMedia.php +++ b/src/Type/AbstractInputMedia.php @@ -2,4 +2,4 @@ namespace MadmagesTelegram\Types\Type; -abstract class AbstractInputMedia {} \ No newline at end of file +abstract class AbstractInputMedia extends AbstractType {} \ No newline at end of file diff --git a/src/Type/AbstractInputMessageContent.php b/src/Type/AbstractInputMessageContent.php index 71f3ceb..1068c8f 100644 --- a/src/Type/AbstractInputMessageContent.php +++ b/src/Type/AbstractInputMessageContent.php @@ -2,4 +2,4 @@ namespace MadmagesTelegram\Types\Type; -abstract class AbstractInputMessageContent {} \ No newline at end of file +abstract class AbstractInputMessageContent extends AbstractType {} \ No newline at end of file diff --git a/src/Type/AbstractPassportElementError.php b/src/Type/AbstractPassportElementError.php index 22bee89..6aaf6a4 100644 --- a/src/Type/AbstractPassportElementError.php +++ b/src/Type/AbstractPassportElementError.php @@ -2,4 +2,4 @@ namespace MadmagesTelegram\Types\Type; -abstract class AbstractPassportElementError {} \ No newline at end of file +abstract class AbstractPassportElementError extends AbstractType {} \ No newline at end of file diff --git a/src/Type/AbstractType.php b/src/Type/AbstractType.php index 68366cd..53406f3 100644 --- a/src/Type/AbstractType.php +++ b/src/Type/AbstractType.php @@ -16,6 +16,15 @@ abstract public static function _getPropertyNames(): array; * * @return array */ - abstract public function _getRawData(): array; + abstract public function _getData(): array; + + protected function normalizeData(array $data):array { + array_filter($data); + array_walk_recursive($data, static function(&$item){ + $item = $item instanceof AbstractType ? $item->_getData(): $item; + }); + + return $data; + } } \ No newline at end of file diff --git a/src/Type/Animation.php b/src/Type/Animation.php index dd4d33b..9367384 100644 --- a/src/Type/Animation.php +++ b/src/Type/Animation.php @@ -45,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -59,10 +59,7 @@ public function _getRawData(): array 'file_size' => $this->getFileSize(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Audio.php b/src/Type/Audio.php index 08ce238..33b18db 100644 --- a/src/Type/Audio.php +++ b/src/Type/Audio.php @@ -33,6 +33,7 @@ public static function _getPropertyNames(): array 'duration', 'performer', 'title', + 'file_name', 'mime_type', 'file_size', 'thumb', @@ -44,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -52,15 +53,13 @@ public function _getRawData(): array 'duration' => $this->getDuration(), 'performer' => $this->getPerformer(), 'title' => $this->getTitle(), + 'file_name' => $this->getFileName(), 'mime_type' => $this->getMimeType(), 'file_size' => $this->getFileSize(), 'thumb' => $this->getThumb(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -116,6 +115,17 @@ public function _getRawData(): array */ protected $title; + /** + * Optional. Original filename as defined by sender + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("file_name") + * @Accessor(getter="getFileName",setter="setFileName") + * @Type("string") + */ + protected $fileName; + /** * Optional. MIME type of the file as defined by sender * @@ -245,6 +255,25 @@ public function getTitle(): ?string return $this->title; } + /** + * @param string $fileName + * @return static + */ + public function setFileName(string $fileName): self + { + $this->fileName = $fileName; + + return $this; + } + + /** + * @return string|null + */ + public function getFileName(): ?string + { + return $this->fileName; + } + /** * @param string $mimeType * @return static diff --git a/src/Type/BotCommand.php b/src/Type/BotCommand.php index 3bea105..101e744 100644 --- a/src/Type/BotCommand.php +++ b/src/Type/BotCommand.php @@ -38,17 +38,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'command' => $this->getCommand(), 'description' => $this->getDescription(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/CallbackQuery.php b/src/Type/CallbackQuery.php index db2f9ab..13cc5de 100644 --- a/src/Type/CallbackQuery.php +++ b/src/Type/CallbackQuery.php @@ -13,7 +13,8 @@ * https://core.telegram.org/bots/api#callbackquery * * This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field - * message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or + * message will be present. If the button was attached to a message sent via the bot (in inline + * mode), the field inline_message_id will be present. Exactly one of the fields data or * game_short_name will be present. * * @ExclusionPolicy("none") @@ -45,7 +46,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), @@ -57,10 +58,7 @@ public function _getRawData(): array 'game_short_name' => $this->getGameShortName(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Chat.php b/src/Type/Chat.php index 5939c20..7d75cab 100644 --- a/src/Type/Chat.php +++ b/src/Type/Chat.php @@ -35,13 +35,17 @@ public static function _getPropertyNames(): array 'first_name', 'last_name', 'photo', + 'bio', 'description', 'invite_link', 'pinned_message', 'permissions', 'slow_mode_delay', + 'message_auto_delete_time', 'sticker_set_name', 'can_set_sticker_set', + 'linked_chat_id', + 'location', ]; } @@ -50,7 +54,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), @@ -60,25 +64,26 @@ public function _getRawData(): array 'first_name' => $this->getFirstName(), 'last_name' => $this->getLastName(), 'photo' => $this->getPhoto(), + 'bio' => $this->getBio(), 'description' => $this->getDescription(), 'invite_link' => $this->getInviteLink(), 'pinned_message' => $this->getPinnedMessage(), 'permissions' => $this->getPermissions(), 'slow_mode_delay' => $this->getSlowModeDelay(), + 'message_auto_delete_time' => $this->getMessageAutoDeleteTime(), 'sticker_set_name' => $this->getStickerSetName(), 'can_set_sticker_set' => $this->getCanSetStickerSet(), + 'linked_chat_id' => $this->getLinkedChatId(), + 'location' => $this->getLocation(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** - * 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 is smaller than 52 bits, so a signed 64 bit integer or double-precision float type - * are safe for storing this identifier. + * Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages + * may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit + * integer or double-precision float type are safe for storing this identifier. * * @var int * @SerializedName("id") @@ -152,6 +157,17 @@ public function _getRawData(): array */ protected $photo; + /** + * Optional. Bio of the other party in a private chat. Returned only in getChat. + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("bio") + * @Accessor(getter="getBio",setter="setBio") + * @Type("string") + */ + protected $bio; + /** * Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. * @@ -164,8 +180,7 @@ public function _getRawData(): array protected $description; /** - * Optional. Chat invite link, for groups, supergroups and channel chats. Each administrator in a chat generates - * their own invite links, so the bot must first generate the link using exportChatInviteLink. Returned only in getChat. + * Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. * * @var string|null * @SkipWhenEmpty @@ -176,7 +191,7 @@ public function _getRawData(): array protected $inviteLink; /** - * Optional. Pinned message, for groups, supergroups and channels. Returned only in getChat. + * Optional. The most recent pinned message (by sending date). Returned only in getChat. * * @var Message|null * @SkipWhenEmpty @@ -209,6 +224,18 @@ public function _getRawData(): array */ protected $slowModeDelay; + /** + * Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned + * only in getChat. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("message_auto_delete_time") + * @Accessor(getter="getMessageAutoDeleteTime",setter="setMessageAutoDeleteTime") + * @Type("int") + */ + protected $messageAutoDeleteTime; + /** * Optional. For supergroups, name of group sticker set. Returned only in getChat. * @@ -231,6 +258,31 @@ public function _getRawData(): array */ protected $canSetStickerSet; + /** + * Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; + * for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have + * difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type + * are safe for storing this identifier. Returned only in getChat. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("linked_chat_id") + * @Accessor(getter="getLinkedChatId",setter="setLinkedChatId") + * @Type("int") + */ + protected $linkedChatId; + + /** + * Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. + * + * @var ChatLocation|null + * @SkipWhenEmpty + * @SerializedName("location") + * @Accessor(getter="getLocation",setter="setLocation") + * @Type("MadmagesTelegram\Types\Type\ChatLocation") + */ + protected $location; + /** * @param int $id @@ -365,6 +417,25 @@ public function getPhoto(): ?ChatPhoto return $this->photo; } + /** + * @param string $bio + * @return static + */ + public function setBio(string $bio): self + { + $this->bio = $bio; + + return $this; + } + + /** + * @return string|null + */ + public function getBio(): ?string + { + return $this->bio; + } + /** * @param string $description * @return static @@ -460,6 +531,25 @@ public function getSlowModeDelay(): ?int return $this->slowModeDelay; } + /** + * @param int $messageAutoDeleteTime + * @return static + */ + public function setMessageAutoDeleteTime(int $messageAutoDeleteTime): self + { + $this->messageAutoDeleteTime = $messageAutoDeleteTime; + + return $this; + } + + /** + * @return int|null + */ + public function getMessageAutoDeleteTime(): ?int + { + return $this->messageAutoDeleteTime; + } + /** * @param string $stickerSetName * @return static @@ -498,4 +588,42 @@ public function getCanSetStickerSet(): ?bool return $this->canSetStickerSet; } + /** + * @param int $linkedChatId + * @return static + */ + public function setLinkedChatId(int $linkedChatId): self + { + $this->linkedChatId = $linkedChatId; + + return $this; + } + + /** + * @return int|null + */ + public function getLinkedChatId(): ?int + { + return $this->linkedChatId; + } + + /** + * @param ChatLocation $location + * @return static + */ + public function setLocation(ChatLocation $location): self + { + $this->location = $location; + + return $this; + } + + /** + * @return ChatLocation|null + */ + public function getLocation(): ?ChatLocation + { + return $this->location; + } + } \ No newline at end of file diff --git a/src/Type/ChatInviteLink.php b/src/Type/ChatInviteLink.php new file mode 100644 index 0000000..c811c49 --- /dev/null +++ b/src/Type/ChatInviteLink.php @@ -0,0 +1,238 @@ + $this->getInviteLink(), + 'creator' => $this->getCreator(), + 'is_primary' => $this->getIsPrimary(), + 'is_revoked' => $this->getIsRevoked(), + 'expire_date' => $this->getExpireDate(), + 'member_limit' => $this->getMemberLimit(), + ]; + + return parent::normalizeData($result); + } + + /** + * The invite link. If the link was created by another chat administrator, then the second part of the link will be + * replaced with “…”. + * + * @var string + * @SerializedName("invite_link") + * @Accessor(getter="getInviteLink",setter="setInviteLink") + * @Type("string") + */ + protected $inviteLink; + + /** + * Creator of the link + * + * @var User + * @SerializedName("creator") + * @Accessor(getter="getCreator",setter="setCreator") + * @Type("MadmagesTelegram\Types\Type\User") + */ + protected $creator; + + /** + * True, if the link is primary + * + * @var bool + * @SerializedName("is_primary") + * @Accessor(getter="getIsPrimary",setter="setIsPrimary") + * @Type("bool") + */ + protected $isPrimary; + + /** + * True, if the link is revoked + * + * @var bool + * @SerializedName("is_revoked") + * @Accessor(getter="getIsRevoked",setter="setIsRevoked") + * @Type("bool") + */ + protected $isRevoked; + + /** + * Optional. Point in time (Unix timestamp) when the link will expire or has been expired + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("expire_date") + * @Accessor(getter="getExpireDate",setter="setExpireDate") + * @Type("int") + */ + protected $expireDate; + + /** + * Optional. Maximum number of users that can be members of the chat simultaneously after joining the chat via this + * invite link; 1-99999 + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("member_limit") + * @Accessor(getter="getMemberLimit",setter="setMemberLimit") + * @Type("int") + */ + protected $memberLimit; + + + /** + * @param string $inviteLink + * @return static + */ + public function setInviteLink(string $inviteLink): self + { + $this->inviteLink = $inviteLink; + + return $this; + } + + /** + * @return string + */ + public function getInviteLink(): string + { + return $this->inviteLink; + } + + /** + * @param User $creator + * @return static + */ + public function setCreator(User $creator): self + { + $this->creator = $creator; + + return $this; + } + + /** + * @return User + */ + public function getCreator(): User + { + return $this->creator; + } + + /** + * @param bool $isPrimary + * @return static + */ + public function setIsPrimary(bool $isPrimary): self + { + $this->isPrimary = $isPrimary; + + return $this; + } + + /** + * @return bool + */ + public function getIsPrimary(): bool + { + return $this->isPrimary; + } + + /** + * @param bool $isRevoked + * @return static + */ + public function setIsRevoked(bool $isRevoked): self + { + $this->isRevoked = $isRevoked; + + return $this; + } + + /** + * @return bool + */ + public function getIsRevoked(): bool + { + return $this->isRevoked; + } + + /** + * @param int $expireDate + * @return static + */ + public function setExpireDate(int $expireDate): self + { + $this->expireDate = $expireDate; + + return $this; + } + + /** + * @return int|null + */ + public function getExpireDate(): ?int + { + return $this->expireDate; + } + + /** + * @param int $memberLimit + * @return static + */ + public function setMemberLimit(int $memberLimit): self + { + $this->memberLimit = $memberLimit; + + return $this; + } + + /** + * @return int|null + */ + public function getMemberLimit(): ?int + { + return $this->memberLimit; + } + +} \ No newline at end of file diff --git a/src/Type/ChatLocation.php b/src/Type/ChatLocation.php new file mode 100644 index 0000000..ce39918 --- /dev/null +++ b/src/Type/ChatLocation.php @@ -0,0 +1,110 @@ + $this->getLocation(), + 'address' => $this->getAddress(), + ]; + + return parent::normalizeData($result); + } + + /** + * The location to which the supergroup is connected. Can't be a live location. + * + * @var Location + * @SerializedName("location") + * @Accessor(getter="getLocation",setter="setLocation") + * @Type("MadmagesTelegram\Types\Type\Location") + */ + protected $location; + + /** + * Location address; 1-64 characters, as defined by the chat owner + * + * @var string + * @SerializedName("address") + * @Accessor(getter="getAddress",setter="setAddress") + * @Type("string") + */ + protected $address; + + + /** + * @param Location $location + * @return static + */ + public function setLocation(Location $location): self + { + $this->location = $location; + + return $this; + } + + /** + * @return Location + */ + public function getLocation(): Location + { + return $this->location; + } + + /** + * @param string $address + * @return static + */ + public function setAddress(string $address): self + { + $this->address = $address; + + return $this; + } + + /** + * @return string + */ + public function getAddress(): string + { + return $this->address; + } + +} \ No newline at end of file diff --git a/src/Type/ChatMember.php b/src/Type/ChatMember.php index d962bb0..7736464 100644 --- a/src/Type/ChatMember.php +++ b/src/Type/ChatMember.php @@ -31,11 +31,13 @@ public static function _getPropertyNames(): array 'user', 'status', 'custom_title', - 'until_date', + 'is_anonymous', 'can_be_edited', + 'can_manage_chat', 'can_post_messages', 'can_edit_messages', 'can_delete_messages', + 'can_manage_voice_chats', 'can_restrict_members', 'can_promote_members', 'can_change_info', @@ -47,6 +49,7 @@ public static function _getPropertyNames(): array 'can_send_polls', 'can_send_other_messages', 'can_add_web_page_previews', + 'until_date', ]; } @@ -55,17 +58,19 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'user' => $this->getUser(), 'status' => $this->getStatus(), 'custom_title' => $this->getCustomTitle(), - 'until_date' => $this->getUntilDate(), + 'is_anonymous' => $this->getIsAnonymous(), 'can_be_edited' => $this->getCanBeEdited(), + 'can_manage_chat' => $this->getCanManageChat(), 'can_post_messages' => $this->getCanPostMessages(), 'can_edit_messages' => $this->getCanEditMessages(), 'can_delete_messages' => $this->getCanDeleteMessages(), + 'can_manage_voice_chats' => $this->getCanManageVoiceChats(), 'can_restrict_members' => $this->getCanRestrictMembers(), 'can_promote_members' => $this->getCanPromoteMembers(), 'can_change_info' => $this->getCanChangeInfo(), @@ -77,12 +82,10 @@ public function _getRawData(): array 'can_send_polls' => $this->getCanSendPolls(), 'can_send_other_messages' => $this->getCanSendOtherMessages(), 'can_add_web_page_previews' => $this->getCanAddWebPagePreviews(), + 'until_date' => $this->getUntilDate(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -118,15 +121,15 @@ public function _getRawData(): array protected $customTitle; /** - * Optional. Restricted and kicked only. Date when restrictions will be lifted for this user; unix time + * Optional. Owner and administrators only. True, if the user's presence in the chat is hidden * - * @var int|null + * @var bool|null * @SkipWhenEmpty - * @SerializedName("until_date") - * @Accessor(getter="getUntilDate",setter="setUntilDate") - * @Type("int") + * @SerializedName("is_anonymous") + * @Accessor(getter="getIsAnonymous",setter="setIsAnonymous") + * @Type("bool") */ - protected $untilDate; + protected $isAnonymous; /** * Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user @@ -139,6 +142,19 @@ public function _getRawData(): array */ protected $canBeEdited; + /** + * Optional. Administrators only. True, if the administrator can access the chat event log, chat statistics, message + * statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any + * other administrator privilege + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("can_manage_chat") + * @Accessor(getter="getCanManageChat",setter="setCanManageChat") + * @Type("bool") + */ + protected $canManageChat; + /** * Optional. Administrators only. True, if the administrator can post in the channel; channels only * @@ -173,6 +189,17 @@ public function _getRawData(): array */ protected $canDeleteMessages; + /** + * Optional. Administrators only. True, if the administrator can manage voice chats + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("can_manage_voice_chats") + * @Accessor(getter="getCanManageVoiceChats",setter="setCanManageVoiceChats") + * @Type("bool") + */ + protected $canManageVoiceChats; + /** * Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members * @@ -299,6 +326,17 @@ public function _getRawData(): array */ protected $canAddWebPagePreviews; + /** + * Optional. Restricted and kicked only. Date when restrictions will be lifted for this user; unix time + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("until_date") + * @Accessor(getter="getUntilDate",setter="setUntilDate") + * @Type("int") + */ + protected $untilDate; + /** * @param User $user @@ -358,22 +396,22 @@ public function getCustomTitle(): ?string } /** - * @param int $untilDate + * @param bool $isAnonymous * @return static */ - public function setUntilDate(int $untilDate): self + public function setIsAnonymous(bool $isAnonymous): self { - $this->untilDate = $untilDate; + $this->isAnonymous = $isAnonymous; return $this; } /** - * @return int|null + * @return bool|null */ - public function getUntilDate(): ?int + public function getIsAnonymous(): ?bool { - return $this->untilDate; + return $this->isAnonymous; } /** @@ -395,6 +433,25 @@ public function getCanBeEdited(): ?bool return $this->canBeEdited; } + /** + * @param bool $canManageChat + * @return static + */ + public function setCanManageChat(bool $canManageChat): self + { + $this->canManageChat = $canManageChat; + + return $this; + } + + /** + * @return bool|null + */ + public function getCanManageChat(): ?bool + { + return $this->canManageChat; + } + /** * @param bool $canPostMessages * @return static @@ -452,6 +509,25 @@ public function getCanDeleteMessages(): ?bool return $this->canDeleteMessages; } + /** + * @param bool $canManageVoiceChats + * @return static + */ + public function setCanManageVoiceChats(bool $canManageVoiceChats): self + { + $this->canManageVoiceChats = $canManageVoiceChats; + + return $this; + } + + /** + * @return bool|null + */ + public function getCanManageVoiceChats(): ?bool + { + return $this->canManageVoiceChats; + } + /** * @param bool $canRestrictMembers * @return static @@ -661,4 +737,23 @@ public function getCanAddWebPagePreviews(): ?bool return $this->canAddWebPagePreviews; } + /** + * @param int $untilDate + * @return static + */ + public function setUntilDate(int $untilDate): self + { + $this->untilDate = $untilDate; + + return $this; + } + + /** + * @return int|null + */ + public function getUntilDate(): ?int + { + return $this->untilDate; + } + } \ No newline at end of file diff --git a/src/Type/ChatMemberUpdated.php b/src/Type/ChatMemberUpdated.php new file mode 100644 index 0000000..8c5f316 --- /dev/null +++ b/src/Type/ChatMemberUpdated.php @@ -0,0 +1,235 @@ + $this->getChat(), + 'from' => $this->getFrom(), + 'date' => $this->getDate(), + 'old_chat_member' => $this->getOldChatMember(), + 'new_chat_member' => $this->getNewChatMember(), + 'invite_link' => $this->getInviteLink(), + ]; + + return parent::normalizeData($result); + } + + /** + * Chat the user belongs to + * + * @var Chat + * @SerializedName("chat") + * @Accessor(getter="getChat",setter="setChat") + * @Type("MadmagesTelegram\Types\Type\Chat") + */ + protected $chat; + + /** + * Performer of the action, which resulted in the change + * + * @var User + * @SerializedName("from") + * @Accessor(getter="getFrom",setter="setFrom") + * @Type("MadmagesTelegram\Types\Type\User") + */ + protected $from; + + /** + * Date the change was done in Unix time + * + * @var int + * @SerializedName("date") + * @Accessor(getter="getDate",setter="setDate") + * @Type("int") + */ + protected $date; + + /** + * Previous information about the chat member + * + * @var ChatMember + * @SerializedName("old_chat_member") + * @Accessor(getter="getOldChatMember",setter="setOldChatMember") + * @Type("MadmagesTelegram\Types\Type\ChatMember") + */ + protected $oldChatMember; + + /** + * New information about the chat member + * + * @var ChatMember + * @SerializedName("new_chat_member") + * @Accessor(getter="getNewChatMember",setter="setNewChatMember") + * @Type("MadmagesTelegram\Types\Type\ChatMember") + */ + protected $newChatMember; + + /** + * Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. + * + * @var ChatInviteLink|null + * @SkipWhenEmpty + * @SerializedName("invite_link") + * @Accessor(getter="getInviteLink",setter="setInviteLink") + * @Type("MadmagesTelegram\Types\Type\ChatInviteLink") + */ + protected $inviteLink; + + + /** + * @param Chat $chat + * @return static + */ + public function setChat(Chat $chat): self + { + $this->chat = $chat; + + return $this; + } + + /** + * @return Chat + */ + public function getChat(): Chat + { + return $this->chat; + } + + /** + * @param User $from + * @return static + */ + public function setFrom(User $from): self + { + $this->from = $from; + + return $this; + } + + /** + * @return User + */ + public function getFrom(): User + { + return $this->from; + } + + /** + * @param int $date + * @return static + */ + public function setDate(int $date): self + { + $this->date = $date; + + return $this; + } + + /** + * @return int + */ + public function getDate(): int + { + return $this->date; + } + + /** + * @param ChatMember $oldChatMember + * @return static + */ + public function setOldChatMember(ChatMember $oldChatMember): self + { + $this->oldChatMember = $oldChatMember; + + return $this; + } + + /** + * @return ChatMember + */ + public function getOldChatMember(): ChatMember + { + return $this->oldChatMember; + } + + /** + * @param ChatMember $newChatMember + * @return static + */ + public function setNewChatMember(ChatMember $newChatMember): self + { + $this->newChatMember = $newChatMember; + + return $this; + } + + /** + * @return ChatMember + */ + public function getNewChatMember(): ChatMember + { + return $this->newChatMember; + } + + /** + * @param ChatInviteLink $inviteLink + * @return static + */ + public function setInviteLink(ChatInviteLink $inviteLink): self + { + $this->inviteLink = $inviteLink; + + return $this; + } + + /** + * @return ChatInviteLink|null + */ + public function getInviteLink(): ?ChatInviteLink + { + return $this->inviteLink; + } + +} \ No newline at end of file diff --git a/src/Type/ChatPermissions.php b/src/Type/ChatPermissions.php index 0d9f55d..0818a98 100644 --- a/src/Type/ChatPermissions.php +++ b/src/Type/ChatPermissions.php @@ -44,7 +44,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'can_send_messages' => $this->getCanSendMessages(), @@ -57,10 +57,7 @@ public function _getRawData(): array 'can_pin_messages' => $this->getCanPinMessages(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ChatPhoto.php b/src/Type/ChatPhoto.php index 344e497..4b98f74 100644 --- a/src/Type/ChatPhoto.php +++ b/src/Type/ChatPhoto.php @@ -40,7 +40,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'small_file_id' => $this->getSmallFileId(), @@ -49,10 +49,7 @@ public function _getRawData(): array 'big_file_unique_id' => $this->getBigFileUniqueId(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ChosenInlineResult.php b/src/Type/ChosenInlineResult.php index 6c80cba..797d574 100644 --- a/src/Type/ChosenInlineResult.php +++ b/src/Type/ChosenInlineResult.php @@ -12,8 +12,8 @@ /** * https://core.telegram.org/bots/api#choseninlineresult * - * Represents a result of an inline query - * that was chosen by the user and sent to their chat partner. + * Represents a result of an inline query that was chosen by the user and sent to + * their chat partner. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'result_id' => $this->getResultId(), @@ -52,10 +52,7 @@ public function _getRawData(): array 'query' => $this->getQuery(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Contact.php b/src/Type/Contact.php index 9cc6dda..c0c4bef 100644 --- a/src/Type/Contact.php +++ b/src/Type/Contact.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'phone_number' => $this->getPhoneNumber(), @@ -51,10 +51,7 @@ public function _getRawData(): array 'vcard' => $this->getVcard(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -89,7 +86,9 @@ public function _getRawData(): array protected $lastName; /** - * Optional. Contact's user identifier in Telegram + * Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits and some + * programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit + * integer or double-precision float type are safe for storing this identifier. * * @var int|null * @SkipWhenEmpty diff --git a/src/Type/Dice.php b/src/Type/Dice.php index d385b0d..2cd95ec 100644 --- a/src/Type/Dice.php +++ b/src/Type/Dice.php @@ -38,17 +38,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'emoji' => $this->getEmoji(), 'value' => $this->getValue(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -62,7 +59,8 @@ public function _getRawData(): array protected $emoji; /** - * Value of the dice, 1-6 for “” and “” base emoji, 1-5 for “” base emoji + * Value of the dice, 1-6 for “”, “” and “” base emoji, 1-5 for “” and “” base emoji, 1-64 for “” + * base emoji * * @var int * @SerializedName("value") diff --git a/src/Type/Document.php b/src/Type/Document.php index 8dd6feb..3b9358f 100644 --- a/src/Type/Document.php +++ b/src/Type/Document.php @@ -12,7 +12,8 @@ /** * https://core.telegram.org/bots/api#document * - * This object represents a general file (as opposed to photos, voice messages and audio files). + * This object represents a general file (as opposed to photos, voice + * messages and audio files). * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -42,7 +43,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -53,10 +54,7 @@ public function _getRawData(): array 'file_size' => $this->getFileSize(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/EncryptedCredentials.php b/src/Type/EncryptedCredentials.php index bf6a5b1..97cfecd 100644 --- a/src/Type/EncryptedCredentials.php +++ b/src/Type/EncryptedCredentials.php @@ -40,7 +40,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'data' => $this->getData(), @@ -48,10 +48,7 @@ public function _getRawData(): array 'secret' => $this->getSecret(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/EncryptedPassportElement.php b/src/Type/EncryptedPassportElement.php index 601a819..f08127c 100644 --- a/src/Type/EncryptedPassportElement.php +++ b/src/Type/EncryptedPassportElement.php @@ -46,7 +46,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -61,10 +61,7 @@ public function _getRawData(): array 'hash' => $this->getHash(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/File.php b/src/Type/File.php index 0ceb879..54079dd 100644 --- a/src/Type/File.php +++ b/src/Type/File.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -51,10 +51,7 @@ public function _getRawData(): array 'file_path' => $this->getFilePath(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ForceReply.php b/src/Type/ForceReply.php index 409eed1..ac5a29d 100644 --- a/src/Type/ForceReply.php +++ b/src/Type/ForceReply.php @@ -14,8 +14,7 @@ * * Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the * user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly - * step-by-step interfaces without having to sacrifice privacy - * mode. + * step-by-step interfaces without having to sacrifice privacy mode. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -41,17 +40,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'force_reply' => $this->getForceReply(), 'selective' => $this->getSelective(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Game.php b/src/Type/Game.php index 1cb0676..103b25d 100644 --- a/src/Type/Game.php +++ b/src/Type/Game.php @@ -43,7 +43,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'title' => $this->getTitle(), @@ -54,10 +54,7 @@ public function _getRawData(): array 'animation' => $this->getAnimation(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/GameHighScore.php b/src/Type/GameHighScore.php index c057e94..ce1be86 100644 --- a/src/Type/GameHighScore.php +++ b/src/Type/GameHighScore.php @@ -39,7 +39,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'position' => $this->getPosition(), @@ -47,10 +47,7 @@ public function _getRawData(): array 'score' => $this->getScore(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InlineKeyboardButton.php b/src/Type/InlineKeyboardButton.php index ae6433e..e55c55b 100644 --- a/src/Type/InlineKeyboardButton.php +++ b/src/Type/InlineKeyboardButton.php @@ -45,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'text' => $this->getText(), @@ -58,10 +58,7 @@ public function _getRawData(): array 'pay' => $this->getPay(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InlineKeyboardMarkup.php b/src/Type/InlineKeyboardMarkup.php index 72f87e5..f4c426f 100644 --- a/src/Type/InlineKeyboardMarkup.php +++ b/src/Type/InlineKeyboardMarkup.php @@ -37,16 +37,13 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'inline_keyboard' => $this->getInlineKeyboard(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InlineQuery.php b/src/Type/InlineQuery.php index 8114659..591f93c 100644 --- a/src/Type/InlineQuery.php +++ b/src/Type/InlineQuery.php @@ -31,9 +31,10 @@ public static function _getPropertyNames(): array return [ 'id', 'from', - 'location', 'query', 'offset', + 'chat_type', + 'location', ]; } @@ -42,20 +43,18 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), 'from' => $this->getFrom(), - 'location' => $this->getLocation(), 'query' => $this->getQuery(), 'offset' => $this->getOffset(), + 'chat_type' => $this->getChatType(), + 'location' => $this->getLocation(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -78,17 +77,6 @@ public function _getRawData(): array */ protected $from; - /** - * Optional. Sender location, only for bots that request user location - * - * @var Location|null - * @SkipWhenEmpty - * @SerializedName("location") - * @Accessor(getter="getLocation",setter="setLocation") - * @Type("MadmagesTelegram\Types\Type\Location") - */ - protected $location; - /** * Text of the query (up to 256 characters) * @@ -109,6 +97,31 @@ public function _getRawData(): array */ protected $offset; + /** + * Optional. Type of the chat, from which the inline query was sent. Can be either “sender” for a private chat with + * the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be + * always known for requests sent from official clients and most third-party clients, unless the request was sent from a + * secret chat + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("chat_type") + * @Accessor(getter="getChatType",setter="setChatType") + * @Type("string") + */ + protected $chatType; + + /** + * Optional. Sender location, only for bots that request user location + * + * @var Location|null + * @SkipWhenEmpty + * @SerializedName("location") + * @Accessor(getter="getLocation",setter="setLocation") + * @Type("MadmagesTelegram\Types\Type\Location") + */ + protected $location; + /** * @param string $id @@ -149,31 +162,31 @@ public function getFrom(): User } /** - * @param Location $location + * @param string $query * @return static */ - public function setLocation(Location $location): self + public function setQuery(string $query): self { - $this->location = $location; + $this->query = $query; return $this; } /** - * @return Location|null + * @return string */ - public function getLocation(): ?Location + public function getQuery(): string { - return $this->location; + return $this->query; } /** - * @param string $query + * @param string $offset * @return static */ - public function setQuery(string $query): self + public function setOffset(string $offset): self { - $this->query = $query; + $this->offset = $offset; return $this; } @@ -181,28 +194,47 @@ public function setQuery(string $query): self /** * @return string */ - public function getQuery(): string + public function getOffset(): string { - return $this->query; + return $this->offset; } /** - * @param string $offset + * @param string $chatType * @return static */ - public function setOffset(string $offset): self + public function setChatType(string $chatType): self { - $this->offset = $offset; + $this->chatType = $chatType; return $this; } /** - * @return string + * @return string|null */ - public function getOffset(): string + public function getChatType(): ?string { - return $this->offset; + return $this->chatType; + } + + /** + * @param Location $location + * @return static + */ + public function setLocation(Location $location): self + { + $this->location = $location; + + return $this; + } + + /** + * @return Location|null + */ + public function getLocation(): ?Location + { + return $this->location; } } \ No newline at end of file diff --git a/src/Type/InlineQueryResultArticle.php b/src/Type/InlineQueryResultArticle.php index 128bd3f..05a9854 100644 --- a/src/Type/InlineQueryResultArticle.php +++ b/src/Type/InlineQueryResultArticle.php @@ -47,7 +47,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -63,10 +63,7 @@ public function _getRawData(): array 'thumb_height' => $this->getThumbHeight(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InlineQueryResultAudio.php b/src/Type/InlineQueryResultAudio.php index 7e9889f..99047c4 100644 --- a/src/Type/InlineQueryResultAudio.php +++ b/src/Type/InlineQueryResultAudio.php @@ -35,6 +35,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'performer', 'audio_duration', 'reply_markup', @@ -47,7 +48,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -56,16 +57,14 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'performer' => $this->getPerformer(), 'audio_duration' => $this->getAudioDuration(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -130,6 +129,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Performer * @@ -289,6 +299,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param string $performer * @return static diff --git a/src/Type/InlineQueryResultCachedAudio.php b/src/Type/InlineQueryResultCachedAudio.php index 7ab720b..944d097 100644 --- a/src/Type/InlineQueryResultCachedAudio.php +++ b/src/Type/InlineQueryResultCachedAudio.php @@ -35,6 +35,7 @@ public static function _getPropertyNames(): array 'audio_file_id', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -45,7 +46,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -53,14 +54,12 @@ public function _getRawData(): array 'audio_file_id' => $this->getAudioFileId(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -115,6 +114,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -233,6 +243,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultCachedDocument.php b/src/Type/InlineQueryResultCachedDocument.php index 75304bf..1e422fb 100644 --- a/src/Type/InlineQueryResultCachedDocument.php +++ b/src/Type/InlineQueryResultCachedDocument.php @@ -37,6 +37,7 @@ public static function _getPropertyNames(): array 'description', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -47,7 +48,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -57,14 +58,12 @@ public function _getRawData(): array 'description' => $this->getDescription(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -140,6 +139,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -296,6 +306,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultCachedGif.php b/src/Type/InlineQueryResultCachedGif.php index e63e963..eabfcff 100644 --- a/src/Type/InlineQueryResultCachedGif.php +++ b/src/Type/InlineQueryResultCachedGif.php @@ -36,6 +36,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -46,7 +47,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -55,14 +56,12 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -128,6 +127,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -265,6 +275,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultCachedMpeg4Gif.php b/src/Type/InlineQueryResultCachedMpeg4Gif.php index 9e790a2..8307da8 100644 --- a/src/Type/InlineQueryResultCachedMpeg4Gif.php +++ b/src/Type/InlineQueryResultCachedMpeg4Gif.php @@ -36,6 +36,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -46,7 +47,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -55,14 +56,12 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -128,6 +127,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -265,6 +275,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultCachedPhoto.php b/src/Type/InlineQueryResultCachedPhoto.php index aed4831..25530a5 100644 --- a/src/Type/InlineQueryResultCachedPhoto.php +++ b/src/Type/InlineQueryResultCachedPhoto.php @@ -37,6 +37,7 @@ public static function _getPropertyNames(): array 'description', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -47,7 +48,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -57,14 +58,12 @@ public function _getRawData(): array 'description' => $this->getDescription(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -141,6 +140,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -297,6 +307,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultCachedSticker.php b/src/Type/InlineQueryResultCachedSticker.php index 21ac919..670604f 100644 --- a/src/Type/InlineQueryResultCachedSticker.php +++ b/src/Type/InlineQueryResultCachedSticker.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -52,10 +52,7 @@ public function _getRawData(): array 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InlineQueryResultCachedVideo.php b/src/Type/InlineQueryResultCachedVideo.php index f9ef5a3..ab6b65c 100644 --- a/src/Type/InlineQueryResultCachedVideo.php +++ b/src/Type/InlineQueryResultCachedVideo.php @@ -37,6 +37,7 @@ public static function _getPropertyNames(): array 'description', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -47,7 +48,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -57,14 +58,12 @@ public function _getRawData(): array 'description' => $this->getDescription(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -140,6 +139,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -296,6 +306,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultCachedVoice.php b/src/Type/InlineQueryResultCachedVoice.php index 6282c8c..34a9c66 100644 --- a/src/Type/InlineQueryResultCachedVoice.php +++ b/src/Type/InlineQueryResultCachedVoice.php @@ -36,6 +36,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -46,7 +47,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -55,14 +56,12 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -127,6 +126,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -264,6 +274,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultContact.php b/src/Type/InlineQueryResultContact.php index 62a67b3..cf58e98 100644 --- a/src/Type/InlineQueryResultContact.php +++ b/src/Type/InlineQueryResultContact.php @@ -48,7 +48,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -64,10 +64,7 @@ public function _getRawData(): array 'thumb_height' => $this->getThumbHeight(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InlineQueryResultDocument.php b/src/Type/InlineQueryResultDocument.php index 1fe622d..c2c895a 100644 --- a/src/Type/InlineQueryResultDocument.php +++ b/src/Type/InlineQueryResultDocument.php @@ -35,6 +35,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'document_url', 'mime_type', 'description', @@ -51,7 +52,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -59,6 +60,7 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'document_url' => $this->getDocumentUrl(), 'mime_type' => $this->getMimeType(), 'description' => $this->getDescription(), @@ -69,10 +71,7 @@ public function _getRawData(): array 'thumb_height' => $this->getThumbHeight(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -127,6 +126,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * A valid URL for the file * @@ -309,6 +319,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param string $documentUrl * @return static diff --git a/src/Type/InlineQueryResultGame.php b/src/Type/InlineQueryResultGame.php index 60c7004..be94307 100644 --- a/src/Type/InlineQueryResultGame.php +++ b/src/Type/InlineQueryResultGame.php @@ -40,7 +40,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -49,10 +49,7 @@ public function _getRawData(): array 'reply_markup' => $this->getReplyMarkup(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InlineQueryResultGif.php b/src/Type/InlineQueryResultGif.php index 47300af..086b786 100644 --- a/src/Type/InlineQueryResultGif.php +++ b/src/Type/InlineQueryResultGif.php @@ -41,6 +41,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -51,7 +52,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -65,14 +66,12 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -193,6 +192,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -425,6 +435,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultLocation.php b/src/Type/InlineQueryResultLocation.php index ed30609..c168a72 100644 --- a/src/Type/InlineQueryResultLocation.php +++ b/src/Type/InlineQueryResultLocation.php @@ -34,7 +34,10 @@ public static function _getPropertyNames(): array 'latitude', 'longitude', 'title', + 'horizontal_accuracy', 'live_period', + 'heading', + 'proximity_alert_radius', 'reply_markup', 'input_message_content', 'thumb_url', @@ -48,7 +51,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -56,7 +59,10 @@ public function _getRawData(): array 'latitude' => $this->getLatitude(), 'longitude' => $this->getLongitude(), 'title' => $this->getTitle(), + 'horizontal_accuracy' => $this->getHorizontalAccuracy(), 'live_period' => $this->getLivePeriod(), + 'heading' => $this->getHeading(), + 'proximity_alert_radius' => $this->getProximityAlertRadius(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), 'thumb_url' => $this->getThumbUrl(), @@ -64,10 +70,7 @@ public function _getRawData(): array 'thumb_height' => $this->getThumbHeight(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -120,6 +123,17 @@ public function _getRawData(): array */ protected $title; + /** + * Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * + * @var float|null + * @SkipWhenEmpty + * @SerializedName("horizontal_accuracy") + * @Accessor(getter="getHorizontalAccuracy",setter="setHorizontalAccuracy") + * @Type("float") + */ + protected $horizontalAccuracy; + /** * Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. * @@ -131,6 +145,30 @@ public function _getRawData(): array */ protected $livePeriod; + /** + * Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if + * specified. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("heading") + * @Accessor(getter="getHeading",setter="setHeading") + * @Type("int") + */ + protected $heading; + + /** + * Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in + * meters. Must be between 1 and 100000 if specified. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("proximity_alert_radius") + * @Accessor(getter="getProximityAlertRadius",setter="setProximityAlertRadius") + * @Type("int") + */ + protected $proximityAlertRadius; + /** * Optional. Inline keyboard attached to the message * @@ -282,6 +320,25 @@ public function getTitle(): string return $this->title; } + /** + * @param float $horizontalAccuracy + * @return static + */ + public function setHorizontalAccuracy(float $horizontalAccuracy): self + { + $this->horizontalAccuracy = $horizontalAccuracy; + + return $this; + } + + /** + * @return float|null + */ + public function getHorizontalAccuracy(): ?float + { + return $this->horizontalAccuracy; + } + /** * @param int $livePeriod * @return static @@ -301,6 +358,44 @@ public function getLivePeriod(): ?int return $this->livePeriod; } + /** + * @param int $heading + * @return static + */ + public function setHeading(int $heading): self + { + $this->heading = $heading; + + return $this; + } + + /** + * @return int|null + */ + public function getHeading(): ?int + { + return $this->heading; + } + + /** + * @param int $proximityAlertRadius + * @return static + */ + public function setProximityAlertRadius(int $proximityAlertRadius): self + { + $this->proximityAlertRadius = $proximityAlertRadius; + + return $this; + } + + /** + * @return int|null + */ + public function getProximityAlertRadius(): ?int + { + return $this->proximityAlertRadius; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultMpeg4Gif.php b/src/Type/InlineQueryResultMpeg4Gif.php index 4d342f9..a1ffd77 100644 --- a/src/Type/InlineQueryResultMpeg4Gif.php +++ b/src/Type/InlineQueryResultMpeg4Gif.php @@ -41,6 +41,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -51,7 +52,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -65,14 +66,12 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -193,6 +192,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -425,6 +435,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultPhoto.php b/src/Type/InlineQueryResultPhoto.php index c8bee78..ccef691 100644 --- a/src/Type/InlineQueryResultPhoto.php +++ b/src/Type/InlineQueryResultPhoto.php @@ -39,6 +39,7 @@ public static function _getPropertyNames(): array 'description', 'caption', 'parse_mode', + 'caption_entities', 'reply_markup', 'input_message_content', ]; @@ -49,7 +50,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -62,14 +63,12 @@ public function _getRawData(): array 'description' => $this->getDescription(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -178,6 +177,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Inline keyboard attached to the message * @@ -391,6 +401,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultVenue.php b/src/Type/InlineQueryResultVenue.php index 35c430d..1e7104b 100644 --- a/src/Type/InlineQueryResultVenue.php +++ b/src/Type/InlineQueryResultVenue.php @@ -37,6 +37,8 @@ public static function _getPropertyNames(): array 'address', 'foursquare_id', 'foursquare_type', + 'google_place_id', + 'google_place_type', 'reply_markup', 'input_message_content', 'thumb_url', @@ -50,7 +52,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -61,6 +63,8 @@ public function _getRawData(): array 'address' => $this->getAddress(), 'foursquare_id' => $this->getFoursquareId(), 'foursquare_type' => $this->getFoursquareType(), + 'google_place_id' => $this->getGooglePlaceId(), + 'google_place_type' => $this->getGooglePlaceType(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), 'thumb_url' => $this->getThumbUrl(), @@ -68,10 +72,7 @@ public function _getRawData(): array 'thumb_height' => $this->getThumbHeight(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -157,6 +158,28 @@ public function _getRawData(): array */ protected $foursquareType; + /** + * Optional. Google Places identifier of the venue + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("google_place_id") + * @Accessor(getter="getGooglePlaceId",setter="setGooglePlaceId") + * @Type("string") + */ + protected $googlePlaceId; + + /** + * Optional. Google Places type of the venue. (See supported types.) + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("google_place_type") + * @Accessor(getter="getGooglePlaceType",setter="setGooglePlaceType") + * @Type("string") + */ + protected $googlePlaceType; + /** * Optional. Inline keyboard attached to the message * @@ -365,6 +388,44 @@ public function getFoursquareType(): ?string return $this->foursquareType; } + /** + * @param string $googlePlaceId + * @return static + */ + public function setGooglePlaceId(string $googlePlaceId): self + { + $this->googlePlaceId = $googlePlaceId; + + return $this; + } + + /** + * @return string|null + */ + public function getGooglePlaceId(): ?string + { + return $this->googlePlaceId; + } + + /** + * @param string $googlePlaceType + * @return static + */ + public function setGooglePlaceType(string $googlePlaceType): self + { + $this->googlePlaceType = $googlePlaceType; + + return $this; + } + + /** + * @return string|null + */ + public function getGooglePlaceType(): ?string + { + return $this->googlePlaceType; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/InlineQueryResultVideo.php b/src/Type/InlineQueryResultVideo.php index 791b098..2acc56b 100644 --- a/src/Type/InlineQueryResultVideo.php +++ b/src/Type/InlineQueryResultVideo.php @@ -38,6 +38,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'video_width', 'video_height', 'video_duration', @@ -52,7 +53,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -63,6 +64,7 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'video_width' => $this->getVideoWidth(), 'video_height' => $this->getVideoHeight(), 'video_duration' => $this->getVideoDuration(), @@ -71,10 +73,7 @@ public function _getRawData(): array 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -159,6 +158,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Video width * @@ -379,6 +389,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param int $videoWidth * @return static diff --git a/src/Type/InlineQueryResultVoice.php b/src/Type/InlineQueryResultVoice.php index 5c4cd57..5227514 100644 --- a/src/Type/InlineQueryResultVoice.php +++ b/src/Type/InlineQueryResultVoice.php @@ -36,6 +36,7 @@ public static function _getPropertyNames(): array 'title', 'caption', 'parse_mode', + 'caption_entities', 'voice_duration', 'reply_markup', 'input_message_content', @@ -47,7 +48,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -56,15 +57,13 @@ public function _getRawData(): array 'title' => $this->getTitle(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'voice_duration' => $this->getVoiceDuration(), 'reply_markup' => $this->getReplyMarkup(), 'input_message_content' => $this->getInputMessageContent(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -129,6 +128,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Recording duration in seconds * @@ -277,6 +287,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param int $voiceDuration * @return static diff --git a/src/Type/InputContactMessageContent.php b/src/Type/InputContactMessageContent.php index 717eaf4..794d266 100644 --- a/src/Type/InputContactMessageContent.php +++ b/src/Type/InputContactMessageContent.php @@ -12,8 +12,8 @@ /** * https://core.telegram.org/bots/api#inputcontactmessagecontent * - * Represents the content of a contact - * message to be sent as the result of an inline query. + * Represents the content of a contact message to be sent as the result of an + * inline query. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'phone_number' => $this->getPhoneNumber(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'vcard' => $this->getVcard(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/InputInvoiceMessageContent.php b/src/Type/InputInvoiceMessageContent.php new file mode 100644 index 0000000..d32eb10 --- /dev/null +++ b/src/Type/InputInvoiceMessageContent.php @@ -0,0 +1,690 @@ + $this->getTitle(), + 'description' => $this->getDescription(), + 'payload' => $this->getPayload(), + 'provider_token' => $this->getProviderToken(), + 'currency' => $this->getCurrency(), + 'prices' => $this->getPrices(), + 'max_tip_amount' => $this->getMaxTipAmount(), + 'suggested_tip_amounts' => $this->getSuggestedTipAmounts(), + 'provider_data' => $this->getProviderData(), + 'photo_url' => $this->getPhotoUrl(), + 'photo_size' => $this->getPhotoSize(), + 'photo_width' => $this->getPhotoWidth(), + 'photo_height' => $this->getPhotoHeight(), + 'need_name' => $this->getNeedName(), + 'need_phone_number' => $this->getNeedPhoneNumber(), + 'need_email' => $this->getNeedEmail(), + 'need_shipping_address' => $this->getNeedShippingAddress(), + 'send_phone_number_to_provider' => $this->getSendPhoneNumberToProvider(), + 'send_email_to_provider' => $this->getSendEmailToProvider(), + 'is_flexible' => $this->getIsFlexible(), + ]; + + return parent::normalizeData($result); + } + + /** + * Product name, 1-32 characters + * + * @var string + * @SerializedName("title") + * @Accessor(getter="getTitle",setter="setTitle") + * @Type("string") + */ + protected $title; + + /** + * Product description, 1-255 characters + * + * @var string + * @SerializedName("description") + * @Accessor(getter="getDescription",setter="setDescription") + * @Type("string") + */ + protected $description; + + /** + * Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * + * @var string + * @SerializedName("payload") + * @Accessor(getter="getPayload",setter="setPayload") + * @Type("string") + */ + protected $payload; + + /** + * Payment provider token, obtained via Botfather + * + * @var string + * @SerializedName("provider_token") + * @Accessor(getter="getProviderToken",setter="setProviderToken") + * @Type("string") + */ + protected $providerToken; + + /** + * Three-letter ISO 4217 currency code, see more on currencies + * + * @var string + * @SerializedName("currency") + * @Accessor(getter="getCurrency",setter="setCurrency") + * @Type("string") + */ + protected $currency; + + /** + * Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, + * delivery tax, bonus, etc.) + * + * @var LabeledPrice[] + * @SerializedName("prices") + * @Accessor(getter="getPrices",setter="setPrices") + * @Type("array") + */ + protected $prices; + + /** + * Optional. The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). + * For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows + * the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("max_tip_amount") + * @Accessor(getter="getMaxTipAmount",setter="setMaxTipAmount") + * @Type("int") + */ + protected $maxTipAmount; + + /** + * Optional. A JSON-serialized array of suggested amounts of tip in the smallest units of the currency (integer, not + * float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly + * increased order and must not exceed max_tip_amount. + * + * @var int[]|null + * @SkipWhenEmpty + * @SerializedName("suggested_tip_amounts") + * @Accessor(getter="getSuggestedTipAmounts",setter="setSuggestedTipAmounts") + * @Type("array") + */ + protected $suggestedTipAmounts; + + /** + * Optional. A JSON-serialized object for data about the invoice, which will be shared with the payment provider. A + * detailed description of the required fields should be provided by the payment provider. + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("provider_data") + * @Accessor(getter="getProviderData",setter="setProviderData") + * @Type("string") + */ + protected $providerData; + + /** + * Optional. URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. + * People like it better when they see what they are paying for. + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("photo_url") + * @Accessor(getter="getPhotoUrl",setter="setPhotoUrl") + * @Type("string") + */ + protected $photoUrl; + + /** + * Optional. Photo size + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("photo_size") + * @Accessor(getter="getPhotoSize",setter="setPhotoSize") + * @Type("int") + */ + protected $photoSize; + + /** + * Optional. Photo width + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("photo_width") + * @Accessor(getter="getPhotoWidth",setter="setPhotoWidth") + * @Type("int") + */ + protected $photoWidth; + + /** + * Optional. Photo height + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("photo_height") + * @Accessor(getter="getPhotoHeight",setter="setPhotoHeight") + * @Type("int") + */ + protected $photoHeight; + + /** + * Optional. Pass True, if you require the user's full name to complete the order + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("need_name") + * @Accessor(getter="getNeedName",setter="setNeedName") + * @Type("bool") + */ + protected $needName; + + /** + * Optional. Pass True, if you require the user's phone number to complete the order + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("need_phone_number") + * @Accessor(getter="getNeedPhoneNumber",setter="setNeedPhoneNumber") + * @Type("bool") + */ + protected $needPhoneNumber; + + /** + * Optional. Pass True, if you require the user's email address to complete the order + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("need_email") + * @Accessor(getter="getNeedEmail",setter="setNeedEmail") + * @Type("bool") + */ + protected $needEmail; + + /** + * Optional. Pass True, if you require the user's shipping address to complete the order + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("need_shipping_address") + * @Accessor(getter="getNeedShippingAddress",setter="setNeedShippingAddress") + * @Type("bool") + */ + protected $needShippingAddress; + + /** + * Optional. Pass True, if user's phone number should be sent to provider + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("send_phone_number_to_provider") + * @Accessor(getter="getSendPhoneNumberToProvider",setter="setSendPhoneNumberToProvider") + * @Type("bool") + */ + protected $sendPhoneNumberToProvider; + + /** + * Optional. Pass True, if user's email address should be sent to provider + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("send_email_to_provider") + * @Accessor(getter="getSendEmailToProvider",setter="setSendEmailToProvider") + * @Type("bool") + */ + protected $sendEmailToProvider; + + /** + * Optional. Pass True, if the final price depends on the shipping method + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("is_flexible") + * @Accessor(getter="getIsFlexible",setter="setIsFlexible") + * @Type("bool") + */ + protected $isFlexible; + + + /** + * @param string $title + * @return static + */ + public function setTitle(string $title): self + { + $this->title = $title; + + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $description + * @return static + */ + public function setDescription(string $description): self + { + $this->description = $description; + + return $this; + } + + /** + * @return string + */ + public function getDescription(): string + { + return $this->description; + } + + /** + * @param string $payload + * @return static + */ + public function setPayload(string $payload): self + { + $this->payload = $payload; + + return $this; + } + + /** + * @return string + */ + public function getPayload(): string + { + return $this->payload; + } + + /** + * @param string $providerToken + * @return static + */ + public function setProviderToken(string $providerToken): self + { + $this->providerToken = $providerToken; + + return $this; + } + + /** + * @return string + */ + public function getProviderToken(): string + { + return $this->providerToken; + } + + /** + * @param string $currency + * @return static + */ + public function setCurrency(string $currency): self + { + $this->currency = $currency; + + return $this; + } + + /** + * @return string + */ + public function getCurrency(): string + { + return $this->currency; + } + + /** + * @param LabeledPrice[] $prices + * @return static + */ + public function setPrices(array $prices): self + { + $this->prices = $prices; + + return $this; + } + + /** + * @return LabeledPrice[] + */ + public function getPrices(): array + { + return $this->prices; + } + + /** + * @param int $maxTipAmount + * @return static + */ + public function setMaxTipAmount(int $maxTipAmount): self + { + $this->maxTipAmount = $maxTipAmount; + + return $this; + } + + /** + * @return int|null + */ + public function getMaxTipAmount(): ?int + { + return $this->maxTipAmount; + } + + /** + * @param int[] $suggestedTipAmounts + * @return static + */ + public function setSuggestedTipAmounts(array $suggestedTipAmounts): self + { + $this->suggestedTipAmounts = $suggestedTipAmounts; + + return $this; + } + + /** + * @return int[]|null + */ + public function getSuggestedTipAmounts(): ?array + { + return $this->suggestedTipAmounts; + } + + /** + * @param string $providerData + * @return static + */ + public function setProviderData(string $providerData): self + { + $this->providerData = $providerData; + + return $this; + } + + /** + * @return string|null + */ + public function getProviderData(): ?string + { + return $this->providerData; + } + + /** + * @param string $photoUrl + * @return static + */ + public function setPhotoUrl(string $photoUrl): self + { + $this->photoUrl = $photoUrl; + + return $this; + } + + /** + * @return string|null + */ + public function getPhotoUrl(): ?string + { + return $this->photoUrl; + } + + /** + * @param int $photoSize + * @return static + */ + public function setPhotoSize(int $photoSize): self + { + $this->photoSize = $photoSize; + + return $this; + } + + /** + * @return int|null + */ + public function getPhotoSize(): ?int + { + return $this->photoSize; + } + + /** + * @param int $photoWidth + * @return static + */ + public function setPhotoWidth(int $photoWidth): self + { + $this->photoWidth = $photoWidth; + + return $this; + } + + /** + * @return int|null + */ + public function getPhotoWidth(): ?int + { + return $this->photoWidth; + } + + /** + * @param int $photoHeight + * @return static + */ + public function setPhotoHeight(int $photoHeight): self + { + $this->photoHeight = $photoHeight; + + return $this; + } + + /** + * @return int|null + */ + public function getPhotoHeight(): ?int + { + return $this->photoHeight; + } + + /** + * @param bool $needName + * @return static + */ + public function setNeedName(bool $needName): self + { + $this->needName = $needName; + + return $this; + } + + /** + * @return bool|null + */ + public function getNeedName(): ?bool + { + return $this->needName; + } + + /** + * @param bool $needPhoneNumber + * @return static + */ + public function setNeedPhoneNumber(bool $needPhoneNumber): self + { + $this->needPhoneNumber = $needPhoneNumber; + + return $this; + } + + /** + * @return bool|null + */ + public function getNeedPhoneNumber(): ?bool + { + return $this->needPhoneNumber; + } + + /** + * @param bool $needEmail + * @return static + */ + public function setNeedEmail(bool $needEmail): self + { + $this->needEmail = $needEmail; + + return $this; + } + + /** + * @return bool|null + */ + public function getNeedEmail(): ?bool + { + return $this->needEmail; + } + + /** + * @param bool $needShippingAddress + * @return static + */ + public function setNeedShippingAddress(bool $needShippingAddress): self + { + $this->needShippingAddress = $needShippingAddress; + + return $this; + } + + /** + * @return bool|null + */ + public function getNeedShippingAddress(): ?bool + { + return $this->needShippingAddress; + } + + /** + * @param bool $sendPhoneNumberToProvider + * @return static + */ + public function setSendPhoneNumberToProvider(bool $sendPhoneNumberToProvider): self + { + $this->sendPhoneNumberToProvider = $sendPhoneNumberToProvider; + + return $this; + } + + /** + * @return bool|null + */ + public function getSendPhoneNumberToProvider(): ?bool + { + return $this->sendPhoneNumberToProvider; + } + + /** + * @param bool $sendEmailToProvider + * @return static + */ + public function setSendEmailToProvider(bool $sendEmailToProvider): self + { + $this->sendEmailToProvider = $sendEmailToProvider; + + return $this; + } + + /** + * @return bool|null + */ + public function getSendEmailToProvider(): ?bool + { + return $this->sendEmailToProvider; + } + + /** + * @param bool $isFlexible + * @return static + */ + public function setIsFlexible(bool $isFlexible): self + { + $this->isFlexible = $isFlexible; + + return $this; + } + + /** + * @return bool|null + */ + public function getIsFlexible(): ?bool + { + return $this->isFlexible; + } + +} \ No newline at end of file diff --git a/src/Type/InputLocationMessageContent.php b/src/Type/InputLocationMessageContent.php index 53bf40f..d047a17 100644 --- a/src/Type/InputLocationMessageContent.php +++ b/src/Type/InputLocationMessageContent.php @@ -12,8 +12,8 @@ /** * https://core.telegram.org/bots/api#inputlocationmessagecontent * - * Represents the content of a location - * message to be sent as the result of an inline query. + * Represents the content of a location message to be sent as the result of an + * inline query. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -31,7 +31,10 @@ public static function _getPropertyNames(): array return [ 'latitude', 'longitude', + 'horizontal_accuracy', 'live_period', + 'heading', + 'proximity_alert_radius', ]; } @@ -40,18 +43,18 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'latitude' => $this->getLatitude(), 'longitude' => $this->getLongitude(), + 'horizontal_accuracy' => $this->getHorizontalAccuracy(), 'live_period' => $this->getLivePeriod(), + 'heading' => $this->getHeading(), + 'proximity_alert_radius' => $this->getProximityAlertRadius(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -74,6 +77,17 @@ public function _getRawData(): array */ protected $longitude; + /** + * Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * + * @var float|null + * @SkipWhenEmpty + * @SerializedName("horizontal_accuracy") + * @Accessor(getter="getHorizontalAccuracy",setter="setHorizontalAccuracy") + * @Type("float") + */ + protected $horizontalAccuracy; + /** * Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. * @@ -85,6 +99,30 @@ public function _getRawData(): array */ protected $livePeriod; + /** + * Optional. For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if + * specified. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("heading") + * @Accessor(getter="getHeading",setter="setHeading") + * @Type("int") + */ + protected $heading; + + /** + * Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, in + * meters. Must be between 1 and 100000 if specified. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("proximity_alert_radius") + * @Accessor(getter="getProximityAlertRadius",setter="setProximityAlertRadius") + * @Type("int") + */ + protected $proximityAlertRadius; + /** * @param float $latitude @@ -124,6 +162,25 @@ public function getLongitude(): float return $this->longitude; } + /** + * @param float $horizontalAccuracy + * @return static + */ + public function setHorizontalAccuracy(float $horizontalAccuracy): self + { + $this->horizontalAccuracy = $horizontalAccuracy; + + return $this; + } + + /** + * @return float|null + */ + public function getHorizontalAccuracy(): ?float + { + return $this->horizontalAccuracy; + } + /** * @param int $livePeriod * @return static @@ -143,4 +200,42 @@ public function getLivePeriod(): ?int return $this->livePeriod; } + /** + * @param int $heading + * @return static + */ + public function setHeading(int $heading): self + { + $this->heading = $heading; + + return $this; + } + + /** + * @return int|null + */ + public function getHeading(): ?int + { + return $this->heading; + } + + /** + * @param int $proximityAlertRadius + * @return static + */ + public function setProximityAlertRadius(int $proximityAlertRadius): self + { + $this->proximityAlertRadius = $proximityAlertRadius; + + return $this; + } + + /** + * @return int|null + */ + public function getProximityAlertRadius(): ?int + { + return $this->proximityAlertRadius; + } + } \ No newline at end of file diff --git a/src/Type/InputMediaAnimation.php b/src/Type/InputMediaAnimation.php index 1b310a5..fd25f14 100644 --- a/src/Type/InputMediaAnimation.php +++ b/src/Type/InputMediaAnimation.php @@ -33,6 +33,7 @@ public static function _getPropertyNames(): array 'thumb', 'caption', 'parse_mode', + 'caption_entities', 'width', 'height', 'duration', @@ -44,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -52,15 +53,13 @@ public function _getRawData(): array 'thumb' => $this->getThumb(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'width' => $this->getWidth(), 'height' => $this->getHeight(), 'duration' => $this->getDuration(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -122,6 +121,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Animation width * @@ -251,6 +261,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param int $width * @return static diff --git a/src/Type/InputMediaAudio.php b/src/Type/InputMediaAudio.php index 73d4df8..ec7a00f 100644 --- a/src/Type/InputMediaAudio.php +++ b/src/Type/InputMediaAudio.php @@ -33,6 +33,7 @@ public static function _getPropertyNames(): array 'thumb', 'caption', 'parse_mode', + 'caption_entities', 'duration', 'performer', 'title', @@ -44,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -52,15 +53,13 @@ public function _getRawData(): array 'thumb' => $this->getThumb(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'duration' => $this->getDuration(), 'performer' => $this->getPerformer(), 'title' => $this->getTitle(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -122,6 +121,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Duration of the audio in seconds * @@ -251,6 +261,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param int $duration * @return static diff --git a/src/Type/InputMediaDocument.php b/src/Type/InputMediaDocument.php index 3d8adc5..b8d1e51 100644 --- a/src/Type/InputMediaDocument.php +++ b/src/Type/InputMediaDocument.php @@ -33,6 +33,8 @@ public static function _getPropertyNames(): array 'thumb', 'caption', 'parse_mode', + 'caption_entities', + 'disable_content_type_detection', ]; } @@ -41,7 +43,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -49,12 +51,11 @@ public function _getRawData(): array 'thumb' => $this->getThumb(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), + 'disable_content_type_detection' => $this->getDisableContentTypeDetection(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -116,6 +117,29 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + + /** + * Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data. + * Always true, if the document is sent as part of an album. + * + * @var bool|null + * @SkipWhenEmpty + * @SerializedName("disable_content_type_detection") + * @Accessor(getter="getDisableContentTypeDetection",setter="setDisableContentTypeDetection") + * @Type("bool") + */ + protected $disableContentTypeDetection; + /** * @param string $type @@ -212,4 +236,42 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + + /** + * @param bool $disableContentTypeDetection + * @return static + */ + public function setDisableContentTypeDetection(bool $disableContentTypeDetection): self + { + $this->disableContentTypeDetection = $disableContentTypeDetection; + + return $this; + } + + /** + * @return bool|null + */ + public function getDisableContentTypeDetection(): ?bool + { + return $this->disableContentTypeDetection; + } + } \ No newline at end of file diff --git a/src/Type/InputMediaPhoto.php b/src/Type/InputMediaPhoto.php index af52289..40d322a 100644 --- a/src/Type/InputMediaPhoto.php +++ b/src/Type/InputMediaPhoto.php @@ -32,6 +32,7 @@ public static function _getPropertyNames(): array 'media', 'caption', 'parse_mode', + 'caption_entities', ]; } @@ -40,19 +41,17 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), 'media' => $this->getMedia(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -99,6 +98,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * @param string $type @@ -176,4 +186,23 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + } \ No newline at end of file diff --git a/src/Type/InputMediaVideo.php b/src/Type/InputMediaVideo.php index 4a86c08..5473af8 100644 --- a/src/Type/InputMediaVideo.php +++ b/src/Type/InputMediaVideo.php @@ -33,6 +33,7 @@ public static function _getPropertyNames(): array 'thumb', 'caption', 'parse_mode', + 'caption_entities', 'width', 'height', 'duration', @@ -45,7 +46,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -53,16 +54,14 @@ public function _getRawData(): array 'thumb' => $this->getThumb(), 'caption' => $this->getCaption(), 'parse_mode' => $this->getParseMode(), + 'caption_entities' => $this->getCaptionEntities(), 'width' => $this->getWidth(), 'height' => $this->getHeight(), 'duration' => $this->getDuration(), 'supports_streaming' => $this->getSupportsStreaming(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -124,6 +123,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("caption_entities") + * @Accessor(getter="getCaptionEntities",setter="setCaptionEntities") + * @Type("array") + */ + protected $captionEntities; + /** * Optional. Video width * @@ -264,6 +274,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $captionEntities + * @return static + */ + public function setCaptionEntities(array $captionEntities): self + { + $this->captionEntities = $captionEntities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + /** * @param int $width * @return static diff --git a/src/Type/InputTextMessageContent.php b/src/Type/InputTextMessageContent.php index 9a0beaa..40e7c14 100644 --- a/src/Type/InputTextMessageContent.php +++ b/src/Type/InputTextMessageContent.php @@ -12,8 +12,8 @@ /** * https://core.telegram.org/bots/api#inputtextmessagecontent * - * Represents the content of a text - * message to be sent as the result of an inline query. + * Represents the content of a text message to be sent as the result of an inline + * query. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -31,6 +31,7 @@ public static function _getPropertyNames(): array return [ 'message_text', 'parse_mode', + 'entities', 'disable_web_page_preview', ]; } @@ -40,18 +41,16 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'message_text' => $this->getMessageText(), 'parse_mode' => $this->getParseMode(), + 'entities' => $this->getEntities(), 'disable_web_page_preview' => $this->getDisableWebPagePreview(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -75,6 +74,17 @@ public function _getRawData(): array */ protected $parseMode; + /** + * Optional. List of special entities that appear in message text, which can be specified instead of parse_mode + * + * @var MessageEntity[]|null + * @SkipWhenEmpty + * @SerializedName("entities") + * @Accessor(getter="getEntities",setter="setEntities") + * @Type("array") + */ + protected $entities; + /** * Optional. Disables link previews for links in the sent message * @@ -125,6 +135,25 @@ public function getParseMode(): ?string return $this->parseMode; } + /** + * @param MessageEntity[] $entities + * @return static + */ + public function setEntities(array $entities): self + { + $this->entities = $entities; + + return $this; + } + + /** + * @return MessageEntity[]|null + */ + public function getEntities(): ?array + { + return $this->entities; + } + /** * @param bool $disableWebPagePreview * @return static diff --git a/src/Type/InputVenueMessageContent.php b/src/Type/InputVenueMessageContent.php index a6ef165..b7da48b 100644 --- a/src/Type/InputVenueMessageContent.php +++ b/src/Type/InputVenueMessageContent.php @@ -12,8 +12,8 @@ /** * https://core.telegram.org/bots/api#inputvenuemessagecontent * - * Represents the content of a venue - * message to be sent as the result of an inline query. + * Represents the content of a venue message to be sent as the result of an inline + * query. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -35,6 +35,8 @@ public static function _getPropertyNames(): array 'address', 'foursquare_id', 'foursquare_type', + 'google_place_id', + 'google_place_type', ]; } @@ -43,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'latitude' => $this->getLatitude(), @@ -52,12 +54,11 @@ public function _getRawData(): array 'address' => $this->getAddress(), 'foursquare_id' => $this->getFoursquareId(), 'foursquare_type' => $this->getFoursquareType(), + 'google_place_id' => $this->getGooglePlaceId(), + 'google_place_type' => $this->getGooglePlaceType(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -123,6 +124,28 @@ public function _getRawData(): array */ protected $foursquareType; + /** + * Optional. Google Places identifier of the venue + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("google_place_id") + * @Accessor(getter="getGooglePlaceId",setter="setGooglePlaceId") + * @Type("string") + */ + protected $googlePlaceId; + + /** + * Optional. Google Places type of the venue. (See supported types.) + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("google_place_type") + * @Accessor(getter="getGooglePlaceType",setter="setGooglePlaceType") + * @Type("string") + */ + protected $googlePlaceType; + /** * @param float $latitude @@ -238,4 +261,42 @@ public function getFoursquareType(): ?string return $this->foursquareType; } + /** + * @param string $googlePlaceId + * @return static + */ + public function setGooglePlaceId(string $googlePlaceId): self + { + $this->googlePlaceId = $googlePlaceId; + + return $this; + } + + /** + * @return string|null + */ + public function getGooglePlaceId(): ?string + { + return $this->googlePlaceId; + } + + /** + * @param string $googlePlaceType + * @return static + */ + public function setGooglePlaceType(string $googlePlaceType): self + { + $this->googlePlaceType = $googlePlaceType; + + return $this; + } + + /** + * @return string|null + */ + public function getGooglePlaceType(): ?string + { + return $this->googlePlaceType; + } + } \ No newline at end of file diff --git a/src/Type/Invoice.php b/src/Type/Invoice.php index 60201e5..541962a 100644 --- a/src/Type/Invoice.php +++ b/src/Type/Invoice.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'title' => $this->getTitle(), @@ -51,10 +51,7 @@ public function _getRawData(): array 'total_amount' => $this->getTotalAmount(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/KeyboardButton.php b/src/Type/KeyboardButton.php index e520efc..7db4d00 100644 --- a/src/Type/KeyboardButton.php +++ b/src/Type/KeyboardButton.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'text' => $this->getText(), @@ -51,10 +51,7 @@ public function _getRawData(): array 'request_poll' => $this->getRequestPoll(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/KeyboardButtonPollType.php b/src/Type/KeyboardButtonPollType.php index 21dba5b..78f685c 100644 --- a/src/Type/KeyboardButtonPollType.php +++ b/src/Type/KeyboardButtonPollType.php @@ -38,16 +38,13 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/LabeledPrice.php b/src/Type/LabeledPrice.php index 76de102..85e5163 100644 --- a/src/Type/LabeledPrice.php +++ b/src/Type/LabeledPrice.php @@ -38,17 +38,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'label' => $this->getLabel(), 'amount' => $this->getAmount(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Location.php b/src/Type/Location.php index cbb5da4..7ea594a 100644 --- a/src/Type/Location.php +++ b/src/Type/Location.php @@ -30,6 +30,10 @@ public static function _getPropertyNames(): array return [ 'longitude', 'latitude', + 'horizontal_accuracy', + 'live_period', + 'heading', + 'proximity_alert_radius', ]; } @@ -38,17 +42,18 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'longitude' => $this->getLongitude(), 'latitude' => $this->getLatitude(), + 'horizontal_accuracy' => $this->getHorizontalAccuracy(), + 'live_period' => $this->getLivePeriod(), + 'heading' => $this->getHeading(), + 'proximity_alert_radius' => $this->getProximityAlertRadius(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -71,6 +76,52 @@ public function _getRawData(): array */ protected $latitude; + /** + * Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * + * @var float|null + * @SkipWhenEmpty + * @SerializedName("horizontal_accuracy") + * @Accessor(getter="getHorizontalAccuracy",setter="setHorizontalAccuracy") + * @Type("float") + */ + protected $horizontalAccuracy; + + /** + * Optional. Time relative to the message sending date, during which the location can be updated, in seconds. For + * active live locations only. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("live_period") + * @Accessor(getter="getLivePeriod",setter="setLivePeriod") + * @Type("int") + */ + protected $livePeriod; + + /** + * Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("heading") + * @Accessor(getter="getHeading",setter="setHeading") + * @Type("int") + */ + protected $heading; + + /** + * Optional. Maximum distance for proximity alerts about approaching another chat member, in meters. For sent live + * locations only. + * + * @var int|null + * @SkipWhenEmpty + * @SerializedName("proximity_alert_radius") + * @Accessor(getter="getProximityAlertRadius",setter="setProximityAlertRadius") + * @Type("int") + */ + protected $proximityAlertRadius; + /** * @param float $longitude @@ -110,4 +161,80 @@ public function getLatitude(): float return $this->latitude; } + /** + * @param float $horizontalAccuracy + * @return static + */ + public function setHorizontalAccuracy(float $horizontalAccuracy): self + { + $this->horizontalAccuracy = $horizontalAccuracy; + + return $this; + } + + /** + * @return float|null + */ + public function getHorizontalAccuracy(): ?float + { + return $this->horizontalAccuracy; + } + + /** + * @param int $livePeriod + * @return static + */ + public function setLivePeriod(int $livePeriod): self + { + $this->livePeriod = $livePeriod; + + return $this; + } + + /** + * @return int|null + */ + public function getLivePeriod(): ?int + { + return $this->livePeriod; + } + + /** + * @param int $heading + * @return static + */ + public function setHeading(int $heading): self + { + $this->heading = $heading; + + return $this; + } + + /** + * @return int|null + */ + public function getHeading(): ?int + { + return $this->heading; + } + + /** + * @param int $proximityAlertRadius + * @return static + */ + public function setProximityAlertRadius(int $proximityAlertRadius): self + { + $this->proximityAlertRadius = $proximityAlertRadius; + + return $this; + } + + /** + * @return int|null + */ + public function getProximityAlertRadius(): ?int + { + return $this->proximityAlertRadius; + } + } \ No newline at end of file diff --git a/src/Type/LoginUrl.php b/src/Type/LoginUrl.php index d3df2d6..2b53f77 100644 --- a/src/Type/LoginUrl.php +++ b/src/Type/LoginUrl.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'url' => $this->getUrl(), @@ -51,10 +51,7 @@ public function _getRawData(): array 'request_write_access' => $this->getRequestWriteAccess(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/MaskPosition.php b/src/Type/MaskPosition.php index 175caac..e114d3e 100644 --- a/src/Type/MaskPosition.php +++ b/src/Type/MaskPosition.php @@ -40,7 +40,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'point' => $this->getPoint(), @@ -49,10 +49,7 @@ public function _getRawData(): array 'scale' => $this->getScale(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Message.php b/src/Type/Message.php index 51523f5..bb57ca2 100644 --- a/src/Type/Message.php +++ b/src/Type/Message.php @@ -30,6 +30,7 @@ public static function _getPropertyNames(): array return [ 'message_id', 'from', + 'sender_chat', 'date', 'chat', 'forward_from', @@ -69,6 +70,7 @@ public static function _getPropertyNames(): array 'group_chat_created', 'supergroup_chat_created', 'channel_chat_created', + 'message_auto_delete_timer_changed', 'migrate_to_chat_id', 'migrate_from_chat_id', 'pinned_message', @@ -76,6 +78,11 @@ public static function _getPropertyNames(): array 'successful_payment', 'connected_website', 'passport_data', + 'proximity_alert_triggered', + 'voice_chat_scheduled', + 'voice_chat_started', + 'voice_chat_ended', + 'voice_chat_participants_invited', 'reply_markup', ]; } @@ -85,11 +92,12 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'message_id' => $this->getMessageId(), 'from' => $this->getFrom(), + 'sender_chat' => $this->getSenderChat(), 'date' => $this->getDate(), 'chat' => $this->getChat(), 'forward_from' => $this->getForwardFrom(), @@ -129,6 +137,7 @@ public function _getRawData(): array 'group_chat_created' => $this->getGroupChatCreated(), 'supergroup_chat_created' => $this->getSupergroupChatCreated(), 'channel_chat_created' => $this->getChannelChatCreated(), + 'message_auto_delete_timer_changed' => $this->getMessageAutoDeleteTimerChanged(), 'migrate_to_chat_id' => $this->getMigrateToChatId(), 'migrate_from_chat_id' => $this->getMigrateFromChatId(), 'pinned_message' => $this->getPinnedMessage(), @@ -136,13 +145,15 @@ public function _getRawData(): array 'successful_payment' => $this->getSuccessfulPayment(), 'connected_website' => $this->getConnectedWebsite(), 'passport_data' => $this->getPassportData(), + 'proximity_alert_triggered' => $this->getProximityAlertTriggered(), + 'voice_chat_scheduled' => $this->getVoiceChatScheduled(), + 'voice_chat_started' => $this->getVoiceChatStarted(), + 'voice_chat_ended' => $this->getVoiceChatEnded(), + 'voice_chat_participants_invited' => $this->getVoiceChatParticipantsInvited(), 'reply_markup' => $this->getReplyMarkup(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -166,6 +177,19 @@ public function _getRawData(): array */ protected $from; + /** + * Optional. Sender of the message, sent on behalf of a chat. The channel itself for channel messages. The supergroup + * itself for messages from anonymous group administrators. The linked channel for messages automatically forwarded to the + * discussion group + * + * @var Chat|null + * @SkipWhenEmpty + * @SerializedName("sender_chat") + * @Accessor(getter="getSenderChat",setter="setSenderChat") + * @Type("MadmagesTelegram\Types\Type\Chat") + */ + protected $senderChat; + /** * Date the message was sent in Unix time * @@ -198,7 +222,8 @@ public function _getRawData(): array protected $forwardFrom; /** - * Optional. For messages forwarded from channels, information about the original channel + * Optional. For messages forwarded from channels or from anonymous administrators, information about the original + * sender chat * * @var Chat|null * @SkipWhenEmpty @@ -299,7 +324,8 @@ public function _getRawData(): array protected $mediaGroupId; /** - * Optional. Signature of the post author for messages in channels + * Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group + * administrator * * @var string|null * @SkipWhenEmpty @@ -455,7 +481,7 @@ public function _getRawData(): array protected $contact; /** - * Optional. Message is a dice with random value from 1 to 6 + * Optional. Message is a dice with random value * * @var Dice|null * @SkipWhenEmpty @@ -604,9 +630,21 @@ public function _getRawData(): array protected $channelChatCreated; /** - * Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than - * 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than - * 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. + * Optional. Service message: auto-delete timer settings changed in the chat + * + * @var MessageAutoDeleteTimerChanged|null + * @SkipWhenEmpty + * @SerializedName("message_auto_delete_timer_changed") + * @Accessor(getter="getMessageAutoDeleteTimerChanged",setter="setMessageAutoDeleteTimerChanged") + * @Type("MadmagesTelegram\Types\Type\MessageAutoDeleteTimerChanged") + */ + protected $messageAutoDeleteTimerChanged; + + /** + * Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than + * 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has + * at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this + * identifier. * * @var int|null * @SkipWhenEmpty @@ -617,9 +655,10 @@ public function _getRawData(): array protected $migrateToChatId; /** - * Optional. The supergroup has been migrated from a group with the specified identifier. This number may be greater - * than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller - * than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. + * Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more + * than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it + * has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this + * identifier. * * @var int|null * @SkipWhenEmpty @@ -686,6 +725,62 @@ public function _getRawData(): array */ protected $passportData; + /** + * Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live + * Location. + * + * @var ProximityAlertTriggered|null + * @SkipWhenEmpty + * @SerializedName("proximity_alert_triggered") + * @Accessor(getter="getProximityAlertTriggered",setter="setProximityAlertTriggered") + * @Type("MadmagesTelegram\Types\Type\ProximityAlertTriggered") + */ + protected $proximityAlertTriggered; + + /** + * Optional. Service message: voice chat scheduled + * + * @var VoiceChatScheduled|null + * @SkipWhenEmpty + * @SerializedName("voice_chat_scheduled") + * @Accessor(getter="getVoiceChatScheduled",setter="setVoiceChatScheduled") + * @Type("MadmagesTelegram\Types\Type\VoiceChatScheduled") + */ + protected $voiceChatScheduled; + + /** + * Optional. Service message: voice chat started + * + * @var VoiceChatStarted|null + * @SkipWhenEmpty + * @SerializedName("voice_chat_started") + * @Accessor(getter="getVoiceChatStarted",setter="setVoiceChatStarted") + * @Type("MadmagesTelegram\Types\Type\VoiceChatStarted") + */ + protected $voiceChatStarted; + + /** + * Optional. Service message: voice chat ended + * + * @var VoiceChatEnded|null + * @SkipWhenEmpty + * @SerializedName("voice_chat_ended") + * @Accessor(getter="getVoiceChatEnded",setter="setVoiceChatEnded") + * @Type("MadmagesTelegram\Types\Type\VoiceChatEnded") + */ + protected $voiceChatEnded; + + /** + * Optional. Service message: new participants invited to a voice chat + * + * @var VoiceChatParticipantsInvited|null + * @SkipWhenEmpty + * @SerializedName("voice_chat_participants_invited") + * @Accessor(getter="getVoiceChatParticipantsInvited",setter="setVoiceChatParticipantsInvited") + * @Type("MadmagesTelegram\Types\Type\VoiceChatParticipantsInvited") + */ + protected $voiceChatParticipantsInvited; + /** * Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. * @@ -736,6 +831,25 @@ public function getFrom(): ?User return $this->from; } + /** + * @param Chat $senderChat + * @return static + */ + public function setSenderChat(Chat $senderChat): self + { + $this->senderChat = $senderChat; + + return $this; + } + + /** + * @return Chat|null + */ + public function getSenderChat(): ?Chat + { + return $this->senderChat; + } + /** * @param int $date * @return static @@ -1477,6 +1591,25 @@ public function getChannelChatCreated(): ?bool return $this->channelChatCreated; } + /** + * @param MessageAutoDeleteTimerChanged $messageAutoDeleteTimerChanged + * @return static + */ + public function setMessageAutoDeleteTimerChanged(MessageAutoDeleteTimerChanged $messageAutoDeleteTimerChanged): self + { + $this->messageAutoDeleteTimerChanged = $messageAutoDeleteTimerChanged; + + return $this; + } + + /** + * @return MessageAutoDeleteTimerChanged|null + */ + public function getMessageAutoDeleteTimerChanged(): ?MessageAutoDeleteTimerChanged + { + return $this->messageAutoDeleteTimerChanged; + } + /** * @param int $migrateToChatId * @return static @@ -1610,6 +1743,101 @@ public function getPassportData(): ?PassportData return $this->passportData; } + /** + * @param ProximityAlertTriggered $proximityAlertTriggered + * @return static + */ + public function setProximityAlertTriggered(ProximityAlertTriggered $proximityAlertTriggered): self + { + $this->proximityAlertTriggered = $proximityAlertTriggered; + + return $this; + } + + /** + * @return ProximityAlertTriggered|null + */ + public function getProximityAlertTriggered(): ?ProximityAlertTriggered + { + return $this->proximityAlertTriggered; + } + + /** + * @param VoiceChatScheduled $voiceChatScheduled + * @return static + */ + public function setVoiceChatScheduled(VoiceChatScheduled $voiceChatScheduled): self + { + $this->voiceChatScheduled = $voiceChatScheduled; + + return $this; + } + + /** + * @return VoiceChatScheduled|null + */ + public function getVoiceChatScheduled(): ?VoiceChatScheduled + { + return $this->voiceChatScheduled; + } + + /** + * @param VoiceChatStarted $voiceChatStarted + * @return static + */ + public function setVoiceChatStarted(VoiceChatStarted $voiceChatStarted): self + { + $this->voiceChatStarted = $voiceChatStarted; + + return $this; + } + + /** + * @return VoiceChatStarted|null + */ + public function getVoiceChatStarted(): ?VoiceChatStarted + { + return $this->voiceChatStarted; + } + + /** + * @param VoiceChatEnded $voiceChatEnded + * @return static + */ + public function setVoiceChatEnded(VoiceChatEnded $voiceChatEnded): self + { + $this->voiceChatEnded = $voiceChatEnded; + + return $this; + } + + /** + * @return VoiceChatEnded|null + */ + public function getVoiceChatEnded(): ?VoiceChatEnded + { + return $this->voiceChatEnded; + } + + /** + * @param VoiceChatParticipantsInvited $voiceChatParticipantsInvited + * @return static + */ + public function setVoiceChatParticipantsInvited(VoiceChatParticipantsInvited $voiceChatParticipantsInvited): self + { + $this->voiceChatParticipantsInvited = $voiceChatParticipantsInvited; + + return $this; + } + + /** + * @return VoiceChatParticipantsInvited|null + */ + public function getVoiceChatParticipantsInvited(): ?VoiceChatParticipantsInvited + { + return $this->voiceChatParticipantsInvited; + } + /** * @param InlineKeyboardMarkup $replyMarkup * @return static diff --git a/src/Type/MessageAutoDeleteTimerChanged.php b/src/Type/MessageAutoDeleteTimerChanged.php new file mode 100644 index 0000000..6754876 --- /dev/null +++ b/src/Type/MessageAutoDeleteTimerChanged.php @@ -0,0 +1,79 @@ + $this->getMessageAutoDeleteTime(), + ]; + + return parent::normalizeData($result); + } + + /** + * New auto-delete time for messages in the chat + * + * @var int + * @SerializedName("message_auto_delete_time") + * @Accessor(getter="getMessageAutoDeleteTime",setter="setMessageAutoDeleteTime") + * @Type("int") + */ + protected $messageAutoDeleteTime; + + + /** + * @param int $messageAutoDeleteTime + * @return static + */ + public function setMessageAutoDeleteTime(int $messageAutoDeleteTime): self + { + $this->messageAutoDeleteTime = $messageAutoDeleteTime; + + return $this; + } + + /** + * @return int + */ + public function getMessageAutoDeleteTime(): int + { + return $this->messageAutoDeleteTime; + } + +} \ No newline at end of file diff --git a/src/Type/MessageEntity.php b/src/Type/MessageEntity.php index 345170c..803a5e6 100644 --- a/src/Type/MessageEntity.php +++ b/src/Type/MessageEntity.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'type' => $this->getType(), @@ -53,10 +53,7 @@ public function _getRawData(): array 'language' => $this->getLanguage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/MessageId.php b/src/Type/MessageId.php new file mode 100644 index 0000000..2bfe6ea --- /dev/null +++ b/src/Type/MessageId.php @@ -0,0 +1,79 @@ + $this->getMessageId(), + ]; + + return parent::normalizeData($result); + } + + /** + * Unique message identifier + * + * @var int + * @SerializedName("message_id") + * @Accessor(getter="getMessageId",setter="setMessageId") + * @Type("int") + */ + protected $messageId; + + + /** + * @param int $messageId + * @return static + */ + public function setMessageId(int $messageId): self + { + $this->messageId = $messageId; + + return $this; + } + + /** + * @return int + */ + public function getMessageId(): int + { + return $this->messageId; + } + +} \ No newline at end of file diff --git a/src/Type/OrderInfo.php b/src/Type/OrderInfo.php index d30f27c..f282f0f 100644 --- a/src/Type/OrderInfo.php +++ b/src/Type/OrderInfo.php @@ -40,7 +40,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'name' => $this->getName(), @@ -49,10 +49,7 @@ public function _getRawData(): array 'shipping_address' => $this->getShippingAddress(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportData.php b/src/Type/PassportData.php index b3fa655..d45bbc1 100644 --- a/src/Type/PassportData.php +++ b/src/Type/PassportData.php @@ -38,17 +38,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'data' => $this->getData(), 'credentials' => $this->getCredentials(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorDataField.php b/src/Type/PassportElementErrorDataField.php index aa7a197..e6c65a8 100644 --- a/src/Type/PassportElementErrorDataField.php +++ b/src/Type/PassportElementErrorDataField.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -52,10 +52,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorFile.php b/src/Type/PassportElementErrorFile.php index bb684ff..3fb87e3 100644 --- a/src/Type/PassportElementErrorFile.php +++ b/src/Type/PassportElementErrorFile.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorFiles.php b/src/Type/PassportElementErrorFiles.php index c493436..f4c6e3b 100644 --- a/src/Type/PassportElementErrorFiles.php +++ b/src/Type/PassportElementErrorFiles.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorFrontSide.php b/src/Type/PassportElementErrorFrontSide.php index 4ecd039..8d55d1e 100644 --- a/src/Type/PassportElementErrorFrontSide.php +++ b/src/Type/PassportElementErrorFrontSide.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorReverseSide.php b/src/Type/PassportElementErrorReverseSide.php index 9509e3c..d894e34 100644 --- a/src/Type/PassportElementErrorReverseSide.php +++ b/src/Type/PassportElementErrorReverseSide.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorSelfie.php b/src/Type/PassportElementErrorSelfie.php index 352ce89..5522369 100644 --- a/src/Type/PassportElementErrorSelfie.php +++ b/src/Type/PassportElementErrorSelfie.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorTranslationFile.php b/src/Type/PassportElementErrorTranslationFile.php index 5f6358e..093e1b2 100644 --- a/src/Type/PassportElementErrorTranslationFile.php +++ b/src/Type/PassportElementErrorTranslationFile.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorTranslationFiles.php b/src/Type/PassportElementErrorTranslationFiles.php index bf63c21..2e1ad70 100644 --- a/src/Type/PassportElementErrorTranslationFiles.php +++ b/src/Type/PassportElementErrorTranslationFiles.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportElementErrorUnspecified.php b/src/Type/PassportElementErrorUnspecified.php index 54c584a..15f7ac2 100644 --- a/src/Type/PassportElementErrorUnspecified.php +++ b/src/Type/PassportElementErrorUnspecified.php @@ -40,7 +40,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'source' => $this->getSource(), @@ -49,10 +49,7 @@ public function _getRawData(): array 'message' => $this->getMessage(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PassportFile.php b/src/Type/PassportFile.php index fe17756..e45c7a8 100644 --- a/src/Type/PassportFile.php +++ b/src/Type/PassportFile.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'file_date' => $this->getFileDate(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PhotoSize.php b/src/Type/PhotoSize.php index d78f562..5e781d6 100644 --- a/src/Type/PhotoSize.php +++ b/src/Type/PhotoSize.php @@ -12,8 +12,8 @@ /** * https://core.telegram.org/bots/api#photosize * - * This object represents one size of a photo or a file - * / sticker thumbnail. + * This object represents one size of a photo or a file / sticker + * thumbnail. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -52,10 +52,7 @@ public function _getRawData(): array 'file_size' => $this->getFileSize(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Poll.php b/src/Type/Poll.php index a66fc15..46b1bf4 100644 --- a/src/Type/Poll.php +++ b/src/Type/Poll.php @@ -49,7 +49,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), @@ -67,10 +67,7 @@ public function _getRawData(): array 'close_date' => $this->getCloseDate(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -84,7 +81,7 @@ public function _getRawData(): array protected $id; /** - * Poll question, 1-255 characters + * Poll question, 1-300 characters * * @var string * @SerializedName("question") diff --git a/src/Type/PollAnswer.php b/src/Type/PollAnswer.php index 4e47168..1c48d45 100644 --- a/src/Type/PollAnswer.php +++ b/src/Type/PollAnswer.php @@ -39,7 +39,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'poll_id' => $this->getPollId(), @@ -47,10 +47,7 @@ public function _getRawData(): array 'option_ids' => $this->getOptionIds(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PollOption.php b/src/Type/PollOption.php index 8d691e5..f016608 100644 --- a/src/Type/PollOption.php +++ b/src/Type/PollOption.php @@ -38,17 +38,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'text' => $this->getText(), 'voter_count' => $this->getVoterCount(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/PreCheckoutQuery.php b/src/Type/PreCheckoutQuery.php index 8f6e51b..2f51c33 100644 --- a/src/Type/PreCheckoutQuery.php +++ b/src/Type/PreCheckoutQuery.php @@ -43,7 +43,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), @@ -55,10 +55,7 @@ public function _getRawData(): array 'order_info' => $this->getOrderInfo(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ProximityAlertTriggered.php b/src/Type/ProximityAlertTriggered.php new file mode 100644 index 0000000..8c34de1 --- /dev/null +++ b/src/Type/ProximityAlertTriggered.php @@ -0,0 +1,142 @@ + $this->getTraveler(), + 'watcher' => $this->getWatcher(), + 'distance' => $this->getDistance(), + ]; + + return parent::normalizeData($result); + } + + /** + * User that triggered the alert + * + * @var User + * @SerializedName("traveler") + * @Accessor(getter="getTraveler",setter="setTraveler") + * @Type("MadmagesTelegram\Types\Type\User") + */ + protected $traveler; + + /** + * User that set the alert + * + * @var User + * @SerializedName("watcher") + * @Accessor(getter="getWatcher",setter="setWatcher") + * @Type("MadmagesTelegram\Types\Type\User") + */ + protected $watcher; + + /** + * The distance between the users + * + * @var int + * @SerializedName("distance") + * @Accessor(getter="getDistance",setter="setDistance") + * @Type("int") + */ + protected $distance; + + + /** + * @param User $traveler + * @return static + */ + public function setTraveler(User $traveler): self + { + $this->traveler = $traveler; + + return $this; + } + + /** + * @return User + */ + public function getTraveler(): User + { + return $this->traveler; + } + + /** + * @param User $watcher + * @return static + */ + public function setWatcher(User $watcher): self + { + $this->watcher = $watcher; + + return $this; + } + + /** + * @return User + */ + public function getWatcher(): User + { + return $this->watcher; + } + + /** + * @param int $distance + * @return static + */ + public function setDistance(int $distance): self + { + $this->distance = $distance; + + return $this; + } + + /** + * @return int + */ + public function getDistance(): int + { + return $this->distance; + } + +} \ No newline at end of file diff --git a/src/Type/ReplyKeyboardMarkup.php b/src/Type/ReplyKeyboardMarkup.php index b768d7c..5b8bde1 100644 --- a/src/Type/ReplyKeyboardMarkup.php +++ b/src/Type/ReplyKeyboardMarkup.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'keyboard' => $this->getKeyboard(), @@ -50,10 +50,7 @@ public function _getRawData(): array 'selective' => $this->getSelective(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ReplyKeyboardRemove.php b/src/Type/ReplyKeyboardRemove.php index 69d2696..2e6a6bd 100644 --- a/src/Type/ReplyKeyboardRemove.php +++ b/src/Type/ReplyKeyboardRemove.php @@ -40,17 +40,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'remove_keyboard' => $this->getRemoveKeyboard(), 'selective' => $this->getSelective(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ResponseParameters.php b/src/Type/ResponseParameters.php index a2797d9..1a613b6 100644 --- a/src/Type/ResponseParameters.php +++ b/src/Type/ResponseParameters.php @@ -38,23 +38,21 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'migrate_to_chat_id' => $this->getMigrateToChatId(), 'retry_after' => $this->getRetryAfter(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** - * Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than - * 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than - * 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. + * Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than + * 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has + * at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this + * identifier. * * @var int|null * @SkipWhenEmpty diff --git a/src/Type/ShippingAddress.php b/src/Type/ShippingAddress.php index eda41f5..8b96b2e 100644 --- a/src/Type/ShippingAddress.php +++ b/src/Type/ShippingAddress.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'country_code' => $this->getCountryCode(), @@ -53,10 +53,7 @@ public function _getRawData(): array 'post_code' => $this->getPostCode(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ShippingOption.php b/src/Type/ShippingOption.php index 9a25ad0..e7ae70a 100644 --- a/src/Type/ShippingOption.php +++ b/src/Type/ShippingOption.php @@ -39,7 +39,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), @@ -47,10 +47,7 @@ public function _getRawData(): array 'prices' => $this->getPrices(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/ShippingQuery.php b/src/Type/ShippingQuery.php index 1a6756d..888cf91 100644 --- a/src/Type/ShippingQuery.php +++ b/src/Type/ShippingQuery.php @@ -40,7 +40,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), @@ -49,10 +49,7 @@ public function _getRawData(): array 'shipping_address' => $this->getShippingAddress(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Sticker.php b/src/Type/Sticker.php index 81a6e75..42d88f2 100644 --- a/src/Type/Sticker.php +++ b/src/Type/Sticker.php @@ -46,7 +46,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -61,10 +61,7 @@ public function _getRawData(): array 'file_size' => $this->getFileSize(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/StickerSet.php b/src/Type/StickerSet.php index 873c169..87c61b4 100644 --- a/src/Type/StickerSet.php +++ b/src/Type/StickerSet.php @@ -42,7 +42,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'name' => $this->getName(), @@ -53,10 +53,7 @@ public function _getRawData(): array 'thumb' => $this->getThumb(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/SuccessfulPayment.php b/src/Type/SuccessfulPayment.php index 3468311..73b454d 100644 --- a/src/Type/SuccessfulPayment.php +++ b/src/Type/SuccessfulPayment.php @@ -43,7 +43,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'currency' => $this->getCurrency(), @@ -55,10 +55,7 @@ public function _getRawData(): array 'provider_payment_charge_id' => $this->getProviderPaymentChargeId(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Update.php b/src/Type/Update.php index 0ffc616..c88a4be 100644 --- a/src/Type/Update.php +++ b/src/Type/Update.php @@ -12,8 +12,8 @@ /** * https://core.telegram.org/bots/api#update * - * This object represents an incoming - * update.At most one of the optional parameters can be present in any given update. + * This object represents an incoming update.At most one of + * the optional parameters can be present in any given update. * * @ExclusionPolicy("none") * @AccessType("public_method") @@ -41,6 +41,8 @@ public static function _getPropertyNames(): array 'pre_checkout_query', 'poll', 'poll_answer', + 'my_chat_member', + 'chat_member', ]; } @@ -49,7 +51,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'update_id' => $this->getUpdateId(), @@ -64,12 +66,11 @@ public function _getRawData(): array 'pre_checkout_query' => $this->getPreCheckoutQuery(), 'poll' => $this->getPoll(), 'poll_answer' => $this->getPollAnswer(), + 'my_chat_member' => $this->getMyChatMember(), + 'chat_member' => $this->getChatMember(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -208,6 +209,30 @@ public function _getRawData(): array */ protected $pollAnswer; + /** + * Optional. The bot's chat member status was updated in a chat. For private chats, this update is received only when the + * bot is blocked or unblocked by the user. + * + * @var ChatMemberUpdated|null + * @SkipWhenEmpty + * @SerializedName("my_chat_member") + * @Accessor(getter="getMyChatMember",setter="setMyChatMember") + * @Type("MadmagesTelegram\Types\Type\ChatMemberUpdated") + */ + protected $myChatMember; + + /** + * Optional. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must + * explicitly specify “chat_member” in the list of allowed_updates to receive these updates. + * + * @var ChatMemberUpdated|null + * @SkipWhenEmpty + * @SerializedName("chat_member") + * @Accessor(getter="getChatMember",setter="setChatMember") + * @Type("MadmagesTelegram\Types\Type\ChatMemberUpdated") + */ + protected $chatMember; + /** * @param int $updateId @@ -437,4 +462,42 @@ public function getPollAnswer(): ?PollAnswer return $this->pollAnswer; } + /** + * @param ChatMemberUpdated $myChatMember + * @return static + */ + public function setMyChatMember(ChatMemberUpdated $myChatMember): self + { + $this->myChatMember = $myChatMember; + + return $this; + } + + /** + * @return ChatMemberUpdated|null + */ + public function getMyChatMember(): ?ChatMemberUpdated + { + return $this->myChatMember; + } + + /** + * @param ChatMemberUpdated $chatMember + * @return static + */ + public function setChatMember(ChatMemberUpdated $chatMember): self + { + $this->chatMember = $chatMember; + + return $this; + } + + /** + * @return ChatMemberUpdated|null + */ + public function getChatMember(): ?ChatMemberUpdated + { + return $this->chatMember; + } + } \ No newline at end of file diff --git a/src/Type/User.php b/src/Type/User.php index 52f5efb..53a9534 100644 --- a/src/Type/User.php +++ b/src/Type/User.php @@ -45,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'id' => $this->getId(), @@ -59,14 +59,13 @@ public function _getRawData(): array 'supports_inline_queries' => $this->getSupportsInlineQueries(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** - * Unique identifier for this user or bot + * Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming + * languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or + * double-precision float type are safe for storing this identifier. * * @var int * @SerializedName("id") diff --git a/src/Type/UserProfilePhotos.php b/src/Type/UserProfilePhotos.php index 8445420..e0c8620 100644 --- a/src/Type/UserProfilePhotos.php +++ b/src/Type/UserProfilePhotos.php @@ -38,17 +38,14 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'total_count' => $this->getTotalCount(), 'photos' => $this->getPhotos(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Venue.php b/src/Type/Venue.php index c307126..34ab898 100644 --- a/src/Type/Venue.php +++ b/src/Type/Venue.php @@ -33,6 +33,8 @@ public static function _getPropertyNames(): array 'address', 'foursquare_id', 'foursquare_type', + 'google_place_id', + 'google_place_type', ]; } @@ -41,7 +43,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'location' => $this->getLocation(), @@ -49,16 +51,15 @@ public function _getRawData(): array 'address' => $this->getAddress(), 'foursquare_id' => $this->getFoursquareId(), 'foursquare_type' => $this->getFoursquareType(), + 'google_place_id' => $this->getGooglePlaceId(), + 'google_place_type' => $this->getGooglePlaceType(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** - * Venue location + * Venue location. Can't be a live location * * @var Location * @SerializedName("location") @@ -110,6 +111,28 @@ public function _getRawData(): array */ protected $foursquareType; + /** + * Optional. Google Places identifier of the venue + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("google_place_id") + * @Accessor(getter="getGooglePlaceId",setter="setGooglePlaceId") + * @Type("string") + */ + protected $googlePlaceId; + + /** + * Optional. Google Places type of the venue. (See supported types.) + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("google_place_type") + * @Accessor(getter="getGooglePlaceType",setter="setGooglePlaceType") + * @Type("string") + */ + protected $googlePlaceType; + /** * @param Location $location @@ -206,4 +229,42 @@ public function getFoursquareType(): ?string return $this->foursquareType; } + /** + * @param string $googlePlaceId + * @return static + */ + public function setGooglePlaceId(string $googlePlaceId): self + { + $this->googlePlaceId = $googlePlaceId; + + return $this; + } + + /** + * @return string|null + */ + public function getGooglePlaceId(): ?string + { + return $this->googlePlaceId; + } + + /** + * @param string $googlePlaceType + * @return static + */ + public function setGooglePlaceType(string $googlePlaceType): self + { + $this->googlePlaceType = $googlePlaceType; + + return $this; + } + + /** + * @return string|null + */ + public function getGooglePlaceType(): ?string + { + return $this->googlePlaceType; + } + } \ No newline at end of file diff --git a/src/Type/Video.php b/src/Type/Video.php index a4986ae..dbbc601 100644 --- a/src/Type/Video.php +++ b/src/Type/Video.php @@ -34,6 +34,7 @@ public static function _getPropertyNames(): array 'height', 'duration', 'thumb', + 'file_name', 'mime_type', 'file_size', ]; @@ -44,7 +45,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -53,14 +54,12 @@ public function _getRawData(): array 'height' => $this->getHeight(), 'duration' => $this->getDuration(), 'thumb' => $this->getThumb(), + 'file_name' => $this->getFileName(), 'mime_type' => $this->getMimeType(), 'file_size' => $this->getFileSize(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -125,6 +124,17 @@ public function _getRawData(): array */ protected $thumb; + /** + * Optional. Original filename as defined by sender + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("file_name") + * @Accessor(getter="getFileName",setter="setFileName") + * @Type("string") + */ + protected $fileName; + /** * Optional. Mime type of a file as defined by sender * @@ -262,6 +272,25 @@ public function getThumb(): ?PhotoSize return $this->thumb; } + /** + * @param string $fileName + * @return static + */ + public function setFileName(string $fileName): self + { + $this->fileName = $fileName; + + return $this; + } + + /** + * @return string|null + */ + public function getFileName(): ?string + { + return $this->fileName; + } + /** * @param string $mimeType * @return static diff --git a/src/Type/VideoNote.php b/src/Type/VideoNote.php index 338c9b9..c42679d 100644 --- a/src/Type/VideoNote.php +++ b/src/Type/VideoNote.php @@ -43,7 +43,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -54,10 +54,7 @@ public function _getRawData(): array 'file_size' => $this->getFileSize(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/Voice.php b/src/Type/Voice.php index d79ca6c..d496987 100644 --- a/src/Type/Voice.php +++ b/src/Type/Voice.php @@ -41,7 +41,7 @@ public static function _getPropertyNames(): array * * @return array */ - public function _getRawData(): array + public function _getData(): array { $result = [ 'file_id' => $this->getFileId(), @@ -51,10 +51,7 @@ public function _getRawData(): array 'file_size' => $this->getFileSize(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** diff --git a/src/Type/VoiceChatEnded.php b/src/Type/VoiceChatEnded.php new file mode 100644 index 0000000..3276162 --- /dev/null +++ b/src/Type/VoiceChatEnded.php @@ -0,0 +1,79 @@ + $this->getDuration(), + ]; + + return parent::normalizeData($result); + } + + /** + * Voice chat duration; in seconds + * + * @var int + * @SerializedName("duration") + * @Accessor(getter="getDuration",setter="setDuration") + * @Type("int") + */ + protected $duration; + + + /** + * @param int $duration + * @return static + */ + public function setDuration(int $duration): self + { + $this->duration = $duration; + + return $this; + } + + /** + * @return int + */ + public function getDuration(): int + { + return $this->duration; + } + +} \ No newline at end of file diff --git a/src/Type/VoiceChatParticipantsInvited.php b/src/Type/VoiceChatParticipantsInvited.php new file mode 100644 index 0000000..9903f18 --- /dev/null +++ b/src/Type/VoiceChatParticipantsInvited.php @@ -0,0 +1,80 @@ + $this->getUsers(), + ]; + + return parent::normalizeData($result); + } + + /** + * Optional. New members that were invited to the voice chat + * + * @var User[]|null + * @SkipWhenEmpty + * @SerializedName("users") + * @Accessor(getter="getUsers",setter="setUsers") + * @Type("array") + */ + protected $users; + + + /** + * @param User[] $users + * @return static + */ + public function setUsers(array $users): self + { + $this->users = $users; + + return $this; + } + + /** + * @return User[]|null + */ + public function getUsers(): ?array + { + return $this->users; + } + +} \ No newline at end of file diff --git a/src/Type/VoiceChatScheduled.php b/src/Type/VoiceChatScheduled.php new file mode 100644 index 0000000..c6bf463 --- /dev/null +++ b/src/Type/VoiceChatScheduled.php @@ -0,0 +1,79 @@ + $this->getStartDate(), + ]; + + return parent::normalizeData($result); + } + + /** + * Point in time (Unix timestamp) when the voice chat is supposed to be started by a chat administrator + * + * @var int + * @SerializedName("start_date") + * @Accessor(getter="getStartDate",setter="setStartDate") + * @Type("int") + */ + protected $startDate; + + + /** + * @param int $startDate + * @return static + */ + public function setStartDate(int $startDate): self + { + $this->startDate = $startDate; + + return $this; + } + + /** + * @return int + */ + public function getStartDate(): int + { + return $this->startDate; + } + +} \ No newline at end of file diff --git a/src/Type/VoiceChatStarted.php b/src/Type/VoiceChatStarted.php new file mode 100644 index 0000000..537db0b --- /dev/null +++ b/src/Type/VoiceChatStarted.php @@ -0,0 +1,48 @@ + $this->getUrl(), 'has_custom_certificate' => $this->getHasCustomCertificate(), 'pending_update_count' => $this->getPendingUpdateCount(), + 'ip_address' => $this->getIpAddress(), 'last_error_date' => $this->getLastErrorDate(), 'last_error_message' => $this->getLastErrorMessage(), 'max_connections' => $this->getMaxConnections(), 'allowed_updates' => $this->getAllowedUpdates(), ]; - $result = array_filter($result, static function($item){ return $item!==null; }); - return array_map(static function(&$item){ - return is_object($item) ? $item->_getRawData():$item; - }, $result); + return parent::normalizeData($result); } /** @@ -92,6 +91,17 @@ public function _getRawData(): array */ protected $pendingUpdateCount; + /** + * Optional. Currently used webhook IP address + * + * @var string|null + * @SkipWhenEmpty + * @SerializedName("ip_address") + * @Accessor(getter="getIpAddress",setter="setIpAddress") + * @Type("string") + */ + protected $ipAddress; + /** * Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook * @@ -127,7 +137,7 @@ public function _getRawData(): array protected $maxConnections; /** - * Optional. A list of update types the bot is subscribed to. Defaults to all update types + * Optional. A list of update types the bot is subscribed to. Defaults to all update types except chat_member * * @var string[]|null * @SkipWhenEmpty @@ -195,6 +205,25 @@ public function getPendingUpdateCount(): int return $this->pendingUpdateCount; } + /** + * @param string $ipAddress + * @return static + */ + public function setIpAddress(string $ipAddress): self + { + $this->ipAddress = $ipAddress; + + return $this; + } + + /** + * @return string|null + */ + public function getIpAddress(): ?string + { + return $this->ipAddress; + } + /** * @param int $lastErrorDate * @return static diff --git a/src/TypedClient.php b/src/TypedClient.php index 034bddf..b7ac081 100644 --- a/src/TypedClient.php +++ b/src/TypedClient.php @@ -22,7 +22,7 @@ abstract class TypedClient { * @param bool $withFiles * @return string Returned json string */ - abstract protected function _rawApiCall(string $method, array $parameters, bool $withFiles = false): string; + abstract public function _apiCall(string $method, array $parameters): string; /** * @return SerializerInterface @@ -48,7 +48,7 @@ private static function _getSerializer(): SerializerInterface */ private function _requestWithMap(string $method, array $requestParams, array $returnType) { - $jsonString = $this->_rawApiCall($method, ...$this->_prepareRequest($requestParams)); + $jsonString = $this->_apiCall($method, $this->_prepareRequest($requestParams)); if (empty($returnType)) { return json_decode($jsonString, true); } @@ -62,34 +62,28 @@ private function _requestWithMap(string $method, array $requestParams, array $re private function _prepareRequest(array $requestParams): array { - $requestParams = array_filter($requestParams, static function($i) - { - return $i !== null; - }); + $requestParams = array_filter($requestParams); if (empty($requestParams)) { - return [[], false]; + return []; } - $withFiles = false; - array_walk_recursive($requestParams, function(&$item) use (&$withFiles) + array_walk_recursive($requestParams, function(&$item) { if (!is_object($item)) { return; } if ($item instanceof AbstractInputFile) { - $withFiles = true; - $file = $item->getFile(); - if (!is_resource($file) && is_file($file)) { - $file = fopen($file, 'rb'); + $item = $item->getFile(); + if (!is_resource($item) && is_file($item)) { + $item = fopen($item, 'rb'); } - $item = $file; } else { $item = json_decode($this->_getSerializer()->serialize($item, 'json'), true); } }); - return [$requestParams, $withFiles]; + return $requestParams; } public static function deserialize(string $jsonString, string $type) @@ -125,7 +119,7 @@ public static function serialize(object $objectToSerialize): string * @param string[] $allowedUpdates * A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, * “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available - * update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the + * update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the * previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the * getUpdates, so unwanted updates may be received for a short period of time. * @@ -168,6 +162,9 @@ public function getUpdates( * Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide * for details. * + * @param string $ipAddress + * The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS + * * @param int $maxConnections * Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults * to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput. @@ -175,24 +172,31 @@ public function getUpdates( * @param string[] $allowedUpdates * A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, * “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available - * update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the + * update types. Specify an empty list to receive all update types except chat_member (default). If not specified, the * previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the * setWebhook, so unwanted updates may be received for a short period of time. * + * @param bool $dropPendingUpdates + * Pass True to drop all pending updates + * * @return bool; */ public function setWebhook( string $url, Type\AbstractInputFile $certificate = null, + string $ipAddress = null, int $maxConnections = null, - array $allowedUpdates = null + array $allowedUpdates = null, + bool $dropPendingUpdates = null ): bool { $requestParameters = [ 'url' => $url, 'certificate' => $certificate, + 'ip_address' => $ipAddress, 'max_connections' => $maxConnections, 'allowed_updates' => $allowedUpdates, + 'drop_pending_updates' => $dropPendingUpdates, ]; $returnType = [ @@ -205,14 +209,19 @@ public function setWebhook( /** * https://core.telegram.org/bots/api#deletewebhook * - * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. Requires no parameters. + * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. + * + * @param bool $dropPendingUpdates + * Pass True to drop all pending updates * * @return bool; */ public function deleteWebhook( + bool $dropPendingUpdates = null ): bool { $requestParameters = [ + 'drop_pending_updates' => $dropPendingUpdates, ]; $returnType = [ @@ -225,8 +234,8 @@ public function deleteWebhook( /** * https://core.telegram.org/bots/api#getwebhookinfo * - * Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will - * return an object with the url field empty. + * Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url + * field empty. * * @return Type\WebhookInfo; */ @@ -264,6 +273,51 @@ public function getMe( return $this->_requestWithMap('getMe', $requestParameters, $returnType); } + /** + * https://core.telegram.org/bots/api#logout + * + * Use this method to log out from the cloud Bot API server before launching the bot locally. You must + * log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a + * successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 + * minutes. Returns True on success. Requires no parameters. + * + * @return bool; + */ + public function logOut( + ): bool + { + $requestParameters = [ + ]; + + $returnType = [ + 'bool', + ]; + + return $this->_requestWithMap('logOut', $requestParameters, $returnType); + } + + /** + * https://core.telegram.org/bots/api#close + * + * Use this method to close the bot instance before moving it from one local server to another. You need to delete the + * webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return + * error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters. + * + * @return bool; + */ + public function close( + ): bool + { + $requestParameters = [ + ]; + + $returnType = [ + 'bool', + ]; + + return $this->_requestWithMap('close', $requestParameters, $returnType); + } + /** * https://core.telegram.org/bots/api#sendmessage * @@ -278,6 +332,9 @@ public function getMe( * @param string $parseMode * Mode for parsing entities in the message text. See formatting options for more details. * + * @param Type\MessageEntity[] $entities + * List of special entities that appear in message text, which can be specified instead of parse_mode + * * @param bool $disableWebPagePreview * Disables link previews for links in this message * @@ -287,6 +344,9 @@ public function getMe( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -297,9 +357,11 @@ public function sendMessage( $chatId, string $text, string $parseMode = null, + array $entities = null, bool $disableWebPagePreview = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -307,9 +369,11 @@ public function sendMessage( 'chat_id' => $chatId, 'text' => $text, 'parse_mode' => $parseMode, + 'entities' => $entities, 'disable_web_page_preview' => $disableWebPagePreview, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -323,7 +387,7 @@ public function sendMessage( /** * https://core.telegram.org/bots/api#forwardmessage * - * Use this method to forward messages of any kind. On success, the sent Message is returned. + * Use this method to forward messages of any kind. Service messages can't be forwarded. On success, the sent Message is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -361,6 +425,81 @@ public function forwardMessage( return $this->_requestWithMap('forwardMessage', $requestParameters, $returnType); } + /** + * https://core.telegram.org/bots/api#copymessage + * + * Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. The method is + * analogous to the method forwardMessage, but the copied message doesn't have a link to the + * original message. Returns the MessageId of the sent message on success. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @param int|string $fromChatId + * Unique identifier for the chat where the original message was sent (or channel username in the format + * @|channelusername) + * + * @param int $messageId + * Message identifier in the chat specified in from_chat_id + * + * @param string $caption + * New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is + * kept + * + * @param string $parseMode + * Mode for parsing entities in the new caption. See formatting options for more details. + * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the new caption, which can be specified instead of parse_mode + * + * @param bool $disableNotification + * Sends the message silently. Users will receive a notification with no sound. + * + * @param int $replyToMessageId + * If the message is a reply, ID of the original message + * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * + * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup + * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, + * instructions to remove reply keyboard or to force a reply from the user. + * + * @return Type\MessageId; + */ + public function copyMessage( + $chatId, + $fromChatId, + int $messageId, + string $caption = null, + string $parseMode = null, + array $captionEntities = null, + bool $disableNotification = null, + int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, + $replyMarkup = null + ): Type\MessageId + { + $requestParameters = [ + 'chat_id' => $chatId, + 'from_chat_id' => $fromChatId, + 'message_id' => $messageId, + 'caption' => $caption, + 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, + 'disable_notification' => $disableNotification, + 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, + 'reply_markup' => $replyMarkup, + ]; + + $returnType = [ + Type\MessageId::class, + ]; + + return $this->_requestWithMap('copyMessage', $requestParameters, $returnType); + } + /** * https://core.telegram.org/bots/api#sendphoto * @@ -372,7 +511,8 @@ public function forwardMessage( * @param Type\AbstractInputFile|string $photo * Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an * HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. - * More info on Sending Files » + * The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height + * ratio must be at most 20. More info on Sending Files » * * @param string $caption * Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing @@ -380,12 +520,18 @@ public function forwardMessage( * @param string $parseMode * Mode for parsing entities in the photo caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -397,8 +543,10 @@ public function sendPhoto( $photo, string $caption = null, string $parseMode = null, + array $captionEntities = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -407,8 +555,10 @@ public function sendPhoto( 'photo' => $photo, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -423,9 +573,8 @@ public function sendPhoto( * https://core.telegram.org/bots/api#sendaudio * * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must - * be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For - * sending voice messages, use the sendVoice method - * instead. + * be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently + * send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the sendVoice method instead. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -441,6 +590,9 @@ public function sendPhoto( * @param string $parseMode * Mode for parsing entities in the audio caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param int $duration * Duration of the audio in seconds * @@ -463,6 +615,9 @@ public function sendPhoto( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -474,12 +629,14 @@ public function sendAudio( $audio, string $caption = null, string $parseMode = null, + array $captionEntities = null, int $duration = null, string $performer = null, string $title = null, $thumb = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -488,12 +645,14 @@ public function sendAudio( 'audio' => $audio, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'duration' => $duration, 'performer' => $performer, 'title' => $title, 'thumb' => $thumb, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -507,7 +666,8 @@ public function sendAudio( /** * https://core.telegram.org/bots/api#senddocument * - * 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. + * 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. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -531,12 +691,21 @@ public function sendAudio( * @param string $parseMode * Mode for parsing entities in the document caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @param bool $disableContentTypeDetection + * Disables automatic server-side content type detection for files uploaded using multipart/form-data + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -549,8 +718,11 @@ public function sendDocument( $thumb = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, + bool $disableContentTypeDetection = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -560,8 +732,11 @@ public function sendDocument( 'thumb' => $thumb, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, + 'disable_content_type_detection' => $disableContentTypeDetection, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -575,8 +750,8 @@ public function sendDocument( /** * https://core.telegram.org/bots/api#sendvideo * - * 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. + * 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. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -608,6 +783,9 @@ public function sendDocument( * @param string $parseMode * Mode for parsing entities in the video caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param bool $supportsStreaming * Pass True, if the uploaded video is suitable for streaming * @@ -617,6 +795,9 @@ public function sendDocument( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -632,9 +813,11 @@ public function sendVideo( $thumb = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, bool $supportsStreaming = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -647,9 +830,11 @@ public function sendVideo( 'thumb' => $thumb, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'supports_streaming' => $supportsStreaming, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -696,12 +881,18 @@ public function sendVideo( * @param string $parseMode * Mode for parsing entities in the animation caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -717,8 +908,10 @@ public function sendAnimation( $thumb = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -731,8 +924,10 @@ public function sendAnimation( 'thumb' => $thumb, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -747,7 +942,9 @@ public function sendAnimation( * https://core.telegram.org/bots/api#sendvoice * * 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. + * 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. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -763,6 +960,9 @@ public function sendAnimation( * @param string $parseMode * Mode for parsing entities in the voice message caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param int $duration * Duration of the voice message in seconds * @@ -772,6 +972,9 @@ public function sendAnimation( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -783,9 +986,11 @@ public function sendVoice( $voice, string $caption = null, string $parseMode = null, + array $captionEntities = null, int $duration = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -794,9 +999,11 @@ public function sendVoice( 'voice' => $voice, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'duration' => $duration, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -840,6 +1047,9 @@ public function sendVoice( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -854,6 +1064,7 @@ public function sendVideoNote( $thumb = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -865,6 +1076,7 @@ public function sendVideoNote( 'thumb' => $thumb, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -878,27 +1090,33 @@ public function sendVideoNote( /** * https://core.telegram.org/bots/api#sendmediagroup * - * Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned. + * Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be + * only grouped in an album with messages of the same type. On success, an array of Messages that + * were sent is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * - * @param Type\InputMediaPhoto[]|Type\InputMediaVideo[] $media - * A JSON-serialized array describing photos and videos to be sent, must include 2-10 items + * @param Type\InputMediaAudio[]|Type\InputMediaDocument[]|Type\InputMediaPhoto[]|Type\InputMediaVideo[] $media + * A JSON-serialized array describing messages to be sent, must include 2-10 items * * @param bool $disableNotification - * Sends the messages silently. Users will receive a notification with no sound. + * Sends messages silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the messages are a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @return Type\Message[]; */ public function sendMediaGroup( $chatId, $media, bool $disableNotification = null, - int $replyToMessageId = null + int $replyToMessageId = null, + bool $allowSendingWithoutReply = null ): array { $requestParameters = [ @@ -906,6 +1124,7 @@ public function sendMediaGroup( 'media' => $media, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, ]; $returnType = [ @@ -929,15 +1148,28 @@ public function sendMediaGroup( * @param float $longitude * Longitude of the location * + * @param float $horizontalAccuracy + * The radius of uncertainty for the location, measured in meters; 0-1500 + * * @param int $livePeriod * Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400. * + * @param int $heading + * For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. + * + * @param int $proximityAlertRadius + * For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. + * Must be between 1 and 100000 if specified. + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -948,9 +1180,13 @@ public function sendLocation( $chatId, float $latitude, float $longitude, + float $horizontalAccuracy = null, int $livePeriod = null, + int $heading = null, + int $proximityAlertRadius = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -958,9 +1194,13 @@ public function sendLocation( 'chat_id' => $chatId, 'latitude' => $latitude, 'longitude' => $longitude, + 'horizontal_accuracy' => $horizontalAccuracy, 'live_period' => $livePeriod, + 'heading' => $heading, + 'proximity_alert_radius' => $proximityAlertRadius, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -975,7 +1215,9 @@ public function sendLocation( * https://core.telegram.org/bots/api#editmessagelivelocation * * Use this method to edit live location messages. A location can be edited until its live_period expires or - * editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned. + * editing is explicitly disabled by a call to stopMessageLiveLocation. On + * success, if the edited message is not an inline message, the edited Message is returned, otherwise + * True is returned. * * @param float $latitude * Latitude of new location @@ -993,6 +1235,16 @@ public function sendLocation( * @param string $inlineMessageId * Required if chat_id and message_id are not specified. Identifier of the inline message * + * @param float $horizontalAccuracy + * The radius of uncertainty for the location, measured in meters; 0-1500 + * + * @param int $heading + * Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. + * + * @param int $proximityAlertRadius + * Maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and + * 100000 if specified. + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for a new inline keyboard. * @@ -1004,6 +1256,9 @@ public function editMessageLiveLocation( $chatId = null, int $messageId = null, string $inlineMessageId = null, + float $horizontalAccuracy = null, + int $heading = null, + int $proximityAlertRadius = null, Type\InlineKeyboardMarkup $replyMarkup = null ) { @@ -1013,6 +1268,9 @@ public function editMessageLiveLocation( 'inline_message_id' => $inlineMessageId, 'latitude' => $latitude, 'longitude' => $longitude, + 'horizontal_accuracy' => $horizontalAccuracy, + 'heading' => $heading, + 'proximity_alert_radius' => $proximityAlertRadius, 'reply_markup' => $replyMarkup, ]; @@ -1028,8 +1286,7 @@ public function editMessageLiveLocation( * https://core.telegram.org/bots/api#stopmessagelivelocation * * Use this method to stop updating a live location message before live_period expires. On success, if the - * message was sent by the bot, the sent Message is returned, - * otherwise True is returned. + * message was sent by the bot, the sent Message is returned, otherwise True is returned. * * @param int|string $chatId * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the @@ -1071,7 +1328,8 @@ public function stopMessageLiveLocation( /** * https://core.telegram.org/bots/api#sendvenue * - * Use this method to send information about a venue. On success, the sent Message is returned. + * Use this method to send information about a venue. On success, the sent Message is + * returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -1095,12 +1353,21 @@ public function stopMessageLiveLocation( * Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, * “arts_entertainment/aquarium” or “food/icecream”.) * + * @param string $googlePlaceId + * Google Places identifier of the venue + * + * @param string $googlePlaceType + * Google Places type of the venue. (See supported types.) + * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. * * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -1115,8 +1382,11 @@ public function sendVenue( string $address, string $foursquareId = null, string $foursquareType = null, + string $googlePlaceId = null, + string $googlePlaceType = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -1128,8 +1398,11 @@ public function sendVenue( 'address' => $address, 'foursquare_id' => $foursquareId, 'foursquare_type' => $foursquareType, + 'google_place_id' => $googlePlaceId, + 'google_place_type' => $googlePlaceType, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -1166,6 +1439,9 @@ public function sendVenue( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove keyboard or to force a reply from the user. @@ -1180,6 +1456,7 @@ public function sendContact( string $vcard = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -1191,6 +1468,7 @@ public function sendContact( 'vcard' => $vcard, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -1209,46 +1487,52 @@ public function sendContact( * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * - * @param string $question - * Poll question, 1-255 characters - * * @param string[] $options * A JSON-serialized list of answer options, 2-10 strings 1-100 characters each * - * @param bool $isAnonymous - * True, if the poll needs to be anonymous, defaults to True - * - * @param string $type - * Poll type, “quiz” or “regular”, defaults to “regular” + * @param string $question + * Poll question, 1-300 characters * - * @param bool $allowsMultipleAnswers - * True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False + * @param int $openPeriod + * Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date. * - * @param int $correctOptionId - * 0-based identifier of the correct answer option, required for polls in quiz mode + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found * - * @param string $explanation - * Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 - * characters with at most 2 line feeds after entities parsing + * @param int $replyToMessageId + * If the message is a reply, ID of the original message * - * @param string $explanationParseMode - * Mode for parsing entities in the explanation. See formatting options for more details. + * @param bool $disableNotification + * Sends the message silently. Users will receive a notification with no sound. * - * @param int $openPeriod - * Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date. + * @param bool $isClosed + * Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. * * @param int $closeDate * Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 * seconds in the future. Can't be used together with open_period. * - * @param bool $isClosed - * Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. + * @param string $explanationParseMode + * Mode for parsing entities in the explanation. See formatting options for more details. * - * @param bool $disableNotification - * Sends the message silently. Users will receive a notification with no sound. + * @param Type\MessageEntity[] $explanationEntities + * List of special entities that appear in the poll explanation, which can be specified instead of parse_mode * - * @param int $replyToMessageId - * If the message is a reply, ID of the original message + * @param string $explanation + * Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 + * characters with at most 2 line feeds after entities parsing + * + * @param int $correctOptionId + * 0-based identifier of the correct answer option, required for polls in quiz mode + * + * @param bool $allowsMultipleAnswers + * True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False + * + * @param string $type + * Poll type, “quiz” or “regular”, defaults to “regular” + * + * @param bool $isAnonymous + * True, if the poll needs to be anonymous, defaults to True * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, @@ -1258,19 +1542,21 @@ public function sendContact( */ public function sendPoll( $chatId, - string $question, array $options, - bool $isAnonymous = null, - string $type = null, - bool $allowsMultipleAnswers = null, - int $correctOptionId = null, - string $explanation = null, - string $explanationParseMode = null, + string $question, int $openPeriod = null, - int $closeDate = null, - bool $isClosed = null, - bool $disableNotification = null, + bool $allowSendingWithoutReply = null, int $replyToMessageId = null, + bool $disableNotification = null, + bool $isClosed = null, + int $closeDate = null, + string $explanationParseMode = null, + array $explanationEntities = null, + string $explanation = null, + int $correctOptionId = null, + bool $allowsMultipleAnswers = null, + string $type = null, + bool $isAnonymous = null, $replyMarkup = null ): Type\Message { @@ -1284,11 +1570,13 @@ public function sendPoll( 'correct_option_id' => $correctOptionId, 'explanation' => $explanation, 'explanation_parse_mode' => $explanationParseMode, + 'explanation_entities' => $explanationEntities, 'open_period' => $openPeriod, 'close_date' => $closeDate, 'is_closed' => $isClosed, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -1308,8 +1596,9 @@ public function sendPoll( * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * * @param string $emoji - * Emoji on which the dice throw animation is based. Currently, must be one of “”, “”, or “”. Dice can - * have values 1-6 for “” and “”, and values 1-5 for “”. Defaults to “” + * Emoji on which the dice throw animation is based. Currently, must be one of “”, “”, “”, “”, + * “”, or “”. Dice can have values 1-6 for “”, “” and “”, values 1-5 for “” and “”, and values + * 1-64 for “”. Defaults to “” * * @param bool $disableNotification * Sends the message silently. Users will receive a notification with no sound. @@ -1317,6 +1606,9 @@ public function sendPoll( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -1328,6 +1620,7 @@ public function sendDice( string $emoji = null, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -1336,6 +1629,7 @@ public function sendDice( 'emoji' => $emoji, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -1359,8 +1653,8 @@ public function sendDice( * * @param string $action * Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text - * messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio - * files, upload_document for general files, find_location for location data, record_video_note or + * messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice + * notes, upload_document for general files, find_location for location data, record_video_note or * upload_video_note for video notes. * * @return bool; @@ -1421,10 +1715,10 @@ public function getUserProfilePhotos( * https://core.telegram.org/bots/api#getfile * * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files - * of up to 20MB in size. On success, a File object is - * returned. The file can then be downloaded via the link - * https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for - * at least 1 hour. When the link expires, a new one can be requested by calling getFile again. + * of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the + * link https://api.telegram.org/file/bot<token>/<file_path>, where + * <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new + * one can be requested by calling getFile again. * * @param string $fileId * File identifier to get info about @@ -1450,7 +1744,7 @@ public function getFile( * https://core.telegram.org/bots/api#kickchatmember * * Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user - * will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. + * will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. * Returns True on success. * * @param int|string $chatId @@ -1462,20 +1756,26 @@ public function getFile( * * @param int $untilDate * Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from - * the current time they are considered to be banned forever + * the current time they are considered to be banned forever. Applied for supergroups and channels only. + * + * @param bool $revokeMessages + * Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to + * see messages in the group that were sent before the user was removed. Always True for supergroups and channels. * * @return bool; */ public function kickChatMember( $chatId, int $userId, - int $untilDate = null + int $untilDate = null, + bool $revokeMessages = null ): bool { $requestParameters = [ 'chat_id' => $chatId, 'user_id' => $userId, 'until_date' => $untilDate, + 'revoke_messages' => $revokeMessages, ]; $returnType = [ @@ -1490,7 +1790,9 @@ public function kickChatMember( * * Use this method to unban a previously kicked user in a supergroup or channel. The user will not * return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this - * to work. Returns True on success. + * to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to + * join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want + * this, use the parameter only_if_banned. Returns True on success. * * @param int|string $chatId * Unique identifier for the target group or username of the target supergroup or channel (in the format @@ -1499,16 +1801,21 @@ public function kickChatMember( * @param int $userId * Unique identifier of the target user * + * @param bool $onlyIfBanned + * Do nothing if the user is not banned + * * @return bool; */ public function unbanChatMember( $chatId, - int $userId + int $userId, + bool $onlyIfBanned = null ): bool { $requestParameters = [ 'chat_id' => $chatId, 'user_id' => $userId, + 'only_if_banned' => $onlyIfBanned, ]; $returnType = [ @@ -1575,8 +1882,13 @@ public function restrictChatMember( * @param int $userId * Unique identifier of the target user * - * @param bool $canChangeInfo - * Pass True, if the administrator can change chat title, photo and other settings + * @param bool $isAnonymous + * Pass True, if the administrator's presence in the chat is hidden + * + * @param bool $canManageChat + * Pass True, if the administrator can access the chat event log, chat statistics, message statistics in + * channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other + * administrator privilege * * @param bool $canPostMessages * Pass True, if the administrator can create channel posts, channels only @@ -1587,45 +1899,57 @@ public function restrictChatMember( * @param bool $canDeleteMessages * Pass True, if the administrator can delete messages of other users * - * @param bool $canInviteUsers - * Pass True, if the administrator can invite new users to the chat + * @param bool $canManageVoiceChats + * Pass True, if the administrator can manage voice chats * * @param bool $canRestrictMembers * Pass True, if the administrator can restrict, ban or unban chat members * - * @param bool $canPinMessages - * Pass True, if the administrator can pin messages, supergroups only - * * @param bool $canPromoteMembers * Pass True, if the administrator can add new administrators with a subset of their own privileges or demote * administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) * + * @param bool $canChangeInfo + * Pass True, if the administrator can change chat title, photo and other settings + * + * @param bool $canInviteUsers + * Pass True, if the administrator can invite new users to the chat + * + * @param bool $canPinMessages + * Pass True, if the administrator can pin messages, supergroups only + * * @return bool; */ public function promoteChatMember( $chatId, int $userId, - bool $canChangeInfo = null, + bool $isAnonymous = null, + bool $canManageChat = null, bool $canPostMessages = null, bool $canEditMessages = null, bool $canDeleteMessages = null, - bool $canInviteUsers = null, + bool $canManageVoiceChats = null, bool $canRestrictMembers = null, - bool $canPinMessages = null, - bool $canPromoteMembers = null + bool $canPromoteMembers = null, + bool $canChangeInfo = null, + bool $canInviteUsers = null, + bool $canPinMessages = null ): bool { $requestParameters = [ 'chat_id' => $chatId, 'user_id' => $userId, - 'can_change_info' => $canChangeInfo, + 'is_anonymous' => $isAnonymous, + 'can_manage_chat' => $canManageChat, 'can_post_messages' => $canPostMessages, 'can_edit_messages' => $canEditMessages, 'can_delete_messages' => $canDeleteMessages, - 'can_invite_users' => $canInviteUsers, + 'can_manage_voice_chats' => $canManageVoiceChats, 'can_restrict_members' => $canRestrictMembers, - 'can_pin_messages' => $canPinMessages, 'can_promote_members' => $canPromoteMembers, + 'can_change_info' => $canChangeInfo, + 'can_invite_users' => $canInviteUsers, + 'can_pin_messages' => $canPinMessages, ]; $returnType = [ @@ -1707,9 +2031,9 @@ public function setChatPermissions( /** * https://core.telegram.org/bots/api#exportchatinvitelink * - * Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an - * administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as - * String on success. + * Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. + * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new + * invite link as String on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -1731,6 +2055,117 @@ public function exportChatInviteLink( return $this->_requestWithMap('exportChatInviteLink', $requestParameters, $returnType); } + /** + * https://core.telegram.org/bots/api#createchatinvitelink + * + * Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to + * work and must have the appropriate admin rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @param int $expireDate + * Point in time (Unix timestamp) when the link will expire + * + * @param int $memberLimit + * Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite + * link; 1-99999 + * + * @return Type\ChatInviteLink; + */ + public function createChatInviteLink( + $chatId, + int $expireDate = null, + int $memberLimit = null + ): Type\ChatInviteLink + { + $requestParameters = [ + 'chat_id' => $chatId, + 'expire_date' => $expireDate, + 'member_limit' => $memberLimit, + ]; + + $returnType = [ + Type\ChatInviteLink::class, + ]; + + return $this->_requestWithMap('createChatInviteLink', $requestParameters, $returnType); + } + + /** + * https://core.telegram.org/bots/api#editchatinvitelink + * + * Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for + * this to work and must have the appropriate admin rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @param string $inviteLink + * The invite link to edit + * + * @param int $expireDate + * Point in time (Unix timestamp) when the link will expire + * + * @param int $memberLimit + * Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite + * link; 1-99999 + * + * @return Type\ChatInviteLink; + */ + public function editChatInviteLink( + $chatId, + string $inviteLink, + int $expireDate = null, + int $memberLimit = null + ): Type\ChatInviteLink + { + $requestParameters = [ + 'chat_id' => $chatId, + 'invite_link' => $inviteLink, + 'expire_date' => $expireDate, + 'member_limit' => $memberLimit, + ]; + + $returnType = [ + Type\ChatInviteLink::class, + ]; + + return $this->_requestWithMap('editChatInviteLink', $requestParameters, $returnType); + } + + /** + * https://core.telegram.org/bots/api#revokechatinvitelink + * + * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically + * generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the + * revoked invite link as ChatInviteLink object. + * + * @param int|string $chatId + * Unique identifier of the target chat or username of the target channel (in the format @|channelusername) + * + * @param string $inviteLink + * The invite link to revoke + * + * @return Type\ChatInviteLink; + */ + public function revokeChatInviteLink( + $chatId, + string $inviteLink + ): Type\ChatInviteLink + { + $requestParameters = [ + 'chat_id' => $chatId, + 'invite_link' => $inviteLink, + ]; + + $returnType = [ + Type\ChatInviteLink::class, + ]; + + return $this->_requestWithMap('revokeChatInviteLink', $requestParameters, $returnType); + } + /** * https://core.telegram.org/bots/api#setchatphoto * @@ -1853,9 +2288,9 @@ public function setChatDescription( /** * https://core.telegram.org/bots/api#pinchatmessage * - * Use this method to pin a message in a group, 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. + * Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be + * an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or + * 'can_edit_messages' admin right in a channel. Returns True on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -1865,7 +2300,7 @@ public function setChatDescription( * * @param bool $disableNotification * Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. - * Notifications are always disabled in channels. + * Notifications are always disabled in channels and private chats. * * @return bool; */ @@ -1891,21 +2326,27 @@ public function pinChatMessage( /** * https://core.telegram.org/bots/api#unpinchatmessage * - * Use this method to unpin a message in a group, 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. + * Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot + * must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or + * 'can_edit_messages' admin right in a channel. Returns True on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * + * @param int $messageId + * Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be + * unpinned. + * * @return bool; */ public function unpinChatMessage( - $chatId + $chatId, + int $messageId = null ): bool { $requestParameters = [ 'chat_id' => $chatId, + 'message_id' => $messageId, ]; $returnType = [ @@ -1915,6 +2356,33 @@ public function unpinChatMessage( return $this->_requestWithMap('unpinChatMessage', $requestParameters, $returnType); } + /** + * https://core.telegram.org/bots/api#unpinallchatmessages + * + * Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an + * administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' + * admin right in a channel. Returns True on success. + * + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) + * + * @return bool; + */ + public function unpinAllChatMessages( + $chatId + ): bool + { + $requestParameters = [ + 'chat_id' => $chatId, + ]; + + $returnType = [ + 'bool', + ]; + + return $this->_requestWithMap('unpinAllChatMessages', $requestParameters, $returnType); + } + /** * https://core.telegram.org/bots/api#leavechat * @@ -2024,7 +2492,8 @@ public function getChatMembersCount( /** * https://core.telegram.org/bots/api#getchatmember * - * Use this method to get information about a member of a chat. Returns a ChatMember object on success. + * Use this method to get information about a member of a chat. Returns a ChatMember object + * on success. * * @param int|string $chatId * Unique identifier for the target chat or username of the target supergroup or channel (in the format @@ -2210,8 +2679,8 @@ public function getMyCommands( /** * https://core.telegram.org/bots/api#editmessagetext * - * Use this method to edit text and game messages. On - * success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. + * Use this method to edit text and game messages. On success, if the edited message is not an + * inline message, the edited Message is returned, otherwise True is returned. * * @param string $text * New text of the message, 1-4096 characters after entities parsing @@ -2229,6 +2698,9 @@ public function getMyCommands( * @param string $parseMode * Mode for parsing entities in the message text. See formatting options for more details. * + * @param Type\MessageEntity[] $entities + * List of special entities that appear in message text, which can be specified instead of parse_mode + * * @param bool $disableWebPagePreview * Disables link previews for links in this message * @@ -2243,6 +2715,7 @@ public function editMessageText( int $messageId = null, string $inlineMessageId = null, string $parseMode = null, + array $entities = null, bool $disableWebPagePreview = null, Type\InlineKeyboardMarkup $replyMarkup = null ) @@ -2253,6 +2726,7 @@ public function editMessageText( 'inline_message_id' => $inlineMessageId, 'text' => $text, 'parse_mode' => $parseMode, + 'entities' => $entities, 'disable_web_page_preview' => $disableWebPagePreview, 'reply_markup' => $replyMarkup, ]; @@ -2268,7 +2742,7 @@ public function editMessageText( /** * https://core.telegram.org/bots/api#editmessagecaption * - * Use this method to edit captions of messages. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. + * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. * * @param int|string $chatId * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the @@ -2286,6 +2760,9 @@ public function editMessageText( * @param string $parseMode * Mode for parsing entities in the message caption. See formatting options for more details. * + * @param Type\MessageEntity[] $captionEntities + * List of special entities that appear in the caption, which can be specified instead of parse_mode + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for an inline keyboard. * @@ -2297,6 +2774,7 @@ public function editMessageCaption( string $inlineMessageId = null, string $caption = null, string $parseMode = null, + array $captionEntities = null, Type\InlineKeyboardMarkup $replyMarkup = null ) { @@ -2306,6 +2784,7 @@ public function editMessageCaption( 'inline_message_id' => $inlineMessageId, 'caption' => $caption, 'parse_mode' => $parseMode, + 'caption_entities' => $captionEntities, 'reply_markup' => $replyMarkup, ]; @@ -2320,12 +2799,13 @@ public function editMessageCaption( /** * https://core.telegram.org/bots/api#editmessagemedia * - * Use this method to edit animation, audio, document, photo, or video messages. If a message is a part of a message - * album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline - * message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, if - * the edited message was sent by the bot, the edited Message is returned, otherwise True is returned. + * Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, + * then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video + * otherwise. When an inline message is edited, a new file can't be uploaded. Use a previously uploaded file via its file_id or + * specify a URL. On success, if the edited message was sent by the bot, the edited Message is returned, + * otherwise True is returned. * - * @param Type\InputMediaAnimation|Type\InputMediaDocument|Type\InputMediaAudio|Type\InputMediaPhoto|Type\InputMediaVideo $media + * @param Type\AbstractInputMedia $media * A JSON-serialized object for a new media content of the message * * @param int|string $chatId @@ -2344,7 +2824,7 @@ public function editMessageCaption( * @return Type\Message|bool; */ public function editMessageMedia( - $media, + Type\AbstractInputMedia $media, $chatId = null, int $messageId = null, string $inlineMessageId = null, @@ -2370,9 +2850,8 @@ public function editMessageMedia( /** * https://core.telegram.org/bots/api#editmessagereplymarkup * - * Use this method to edit only the reply markup of messages. On success, if edited message is sent by the bot, the edited - * Message is returned, otherwise True is - * returned. + * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, + * the edited Message is returned, otherwise True is returned. * * @param int|string $chatId * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the @@ -2414,7 +2893,8 @@ public function editMessageReplyMarkup( /** * https://core.telegram.org/bots/api#stoppoll * - * Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned. + * Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the + * final results is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -2486,8 +2966,7 @@ public function deleteMessage( * https://core.telegram.org/bots/api#sendsticker * * Use this method to send static .WEBP or animated - * .TGS stickers. On success, the sent Message is - * returned. + * .TGS stickers. On success, the sent Message is returned. * * @param int|string $chatId * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) @@ -2503,6 +2982,9 @@ public function deleteMessage( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup|Type\ReplyKeyboardMarkup|Type\ReplyKeyboardRemove|Type\ForceReply $replyMarkup * Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, * instructions to remove reply keyboard or to force a reply from the user. @@ -2514,6 +2996,7 @@ public function sendSticker( $sticker, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, $replyMarkup = null ): Type\Message { @@ -2522,6 +3005,7 @@ public function sendSticker( 'sticker' => $sticker, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -2879,8 +3363,8 @@ public function answerInlineQuery( * * Use this method to send invoices. On success, the sent Message is returned. * - * @param int $chatId - * Unique identifier for the target private chat + * @param int|string $chatId + * Unique identifier for the target chat or username of the target channel (in the format @|channelusername) * * @param string $description * Product description, 1-255 characters @@ -2892,9 +3376,6 @@ public function answerInlineQuery( * @param string $providerToken * Payments provider token, obtained via Botfather * - * @param string $startParameter - * Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter - * * @param string $currency * Three-letter ISO 4217 currency code, see more on currencies * @@ -2905,8 +3386,11 @@ public function answerInlineQuery( * @param string $title * Product name, 1-32 characters * - * @param bool $needShippingAddress - * Pass True, if you require the user's shipping address to complete the order + * @param bool $needEmail + * Pass True, if you require the user's email address to complete the order + * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found * * @param int $replyToMessageId * If the message is a reply, ID of the original message @@ -2923,12 +3407,12 @@ public function answerInlineQuery( * @param bool $sendPhoneNumberToProvider * Pass True, if user's phone number should be sent to provider * + * @param bool $needShippingAddress + * Pass True, if you require the user's shipping address to complete the order + * * @param int $photoWidth * Photo width * - * @param bool $needEmail - * Pass True, if you require the user's email address to complete the order - * * @param bool $needPhoneNumber * Pass True, if you require the user's phone number to complete the order * @@ -2949,6 +3433,22 @@ public function answerInlineQuery( * A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed * description of required fields should be provided by the payment provider. * + * @param string $startParameter + * Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, + * allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded + * copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used + * as the start parameter + * + * @param int[] $suggestedTipAmounts + * A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not + * float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a + * strictly increased order and must not exceed max_tip_amount. + * + * @param int $maxTipAmount + * The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For + * example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the + * number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not * empty, the first button must be a Pay button. @@ -2956,28 +3456,31 @@ public function answerInlineQuery( * @return Type\Message; */ public function sendInvoice( - int $chatId, + $chatId, string $description, string $payload, string $providerToken, - string $startParameter, string $currency, array $prices, string $title, - bool $needShippingAddress = null, + bool $needEmail = null, + bool $allowSendingWithoutReply = null, int $replyToMessageId = null, bool $disableNotification = null, bool $isFlexible = null, bool $sendEmailToProvider = null, bool $sendPhoneNumberToProvider = null, + bool $needShippingAddress = null, int $photoWidth = null, - bool $needEmail = null, bool $needPhoneNumber = null, bool $needName = null, int $photoHeight = null, int $photoSize = null, string $photoUrl = null, string $providerData = null, + string $startParameter = null, + array $suggestedTipAmounts = null, + int $maxTipAmount = null, Type\InlineKeyboardMarkup $replyMarkup = null ): Type\Message { @@ -2987,9 +3490,11 @@ public function sendInvoice( 'description' => $description, 'payload' => $payload, 'provider_token' => $providerToken, - 'start_parameter' => $startParameter, 'currency' => $currency, 'prices' => $prices, + 'max_tip_amount' => $maxTipAmount, + 'suggested_tip_amounts' => $suggestedTipAmounts, + 'start_parameter' => $startParameter, 'provider_data' => $providerData, 'photo_url' => $photoUrl, 'photo_size' => $photoSize, @@ -3004,6 +3509,7 @@ public function sendInvoice( 'is_flexible' => $isFlexible, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -3018,8 +3524,8 @@ public function sendInvoice( * https://core.telegram.org/bots/api#answershippingquery * * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot - * API will send an Update with a - * shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * API will send an Update with a shipping_query field to the bot. Use this method to + * reply to shipping queries. On success, True is returned. * * @param string $shippingQueryId * Unique identifier for the query to be answered @@ -3063,9 +3569,9 @@ public function answerShippingQuery( * https://core.telegram.org/bots/api#answerprecheckoutquery * * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form - * of an Update with the field - * pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The - * Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * of an Update with the field pre_checkout_query. Use this method to respond to such + * pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds + * after the pre-checkout query was sent. * * @param string $preCheckoutQueryId * Unique identifier for the query to be answered @@ -3113,14 +3619,14 @@ public function answerPreCheckoutQuery( * @param int $userId * User identifier * - * @param Type\PassportElementErrorDataField[]|Type\PassportElementErrorFrontSide[]|Type\PassportElementErrorReverseSide[]|Type\PassportElementErrorSelfie[]|Type\PassportElementErrorFile[]|Type\PassportElementErrorFiles[]|Type\PassportElementErrorTranslationFile[]|Type\PassportElementErrorTranslationFiles[]|Type\PassportElementErrorUnspecified[] $errors + * @param Type\AbstractPassportElementError[] $errors * A JSON-serialized array describing the errors * * @return bool; */ public function setPassportDataErrors( int $userId, - $errors + array $errors ): bool { $requestParameters = [ @@ -3152,6 +3658,9 @@ public function setPassportDataErrors( * @param int $replyToMessageId * If the message is a reply, ID of the original message * + * @param bool $allowSendingWithoutReply + * Pass True, if the message should be sent even if the specified replied-to message is not found + * * @param Type\InlineKeyboardMarkup $replyMarkup * A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not * empty, the first button must launch the game. @@ -3163,6 +3672,7 @@ public function sendGame( string $gameShortName, bool $disableNotification = null, int $replyToMessageId = null, + bool $allowSendingWithoutReply = null, Type\InlineKeyboardMarkup $replyMarkup = null ): Type\Message { @@ -3171,6 +3681,7 @@ public function sendGame( 'game_short_name' => $gameShortName, 'disable_notification' => $disableNotification, 'reply_to_message_id' => $replyToMessageId, + 'allow_sending_without_reply' => $allowSendingWithoutReply, 'reply_markup' => $replyMarkup, ]; @@ -3185,9 +3696,8 @@ public function sendGame( * https://core.telegram.org/bots/api#setgamescore * * Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns - * the edited Message, otherwise returns - * True. Returns an error, if the new score is not greater than the user's current score in the chat and force is - * False. + * the edited Message, otherwise returns True. Returns an error, if the new score is + * not greater than the user's current score in the chat and force is False. * * @param int $userId * User identifier