1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-22 15:51:15 +01:00

Fix broadcasts with bot API file IDs, fix MTProtoToBotAPI

This commit is contained in:
Daniil Gentili 2023-12-15 14:06:16 +01:00
parent f43782c3a1
commit a3e66c8b53
8 changed files with 33 additions and 31 deletions

View File

@ -21,6 +21,8 @@ It can login with a phone number (MTProto API), or with a bot token (MTProto API
```php
<?php
// PHP 8.2+ is required.
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}

2
docs

@ -1 +1 @@
Subproject commit b42eb2712569558b159263d44430df0848573fa6
Subproject commit bfbaedd6af4dc5b64298189783b81738ec5c5c08

View File

@ -100,8 +100,8 @@
<PossiblyNullReference>
<code>getInputClientProxy</code>
<code>isHttp</code>
<code>refreshNext</code>
<code>refreshNext</code>
<code>refreshNextDisable</code>
<code>refreshNextEnable</code>
</PossiblyNullReference>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$res['chat_id']]]></code>
@ -1713,10 +1713,6 @@
<PossiblyNullArrayOffset>
<code><![CDATA[$res['participants']]]></code>
</PossiblyNullArrayOffset>
<PossiblyUndefinedArrayOffset>
<code><![CDATA[$partial['InputChannel']]]></code>
<code><![CDATA[$partial['InputUser']]]></code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="src/MTProtoTools/ReferenceDatabase.php">
<PossiblyNullArrayAccess>
@ -1751,9 +1747,6 @@
<InaccessibleProperty>
<code><![CDATA[$last->nextSent]]></code>
</InaccessibleProperty>
<InvalidArrayOffset>
<code><![CDATA[$info['User']]]></code>
</InvalidArrayOffset>
<MissingReturnType>
<code>getUpdatesState</code>
<code>loadUpdateState</code>

View File

@ -40,8 +40,8 @@ final class ActionSend implements Action
return;
}
$id = $this->API->extractMessageId($this->API->methodCallAsyncRead(
isset($message['media']['_']) &&
$message['media']['_'] !== 'messageMediaWebPage'
\is_string($message['media']) || (isset($message['media']['_']) &&
$message['media']['_'] !== 'messageMediaWebPage')
? 'messages.sendMedia'
: 'messages.sendMessage',
array_merge($message, ['peer' => $peer, 'floodWaitLimit' => 2*86400, 'cancellation' => $cancellation]),

View File

@ -555,16 +555,19 @@ final class Connection
if (!$message->hasSerializedBody() || $message->shouldRefreshReferences()) {
$body = $message->getBody();
if ($message->shouldRefreshReferences()) {
$this->API->referenceDatabase->refreshNext(true);
$this->API->referenceDatabase->refreshNextEnable();
}
if ($message->isMethod) {
$body = $this->API->getTL()->serializeMethod($message->constructor, $body);
} else {
$body['_'] = $message->constructor;
$body = $this->API->getTL()->serializeObject(['type' => ''], $body, $message->constructor);
}
if ($message->shouldRefreshReferences()) {
$this->API->referenceDatabase->refreshNext(false);
try {
if ($message->isMethod) {
$body = $this->API->getTL()->serializeMethod($message->constructor, $body);
} else {
$body['_'] = $message->constructor;
$body = $this->API->getTL()->serializeObject(['type' => ''], $body, $message->constructor);
}
} finally {
if ($message->shouldRefreshReferences()) {
$this->API->referenceDatabase->refreshNextDisable();
}
}
$message->setSerializedBody($body);
unset($body);

View File

@ -1110,7 +1110,7 @@ trait Files
$origCb(100, 0, 0);
return;
}
$parallel_chunks = $seekable ? $parallel_chunks : 1;
$parallel_chunks = $seekable ? $parallel_chunks : 2;
if ($params) {
$previous_promise = true;
$promises = [];

View File

@ -441,19 +441,23 @@ final class ReferenceDatabase implements TLCallback
EventLoop::queue($this->flush(...), $location);
}
public function refreshNext(bool $refresh = false): void
public function refreshNextEnable(): void
{
if ($this->refreshCount === 1 && !$refresh) {
$this->refreshed = [];
$this->refreshCount--;
$this->refresh = false;
} elseif ($this->refreshCount === 0 && $refresh) {
if ($this->refreshCount === 0) {
$this->refreshed = [];
$this->refreshCount++;
$this->refresh = true;
} elseif ($this->refreshCount === 0 && !$refresh) {
} elseif ($refresh) {
} else {
$this->refreshCount++;
}
}
public function refreshNextDisable(): void
{
if ($this->refreshCount === 1) {
$this->refreshed = [];
$this->refreshCount--;
$this->refresh = false;
} elseif ($this->refreshCount === 0) {
} else {
$this->refreshCount--;
}

View File

@ -206,7 +206,7 @@ trait BotAPI
if (isset($data['fwd_from']['from_id'])) {
$newd['forward_from'] = ($this->getPwrChat($data['fwd_from']['from_id'], false));
}
if ($data['fwd_from'] < 0) {
if (isset($data['fwd_from']) && $data['fwd_from'] < 0) {
try {
$newd['forward_from_chat'] = $this->getPwrChat($data['fwd_from'], false);
} catch (Throwable $e) {