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

Remove internal details from API, remove getDialogs (use only getDialogIds now), remove useless getInfo fields

This commit is contained in:
Daniil Gentili 2023-12-14 19:38:22 +01:00
parent 9dcfa24197
commit f0cd35f039
14 changed files with 40 additions and 151 deletions

View File

@ -225,7 +225,6 @@ Want to add your own open-source project to this list? [Click here!](https://doc
* [Just the chat ID (extremely fast)](https://docs.madelineproto.xyz/docs/CHAT_INFO.html#getId)
* [Getting all chats (dialogs)](https://docs.madelineproto.xyz/docs/DIALOGS.html) - There are two ways to get a list of all chats, depending if you logged in as a user, or as a bot.
* [Dialog ID list](https://docs.madelineproto.xyz/docs/DIALOGS.html#getDialogIds)
* [Dialog list](https://docs.madelineproto.xyz/docs/DIALOGS.html#getDialogs)
* [Full dialog info](https://docs.madelineproto.xyz/docs/DIALOGS.html#getFullDialogs)
* [Inline buttons](https://docs.madelineproto.xyz/docs/INLINE_BUTTONS.html) - You can easily click inline buttons using MadelineProto, just access the correct button:
* [Secret chats](https://docs.madelineproto.xyz/docs/SECRET_CHATS.html) - MadelineProto provides wrappers to work with secret chats.

2
docs

@ -1 +1 @@
Subproject commit 55c803083f2f2d9b263d361148d30a44706c6780
Subproject commit 742e2d91ab92fdc99304753d29335ed950b139f6

View File

@ -1,25 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@a75d26a3d425d183da8bef37cfc14976c8d817d6">
<file src="examples/bot.php">
<LessSpecificImplementedReturnType>
<code>int|string|array</code>
</LessSpecificImplementedReturnType>
<MissingFile>
<code><![CDATA[require_once 'madeline.php']]></code>
</MissingFile>
<PossiblyNullArrayAccess>
<code><![CDATA[$message->matches[1]]]></code>
</PossiblyNullArrayAccess>
<PossiblyNullPropertyFetch>
<code><![CDATA[$reply->media]]></code>
</PossiblyNullPropertyFetch>
<PossiblyNullReference>
<code>addReaction</code>
<code>delReaction</code>
<code>getDownloadLink</code>
<code>reply</code>
</PossiblyNullReference>
</file>
<file src="src/API.php">
<ArgumentTypeCoercion>
<code>$settings</code>
@ -1318,16 +1298,6 @@
],
$this->getInputConstructor(...),
),
array_fill_keys(
[
'User',
'Chat',
'Peer',
'InputDialogPeer',
'InputNotifyPeer',
],
$this->getInfo(...),
),
array_fill_keys(
[
'InputMedia',
@ -1692,7 +1662,6 @@
<code>$filter</code>
<code>$filter</code>
<code>$filter</code>
<code>$folder_id</code>
<code>$gres</code>
<code>$limit</code>
<code>$limit</code>
@ -1808,9 +1777,6 @@
<code><![CDATA[$this->authorization['user']['id']]]></code>
<code><![CDATA[$this->authorization['user']['id']]]></code>
</PossiblyNullArrayAccess>
<PossiblyNullArrayOffset>
<code><![CDATA[$this->msg_ids]]></code>
</PossiblyNullArrayOffset>
<PossiblyNullReference>
<code>addPendingWakeups</code>
<code>waitForInternalStart</code>
@ -2471,8 +2437,6 @@
<code><![CDATA[$this->authorization['user']]]></code>
<code><![CDATA[$this->authorization['user']]]></code>
<code><![CDATA[$this->authorization['user']]]></code>
<code><![CDATA[$this->authorization['user']]]></code>
<code><![CDATA[$this->authorization['user']['bot']]]></code>
<code><![CDATA[$this->authorization['user']['bot']]]></code>
<code><![CDATA[$this->authorization['user']['bot']]]></code>
<code><![CDATA[$this->authorization['user']['bot']]]></code>

View File

@ -28,7 +28,7 @@ use danog\MadelineProto\TL\TL;
final class DocsBuilder
{
public const DEFAULT_TEMPLATES = [
'User' => ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputDialogPeer', 'DialogPeer', 'InputPeer', 'NotifyPeer', 'InputNotifyPeer'],
'User' => ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'],
'ReplyMarkup' => ['ReplyMarkup'],
'InputFile' => ['InputFile', 'InputEncryptedFile'],
'InputEncryptedChat' => ['InputEncryptedChat'],

View File

@ -149,7 +149,7 @@ trait Constructors
$ptype = 'Bool';
}
$human_ptype = $ptype;
if (str_starts_with($type, 'Input') && \in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputDialogPeer', 'DialogPeer', 'NotifyPeer', 'InputNotifyPeer', 'InputPeer'], true) && !isset($this->settings['td'])) {
if (str_starts_with($type, 'Input') && \in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'], true) && !isset($this->settings['td'])) {
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
}
if (str_starts_with($type, 'Input') && \in_array($ptype, ['InputMedia', 'InputDocument', 'InputPhoto'], true) && !isset($this->settings['td'])) {

View File

@ -169,7 +169,7 @@ trait Methods
$ptype = 'Bool';
}
$human_ptype = $ptype;
if (\in_array($ptype, ['InputDialogPeer', 'DialogPeer', 'NotifyPeer', 'InputNotifyPeer', 'User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'], true) && !isset($this->settings['td'])) {
if (\in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'], true) && !isset($this->settings['td'])) {
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
}
if (\in_array($ptype, ['InputMedia', 'InputPhoto', 'InputDocument'], true) && !isset($this->settings['td'])) {

View File

@ -819,15 +819,6 @@ abstract class InternalDoc
{
return $this->wrapper->getAPI()->getFileInfo($constructor);
}
/**
* Get folder ID from object.
*
* @param mixed $id Object
*/
public static function getFolderId(mixed $id): ?int
{
return \danog\MadelineProto\MTProto::getFolderId($id);
}
/**
* Get full info of all dialogs.
*
@ -882,18 +873,12 @@ abstract class InternalDoc
* @param \danog\MadelineProto\API::INFO_TYPE_* $type Whether to generate an Input*, an InputPeer or the full set of constructors
* @see https://docs.madelineproto.xyz/Info.html
* @return ($type is \danog\MadelineProto\API::INFO_TYPE_ALL ? array{
* InputPeer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int},
* Peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int},
* DialogPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* NotifyPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* InputDialogPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* InputNotifyPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* User?: array,
* Chat?: array,
* bot_api_id: int,
* user_id?: int,
* chat_id?: int,
* channel_id?: int,
* InputUser?: array{_: string, user_id?: int, access_hash?: int, min?: bool},
* InputChannel?: array{_: string, channel_id: int, access_hash: int, min: bool},
* type: string
* } : ($type is API::INFO_TYPE_TYPE ? string : ($type is \danog\MadelineProto\API::INFO_TYPE_ID ? int : array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}|array{_: string, user_id?: int, access_hash?: int, min?: bool}|array{_: string, channel_id: int, access_hash: int, min: bool})))
*/

View File

@ -1825,16 +1825,6 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
],
$this->getInputConstructor(...),
),
array_fill_keys(
[
'User',
'Chat',
'Peer',
'InputDialogPeer',
'InputNotifyPeer',
],
$this->getInfo(...),
),
array_fill_keys(
[
'InputMedia',

View File

@ -868,7 +868,7 @@ trait Files
if (\is_array($messageMedia) && ($messageMedia['min'] ?? false) && isset($messageMedia['access_hash'])) {
// bot API file ID
$messageMedia['min'] = false;
$peer = $this->genAll($messageMedia, null, \danog\MadelineProto\API::INFO_TYPE_PEER);
$peer = $this->genAll($messageMedia, \danog\MadelineProto\API::INFO_TYPE_PEER);
} else {
$peer = $this->getInfo($messageMedia, \danog\MadelineProto\API::INFO_TYPE_PEER);
}

View File

@ -144,21 +144,6 @@ trait PeerHandler
}
return true;
}
/**
* Get folder ID from object.
*
* @param mixed $id Object
*/
public static function getFolderId(mixed $id): ?int
{
if (!\is_array($id)) {
return null;
}
if (!isset($id['folder_id'])) {
return null;
}
return $id['folder_id'];
}
/**
* Get the bot API ID of a peer.
@ -372,18 +357,12 @@ trait PeerHandler
* @param \danog\MadelineProto\API::INFO_TYPE_* $type Whether to generate an Input*, an InputPeer or the full set of constructors
* @see https://docs.madelineproto.xyz/Info.html
* @return ($type is \danog\MadelineProto\API::INFO_TYPE_ALL ? array{
* InputPeer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int},
* Peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int},
* DialogPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* NotifyPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* InputDialogPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* InputNotifyPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* User?: array,
* Chat?: array,
* bot_api_id: int,
* user_id?: int,
* chat_id?: int,
* channel_id?: int,
* InputUser?: array{_: string, user_id?: int, access_hash?: int, min?: bool},
* InputChannel?: array{_: string, channel_id: int, access_hash: int, min: bool},
* type: string
* } : ($type is API::INFO_TYPE_TYPE ? string : ($type is \danog\MadelineProto\API::INFO_TYPE_ID ? int : array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}|array{_: string, user_id?: int, access_hash?: int, min?: bool}|array{_: string, channel_id: int, access_hash: int, min: bool})))
*/
@ -406,7 +385,6 @@ trait PeerHandler
break;
}
}
$folder_id = $this->getFolderId($id);
$try_id = $this->getIdInternal($id);
if ($try_id !== null) {
$id = $try_id;
@ -448,9 +426,9 @@ trait PeerHandler
$this->logger->logger("Only have min peer for {$id} in database, trying to fetch full info");
try {
if ($id < 0) {
$this->methodCallAsyncRead('channels.getChannels', ['id' => [$this->genAll($chat, $folder_id, \danog\MadelineProto\API::INFO_TYPE_CONSTRUCTOR)]]);
$this->methodCallAsyncRead('channels.getChannels', ['id' => [$this->genAll($chat, \danog\MadelineProto\API::INFO_TYPE_CONSTRUCTOR)]]);
} else {
$this->methodCallAsyncRead('users.getUsers', ['id' => [$this->genAll($chat, $folder_id, \danog\MadelineProto\API::INFO_TYPE_CONSTRUCTOR)]]);
$this->methodCallAsyncRead('users.getUsers', ['id' => [$this->genAll($chat, \danog\MadelineProto\API::INFO_TYPE_CONSTRUCTOR)]]);
}
} catch (Exception $e) {
$this->logger->logger($e->getMessage(), Logger::WARNING);
@ -461,7 +439,7 @@ trait PeerHandler
}
}
try {
return $this->genAll($chat, $folder_id, $type);
return $this->genAll($chat, $type);
} catch (PeerNotInDbException $e) {
$this->peerDatabase->clear($id);
throw $e;
@ -504,22 +482,16 @@ trait PeerHandler
* @param array $constructor
* @param \danog\MadelineProto\API::INFO_TYPE_* $type
* @return ($type is \danog\MadelineProto\API::INFO_TYPE_ALL ? (array{
* InputPeer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int},
* Peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int},
* DialogPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* NotifyPeer: array{_: string, peer: array{_: string, user_id?: int, chat_id?: int, channel_id?: int}},
* InputDialogPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* InputNotifyPeer: array{_: string, peer: array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}},
* User?: array,
* Chat?: array,
* bot_api_id: int,
* user_id?: int,
* chat_id?: int,
* channel_id?: int,
* InputUser?: array{_: string, user_id?: int, access_hash?: int, min?: bool},
* InputChannel?: array{_: string, channel_id: int, access_hash: int, min: bool},
* type: string
* }&array) : array|int)
*/
private function genAll($constructor, $folder_id, int $type): array|int|string
private function genAll($constructor, int $type): array|int|string
{
if ($type === \danog\MadelineProto\API::INFO_TYPE_CONSTRUCTOR) {
if ($constructor['_'] === 'user') {
@ -568,27 +540,16 @@ trait PeerHandler
$res = [$this->TL->getConstructors()->findByPredicate($constructor['_'])['type'] => $constructor];
switch ($constructor['_']) {
case 'user':
if ($constructor['self'] ?? false) {
$res['InputPeer'] = ['_' => 'inputPeerSelf'];
$res['InputUser'] = ['_' => 'inputUserSelf'];
} elseif (isset($constructor['access_hash'])) {
$res['InputPeer'] = ['_' => 'inputPeerUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min'] ?? false];
$res['InputUser'] = ['_' => 'inputUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min'] ?? false];
} else {
if (!isset($constructor['access_hash'])) {
$this->cacheFullDialogs();
throw new PeerNotInDbException();
}
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
$res['user_id'] = $constructor['id'];
$res['bot_api_id'] = $constructor['id'];
$res['type'] = $constructor['bot'] ?? false ? 'bot' : 'user';
break;
case 'chat':
case 'chatForbidden':
$res['InputPeer'] = ['_' => 'inputPeerChat', 'chat_id' => $constructor['id']];
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
$res['chat_id'] = $constructor['id'];
$res['bot_api_id'] = -$constructor['id'];
$res['type'] = 'chat';
@ -598,10 +559,6 @@ trait PeerHandler
$this->cacheFullDialogs();
throw new PeerNotInDbException();
}
$res['InputPeer'] = ['_' => 'inputPeerChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min'] ?? false];
$res['InputDialogPeer'] = ['_' => 'inputDialogPeer', 'peer' => $res['InputPeer']];
$res['InputNotifyPeer'] = ['_' => 'inputNotifyPeer', 'peer' => $res['InputPeer']];
$res['InputChannel'] = ['_' => 'inputChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash'], 'min' => $constructor['min'] ?? false];
$res['channel_id'] = $constructor['id'];
$res['bot_api_id'] = DialogId::fromSupergroupOrChannel($constructor['id']);
$res['type'] = $constructor['megagroup'] ?? false ? 'supergroup' : 'channel';
@ -611,9 +568,6 @@ trait PeerHandler
default:
throw new Exception('Invalid constructor given '.$constructor['_']);
}
if ($folder_id) {
$res['InputFolderPeer'] = ['_' => 'inputFolderPeer', 'peer' => $res['InputPeer'], 'folder_id' => $folder_id];
}
return $res;
}
/**
@ -715,14 +669,14 @@ trait PeerHandler
switch ($partial['type']) {
case 'user':
case 'bot':
$this->methodCallAsyncRead('users.getFullUser', ['id' => $partial['InputUser']]);
$this->methodCallAsyncRead('users.getFullUser', ['id' => $partial['bot_api_id']]);
break;
case 'chat':
$this->methodCallAsyncRead('messages.getFullChat', $partial);
break;
case 'channel':
case 'supergroup':
$this->methodCallAsyncRead('channels.getFullChannel', ['channel' => $partial['InputChannel']]);
$this->methodCallAsyncRead('channels.getFullChannel', ['channel' => $partial['bot_api_id']]);
break;
}
return array_merge($partial, $this->peerDatabase->getFull($partial['bot_api_id']));
@ -853,8 +807,8 @@ trait PeerHandler
$filters = ['channelParticipantsAdmins', 'channelParticipantsBots'];
$promises = [];
foreach ($filters as $filter) {
$promises []= async(function () use ($full, $filter, $total_count, &$res): void {
$this->fetchParticipants($full['InputChannel'], $filter, '', $total_count, $res);
$promises []= async(function () use ($filter, $total_count, &$res): void {
$this->fetchParticipants($res['id'], $filter, '', $total_count, $res);
});
}
await($promises);
@ -863,8 +817,8 @@ trait PeerHandler
$filters = ['channelParticipantsSearch', 'channelParticipantsKicked', 'channelParticipantsBanned'];
$promises = [];
foreach ($filters as $filter) {
$promises []= async(function () use ($full, $filter, $q, $total_count, &$res): void {
$this->recurseAlphabetSearchParticipants($full['InputChannel'], $filter, $q, $total_count, $res, 0);
$promises []= async(function () use ($filter, $q, $total_count, &$res): void {
$this->recurseAlphabetSearchParticipants($res['id'], $filter, $q, $total_count, $res, 0);
});
}
await($promises);

View File

@ -39,24 +39,24 @@ interface Account
/**
* Edits notification settings from a given user/group, from all users/all groups.
*
* @param array|int|string $peer Notification source @see https://docs.madelineproto.xyz/API_docs/types/InputNotifyPeer.html
* @param array{_: 'inputNotifyPeer', peer?: array|int|string}|array{_: 'inputNotifyUsers'}|array{_: 'inputNotifyChats'}|array{_: 'inputNotifyBroadcasts'}|array{_: 'inputNotifyForumTopic', peer?: array|int|string, top_msg_id?: int} $peer Notification source @see https://docs.madelineproto.xyz/API_docs/types/InputNotifyPeer.html
* @param array{_: 'inputPeerNotifySettings', show_previews?: bool, silent?: bool, mute_until?: int, sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title?: string, data?: string}|array{_: 'notificationSoundRingtone', id?: int}, stories_muted?: bool, stories_hide_sender?: bool, stories_sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title?: string, data?: string}|array{_: 'notificationSoundRingtone', id?: int}} $settings Notification settings @see https://docs.madelineproto.xyz/API_docs/types/InputPeerNotifySettings.html
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
*/
public function updateNotifySettings(array|int|string $peer, array $settings, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool;
public function updateNotifySettings(array $peer, array $settings, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool;
/**
* Gets current notification settings for a given user/group, from all users/all groups.
*
* @param array|int|string $peer Notification source @see https://docs.madelineproto.xyz/API_docs/types/InputNotifyPeer.html
* @param array{_: 'inputNotifyPeer', peer?: array|int|string}|array{_: 'inputNotifyUsers'}|array{_: 'inputNotifyChats'}|array{_: 'inputNotifyBroadcasts'}|array{_: 'inputNotifyForumTopic', peer?: array|int|string, top_msg_id?: int} $peer Notification source @see https://docs.madelineproto.xyz/API_docs/types/InputNotifyPeer.html
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return array{_: 'peerNotifySettings', show_previews?: bool, silent?: bool, mute_until: int, ios_sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title: string, data: string}|array{_: 'notificationSoundRingtone', id: int}, android_sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title: string, data: string}|array{_: 'notificationSoundRingtone', id: int}, other_sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title: string, data: string}|array{_: 'notificationSoundRingtone', id: int}, stories_muted?: bool, stories_hide_sender?: bool, stories_ios_sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title: string, data: string}|array{_: 'notificationSoundRingtone', id: int}, stories_android_sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title: string, data: string}|array{_: 'notificationSoundRingtone', id: int}, stories_other_sound?: array{_: 'notificationSoundDefault'}|array{_: 'notificationSoundNone'}|array{_: 'notificationSoundLocal', title: string, data: string}|array{_: 'notificationSoundRingtone', id: int}} @see https://docs.madelineproto.xyz/API_docs/types/PeerNotifySettings.html
*/
public function getNotifySettings(array|int|string $peer, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getNotifySettings(array $peer, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
/**
* Resets all notification settings from users and groups.
@ -515,13 +515,13 @@ interface Account
* Returns list of chats with non-default notification settings.
*
* @param bool $compare_sound If true, chats with non-default sound will also be returned
* @param array|int|string $peer If specified, only chats of the specified category will be returned @see https://docs.madelineproto.xyz/API_docs/types/InputNotifyPeer.html
* @param array{_: 'inputNotifyPeer', peer?: array|int|string}|array{_: 'inputNotifyUsers'}|array{_: 'inputNotifyChats'}|array{_: 'inputNotifyBroadcasts'}|array{_: 'inputNotifyForumTopic', peer?: array|int|string, top_msg_id?: int} $peer If specified, only chats of the specified category will be returned @see https://docs.madelineproto.xyz/API_docs/types/InputNotifyPeer.html
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return array @see https://docs.madelineproto.xyz/API_docs/types/Updates.html
*/
public function getNotifyExceptions(bool|null $compare_sound = false, bool|null $compare_stories = false, array|int|string|null $peer = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
public function getNotifyExceptions(bool|null $compare_sound = false, bool|null $compare_stories = false, array|null $peer = null, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array;
/**
* Get info about a certain [wallpaper](https://core.telegram.org/api/wallpapers).

View File

@ -764,7 +764,7 @@ interface Messages
/**
* Get dialog info of specified peers.
*
* @param list<array|int|string>|array<never, never> $peers Array of Peers @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param list<array{_: 'inputDialogPeer', peer?: array|int|string}|array{_: 'inputDialogPeerFolder', folder_id?: int}>|array<never, never> $peers Array of Peers @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
@ -974,20 +974,20 @@ interface Messages
/**
* Pin/unpin a dialog.
*
* @param array|int|string $peer The dialog to pin @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param array{_: 'inputDialogPeer', peer?: array|int|string}|array{_: 'inputDialogPeerFolder', folder_id?: int} $peer The dialog to pin @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param bool $pinned Whether to pin or unpin the dialog
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
*/
public function toggleDialogPin(array|int|string $peer, bool|null $pinned = false, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool;
public function toggleDialogPin(array $peer, bool|null $pinned = false, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool;
/**
* Reorder pinned dialogs.
*
* @param bool $force If set, dialogs pinned server-side but not present in the `order` field will be unpinned.
* @param int $folder_id [Peer folder ID, for more info click here](https://core.telegram.org/api/folders#peer-folders)
* @param list<array|int|string>|array<never, never> $order Array of New dialog order @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param list<array{_: 'inputDialogPeer', peer?: array|int|string}|array{_: 'inputDialogPeerFolder', folder_id?: int}>|array<never, never> $order Array of New dialog order @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
@ -1181,13 +1181,13 @@ interface Messages
/**
* Manually mark dialog as unread.
*
* @param array|int|string $peer Dialog @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param array{_: 'inputDialogPeer', peer?: array|int|string}|array{_: 'inputDialogPeerFolder', folder_id?: int} $peer Dialog @see https://docs.madelineproto.xyz/API_docs/types/InputDialogPeer.html
* @param bool $unread Mark as unread/read
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
*/
public function markDialogUnread(array|int|string $peer, bool|null $unread = false, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool;
public function markDialogUnread(array $peer, bool|null $unread = false, ?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): bool;
/**
* Get dialogs manually marked as unread.
@ -1195,7 +1195,7 @@ interface Messages
* @param ?int $floodWaitLimit Can be used to specify a custom flood wait limit: if a FLOOD_WAIT_ rate limiting error is received with a waiting period bigger than this integer, an RPCErrorException will be thrown; otherwise, MadelineProto will simply wait for the specified amount of time. Defaults to the value specified in the settings: https://docs.madelineproto.xyz/PHP/danog/MadelineProto/Settings/RPC.html#setfloodtimeout-int-floodtimeout-self
* @param ?string $queueId If specified, ensures strict server-side execution order of concurrent calls with the same queue ID.
* @param ?\Amp\Cancellation $cancellation Cancellation
* @return list<array|int|string> Array of @see https://docs.madelineproto.xyz/API_docs/types/DialogPeer.html
* @return list<array{_: 'dialogPeer', peer: array|int|string}|array{_: 'dialogPeerFolder', folder_id: int}> Array of @see https://docs.madelineproto.xyz/API_docs/types/DialogPeer.html
*/
public function getDialogUnreadMarks(?int $floodWaitLimit = null, ?string $queueId = null, ?\Amp\Cancellation $cancellation = null): array|null;

View File

@ -27,7 +27,6 @@ use danog\MadelineProto\Logger;
use danog\MadelineProto\Loop\Update\UpdateLoop;
use danog\MadelineProto\MTProtoTools\Crypt;
use danog\MadelineProto\MTProtoTools\DialogId;
use danog\MadelineProto\PeerNotInDbException;
use danog\MadelineProto\RPCErrorException;
use danog\MadelineProto\SecretPeerNotInDbException;
use danog\MadelineProto\SecurityException;
@ -64,11 +63,10 @@ trait AuthKeyHandler
*/
public function requestSecretChat(mixed $user): int
{
$user = ($this->getInfo($user));
if (!isset($user['InputUser'])) {
throw new PeerNotInDbException();
$user = $this->getInfo($user);
if ($user['type'] !== 'user') {
throw new AssertionError("Can only create a secret chat with a user!");
}
$user = $user['InputUser'];
$this->logger->logger('Creating secret chat with '.$user['user_id'].'...', Logger::VERBOSE);
$dh_config = ($this->getDhConfig());
$this->logger->logger('Generating a...', Logger::VERBOSE);

View File

@ -28,7 +28,6 @@ use danog\MadelineProto\Logger;
use danog\MadelineProto\Magic;
use danog\MadelineProto\MTProtoTools\Crypt;
use danog\MadelineProto\Ogg;
use danog\MadelineProto\PeerNotInDbException;
use danog\MadelineProto\RemoteUrl;
use danog\MadelineProto\Tools;
use danog\MadelineProto\VoIP;
@ -61,8 +60,8 @@ trait AuthKeyHandler
public function requestCall(mixed $user): VoIP
{
$user = ($this->getInfo($user));
if (!isset($user['InputUser']) || $user['InputUser']['_'] === 'inputUserSelf') {
throw new PeerNotInDbException();
if ($user['type'] !== 'user') {
throw new AssertionError("Can only create a call with a user!");
}
$user = $user['bot_api_id'];
if (isset($this->pendingCalls[$user])) {