Fixes to get_pwr_chat and bot API file ids

This commit is contained in:
Daniil Gentili 2017-03-26 19:29:52 +02:00
parent 44756267ad
commit 87a5152927
5 changed files with 10 additions and 9 deletions

View File

@ -483,7 +483,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
public function getV() public function getV()
{ {
return 5; return 6;
} }
public function get_self() public function get_self()

View File

@ -404,9 +404,9 @@ trait PeerHandler
} }
if (!isset($res['participants']) && isset($res['can_view_participants']) && $res['can_view_participants']) { if (!isset($res['participants']) && isset($res['can_view_participants']) && $res['can_view_participants']) {
$res['participants'] = []; $res['participants'] = [];
$limit = 400; $limit = 200;
$offset = -$limit; $offset = -$limit;
$gres = $this->method_call('channels.getParticipants', ['channel' => $full['InputChannel'], 'filter' => ['_' => 'channelParticipantsRecent'], 'offset' => $offset += $limit, 'limit' => 200], ['datacenter' => $this->datacenter->curdc]); $gres = $this->method_call('channels.getParticipants', ['channel' => $full['InputChannel'], 'filter' => ['_' => 'channelParticipantsRecent'], 'offset' => $offset += $limit, 'limit' => $limit], ['datacenter' => $this->datacenter->curdc]);
$count = $gres['count']; $count = $gres['count'];
$key = -1; $key = -1;
while ($offset <= $count) { while ($offset <= $count) {

View File

@ -322,9 +322,10 @@ trait BotAPI
} else { } else {
$res['file_name'] .= $this->get_extension_from_mime($data['document']['mime_type']); $res['file_name'] .= $this->get_extension_from_mime($data['document']['mime_type']);
} }
$data['document']['_'] = 'bot_'.$type_name;
$res['file_size'] = $data['document']['size']; $res['file_size'] = $data['document']['size'];
$res['mime_type'] = $data['document']['mime_type']; $res['mime_type'] = $data['document']['mime_type'];
$res['file_id'] = $this->base64url_encode($this->rle_encode($this->serialize_object(['type' => 'bot_'.$type_name], $data['document']).chr(2))); $res['file_id'] = $this->base64url_encode($this->rle_encode($this->serialize_object(['type' => 'File'], $data['document']).chr(2)));
return [$type_name => $res, 'caption' => $data['caption']]; return [$type_name => $res, 'caption' => $data['caption']];
default: default:

View File

@ -68,9 +68,8 @@ trait BotAPIFiles
$ext = $this->get_extension_from_location(['_' => 'inputFileLocation', 'volume_id' => $photo['location']['volume_id'], 'local_id' => $photo['location']['local_id'], 'secret' => $photo['location']['secret'], 'dc_id' => $photo['location']['dc_id']], '.jpg'); $ext = $this->get_extension_from_location(['_' => 'inputFileLocation', 'volume_id' => $photo['location']['volume_id'], 'local_id' => $photo['location']['local_id'], 'secret' => $photo['location']['secret'], 'dc_id' => $photo['location']['dc_id']], '.jpg');
$photo['location']['access_hash'] = isset($message_media['access_hash']) ? $message_media['access_hash'] : 0; $photo['location']['access_hash'] = isset($message_media['access_hash']) ? $message_media['access_hash'] : 0;
$photo['location']['id'] = isset($message_media['id']) ? $message_media['id'] : 0; $photo['location']['id'] = isset($message_media['id']) ? $message_media['id'] : 0;
$photo['location']['_'] = $thumbnail ? 'bot_thumbnail' : 'bot_photo';
$data = $this->serialize_object(['type' => $thumbnail ? 'bot_thumbnail' : 'bot_photo'], $photo['location']).chr(2); $data = $this->serialize_object(['type' => 'File'], $photo['location']).chr(2);
return [ return [
'file_id' => $this->base64url_encode($this->rle_encode($data)), 'file_id' => $this->base64url_encode($this->rle_encode($data)),
'width' => $photo['w'], 'width' => $photo['w'],

View File

@ -119,11 +119,12 @@ trait TL
'', '',
'', ], $line); '', ], $line);
$id = hash('crc32b', $clean); $id = hash('crc32b', $clean);
if (preg_match('/^[^\s]+#/', $line) && $scheme_type !== 'botAPI') { if (preg_match('/^[^\s]+#/', $line)) {
$nid = str_pad(preg_replace(['/^[^#]+#/', '/\s.+/'], '', $line), 8, '0', \STR_PAD_LEFT); $nid = str_pad(preg_replace(['/^[^#]+#/', '/\s.+/'], '', $line), 8, '0', \STR_PAD_LEFT);
if ($id !== $nid) { if ($id !== $nid && $scheme_type !== 'botAPI') {
\danog\MadelineProto\Logger::log(['CRC32 mismatch ('.$id.', '.$nid.') for '.$line], \danog\MadelineProto\Logger::ERROR); \danog\MadelineProto\Logger::log(['CRC32 mismatch ('.$id.', '.$nid.') for '.$line], \danog\MadelineProto\Logger::ERROR);
} }
$id = $nid;
} }
if (!is_null($e)) { if (!is_null($e)) {
$this->td_descriptions[$type][$name] = ['description' => $e, 'params' => $dparams]; $this->td_descriptions[$type][$name] = ['description' => $e, 'params' => $dparams];