1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-02 16:37:47 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
15775a16a4 Bump 2024-07-02 16:02:59 +02:00
b4e0a7823a Add support for invokeWithBusinessConnection 2024-07-02 15:58:31 +02:00
8 changed files with 26 additions and 9 deletions

2
docs

@ -1 +1 @@
Subproject commit c786c5b20411526c7b7d6f1b94d19edf92c11bdb
Subproject commit 4b7c4dcf943bff95e2c16eb56fed0317242ba500

View File

@ -565,6 +565,11 @@ final class Connection
'invokeWithTakeout',
['takeout_id' => $message->takeoutId, 'query' => $body],
);
} elseif ($message->businessConnectionId !== null) {
$body = $this->API->getTL()->serializeMethod(
'invokeWithBusinessConnection',
['connection_id' => $message->businessConnectionId, 'query' => $body],
);
}
} else {
$body['_'] = $message->constructor;

View File

@ -657,7 +657,7 @@ abstract class InternalDoc
*
* Returns a vector hash.
*
* @param array<int|string> $longs IDs
* @param array $longs IDs
*/
final public static function genVectorHash(array $longs): string
{

View File

@ -124,6 +124,7 @@ class MTProtoOutgoingMessage extends MTProtoMessage
*/
public readonly ?int $floodWaitLimit = null,
public readonly ?int $takeoutId = null,
public readonly ?string $businessConnectionId = null,
private ?DeferredFuture $resultDeferred = null,
public readonly ?Cancellation $cancellation = null
) {

View File

@ -176,7 +176,8 @@ trait CallHandler
floodWaitLimit: $args['floodWaitLimit'] ?? null,
resultDeferred: $response,
cancellation: $cancellation,
takeoutId: $args['takeoutId'] ?? null
takeoutId: $args['takeoutId'] ?? null,
businessConnectionId: $args['businessConnectionId'] ?? null,
);
if ($queueId !== null) {
$this->callQueue[$queueId] = $message;

View File

@ -143,8 +143,9 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?string $businessConnectionId Business connection ID, received through an updateBotBusinessConnect update.
*/
public function setTyping(array $action, array|int|string|null $peer = null, int|null $top_msg_id = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool;
public function setTyping(array $action, array|int|string|null $peer = null, int|null $top_msg_id = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?string $businessConnectionId = null): bool;
/**
* Sends a message to a chat.
@ -171,9 +172,10 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?string $businessConnectionId Business connection ID, received through an updateBotBusinessConnect update.
* @return array @see https://docs.madelineproto.xyz/API_docs/types/Updates.html
*/
public function sendMessage(bool|null $no_webpage = null, bool|null $silent = null, bool|null $background = null, bool|null $clear_draft = null, bool|null $noforwards = null, bool|null $update_stickersets_order = null, bool|null $invert_media = null, array|int|string|null $peer = null, int $reply_to_msg_id = 0, int $top_msg_id = 0, array|null $reply_to = null, string|null $message = '', array|null $reply_markup = null, array|null $entities = null, \danog\MadelineProto\ParseMode $parse_mode = \danog\MadelineProto\ParseMode::TEXT, int|null $schedule_date = null, array|int|string|null $send_as = null, array|null $quick_reply_shortcut = null, int|null $effect = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function sendMessage(bool|null $no_webpage = null, bool|null $silent = null, bool|null $background = null, bool|null $clear_draft = null, bool|null $noforwards = null, bool|null $update_stickersets_order = null, bool|null $invert_media = null, array|int|string|null $peer = null, int $reply_to_msg_id = 0, int $top_msg_id = 0, array|null $reply_to = null, string|null $message = '', array|null $reply_markup = null, array|null $entities = null, \danog\MadelineProto\ParseMode $parse_mode = \danog\MadelineProto\ParseMode::TEXT, int|null $schedule_date = null, array|int|string|null $send_as = null, array|null $quick_reply_shortcut = null, int|null $effect = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?string $businessConnectionId = null): array;
/**
* Send a media.
@ -200,9 +202,10 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?string $businessConnectionId Business connection ID, received through an updateBotBusinessConnect update.
* @return array @see https://docs.madelineproto.xyz/API_docs/types/Updates.html
*/
public function sendMedia(bool|null $silent = null, bool|null $background = null, bool|null $clear_draft = null, bool|null $noforwards = null, bool|null $update_stickersets_order = null, bool|null $invert_media = null, array|int|string|null $peer = null, int $reply_to_msg_id = 0, int $top_msg_id = 0, array|null $reply_to = null, \danog\MadelineProto\EventHandler\Media|array|string|null $media = null, string|null $message = '', array|null $reply_markup = null, array|null $entities = null, \danog\MadelineProto\ParseMode $parse_mode = \danog\MadelineProto\ParseMode::TEXT, int|null $schedule_date = null, array|int|string|null $send_as = null, array|null $quick_reply_shortcut = null, int|null $effect = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function sendMedia(bool|null $silent = null, bool|null $background = null, bool|null $clear_draft = null, bool|null $noforwards = null, bool|null $update_stickersets_order = null, bool|null $invert_media = null, array|int|string|null $peer = null, int $reply_to_msg_id = 0, int $top_msg_id = 0, array|null $reply_to = null, \danog\MadelineProto\EventHandler\Media|array|string|null $media = null, string|null $message = '', array|null $reply_markup = null, array|null $entities = null, \danog\MadelineProto\ParseMode $parse_mode = \danog\MadelineProto\ParseMode::TEXT, int|null $schedule_date = null, array|int|string|null $send_as = null, array|null $quick_reply_shortcut = null, int|null $effect = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?string $businessConnectionId = null): array;
/**
* Forwards messages by their IDs.
@ -728,9 +731,10 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?string $businessConnectionId Business connection ID, received through an updateBotBusinessConnect update.
* @return array @see https://docs.madelineproto.xyz/API_docs/types/Updates.html
*/
public function editMessage(bool|null $no_webpage = null, bool|null $invert_media = null, array|int|string|null $peer = null, int|null $id = 0, string|null $message = null, \danog\MadelineProto\EventHandler\Media|array|string|null $media = null, array|null $reply_markup = null, array|null $entities = null, \danog\MadelineProto\ParseMode $parse_mode = \danog\MadelineProto\ParseMode::TEXT, int|null $schedule_date = null, int|null $quick_reply_shortcut_id = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function editMessage(bool|null $no_webpage = null, bool|null $invert_media = null, array|int|string|null $peer = null, int|null $id = 0, string|null $message = null, \danog\MadelineProto\EventHandler\Media|array|string|null $media = null, array|null $reply_markup = null, array|null $entities = null, \danog\MadelineProto\ParseMode $parse_mode = \danog\MadelineProto\ParseMode::TEXT, int|null $schedule_date = null, int|null $quick_reply_shortcut_id = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?string $businessConnectionId = null): array;
/**
* Edit an inline bot message.
@ -1162,9 +1166,10 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @param ?string $businessConnectionId Business connection ID, received through an updateBotBusinessConnect update.
* @return array @see https://docs.madelineproto.xyz/API_docs/types/Updates.html
*/
public function sendMultiMedia(bool|null $silent = null, bool|null $background = null, bool|null $clear_draft = null, bool|null $noforwards = null, bool|null $update_stickersets_order = null, bool|null $invert_media = null, array|int|string|null $peer = null, int $reply_to_msg_id = 0, int $top_msg_id = 0, array|null $reply_to = null, array $multi_media = [], int|null $schedule_date = null, array|int|string|null $send_as = null, array|null $quick_reply_shortcut = null, int|null $effect = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function sendMultiMedia(bool|null $silent = null, bool|null $background = null, bool|null $clear_draft = null, bool|null $noforwards = null, bool|null $update_stickersets_order = null, bool|null $invert_media = null, array|int|string|null $peer = null, int $reply_to_msg_id = 0, int $top_msg_id = 0, array|null $reply_to = null, array $multi_media = [], int|null $schedule_date = null, array|int|string|null $send_as = null, array|null $quick_reply_shortcut = null, int|null $effect = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null, ?string $businessConnectionId = null): array;
/**
* Upload encrypted file and associate it to a secret chat.

View File

@ -52,7 +52,7 @@ abstract class SettingsAbstract
$uc = ucfirst($name);
if ((isset($other->{$name}) || $name === 'metricsBindTo')
&& (
!array_key_exists($name, $defaults)
!\array_key_exists($name, $defaults)
|| (
$other->{$name} !== $defaults[$name] // Isn't equal to the default value
|| $other->{$name} !== $this->{$name} // Is equal, but current value is not the default one

View File

@ -388,6 +388,11 @@ final class Blacklist {
$signature []= "?int \$takeoutId = null";
}
if (\in_array($method, ['messages.sendMessage', 'messages.editMessage', 'messages.sendMedia', 'messages.sendMultiMedia', 'messages.setTyping'], true)) {
$contents .= " * @param ?string \$businessConnectionId Business connection ID, received through an updateBotBusinessConnect update.\n";
$signature []= "?string \$businessConnectionId = null";
}
return [$contents, $signature];
}
/**