mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 09:38:57 +01:00
Remove legacy logic
This commit is contained in:
parent
9796fbe2b2
commit
e516bedfaa
@ -264,7 +264,7 @@ final class GroupMessage extends Message
|
||||
/**
|
||||
* Turn a [basic group into a supergroup](https://core.telegram.org/api/channel#migration).
|
||||
*
|
||||
* @return integer the channel id that migrate to
|
||||
* @return integer the channel id we migrated to
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function toSuperGroup(): int
|
||||
@ -277,7 +277,9 @@ final class GroupMessage extends Message
|
||||
'chat_id' => $this->chatId,
|
||||
]
|
||||
);
|
||||
return DialogId::fromSupergroupOrChannel($result['updates'][0]['channel_id']);
|
||||
$v = $client->getIdInternal($result['updates'][0]);
|
||||
\assert($v !== null);
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,8 +158,8 @@ final class FeedLoop extends Loop
|
||||
switch ($update['_']) {
|
||||
case 'updateNewChannelMessage':
|
||||
case 'updateEditChannelMessage':
|
||||
$channelId = $update['message']['peer_id']['channel_id'] ?? self::GENERIC;
|
||||
if (!$channelId) {
|
||||
$channelId = $update['message']['peer_id'];
|
||||
if (!DialogId::isSupergroupOrChannel($channelId)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -1193,17 +1193,17 @@ trait UpdateHandler
|
||||
if (isset($update['message']['_']) && $update['message']['_'] === 'messageEmpty') {
|
||||
return;
|
||||
}
|
||||
if (isset($update['message']['from_id']['user_id'])) {
|
||||
if ($update['message']['from_id']['user_id'] === $this->authorization['user']['id']) {
|
||||
if ($update['message']['from_id'] > 0) {
|
||||
if ($update['message']['from_id'] === $this->authorization['user']['id']) {
|
||||
$update['message']['out'] = true;
|
||||
}
|
||||
} elseif (!isset($update['message']['from_id'])
|
||||
&& isset($update['message']['peer_id']['user_id'])
|
||||
&& $update['message']['peer_id']['user_id'] === $this->authorization['user']['id']) {
|
||||
&& $update['message']['peer_id'] > 0
|
||||
&& $update['message']['peer_id'] === $this->authorization['user']['id']) {
|
||||
$update['message']['out'] = true;
|
||||
}
|
||||
|
||||
if (!isset($update['message']['from_id']) && isset($update['message']['peer_id']['user_id'])) {
|
||||
if (!isset($update['message']['from_id']) && $update['message']['peer_id'] > 0) {
|
||||
$update['message']['from_id'] = $update['message']['peer_id'];
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ use danog\Decoder\FileId;
|
||||
use danog\MadelineProto\Lang;
|
||||
use danog\MadelineProto\Logger;
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\MTProtoTools\DialogId;
|
||||
use danog\MadelineProto\StrTools;
|
||||
use danog\MadelineProto\Tools;
|
||||
use Throwable;
|
||||
@ -207,9 +206,9 @@ trait BotAPI
|
||||
if (isset($data['fwd_from']['from_id'])) {
|
||||
$newd['forward_from'] = ($this->getPwrChat($data['fwd_from']['from_id'], false));
|
||||
}
|
||||
if (isset($data['fwd_from']['channel_id'])) {
|
||||
if ($data['fwd_from'] < 0) {
|
||||
try {
|
||||
$newd['forward_from_chat'] = $this->getPwrChat(DialogId::fromSupergroupOrChannel($data['fwd_from']['channel_id']), false);
|
||||
$newd['forward_from_chat'] = $this->getPwrChat($data['fwd_from'], false);
|
||||
} catch (Throwable $e) {
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ declare(strict_types=1);
|
||||
namespace danog\MadelineProto\TL\Conversion;
|
||||
|
||||
use danog\MadelineProto\Lang;
|
||||
use danog\MadelineProto\MTProtoTools\DialogId;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -132,8 +133,8 @@ trait TD
|
||||
case 'choose_forward_info':
|
||||
if (isset($params['fwd_from'])) {
|
||||
$newparams[$td] = ['_' => 'messageForwardedFromUser'];
|
||||
if (isset($params['fwd_from']['channel_id'])) {
|
||||
$newparams[$td] = ['_' => 'messageForwardedPost', 'chat_id' => '-100'.$params['fwd_from']['channel_id']];
|
||||
if (DialogId::isSupergroupOrChannel($params['fwd_from']['channel_id'])) {
|
||||
$newparams[$td] = ['_' => 'messageForwardedPost', 'chat_id' => $params['fwd_from']['channel_id']];
|
||||
}
|
||||
$newparams[$td]['date'] = $params['fwd_from']['date'];
|
||||
if (isset($params['fwd_from']['channel_post'])) {
|
||||
|
Loading…
Reference in New Issue
Block a user