Better errors

This commit is contained in:
Daniil Gentili 2017-05-04 19:59:29 +02:00
parent 6b61be2923
commit 70f81d58e3

View File

@ -247,6 +247,8 @@ trait PeerHandler
} elseif (isset($constructor['access_hash'])) {
$res['InputPeer'] = ['_' => 'inputPeerUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
$res['InputUser'] = ['_' => 'inputUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
} else {
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
}
$res['Peer'] = ['_' => 'peerUser', 'user_id' => $constructor['id']];
$res['user_id'] = $constructor['id'];
@ -262,10 +264,11 @@ trait PeerHandler
$res['type'] = 'chat';
break;
case 'channel':
if (isset($constructor['access_hash'])) {
$res['InputPeer'] = ['_' => 'inputPeerChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
$res['InputChannel'] = ['_' => 'inputChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
if (!isset($constructor['access_hash'])) {
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['InputChannel'] = ['_' => 'inputChannel', 'channel_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
$res['Peer'] = ['_' => 'peerChannel', 'channel_id' => $constructor['id']];
$res['channel_id'] = $constructor['id'];
$res['bot_api_id'] = $this->to_supergroup($constructor['id']);
@ -298,9 +301,6 @@ trait PeerHandler
switch ($partial['type']) {
case 'user':
case 'bot':
if (!isset($partial['InputUser'])) {
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
}
$full = $this->method_call('users.getFullUser', ['id' => $partial['InputUser']], ['datacenter' => $this->datacenter->curdc]);
break;