Implement lots of additional peer casting
This commit is contained in:
parent
5de602a1fd
commit
c86488a244
@ -121,7 +121,7 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
|
|||||||
';
|
';
|
||||||
$header .= isset($this->td_descriptions['types'][$otype]) ? $this->td_descriptions['types'][$otype].PHP_EOL.PHP_EOL : '';
|
$header .= isset($this->td_descriptions['types'][$otype]) ? $this->td_descriptions['types'][$otype].PHP_EOL.PHP_EOL : '';
|
||||||
if (!isset($this->settings['td'])) {
|
if (!isset($this->settings['td'])) {
|
||||||
if (in_array($type, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'])) {
|
if (in_array($type, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputDialogPeer', 'DialogPeer', 'InputPeer', 'NotifyPeer', 'InputNotifyPeer'])) {
|
||||||
$header .= 'You can directly provide the [Update](Update.md) or [Message](Message.md) object here, MadelineProto will automatically extract the destination chat id.
|
$header .= 'You can directly provide the [Update](Update.md) or [Message](Message.md) object here, MadelineProto will automatically extract the destination chat id.
|
||||||
|
|
||||||
The following syntaxes can also be used:
|
The following syntaxes can also be used:
|
||||||
@ -143,7 +143,7 @@ $'.$type." = 'https://t.me/danogentili'; // t.me URLs
|
|||||||
\$".$type." = 'channel#38575794'; // tg-cli style id (channels)
|
\$".$type." = 'channel#38575794'; // tg-cli style id (channels)
|
||||||
```
|
```
|
||||||
|
|
||||||
A [Chat](Chat.md), a [User](User.md), an [InputPeer](InputPeer.md), an [InputUser](InputUser.md), an [InputChannel](InputChannel.md), a [Peer](Peer.md), or a [Chat](Chat.md) object can also be used.\n\n\n";
|
A [Chat](Chat.md), a [User](User.md), an [InputPeer](InputPeer.md), an [InputDialogPeer](InputDialogPeer.md), an [InputNotifyPeer](InputNotifyPeer.md), an [InputUser](InputUser.md), an [InputChannel](InputChannel.md), a [Peer](Peer.md), an [DialogPeer](DialogPeer.md), [NotifyPeer](NotifyPeer.md), or a [Chat](Chat.md) object can also be used.\n\n\n";
|
||||||
}
|
}
|
||||||
if (in_array($type, ['InputEncryptedChat'])) {
|
if (in_array($type, ['InputEncryptedChat'])) {
|
||||||
$header .= 'You can directly provide the [Update](Update.md) or [EncryptedMessage](EncryptedMessage.md) object here, MadelineProto will automatically extract the destination chat id.
|
$header .= 'You can directly provide the [Update](Update.md) or [EncryptedMessage](EncryptedMessage.md) object here, MadelineProto will automatically extract the destination chat id.
|
||||||
|
@ -130,7 +130,7 @@ trait Constructors
|
|||||||
$ptype = 'Bool';
|
$ptype = 'Bool';
|
||||||
}
|
}
|
||||||
$human_ptype = $ptype;
|
$human_ptype = $ptype;
|
||||||
if (strpos($type, 'Input') === 0 && in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer']) && !isset($this->settings['td'])) {
|
if (strpos($type, 'Input') === 0 && in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputDialogPeer', 'DialogPeer', 'NotifyPeer', 'InputNotifyPeer', 'InputPeer']) && !isset($this->settings['td'])) {
|
||||||
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
|
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
|
||||||
}
|
}
|
||||||
if (strpos($type, 'Input') === 0 && in_array($ptype, ['InputMedia', 'InputDocument', 'InputPhoto']) && !isset($this->settings['td'])) {
|
if (strpos($type, 'Input') === 0 && in_array($ptype, ['InputMedia', 'InputDocument', 'InputPhoto']) && !isset($this->settings['td'])) {
|
||||||
|
@ -117,7 +117,7 @@ trait Methods
|
|||||||
$ptype = 'Bool';
|
$ptype = 'Bool';
|
||||||
}
|
}
|
||||||
$human_ptype = $ptype;
|
$human_ptype = $ptype;
|
||||||
if (in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer']) && !isset($this->settings['td'])) {
|
if (in_array($ptype, ['InputDialogPeer', 'DialogPeer', 'NotifyPeer', 'InputNotifyPeer', 'User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer']) && !isset($this->settings['td'])) {
|
||||||
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
|
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
|
||||||
}
|
}
|
||||||
if (in_array($ptype, ['InputMedia', 'InputPhoto', 'InputDocument']) && !isset($this->settings['td'])) {
|
if (in_array($ptype, ['InputMedia', 'InputPhoto', 'InputDocument']) && !isset($this->settings['td'])) {
|
||||||
|
@ -223,6 +223,18 @@ trait PeerHandler
|
|||||||
{
|
{
|
||||||
if (is_array($id)) {
|
if (is_array($id)) {
|
||||||
switch ($id['_']) {
|
switch ($id['_']) {
|
||||||
|
case 'updateDialogPinned':
|
||||||
|
case 'updateDialogUnreadMark':
|
||||||
|
case 'updateNotifySettings':
|
||||||
|
$id = $id['peer'];
|
||||||
|
case 'updateDraftMessage':
|
||||||
|
case 'inputDialogPeer':
|
||||||
|
case 'dialogPeer':
|
||||||
|
case 'inputNotifyPeer':
|
||||||
|
case 'notifyPeer':
|
||||||
|
case 'dialog':
|
||||||
|
case 'help.proxyDataPromo':
|
||||||
|
return $this->get_info($id['peer']);
|
||||||
case 'inputUserSelf':
|
case 'inputUserSelf':
|
||||||
case 'inputPeerSelf':
|
case 'inputPeerSelf':
|
||||||
$id = $this->authorization['user']['id'];
|
$id = $this->authorization['user']['id'];
|
||||||
@ -413,6 +425,10 @@ trait PeerHandler
|
|||||||
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
||||||
}
|
}
|
||||||
$res['Peer'] = ['_' => 'peerUser', 'user_id' => $constructor['id']];
|
$res['Peer'] = ['_' => 'peerUser', 'user_id' => $constructor['id']];
|
||||||
|
$res['DialogPeer'] = ['_' => 'dialogPeer', 'peer' => $res['Peer']];
|
||||||
|
$res['NotifyPeer'] = ['_' => 'notifyPeer', 'peer' => $res['Peer']];
|
||||||
|
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
|
||||||
|
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
|
||||||
$res['user_id'] = $constructor['id'];
|
$res['user_id'] = $constructor['id'];
|
||||||
$res['bot_api_id'] = $constructor['id'];
|
$res['bot_api_id'] = $constructor['id'];
|
||||||
$res['type'] = $constructor['bot'] ? 'bot' : 'user';
|
$res['type'] = $constructor['bot'] ? 'bot' : 'user';
|
||||||
@ -420,6 +436,11 @@ trait PeerHandler
|
|||||||
case 'chat':
|
case 'chat':
|
||||||
case 'chatForbidden':
|
case 'chatForbidden':
|
||||||
$res['InputPeer'] = ['_' => 'inputPeerChat', 'chat_id' => $constructor['id']];
|
$res['InputPeer'] = ['_' => 'inputPeerChat', 'chat_id' => $constructor['id']];
|
||||||
|
|
||||||
|
$res['DialogPeer'] = ['_' => 'dialogPeer', 'peer' => $res['Peer']];
|
||||||
|
$res['NotifyPeer'] = ['_' => 'notifyPeer', 'peer' => $res['Peer']];
|
||||||
|
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
|
||||||
|
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
|
||||||
$res['Peer'] = ['_' => 'peerChat', 'chat_id' => $constructor['id']];
|
$res['Peer'] = ['_' => 'peerChat', 'chat_id' => $constructor['id']];
|
||||||
$res['chat_id'] = $constructor['id'];
|
$res['chat_id'] = $constructor['id'];
|
||||||
$res['bot_api_id'] = -$constructor['id'];
|
$res['bot_api_id'] = -$constructor['id'];
|
||||||
@ -430,6 +451,11 @@ trait PeerHandler
|
|||||||
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
|
||||||
}
|
}
|
||||||
$res['InputPeer'] = ['_' => 'inputPeerChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
$res['InputPeer'] = ['_' => 'inputPeerChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
||||||
|
|
||||||
|
$res['DialogPeer'] = ['_' => 'dialogPeer', 'peer' => $res['Peer']];
|
||||||
|
$res['NotifyPeer'] = ['_' => 'notifyPeer', 'peer' => $res['Peer']];
|
||||||
|
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
|
||||||
|
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
|
||||||
$res['InputChannel'] = ['_' => 'inputChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
$res['InputChannel'] = ['_' => 'inputChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
|
||||||
$res['Peer'] = ['_' => 'peerChannel', 'channel_id' => $constructor['id']];
|
$res['Peer'] = ['_' => 'peerChannel', 'channel_id' => $constructor['id']];
|
||||||
$res['channel_id'] = $constructor['id'];
|
$res['channel_id'] = $constructor['id'];
|
||||||
|
@ -346,7 +346,7 @@ trait TL
|
|||||||
if ($type['type'] === 'InputMessage' && !is_array($object)) {
|
if ($type['type'] === 'InputMessage' && !is_array($object)) {
|
||||||
$object = ['_' => 'inputMessageID', 'id' => $object];
|
$object = ['_' => 'inputMessageID', 'id' => $object];
|
||||||
}
|
}
|
||||||
if (in_array($type['type'], ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer']) && (!is_array($object) || isset($object['_']) && $this->constructors->find_by_predicate($object['_'])['type'] !== $type['type'])) {
|
if (in_array($type['type'], ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer', 'InputDialogPeer', 'InputNotifyPeer']) && (!is_array($object) || isset($object['_']) && $this->constructors->find_by_predicate($object['_'])['type'] !== $type['type'])) {
|
||||||
$object = $this->get_info($object);
|
$object = $this->get_info($object);
|
||||||
if (!isset($object[$type['type']])) {
|
if (!isset($object[$type['type']])) {
|
||||||
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['peer_not_in_db']);
|
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['peer_not_in_db']);
|
||||||
|
Loading…
Reference in New Issue
Block a user