This commit is contained in:
Daniil Gentili 2017-05-10 11:41:19 +01:00
commit 7f6481a3fe
327 changed files with 358 additions and 353 deletions

View File

@ -30,10 +30,9 @@ try {
$offset = 0;
while (true) {
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
var_dump($updates);
\danog\MadelineProto\Logger::log([$updates]);
foreach ($updates as $update) {
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
//var_dump($update);
switch ($update['update']['_']) {
case 'updateNewMessage':
case 'updateNewChannelMessage':
@ -45,7 +44,6 @@ while (true) {
$res = var_export($update, true);
}
try {
//var_dump($update);
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['to_id'], 'message' => $res, 'reply_to_msg_id' => $update['update']['message']['id'], 'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]);
} catch (\danog\MadelineProto\RPCErrorException $e) {
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);

View File

@ -18,12 +18,12 @@ $uMadelineProto = false;
try {
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('pipesbot.madeline');
} catch (\danog\MadelineProto\Exception $e) {
var_dump($e->getMessage());
\danog\MadelineProto\Logger::log([$e->getMessage()]);
}
try {
$uMadelineProto = \danog\MadelineProto\Serialization::deserialize('pwr.madeline');
} catch (\danog\MadelineProto\Exception $e) {
var_dump($e->getMessage());
\danog\MadelineProto\Logger::log([$e->getMessage()]);
}
if (file_exists('token.php') && $MadelineProto === false) {
include_once 'token.php';
@ -110,7 +110,6 @@ while (true) {
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
switch ($update['update']['_']) {
case 'updateNewMessage':
var_dump($update);
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
continue;
}

View File

@ -97,16 +97,13 @@ function getfiles($token, &$params)
$offset = 0;
while (true) {
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
//var_dump($updates);
foreach ($updates as $update) {
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
//var_dump($update);
switch ($update['update']['_']) {
case 'updateNewMessage':
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
continue;
}
var_dump($update);
try {
if (isset($update['update']['message']['media'])) {
@ -142,7 +139,6 @@ var_dump($update);
if (isset($update['update']['message']['media']['document'])) {
$mtproto['access_hash'] = $update['update']['message']['media']['document']['access_hash'];
}
//var_dump($mtproto);
foreach ($mtproto as $key => $n) {
foreach ($bot_api as $bn) {
if ($bn['number'] === $n) {

View File

@ -21,17 +21,15 @@ try {
$offset = 0;
while (true) {
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
var_dump($updates);
\danog\MadelineProto\Logger::log([$updates]);
foreach ($updates as $update) {
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
//var_dump($update);
switch ($update['update']['_']) {
case 'updateNewMessage':
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
continue;
}
try {
//var_dump($update);
if ($update['update']['message']['message'] === 'callstorm') {
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'callstorming you', 'reply_to_msg_id' => $update['update']['message']['id']]);
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('calls.madeline', $MadelineProto).' bytes'.PHP_EOL;

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -121,7 +121,7 @@ $MadelineProto = new \danog\MadelineProto\API();
### Settings
The constructor accepts an optional parameter, which is the settings array. This array contains some other arrays, which are the settings for a specific MadelineProto function.
See [here](https://github.com/danog/MadelineProto/blob/master/src/danog/MadelineProto/MTProto.php#L99) for the default values for the settings arrays and explanations for every setting.
See [here](https://github.com/danog/MadelineProto/blob/master/src/danog/MadelineProto/MTProto.php#L232) for the default values for the settings arrays and explanations for every setting.
You can provide part of any subsetting array, that way the remaining arrays will be automagically set to default and undefined values of specified subsetting arrays will be set to the default values.
Example:

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

View File

@ -5,4 +5,4 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.
A string of variable length, with length smaller than or equal to 16777215.

View File

@ -5,4 +5,4 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.

47
src/danog/MadelineProto/DocsBuilder.php Executable file → Normal file
View File

@ -601,7 +601,7 @@ $'.$type.' = -147286699; // Numeric chat id returned by request_secret_chat, can
';
if (file_exists('types/'.$type.'.md')) {
var_dump($type);
\danog\MadelineProto\Logger::log([$type]);
}
file_put_contents('types/'.$type.'.md', $header.$constructors.$methods);
$last_namespace = $new_namespace;
@ -628,7 +628,8 @@ description: A UTF8 string of variable length
## Type: string
[Back to constructor index](index.md)
A string of variable length.');
A string of variable length. The total length in bytes of the string must not be bigger than 16777215.
');
file_put_contents('types/bytes.md', '---
title: bytes
description: A string of variable length
@ -636,7 +637,8 @@ description: A string of variable length
## Type: bytes
[Back to constructor index](index.md)
A string of variable length.');
A string of variable length, with length smaller than or equal to 16777215.
');
file_put_contents('types/int.md', '---
title: integer
@ -645,7 +647,8 @@ description: A 32 bit signed integer ranging from -2147483647 to 2147483647
## Type: int
[Back to constructor index](index.md)
A 32 bit signed integer ranging from `-2147483647` to `2147483647`.');
A 32 bit signed integer ranging from `-2147483647` to `2147483647`.
');
file_put_contents('types/long.md', '---
title: long
@ -654,7 +657,8 @@ description: A 32 bit signed integer ranging from -9223372036854775807 to 922337
## Type: long
[Back to constructor index](index.md)
A 64 bit signed integer ranging from `-9223372036854775807` to `9223372036854775807`.');
A 64 bit signed integer ranging from `-9223372036854775807` to `9223372036854775807`.
');
file_put_contents('types/int128.md', '---
title: int128
@ -663,7 +667,8 @@ description: A 128 bit signed integer
## Type: int128
[Back to constructor index](index.md)
A 128 bit signed integer represented in little-endian base256 (`string`) format.');
A 128 bit signed integer represented in little-endian base256 (`string`) format.
');
file_put_contents('types/int256.md', '---
title: int256
@ -672,7 +677,8 @@ description: A 256 bit signed integer
## Type: int256
[Back to constructor index](index.md)
A 256 bit signed integer represented in little-endian base256 (`string`) format.');
A 256 bit signed integer represented in little-endian base256 (`string`) format.
');
file_put_contents('types/int512.md', '---
title: int512
@ -681,7 +687,8 @@ description: A 512 bit signed integer
## Type: int512
[Back to constructor index](index.md)
A 512 bit signed integer represented in little-endian base256 (`string`) format.');
A 512 bit signed integer represented in little-endian base256 (`string`) format.
');
file_put_contents('types/double.md', '---
title: double
@ -690,7 +697,8 @@ description: A double precision floating point number
## Type: double
[Back to constructor index](index.md)
A double precision floating point number, single precision can also be used (float).');
A double precision floating point number, single precision can also be used (float).
');
file_put_contents('types/!X.md', '---
title: !X
@ -699,7 +707,8 @@ description: Represents a TL serialized payload
## Type: !X
[Back to constructor index](index.md)
Represents a TL serialized payload.');
Represents a TL serialized payload.
');
file_put_contents('types/X.md', '---
title: X
@ -708,7 +717,8 @@ description: Represents a TL serialized payload
## Type: X
[Back to constructor index](index.md)
Represents a TL serialized payload.');
Represents a TL serialized payload.
');
file_put_contents('constructors/boolFalse.md', '---
title: boolFalse
@ -717,7 +727,8 @@ description: Represents a boolean with value equal to false
# boolFalse
[Back to constructor index](index.md)
Represents a boolean with value equal to `false`.');
Represents a boolean with value equal to `false`.
');
file_put_contents('constructors/boolTrue.md', '---
title: boolTrue
@ -726,7 +737,8 @@ description: Represents a boolean with value equal to true
# boolTrue
[Back to constructor index](index.md)
Represents a boolean with value equal to `true`.');
Represents a boolean with value equal to `true`.
');
file_put_contents('constructors/null.md', '---
title: null
@ -735,7 +747,8 @@ description: Represents a null value
# null
[Back to constructor index](index.md)
Represents a `null` value.');
Represents a `null` value.
');
file_put_contents('types/Bool.md', '---
title: Bool
@ -744,7 +757,8 @@ description: Represents a boolean.
# Bool
[Back to types index](index.md)
Represents a boolean.');
Represents a boolean.
');
file_put_contents('types/DataJSON.md', '---
title: DataJSON
@ -753,7 +767,8 @@ description: Any json-encodable data
## Type: DataJSON
[Back to constructor index](index.md)
Any json-encodable data.');
Any json-encodable data.
');
\danog\MadelineProto\Logger::log(['Done!'], \danog\MadelineProto\Logger::NOTICE);
}

View File

@ -195,7 +195,6 @@ class MTProto
if (!$this->readers[$dc]->isRunning()) {
$this->readers[$dc]->garbage = false;
$this->reader_pool->submit($this->readers[$dc]);
var_dump('hey');
Logger::log(['Socket reader on DC '.$dc.': RESTARTED'], Logger::WARNING);
while (!$this->readers[$dc]->ready);
} else {

View File

@ -166,7 +166,7 @@ trait CallHandler
}
if ($server_answer === null) {
if ($last_recv === $this->last_recv && $this->datacenter->sockets[$args['datacenter']]->temp_auth_key != null) {
if ($last_recv === $this->last_recv && $this->datacenter->sockets[$args['datacenter']]->temp_auth_key !== null) {
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
$this->datacenter->sockets[$args['datacenter']]->temp_auth_key = null;
$this->init_authorization();

View File

@ -60,7 +60,7 @@ trait MessageHandler
if (strlen($payload) === 4) {
$error = \danog\PHP\Struct::unpack('<i', $payload)[0];
if ($error === -404) {
if ($this->datacenter->sockets[$datacenter]->temp_auth_key != null) {
if ($this->datacenter->sockets[$datacenter]->temp_auth_key !== null) {
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
$this->datacenter->sockets[$datacenter]->temp_auth_key = null;
$this->init_authorization();

View File

@ -52,9 +52,6 @@ trait PeerHandler
public function add_chats($chats)
{
foreach ($chats as $key => $chat) {
if (!isset($chat['access_hash'])) {
continue;
}
switch ($chat['_']) {
case 'chat':
case 'chatEmpty':
@ -75,6 +72,9 @@ trait PeerHandler
break;
case 'channel':
case 'channelForbidden':
if (!isset($chat['access_hash'])) {
continue;
}
if (!isset($this->chats[$this->to_supergroup($chat['id'])]) || $this->chats[$this->to_supergroup($chat['id'])] !== $chat) {
$this->chats[$this->to_supergroup($chat['id'])] = $chat;
$this->should_serialize = true;

View File

@ -426,7 +426,7 @@ trait ResponseHandler
$this->force_get_updates_difference();
break;
default:
throw new \danog\MadelineProto\ResponseException('Unrecognized update received: '.var_export($updates));
throw new \danog\MadelineProto\ResponseException('Unrecognized update received: '.var_export($updates, true));
break;
}
}

View File

@ -77,7 +77,7 @@ trait ResponseHandler
}
break;
default:
throw new \danog\MadelineProto\ResponseException('Unrecognized decrypted message received: '.var_export($update));
throw new \danog\MadelineProto\ResponseException('Unrecognized decrypted message received: '.var_export($update, true));
break;
}
}