1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-26 17:24:40 +01:00
This commit is contained in:
Daniil Gentili 2024-03-02 19:32:18 +01:00
parent 00d0eb9f7b
commit 0df07f3a37
3 changed files with 23 additions and 11 deletions

View File

@ -389,14 +389,25 @@ abstract class AbstractMessage extends Update implements SimpleFilters
*/
public function read(bool $readAll = false): bool
{
return $this->getClient()->methodCallAsyncRead(
DialogId::isSupergroupOrChannel($this->chatId) ? 'channels.readHistory':'messages.readHistory',
if (DialogId::isSupergroupOrChannel($this->chatId)) {
return $this->getClient()->methodCallAsyncRead(
'channels.readHistory',
[
'peer' => $this->chatId,
'channel' => $this->chatId,
'max_id' => $readAll ? 0 : $this->id,
]
);
}
$this->getClient()->methodCallAsyncRead(
'messages.readHistory',
[
'peer' => $this->chatId,
'channel' => $this->chatId,
'max_id' => $readAll ? 0 : $this->id,
]
);
return true;
}
/**

View File

@ -31,8 +31,6 @@ use const DIRECTORY_SEPARATOR;
use const E_ALL;
use const MADELINE_WORKER_TYPE;
use const PHP_INT_SIZE;
use const PHP_MAJOR_VERSION;
use const PHP_MINOR_VERSION;
use const PHP_SAPI;
use const SIG_DFL;

View File

@ -76,7 +76,8 @@ final class Builder
}
private array $methodsCalled = [];
private array $methodsCreated = [];
private function methodCall(string $method): string {
private function methodCall(string $method): string
{
$this->methodsCalled[$method] = true;
return $this->methodsCreated[$method]
? "\$this->$method(\$stream)"
@ -104,7 +105,7 @@ final class Builder
'int128' => 'stream_get_contents($stream, 16)',
'int256' => 'stream_get_contents($stream, 32)',
'int512' => 'stream_get_contents($stream, 64)',
'string', 'bytes', 'waveform', 'random_bytes' =>
'string', 'bytes', 'waveform', 'random_bytes' =>
$this->methodCall("deserialize_$type"),
default => \in_array($type, self::RECURSIVE_TYPES, true) || isset($param['subtype'])
? $this->methodCall("deserialize_type_{$this->escapeTypeName($type)}")
@ -121,7 +122,7 @@ final class Builder
}
$superBare = $this->typeByPredicate[$predicate] === 'JSONValue'
|| $this->typeByPredicate[$predicate] === 'Peer';
$result = '';
if (!$superBare) {
$result .= "[\n";
@ -231,10 +232,12 @@ final class Builder
return $result;
', 'array', static: $type === 'JSONValue');
}
private function w(string $data): void {
private function w(string $data): void
{
fwrite($this->output, $data);
}
public function m(string $methodName, string $body, string $returnType = 'mixed', bool $public = false, bool $static = true): void {
public function m(string $methodName, string $body, string $returnType = 'mixed', bool $public = false, bool $static = true): void
{
$this->methodsCreated[$methodName] = $static;
$public = $public ? 'public' : 'private';
$static = $static ? 'static' : '';
@ -339,7 +342,7 @@ final class Builder
$initial_constructors = array_filter(
$this->TL->getConstructors()->by_id,
fn (array $arr) => $arr['type'] === 'Update'
static fn (array $arr) => $arr['type'] === 'Update'
|| $arr['predicate'] === 'rpc_result'
|| !$arr['encrypted']
);
@ -369,7 +372,7 @@ final class Builder
continue;
}
$this->m(
"deserialize_type_{$this->escapeTypeName($type)}",
"deserialize_type_{$this->escapeTypeName($type)}",
"return {$this->buildTypes($constructors, $type)};",
static: $type === 'JSONValue'
);