1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 10:19:00 +01:00

Merge branch 'danog:v8' into v8

This commit is contained in:
AhJ 2023-08-29 23:43:10 +03:30 committed by GitHub
commit a3af52d546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 10 deletions

View File

@ -17,7 +17,6 @@
namespace danog\MadelineProto\EventHandler;
use AssertionError;
use danog\MadelineProto\API;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\ParseMode;
@ -146,7 +145,7 @@ abstract class AbstractMessage extends Update implements SimpleFilters
return $this->replyCache;
}
$messages = $this->getClient()->methodCallAsyncRead(
API::isSupergroup($this->chatId) ? 'channels.getMessages' : 'messages.getMessages',
MTProto::isSupergroupOrChannel($this->chatId) ? 'channels.getMessages' : 'messages.getMessages',
[
'channel' => $this->chatId,
'id' => [['_' => 'inputMessageReplyTo', 'id' => $this->id]]
@ -169,7 +168,7 @@ abstract class AbstractMessage extends Update implements SimpleFilters
public function delete(bool $revoke = true): void
{
$this->getClient()->methodCallAsyncRead(
API::isSupergroup($this->chatId) ? 'channels.deleteMessages' : 'messages.deleteMessages',
MTProto::isSupergroupOrChannel($this->chatId) ? 'channels.deleteMessages' : 'messages.deleteMessages',
[
'channel' => $this->chatId,
'id' => [$this->id],

View File

@ -53,7 +53,7 @@ abstract class AbstractFilterFromSenders extends Filter
public function apply(Update $update): bool
{
return $update instanceof GroupMessage && \in_array($update->senderId, $this->peersResolved, true);
($update instanceof ButtonQuery && \in_array($update->userId, $this->peersResolved, true)) ||
($update instanceof InlineQuery && \in_array($update->userId, $this->peersResolved, true));
($update instanceof ButtonQuery && \in_array($update->userId, $this->peersResolved, true)) ||
($update instanceof InlineQuery && \in_array($update->userId, $this->peersResolved, true));
}
}

View File

@ -1249,9 +1249,9 @@ abstract class InternalDoc
*
* @param int $id Bot API ID
*/
public static function isSupergroup(int $id): bool
public static function isSupergroupOrChannel(int $id): bool
{
return \danog\MadelineProto\MTProto::isSupergroup($id);
return \danog\MadelineProto\MTProto::isSupergroupOrChannel($id);
}
/**
* Whether we're currently connected to the test DCs.

View File

@ -76,7 +76,7 @@ trait PeerHandler
*
* @param int $id Bot API ID
*/
public static function isSupergroup(int $id): bool
public static function isSupergroupOrChannel(int $id): bool
{
return $id < Magic::ZERO_CHANNEL_ID;
}
@ -429,7 +429,7 @@ trait PeerHandler
if (!$this->peerDatabase->isset($id)) {
try {
$this->logger->logger("Try fetching {$id} with access hash 0");
if ($this->isSupergroup($id)) {
if (self::isSupergroupOrChannel($id)) {
$this->peerDatabase->addChatBlocking($id);
} elseif ($id < 0) {
$this->methodCallAsyncRead('messages.getChats', ['id' => [-$id]]);

View File

@ -659,7 +659,7 @@ trait UpdateHandler
public function subscribeToUpdates(mixed $channel): bool
{
$channelId = $this->getInfo($channel, API::INFO_TYPE_ID);
if (!MTProto::isSupergroup($channelId)) {
if (!MTProto::isSupergroupOrChannel($channelId)) {
throw new Exception("You can only subscribe to channels or supergroups!");
}
$channelId = MTProto::fromSupergroup($channelId);