Added support for arabic chars and other utf8 chars, and a nice RTFM paragraph in the README

This commit is contained in:
Daniil Gentili 2017-02-22 20:45:20 +01:00
parent 694f5e5ead
commit 53102f9219
6 changed files with 24 additions and 12 deletions

View File

@ -39,6 +39,17 @@ Thanks to the devs that contributed to these projects, MadelineProto is now an e
## Usage
### RTFM
If you have some questions about the usage of the methods of this library, you can contact me [@danogentili](https://telegram.me/danogentili).
But first, please read this WHOLE page very carefully, follow all links to external documentation, and read all examples in the repo.
If you don't understand something, read everything again.
I will NOT answer to questions that can be answered simply by reading this page; I will instead tell you to read it carefully twice.
### Installation
```

View File

@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with Mad
If not, see <http://www.gnu.org/licenses/>.
*/
require 'vendor/autoload.php';
require '../vendor/autoload.php';
$settings = [];
$MadelineProto = false;
try {

View File

@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with Mad
If not, see <http://www.gnu.org/licenses/>.
*/
require 'vendor/autoload.php';
require '../vendor/autoload.php';
$settings = [];
$MadelineProto = false;
try {
@ -22,7 +22,7 @@ $uMadelineProto = \danog\MadelineProto\Serialization::deserialize('pwr.madeline'
if (file_exists('token.php') && $MadelineProto === false) {
include_once 'token.php';
$MadelineProto = new \danog\MadelineProto\API($settings);
$authorization = $MadelineProto->bot_login($token);
$authorization = $MadelineProto->bot_login($pipes_token);
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
}
if ($uMadelineProto === false) {

View File

@ -11,14 +11,14 @@ You should have received a copy of the GNU General Public License along with Mad
If not, see <http://www.gnu.org/licenses/>.
*/
require 'vendor/autoload.php';
require '../vendor/autoload.php';
$settings = [];
$token = '';
include_once 'token.php';
try {
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('b.madeline');
} catch (\danog\MadelineProto\Exception $e) {
$MadelineProto = new \danog\MadelineProto\API($settings);
$authorization = $MadelineProto->bot_login($token);
$authorization = $MadelineProto->bot_login($pwrtelegram_debug_token);
\danog\MadelineProto\Logger::log([$authorization], \danog\MadelineProto\Logger::NOTICE);
}
function base64url_decode($data)
@ -107,9 +107,11 @@ while (true) {
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
continue;
}
var_dump($update);
try {
if (isset($update['update']['message']['media'])) {
getfiles($token, $res);
getfiles($pwrtelegram_debug_token, $res);
$bot_api_id = $message = $res['files'][$update['update']['message']['id']];
$bot_api_id_b256 = base64url_decode($bot_api_id);
$bot_api_id_rledecoded = rle_decode($bot_api_id_b256);
@ -122,7 +124,6 @@ while (true) {
'Total length: '.strlen($bot_api_id_b256).PHP_EOL.
'Total length (rledecoded): '.strlen($bot_api_id_rledecoded).PHP_EOL.
PHP_EOL.'<b>param (value): start-end (length)</b><br>'.PHP_EOL;
//var_dump($update);
$bot_api = foreach_offset_length($bot_api_id_rledecoded);
$mtproto = $MadelineProto->get_download_info($update['update']['message']['media'])['InputFileLocation'];
$m = [];

View File

@ -60,7 +60,7 @@ class Serialization
} else {
throw new Exception('File does not exist');
}
//if ($unserialized === false) throw new Exception('An error occurred on deserialization');
if ($unserialized === false) throw new Exception('An error occurred on deserialization');
return $unserialized;
}
}

View File

@ -148,6 +148,7 @@ trait TL
case 'double':
return \danog\PHP\Struct::pack('<d', $object);
case 'string':
$object = utf8_decode($object);
case 'bytes':
$l = strlen($object);
$concat = '';
@ -776,7 +777,6 @@ trait TL
if (!is_string($x)) {
throw new Exception("deserialize: generated value isn't a string");
}
return $x;
case 'true':
return true;
@ -788,7 +788,7 @@ trait TL
}
switch ($constructorData['predicate']) {
case 'gzip_packed':
return $this->deserialize(gzdecode($this->deserialize($bytes_io, ['type' => 'string'])));
return $this->deserialize(gzdecode($this->deserialize($bytes_io, ['type' => 'bytes'])));
case 'Vector t':
case 'vector':
break;
@ -821,7 +821,7 @@ trait TL
}
}
if ($constructorData['predicate'] === 'gzip_packed') {
return $this->deserialize(gzdecode($this->deserialize($bytes_io, ['type' => 'string'])));
return $this->deserialize(gzdecode($this->deserialize($bytes_io, ['type' => 'bytes'])));
}
$x = ['_' => $constructorData['predicate']];
foreach ($constructorData['params'] as $arg) {