This commit is contained in:
Daniil Gentili 2017-02-22 23:55:37 +01:00
parent f63fd6fecf
commit 2cfc97b6bd
4 changed files with 8 additions and 10 deletions

View File

@ -10,7 +10,6 @@ See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with MadelineProto. You should have received a copy of the GNU General Public License along with MadelineProto.
If not, see <http://www.gnu.org/licenses/>. If not, see <http://www.gnu.org/licenses/>.
*/ */
require '../vendor/autoload.php'; require '../vendor/autoload.php';
$settings = []; $settings = [];
include_once 'token.php'; include_once 'token.php';
@ -159,7 +158,7 @@ var_dump($update);
foreach ($mtproto as $key => $n) { foreach ($mtproto as $key => $n) {
$message .= $key.' ('.$n.'): not found'.PHP_EOL; $message .= $key.' ('.$n.'): not found'.PHP_EOL;
} }
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => $message, 'reply_to_msg_id' => $update['update']['message']['id'], 'parse_mode' => 'html']); $MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => $message, 'reply_to_msg_id' => $update['update']['message']['id'], 'parse_mode' => 'markdown']);
} }
} catch (\danog\MadelineProto\RPCErrorException $e) { } catch (\danog\MadelineProto\RPCErrorException $e) {
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]); $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);

View File

@ -316,7 +316,7 @@ trait PeerHandler
$res['bot_info'] = $full['full']['bot_info']; $res['bot_info'] = $full['full']['bot_info'];
} }
if (isset($full['full']['profile_photo']['sizes'])) { if (isset($full['full']['profile_photo']['sizes'])) {
$res['photo'] = $this->photosize_to_botapi(end($full['full']['profile_photo']['sizes']), $full['User']); $res['photo'] = $this->photosize_to_botapi(end($full['full']['profile_photo']['sizes']), []);
} }
$bio = ''; $bio = '';
if ($full['type'] === 'user' && isset($res['username']) && !isset($res['about']) && $fullfetch) { if ($full['type'] === 'user' && isset($res['username']) && !isset($res['about']) && $fullfetch) {
@ -338,7 +338,7 @@ trait PeerHandler
} }
if (isset($full['full']['chat_photo']['sizes'])) { if (isset($full['full']['chat_photo']['sizes'])) {
$res['photo'] = $this->photosize_to_botapi(end($full['full']['chat_photo']['sizes']), $full['Chat']); $res['photo'] = $this->photosize_to_botapi(end($full['full']['chat_photo']['sizes']), []);
} }
if (isset($full['full']['exported_invite']['link'])) { if (isset($full['full']['exported_invite']['link'])) {
$res['invite'] = $full['full']['exported_invite']['link']; $res['invite'] = $full['full']['exported_invite']['link'];
@ -361,7 +361,7 @@ trait PeerHandler
} }
if (isset($full['full']['chat_photo']['sizes'])) { if (isset($full['full']['chat_photo']['sizes'])) {
$res['photo'] = $this->photosize_to_botapi(end($full['full']['chat_photo']['sizes']), $full['Chat']); $res['photo'] = $this->photosize_to_botapi(end($full['full']['chat_photo']['sizes']), []);
} }
if (isset($full['full']['exported_invite']['link'])) { if (isset($full['full']['exported_invite']['link'])) {
$res['invite'] = $full['full']['exported_invite']['link']; $res['invite'] = $full['full']['exported_invite']['link'];

View File

@ -105,7 +105,7 @@ trait Files
public function photosize_to_botapi($photo, $message_media, $thumbnail = false) public function photosize_to_botapi($photo, $message_media, $thumbnail = false)
{ {
$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');
$data = \danog\PHP\Struct::pack('<iiqqqqib', $thumbnail ? 0 : 2, $photo['location']['dc_id'], $thumbnail ? 0 : $message_media['id'], $thumbnail ? 0 : $message_media['access_hash'], $photo['location']['volume_id'], $photo['location']['secret'], $photo['location']['local_id'], 2); $data = \danog\PHP\Struct::pack('<iiqqqqib', $thumbnail ? 0 : 2, $photo['location']['dc_id'], isset($message_media['id']) ? $message_media['id'] : 0, isset($message_media['access_hash']) ? $message_media['access_hash'] : 0, $photo['location']['volume_id'], $photo['location']['secret'], $photo['location']['local_id'], 2);
return [ return [
'file_id' => $this->base64url_encode($this->rle_encode($data)), 'file_id' => $this->base64url_encode($this->rle_encode($data)),

View File

@ -148,7 +148,7 @@ trait TL
case 'double': case 'double':
return \danog\PHP\Struct::pack('<d', $object); return \danog\PHP\Struct::pack('<d', $object);
case 'string': case 'string':
$object = utf8_decode($object); $object = pack('C*', ...unpack('C*', $object));
case 'bytes': case 'bytes':
$l = strlen($object); $l = strlen($object);
$concat = ''; $concat = '';
@ -460,7 +460,7 @@ trait TL
$type_name = 'document'; $type_name = 'document';
$res = []; $res = [];
if ($data['document']['thumb']['_'] === 'photoSize') { if ($data['document']['thumb']['_'] === 'photoSize') {
$res['thumb'] = $this->photosize_to_botapi($data['document']['thumb'], $data['document'], true); $res['thumb'] = $this->photosize_to_botapi($data['document']['thumb'], [], true);
} }
foreach ($data['document']['attributes'] as $attribute) { foreach ($data['document']['attributes'] as $attribute) {
switch ($attribute['_']) { switch ($attribute['_']) {
@ -644,7 +644,7 @@ trait TL
$nmessage = ''; $nmessage = '';
try { try {
$dom = new \DOMDocument(); $dom = new \DOMDocument();
$dom->loadHTML($arguments['message']); $dom->loadHTML(mb_convert_encoding($arguments['message'], 'HTML-ENTITIES', 'UTF-8'));
if (!isset($arguments['entities'])) { if (!isset($arguments['entities'])) {
$arguments['entities'] = []; $arguments['entities'] = [];
} }
@ -657,7 +657,6 @@ trait TL
} }
$arguments['message'] = $nmessage; $arguments['message'] = $nmessage;
} }
return $arguments; return $arguments;
} }