Fixed some bugs

This commit is contained in:
Daniil Gentili 2016-12-31 12:32:02 +01:00
parent b3d75b106c
commit ad9591c71b
3 changed files with 20 additions and 13 deletions

View File

@ -24,7 +24,7 @@ trait PeerHandler
foreach ($users as $key => $user) {
switch ($user['_']) {
case 'user':
if (!isset($this->chats[$user['id']])) {
if (!isset($this->chats[$user['id']]) || $this->chats[$user['id']] !== $user) {
$this->chats[$user['id']] = $user;
$this->should_serialize = true;
}
@ -43,7 +43,7 @@ trait PeerHandler
switch ($chat['_']) {
case 'chat':
case 'chatEmpty':
if (!isset($this->chats[-$chat['id']])) {
if (!isset($this->chats[-$chat['id']]) || $this->chats[-$chat['id']] !== $chat) {
$this->should_serialize = true;
$this->chats[-$chat['id']] = $chat;
}
@ -52,7 +52,7 @@ trait PeerHandler
case 'channelEmpty':
break;
case 'channel':
if (!isset($this->chats[(int) ('-100'.$chat['id'])])) {
if (!isset($this->chats[(int) ('-100'.$chat['id'])]) || $this->chats[(int) ('-100'.$chat['id'])] !== $chat) {
$this->should_serialize = true;
$this->chats[(int) ('-100'.$chat['id'])] = $chat;
}
@ -184,8 +184,13 @@ trait PeerHandler
$res = [$this->constructors->find_by_predicate($constructor['_'])['type'] => $constructor];
switch ($constructor['_']) {
case 'user':
$res['InputPeer'] = $constructor['self'] ? ['_' => 'inputPeerSelf'] : ['_' => 'inputPeerUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
$res['InputUser'] = $constructor['self'] ? ['_' => 'inputUserSelf'] : ['_' => 'inputUser', 'user_id' => $constructor['id'], 'access_hash' => $constructor['access_hash']];
if ($constructor['self']) {
$res['InputPeer'] = ['_' => 'inputPeerSelf'];
$res['InputUser'] = ['_' => 'inputUserSelf'];
} else if (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']];
}
$res['Peer'] = ['_' => 'peerUser', 'user_id' => $constructor['id']];
$res['user_id'] = $constructor['id'];
$res['bot_api_id'] = $constructor['id'];
@ -197,8 +202,10 @@ trait PeerHandler
$res['bot_api_id'] = -$constructor['id'];
break;
case 'channel':
$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'])) {
$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'] = (int) ('-100'.$constructor['id']);

View File

@ -287,8 +287,8 @@ trait ResponseHandler
if (!$this->peer_isset($from_id) ||
!$this->peer_isset($to_id) ||
(isset($updates['via_bot_id']) && !$this->peer_isset($updates['via_bot_id']))
(isset($updates['entities']) && !$this->entities_peer_isset($updates['entites']))
(isset($updates['via_bot_id']) && !$this->peer_isset($updates['via_bot_id'])) ||
(isset($updates['entities']) && !$this->entities_peer_isset($updates['entites'])) ||
(isset($updates['fwd_from']) && !$this->fwd_peer_isset($updates['fwd_from']))) {
\danog\MadelineProto\Logger::log('getDifference: good - getting user for updateShortMessage');

View File

@ -92,9 +92,9 @@ trait UpdateHandler
}
break;
case 'updates.channelDifferenceTooLong':
unset($this->channels_state[$channel]);
//unset($this->channels_state[$channel]);
//unset($this->chats[$this->get_info('channel#'.$channel)['bot_api_id']]);
//$this->handle_update_messages($difference['messages'], $channel);
$this->handle_update_messages($difference['messages'], $channel);
break;
default:
throw new \danog\MadelineProto\Exception('Unrecognized update difference received: '.var_export($difference, true));
@ -200,12 +200,12 @@ trait UpdateHandler
} else {
$cur_state = &$this->get_channel_state($channel_id, (isset($update['pts']) ? $update['pts'] : 0) - (isset($update['pts_count']) ? $update['pts_count'] : 0));
}
/*
if ($cur_state['sync_loading']) {
\danog\MadelineProto\Logger::log('Sync loading, not handling update');
return false;
}
*/
switch ($update['_']) {
case 'updateChannelTooLong':
\danog\MadelineProto\Logger::log('Got channel too long update, getting difference...');