Fixes to documentation

This commit is contained in:
Daniil Gentili 2018-03-21 16:49:06 +00:00
parent c8a19d9f89
commit 4a7904946d
4 changed files with 51 additions and 30 deletions

View File

@ -35,11 +35,10 @@ require_once 'madeline.php';
composer.json: composer.json:
```json ```json
{ {
"name": "pwrtelegram/pwrtelegram", "name": "yourname/yourprojecr",
"description": "Boosted version of telegram's bot API", "description": "Project description",
"type": "project", "type": "project",
"require": { "require": {
"mhor/php-mediainfo": "^2.2",
"danog/madelineproto": "dev-master" "danog/madelineproto": "dev-master"
}, },
"repositories": [ "repositories": [
@ -58,7 +57,7 @@ composer.json:
], ],
"autoload": { "autoload": {
"psr-0": { "psr-0": {
"PWRTelegram\\PWRTelegram\\": "src/" "Your\\Project\\": "src/"
} }
} }
} }
@ -119,4 +118,4 @@ cp -a *php tests userbots .env* ..
Now open `.env` and edit its values as needed. Now open `.env` and edit its values as needed.
<form action="https://docs.madelineproto.xyz/docs/REQUIREMENTS.html"><input type="submit" value="Previous section" /></form><form action="https://docs.madelineproto.xyz/docs/UPDATES.html"><input type="submit" value="Next section" /></form> <form action="https://docs.madelineproto.xyz/docs/REQUIREMENTS.html"><input type="submit" value="Previous section" /></form><form action="https://docs.madelineproto.xyz/docs/UPDATES.html"><input type="submit" value="Next section" /></form>

View File

@ -20,7 +20,7 @@ You will get to choose if login as user, or as bot.
## Manual (user) ## Manual (user)
```php ```php
MadelineProto->phone_login(readline('Enter your phone number: ')); $MadelineProto->phone_login(readline('Enter your phone number: '));
$authorization = $MadelineProto->complete_phone_login(readline('Enter the phone code: ')); $authorization = $MadelineProto->complete_phone_login(readline('Enter the phone code: '));
if ($authorization['_'] === 'account.password') { if ($authorization['_'] === 'account.password') {
$authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): ')); $authorization = $MadelineProto->complete_2fa_login(readline('Please enter your password (hint '.$authorization['hint'].'): '));

View File

@ -8,6 +8,7 @@ $MadelineProto->settings = $settings;
`$settings` - an array that contains some other arrays, which are the settings for a specific MadelineProto function. `$settings` - an array that contains some other arrays, which are the settings for a specific MadelineProto function.
Here are the default values for the settings arrays and explanations for every setting: Here are the default values for the settings arrays and explanations for every setting:
<hr>
## `$settings['authorization']` ## `$settings['authorization']`
Authorization settings Authorization settings
@ -24,6 +25,7 @@ Description: Array of RSA keys to use during key exchange.
*WARNING*: be _very_ careful while modifying the default value of this setting, the security of telegram's MTProto protocol depends on it. *WARNING*: be _very_ careful while modifying the default value of this setting, the security of telegram's MTProto protocol depends on it.
<hr>
## `$settings['connection']` ## `$settings['connection']`
IP addresses and subdomains of the MTProto datacenters IP addresses and subdomains of the MTProto datacenters
@ -80,6 +82,7 @@ Default: `[
]` ]`
Description: main datacenter IPs Description: main datacenter IPs
<hr>
## `$settings['connection_settings']` ## `$settings['connection_settings']`
Connection settings Connection settings
@ -94,31 +97,31 @@ Description: MTProto transport protocol to use
Available MTProto transport protocols (smaller overhead is better): Available MTProto transport protocols (smaller overhead is better):
* tcp_abridged: Lightest protocol available * tcp_abridged: Lightest protocol available
Overhead: Very small * Overhead: Very small
Pros: * Pros:
- Minimum envelope length: 1 byte (length) * Minimum envelope length: 1 byte (length)
- Maximum envelope length: 4 bytes (length) * Maximum envelope length: 4 bytes (length)
Cons: * Cons:
- Not all Telegram DCs support it * Not all Telegram DCs support it
- No obfuscation * No obfuscation
- No initial integrity check * No initial integrity check
- No transport sequence number * No transport sequence number
* obfuscated2: Like tcp_abridged, but obfuscated * obfuscated2: Like tcp_abridged, but obfuscated
Overhead: Medium-high * Overhead: Medium-high
Pros: * Pros:
* All Telegram DCs support it * All Telegram DCs support it
* Minimum envelope length: 1 byte (length) * Minimum envelope length: 1 byte (length)
* Maximum envelope length: 4 bytes (length) * Maximum envelope length: 4 bytes (length)
* Obfuscation to prevent ISP blocks * Obfuscation to prevent ISP blocks
Cons: * Cons:
* Initial payload of 64 bytes must be sent on every connection * Initial payload of 64 bytes must be sent on every connection
* Additional round of encryption is required * Additional round of encryption is required
* No initial integrity check * No initial integrity check
* No transport sequence number * No transport sequence number
* tcp_intermediate: I guess they like having multiple protocols * tcp_intermediate: I guess they like having multiple protocols
* Overhead: small * Overhead: small
@ -191,6 +194,8 @@ Description: Extra parameters to pass to the proxy class using setExtra
Default: `true` if `php-gmp` is installed, `false` otherwise Default: `true` if `php-gmp` is installed, `false` otherwise
Description: Whether to use PFS (better security, slower key exchange) Description: Whether to use PFS (better security, slower key exchange)
<hr>
## `$settings['app_info']` ## `$settings['app_info']`
Application info Application info
@ -221,6 +226,8 @@ Description: App version
Default: auto-detected Default: auto-detected
Description: Language code Description: Language code
<hr>
## `$settings['tl_schema']` ## `$settings['tl_schema']`
TL scheme files TL scheme files
@ -240,6 +247,7 @@ Default: `[
Description: scheme files to use Description: scheme files to use
<hr>
## `$settings['logger']` ## `$settings['logger']`
Logger settings Logger settings
@ -266,6 +274,7 @@ Description: What logger messages to show
Description: You can provide a token for the rollbar log management system Description: You can provide a token for the rollbar log management system
<hr>
## `$settings['max_tries']` ## `$settings['max_tries']`
Max try settings Max try settings
@ -282,6 +291,7 @@ Description: How many times should I try to generate an authorization key before
Default: 5 Default: 5
Description: How many times should I try to get a response to a query before throwing an exception? Description: How many times should I try to get a response to a query before throwing an exception?
<hr>
## `$settings['flood_timeout']` ## `$settings['flood_timeout']`
Flood timeout settings Flood timeout settings
@ -290,7 +300,7 @@ Flood timeout settings
Default: 20 Default: 20
Description: Sleeps if a `FLOOD_WAIT_` error is received with duration lower than this value Description: Sleeps if a `FLOOD_WAIT_` error is received with duration lower than this value
<hr>
## `$settings['secret_chats']` ## `$settings['secret_chats']`
Secret chat settings Secret chat settings
@ -299,6 +309,7 @@ Secret chat settings
Default: `true` Default: `true`
Description: Can be true to accept all secret chats, false to not accept any secret chat, or an array of user IDs from which to accepts secret chats Description: Can be true to accept all secret chats, false to not accept any secret chat, or an array of user IDs from which to accepts secret chats
<hr>
## `$settings['upload']` ## `$settings['upload']`
Upload settings Upload settings
@ -307,6 +318,7 @@ Upload settings
Default: `true` Default: `true`
Description: If false, [disables automatic upload from file path in constructors](FILES.md) Description: If false, [disables automatic upload from file path in constructors](FILES.md)
<hr>
## `$settings['msg_array_limit']` ## `$settings['msg_array_limit']`
How big should be the arrays containing the incoming and outgoing messages? How big should be the arrays containing the incoming and outgoing messages?
@ -323,6 +335,8 @@ Description: maximum number of allowed MTProto messages in the outgoing message
Default: 200 Default: 200
Description: maximum number of allowed MTProto messages in any [call queue](USING_METHOD.md#call-queues) Description: maximum number of allowed MTProto messages in any [call queue](USING_METHOD.md#call-queues)
<hr>
## `$settings['peer']` ## `$settings['peer']`
Peer caching settings Peer caching settings
@ -340,6 +354,7 @@ Default: false
Description: Should madeline fetch the full chat list on startup? Description: Should madeline fetch the full chat list on startup?
<hr>
## `$settings['requests']` ## `$settings['requests']`
Flood timeout settings Flood timeout settings
@ -349,6 +364,7 @@ Default: 500
Description: Should I try using gzip encoding for requests bigger than N bytes? Set to -1 to disable. Description: Should I try using gzip encoding for requests bigger than N bytes? Set to -1 to disable.
<hr>
## `$settings['updates']` ## `$settings['updates']`
Update handling settings Update handling settings
@ -369,6 +385,7 @@ Description: If positive and bigger than zero, no requests will be sent to the s
Default: `'get_updates_update_handler'` Default: `'get_updates_update_handler'`
Description: A callable function that will be called every time an update is received, must accept an array (for the update) as the only parameter. Description: A callable function that will be called every time an update is received, must accept an array (for the update) as the only parameter.
<hr>
## `$settings['serialization']` ## `$settings['serialization']`
Serialization settings Serialization settings
@ -378,6 +395,7 @@ Default: 30
Description: Serialization will be made automatically every N seconds Description: Serialization will be made automatically every N seconds
<hr>
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. 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: Example:
@ -396,4 +414,4 @@ The settings array can be accessed and modified in the instantiated class by acc
$MadelineProto->settings['updates']['handle_updates'] = true; // reenable update fetching $MadelineProto->settings['updates']['handle_updates'] = true; // reenable update fetching
``` ```
<form action="https://docs.madelineproto.xyz/docs/UPDATES.html"><input type="submit" value="Previous section" /></form><form action="https://docs.madelineproto.xyz/docs/SELF.html"><input type="submit" value="Next section" /></form> <form action="https://docs.madelineproto.xyz/docs/UPDATES.html"><input type="submit" value="Previous section" /></form><form action="https://docs.madelineproto.xyz/docs/SELF.html"><input type="submit" value="Next section" /></form>

View File

@ -10,7 +10,7 @@ Update handling can be done in different ways:
* [Callback](#callback) * [Callback](#callback)
* [Callback multithreaded](#callback-multithreaded) * [Callback multithreaded](#callback-multithreaded)
IMPORTANT: Note that you should turn off update handling if you don't plan to use it because the default get_updates update handling stores updates in an array inside the MadelineProto object, without deleting old ones unless they are read using get_updates. IMPORTANT: Note that you should turn off update handling if you don't want to use it anymore because the default get_updates update handling stores updates in an array inside the MadelineProto object, without deleting old ones unless they are read using get_updates.
```php ```php
$MadelineProto->settings['updates']['handle_updates'] = false; $MadelineProto->settings['updates']['handle_updates'] = false;
``` ```
@ -20,6 +20,10 @@ $MadelineProto->settings['updates']['handle_updates'] = false;
```php ```php
class EventHandler extends \danog\MadelineProto\EventHandler class EventHandler extends \danog\MadelineProto\EventHandler
{ {
public function __construct($MadelineProto)
{
parent::__construct($MadelineProto);
}
public function onAny($update) public function onAny($update)
{ {
\danog\MadelineProto\Logger::log("Received an update of type ".$update['_']); \danog\MadelineProto\Logger::log("Received an update of type ".$update['_']);
@ -193,4 +197,4 @@ $MadelineProto->loop(-1);
This way, each update will be managed in its own fork. This way, each update will be managed in its own fork.
Note that multiprocessing is not the same as multithreading, and should be avoided unless lengthy operations are made in the update handler. Note that multiprocessing is not the same as multithreading, and should be avoided unless lengthy operations are made in the update handler.
<form action="https://docs.madelineproto.xyz/docs/INSTALLATION.html"><input type="submit" value="Previous section" /></form><form action="https://docs.madelineproto.xyz/docs/SETTINGS.html"><input type="submit" value="Next section" /></form> <form action="https://docs.madelineproto.xyz/docs/INSTALLATION.html"><input type="submit" value="Previous section" /></form><form action="https://docs.madelineproto.xyz/docs/SETTINGS.html"><input type="submit" value="Next section" /></form>