Skip to content

Commit

Permalink
Add support for invokeWithBusinessConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jul 2, 2024
1 parent 62b06f1 commit b4e0a78
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ public function sendMessage(MTProtoOutgoingMessage $message): void
'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;
Expand Down
1 change: 1 addition & 0 deletions src/MTProto/MTProtoOutgoingMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function __construct(
*/
public readonly ?int $floodWaitLimit = null,
public readonly ?int $takeoutId = null,
public readonly ?string $businessConnectionId = null,
private ?DeferredFuture $resultDeferred = null,
public readonly ?Cancellation $cancellation = null
) {
Expand Down
3 changes: 2 additions & 1 deletion src/MTProtoSession/CallHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ public function methodCallAsyncWrite(string $method, array $args): WrappedFuture
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;
Expand Down
5 changes: 5 additions & 0 deletions tools/AnnotationsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ private function prepareTLParams(array $data): array
$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];
}
/**
Expand Down

0 comments on commit b4e0a78

Please sign in to comment.