Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2018-03-23 15:39:58 +00:00 committed by StyleCI Bot
parent 1cb3c35ac8
commit 86d146c977
35 changed files with 892 additions and 789 deletions

View File

@ -12,7 +12,7 @@ If not, see <http://www.gnu.org/licenses/>.
*/ */
set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/')); set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/'));
/** /*
* Various ways to load MadelineProto * Various ways to load MadelineProto
*/ */
if (!file_exists(__DIR__.'/vendor/autoload.php')) { if (!file_exists(__DIR__.'/vendor/autoload.php')) {
@ -29,12 +29,14 @@ class EventHandler extends \danog\MadelineProto\EventHandler
{ {
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['_']);
} }
public function onUpdateNewChannelMessage($update) public function onUpdateNewChannelMessage($update)
{ {
$this->onUpdateNewMessage($update); $this->onUpdateNewMessage($update);
} }
public function onUpdateNewMessage($update) public function onUpdateNewMessage($update)
{ {
if (isset($update['message']['out']) && $update['message']['out']) { if (isset($update['message']['out']) && $update['message']['out']) {
@ -63,7 +65,6 @@ class EventHandler extends \danog\MadelineProto\EventHandler
} }
} }
$settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'updates' => ['handle_updates' => true]]; //, 'connection_settings' => ['all' => ['test_mode' => true]]]; $settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'updates' => ['handle_updates' => true]]; //, 'connection_settings' => ['all' => ['test_mode' => true]]];
try { try {

View File

@ -1,51 +1,52 @@
<?php <?php
$index = ''; $index = '';
$files = glob('docs/docs/*md'); $files = glob('docs/docs/*md');
foreach ($files as $file) { foreach ($files as $file) {
$base = basename($file, '.md'); $base = basename($file, '.md');
if ($base === 'CREATING_A_CLIENT') { if ($base === 'CREATING_A_CLIENT') {
$orderedfiles[0] = $file; $orderedfiles[0] = $file;
} else if ($base === 'LOGIN') { } elseif ($base === 'LOGIN') {
$orderedfiles[1] = $file; $orderedfiles[1] = $file;
} else if ($base === 'FEATURES') { } elseif ($base === 'FEATURES') {
$orderedfiles[2] = $file; $orderedfiles[2] = $file;
} else if ($base === 'REQUIREMENTS') { } elseif ($base === 'REQUIREMENTS') {
$orderedfiles[3] = $file; $orderedfiles[3] = $file;
} else if ($base === 'INSTALLATION') { } elseif ($base === 'INSTALLATION') {
$orderedfiles[4] = $file; $orderedfiles[4] = $file;
} else if ($base === 'UPDATES') { } elseif ($base === 'UPDATES') {
$orderedfiles[5] = $file; $orderedfiles[5] = $file;
} else if ($base === 'SETTINGS') { } elseif ($base === 'SETTINGS') {
$orderedfiles[6] = $file; $orderedfiles[6] = $file;
} else if ($base === 'SELF') { } elseif ($base === 'SELF') {
$orderedfiles[7] = $file; $orderedfiles[7] = $file;
} else if ($base === 'EXCEPTIONS') { } elseif ($base === 'EXCEPTIONS') {
$orderedfiles[8] = $file; $orderedfiles[8] = $file;
} else if ($base === 'FLOOD_WAIT') { } elseif ($base === 'FLOOD_WAIT') {
$orderedfiles[9] = $file; $orderedfiles[9] = $file;
} else if ($base === 'LOGGING') { } elseif ($base === 'LOGGING') {
$orderedfiles[10] = $file; $orderedfiles[10] = $file;
} else if ($base === 'USING_METHODS') { } elseif ($base === 'USING_METHODS') {
$orderedfiles[11] = $file; $orderedfiles[11] = $file;
} else if ($base === 'FILES') { } elseif ($base === 'FILES') {
$orderedfiles[12] = $file; $orderedfiles[12] = $file;
} else if ($base === 'CHAT_INFO') { } elseif ($base === 'CHAT_INFO') {
$orderedfiles[13] = $file; $orderedfiles[13] = $file;
} else if ($base === 'DIALOGS') { } elseif ($base === 'DIALOGS') {
$orderedfiles[14] = $file; $orderedfiles[14] = $file;
} else if ($base === 'INLINE_BUTTONS') { } elseif ($base === 'INLINE_BUTTONS') {
$orderedfiles[15] = $file; $orderedfiles[15] = $file;
} else if ($base === 'CALLS') { } elseif ($base === 'CALLS') {
$orderedfiles[16] = $file; $orderedfiles[16] = $file;
} else if ($base === 'SECRET_CHATS') { } elseif ($base === 'SECRET_CHATS') {
$orderedfiles[17] = $file; $orderedfiles[17] = $file;
} else if ($base === 'LUA') { } elseif ($base === 'LUA') {
$orderedfiles[18] = $file; $orderedfiles[18] = $file;
} else if ($base === 'PROXY') { } elseif ($base === 'PROXY') {
$orderedfiles[19] = $file; $orderedfiles[19] = $file;
} else if ($base === 'CONTRIB') { } elseif ($base === 'CONTRIB') {
$orderedfiles[20] = $file; $orderedfiles[20] = $file;
} else if ($base === 'TEMPLATES') { } elseif ($base === 'TEMPLATES') {
$orderedfiles[21] = $file; $orderedfiles[21] = $file;
} }
ksort($orderedfiles); ksort($orderedfiles);
@ -53,12 +54,12 @@ foreach ($files as $file) {
ksort($orderedfiles); ksort($orderedfiles);
foreach ($orderedfiles as $key => $filename) { foreach ($orderedfiles as $key => $filename) {
$lines = explode("\n", file_get_contents($filename)); $lines = explode("\n", file_get_contents($filename));
while (end($lines) === '' || strpos(end($lines), "Next")) { while (end($lines) === '' || strpos(end($lines), 'Next')) {
unset($lines[count($lines)-1]); unset($lines[count($lines) - 1]);
} }
if (isset($orderedfiles[$key+1])) { if (isset($orderedfiles[$key + 1])) {
$nextfile = "https://docs.madelineproto.xyz/docs/".basename($orderedfiles[$key+1], '.md').".html"; $nextfile = 'https://docs.madelineproto.xyz/docs/'.basename($orderedfiles[$key + 1], '.md').'.html';
$prevfile = $key === 0 ? "https://docs.madelineproto.xyz" : "https://docs.madelineproto.xyz/docs/".basename($orderedfiles[$key-1], '.md').".html"; $prevfile = $key === 0 ? 'https://docs.madelineproto.xyz' : 'https://docs.madelineproto.xyz/docs/'.basename($orderedfiles[$key - 1], '.md').'.html';
$lines[count($lines)] = "\n<form action=\"$prevfile\"><input type=\"submit\" value=\"Previous section\" /></form><form action=\"$nextfile\"><input type=\"submit\" value=\"Next section\" /></form>"; $lines[count($lines)] = "\n<form action=\"$prevfile\"><input type=\"submit\" value=\"Previous section\" /></form><form action=\"$nextfile\"><input type=\"submit\" value=\"Next section\" /></form>";
} else { } else {
$lines[count($lines)] = "\n<form action=\"https://docs.madelineproto.xyz/#very-complex-and-complete-examples\"><input type=\"submit\" value=\"Next section\" /></form>"; $lines[count($lines)] = "\n<form action=\"https://docs.madelineproto.xyz/#very-complex-and-complete-examples\"><input type=\"submit\" value=\"Next section\" /></form>";
@ -68,13 +69,13 @@ foreach ($orderedfiles as $key => $filename) {
preg_match('|^# (.*)|', $file = file_get_contents($filename), $matches); preg_match('|^# (.*)|', $file = file_get_contents($filename), $matches);
$title = $matches[1]; $title = $matches[1];
preg_match_all('|( *)\* \[(.*)\]\(#(.*)\)|', $file, $matches); preg_match_all('|( *)\* \[(.*)\]\(#(.*)\)|', $file, $matches);
$file = "https://docs.madelineproto.xyz/docs/".basename($filename, '.md').".html"; $file = 'https://docs.madelineproto.xyz/docs/'.basename($filename, '.md').'.html';
$index .= "* [$title]($file)\n"; $index .= "* [$title]($file)\n";
if (basename($filename) !== 'FEATURES.md') { if (basename($filename) !== 'FEATURES.md') {
foreach ($matches[1] as $key => $match) { foreach ($matches[1] as $key => $match) {
$spaces = " $match"; $spaces = " $match";
$name = $matches[2][$key]; $name = $matches[2][$key];
$url = $file."#".$matches[3][$key]; $url = $file.'#'.$matches[3][$key];
$index .= "$spaces* [$name]($url)\n"; $index .= "$spaces* [$name]($url)\n";
} }
} }

View File

@ -14,493 +14,491 @@ namespace danog\MadelineProto;
class Lang class Lang
{ {
public static $lang = array ( public static $lang = [
'it' => 'it' => [
array ( 'phpseclib_fork' => 'Per favore installa questo fork di phpseclib: https://github.com/danog/phpseclib',
'phpseclib_fork' => 'Per favore installa questo fork di phpseclib: https://github.com/danog/phpseclib', 'inst_dc' => 'Istanziamento dei DataCenter...',
'inst_dc' => 'Istanziamento dei DataCenter...', 'load_rsa' => 'Caricamento delle chiavi RSA...',
'load_rsa' => 'Caricamento delle chiavi RSA...', 'TL_translation' => 'Translazione degli schemi TL...',
'TL_translation' => 'Translazione degli schemi TL...', 'dh_prime_check_0' => 'Esecuzione dei check dh_prime (0/3)...',
'dh_prime_check_0' => 'Esecuzione dei check dh_prime (0/3)...', 'nearest_dc' => 'Siamo in %s, il DC più vicino è %d.',
'nearest_dc' => 'Siamo in %s, il DC più vicino è %d.', 'serialization_ofd' => 'La serializzazione non è aggiornata, reistanziamento dell\'oggetto in corso!',
'serialization_ofd' => 'La serializzazione non è aggiornata, reistanziamento dell\'oggetto in corso!', 'getupdates_deserialization' => 'Ottenimento aggiornamenti dopo deserializzazione...',
'getupdates_deserialization' => 'Ottenimento aggiornamenti dopo deserializzazione...', 'shutdown_reader_pool' => 'Chiusura pool di lettura, %d thread rimasti',
'shutdown_reader_pool' => 'Chiusura pool di lettura, %d thread rimasti', 'threading_on' => 'IL THREADING È ABILITATO',
'threading_on' => 'IL THREADING È ABILITATO', 'socket_reader' => 'Lettore socket su DC %s: ',
'socket_reader' => 'Lettore socket su DC %s: ', 'socket_status_1' => 'CREAZIONE',
'socket_status_1' => 'CREAZIONE', 'socket_status_2' => 'INVIO',
'socket_status_2' => 'INVIO', 'socket_status_3' => 'ATTESA',
'socket_status_3' => 'ATTESA', 'socket_status_4' => 'PRONTO',
'socket_status_4' => 'PRONTO', 'socket_status_5' => 'AVVIATO',
'socket_status_5' => 'AVVIATO', 'api_not_set' => 'Devi specificare una chiave ed un ID API, ottienili su https://my.telegram.org',
'api_not_set' => 'Devi specificare una chiave ed un ID API, ottienili su https://my.telegram.org', 'session_corrupted' => 'La sessione si è corrotta!',
'session_corrupted' => 'La sessione si è corrotta!', 'reset_session_seqno' => 'Resettando ID sessione e numero di sequenza sul DC %s...',
'reset_session_seqno' => 'Resettando ID sessione e numero di sequenza sul DC %s...', 'gen_perm_auth_key' => 'Generando chiave di autorizzazione permanente per il DC %s...',
'gen_perm_auth_key' => 'Generando chiave di autorizzazione permanente per il DC %s...', 'gen_temp_auth_key' => 'Generando chiave di autorizzazione temporanea per il DC %s...',
'gen_temp_auth_key' => 'Generando chiave di autorizzazione temporanea per il DC %s...', 'copy_auth_dcs' => 'Copiando autorizzazione dal DC %s al DC %s...',
'copy_auth_dcs' => 'Copiando autorizzazione dal DC %s al DC %s...', 'write_client_info' => 'Scrittura info sul client (eseguendo nel contempo il metodo %s)...',
'write_client_info' => 'Scrittura info sul client (eseguendo nel contempo il metodo %s)...', 'config_updated' => 'La configurazione è stata aggiornata!',
'config_updated' => 'La configurazione è stata aggiornata!', 'length_not_4' => 'La lunghezza non è uguale a 4',
'length_not_4' => 'La lunghezza non è uguale a 4', 'length_not_8' => 'La lunghezza non è uguale a 8',
'length_not_8' => 'La lunghezza non è uguale a 8', 'value_bigger_than_2147483647' => 'Il valore fornito (%s) è maggiore di 2147483647',
'value_bigger_than_2147483647' => 'Il valore fornito (%s) è maggiore di 2147483647', 'value_smaller_than_2147483648' => 'Il valore fornito (%s) è minore di -2147483648',
'value_smaller_than_2147483648' => 'Il valore fornito (%s) è minore di -2147483648', 'value_bigger_than_9223372036854775807' => 'Il valore fornito (%s) è maggiore di 9223372036854775807',
'value_bigger_than_9223372036854775807' => 'Il valore fornito (%s) è maggiore di 9223372036854775807',
'value_smaller_than_9223372036854775808' => 'Il valore fornito (%s) è minore di -9223372036854775808', 'value_smaller_than_9223372036854775808' => 'Il valore fornito (%s) è minore di -9223372036854775808',
'value_bigger_than_4294967296' => 'Il valore fornito (%s) è maggiore di 4294967296', 'value_bigger_than_4294967296' => 'Il valore fornito (%s) è maggiore di 4294967296',
'value_smaller_than_0' => 'Il valore fornito (%s) è minore di 0', 'value_smaller_than_0' => 'Il valore fornito (%s) è minore di 0',
'encode_double_error' => 'Non sono riuscito a codificare il numero a virgola mobile fornito', 'encode_double_error' => 'Non sono riuscito a codificare il numero a virgola mobile fornito',
'file_not_exist' => 'Il file specificato non esiste', 'file_not_exist' => 'Il file specificato non esiste',
'deserialization_error' => 'C\'è stato un errore durante la deserializzazione', 'deserialization_error' => 'C\'è stato un errore durante la deserializzazione',
'rsa_init' => 'Istanziamento di \\phpseclib\\Crypt\\RSA in corso...', 'rsa_init' => 'Istanziamento di \\phpseclib\\Crypt\\RSA in corso...',
'loading_key' => 'Caricamento della chiave in corso...', 'loading_key' => 'Caricamento della chiave in corso...',
'computing_fingerprint' => 'Calcolo del fingerprint in corso...', 'computing_fingerprint' => 'Calcolo del fingerprint in corso...',
'rsa_encrypting' => 'Criptando con chiave RSA...', 'rsa_encrypting' => 'Criptando con chiave RSA...',
'rpc_tg_error' => 'Telegram ha ritornato un errore RPC: %s (%s), causato da %s:%sTL trace:', 'rpc_tg_error' => 'Telegram ha ritornato un errore RPC: %s (%s), causato da %s:%sTL trace:',
'v_error' => '506572206661766f726520616767696f726e612071756573746120696e7374616c6c617a696f6e65206469204d6164656c696e6550726f746f20636f6e206769742070756c6c206520636f6d706f73657220757064617465', 'v_error' => '506572206661766f726520616767696f726e612071756573746120696e7374616c6c617a696f6e65206469204d6164656c696e6550726f746f20636f6e206769742070756c6c206520636f6d706f73657220757064617465',
'v_tgerror' => '506572206661766f726520616767696f726e61207068702d6c69627467766f6970', 'v_tgerror' => '506572206661766f726520616767696f726e61207068702d6c69627467766f6970',
'no_mode_specified' => 'Nessuna modalità di logging è stata specificata!', 'no_mode_specified' => 'Nessuna modalità di logging è stata specificata!',
'constructor_function_uncalled' => 'Il metodo costruttore non è stato ancora chiamato! Per favore chiama il metodo costruttore prima di usare questo metodo.', 'constructor_function_uncalled' => 'Il metodo costruttore non è stato ancora chiamato! Per favore chiama il metodo costruttore prima di usare questo metodo.',
'proxy_class_invalid' => 'È stata specificata una classe proxy errata!', 'proxy_class_invalid' => 'È stata specificata una classe proxy errata!',
'socket_con_error' => 'Connessione fallita.', 'socket_con_error' => 'Connessione fallita.',
'protocol_not_implemented' => 'Questo protocollo non è stato ancora implementato.', 'protocol_not_implemented' => 'Questo protocollo non è stato ancora implementato.',
'protocol_invalid' => 'È stato fornito un protocollo non valido', 'protocol_invalid' => 'È stato fornito un protocollo non valido',
'nothing_in_socket' => 'Non c\'è niente nel socket!', 'nothing_in_socket' => 'Non c\'è niente nel socket!',
'wrong_length_read' => 'ATTENZIONE: Non sono stati letti abbastanza byte (dovevo leggere %s, ho letto %s)!', 'wrong_length_read' => 'ATTENZIONE: Non sono stati letti abbastanza byte (dovevo leggere %s, ho letto %s)!',
'no_data_in_socket' => 'Non ci sono dati nel socket!', 'no_data_in_socket' => 'Non ci sono dati nel socket!',
'dc_con_start' => 'Connessione al DC %s in corso...', 'dc_con_start' => 'Connessione al DC %s in corso...',
'dc_con_stop' => 'Disconnessione dal DC %s in corso...', 'dc_con_stop' => 'Disconnessione dal DC %s in corso...',
'dc_con_test_start' => 'Connessione al DC %s (server %s, %s, %s)...', 'dc_con_test_start' => 'Connessione al DC %s (server %s, %s, %s)...',
'script_not_exist' => 'Lo script fornito non esiste', 'script_not_exist' => 'Lo script fornito non esiste',
'apifactory_start' => 'Sto avviando la fabbrica di API...', 'apifactory_start' => 'Sto avviando la fabbrica di API...',
'madelineproto_ready' => 'MadelineProto è pronto!', 'madelineproto_ready' => 'MadelineProto è pronto!',
'logout_error' => 'C\'è stato un errore durante il logout!', 'logout_error' => 'C\'è stato un errore durante il logout!',
'logout_ok' => 'Il logout è stato eseguito correttamente!', 'logout_ok' => 'Il logout è stato eseguito correttamente!',
'already_logged_in' => 'Questa istanza di MadelineProto è già loggata, prima faccio il logout...', 'already_logged_in' => 'Questa istanza di MadelineProto è già loggata, prima faccio il logout...',
'login_ok' => 'Il login è stato eseguito correttamente!', 'login_ok' => 'Il login è stato eseguito correttamente!',
'login_user' => 'Sto eseguendo il login come utente normale...', 'login_user' => 'Sto eseguendo il login come utente normale...',
'login_bot' => 'Sto eseguendo il login come bot...', 'login_bot' => 'Sto eseguendo il login come bot...',
'login_code_sending' => 'Sto inviando il codice...', 'login_code_sending' => 'Sto inviando il codice...',
'login_code_sent' => 'Il codice è stato inviato correttamente! Una volta ricevuto il codice dovrai usare la funzione complete_phone_login.', 'login_code_sent' => 'Il codice è stato inviato correttamente! Una volta ricevuto il codice dovrai usare la funzione complete_phone_login.',
'login_code_uncalled' => 'Non sto aspettando il codice! Usa la funzione phone_login.', 'login_code_uncalled' => 'Non sto aspettando il codice! Usa la funzione phone_login.',
'login_2fa_enabled' => 'L\'autenticazione a due fattori è abilitata, dovrai chiamare il metodo complete_2fa_login...', 'login_2fa_enabled' => 'L\'autenticazione a due fattori è abilitata, dovrai chiamare il metodo complete_2fa_login...',
'login_need_signup' => 'Questo numero non è registrato su telegram, dovrai chiamare la funzione complete_signup...', 'login_need_signup' => 'Questo numero non è registrato su telegram, dovrai chiamare la funzione complete_signup...',
'login_auth_key' => 'Sto facendo il login con la chiave di autorizzazione...', 'login_auth_key' => 'Sto facendo il login con la chiave di autorizzazione...',
'not_logged_in' => 'Non ho ancora fatto il login!', 'not_logged_in' => 'Non ho ancora fatto il login!',
'signup_uncalled' => 'Chiama prima le funzioni phone_login e complete_phone_login.', 'signup_uncalled' => 'Chiama prima le funzioni phone_login e complete_phone_login.',
'signing_up' => 'Mi sto registrando su telegram come utente normale...', 'signing_up' => 'Mi sto registrando su telegram come utente normale...',
'signup_ok' => 'Mi sono registrato su Telegram!', 'signup_ok' => 'Mi sono registrato su Telegram!',
'2fa_uncalled' => 'Non sto aspettando la password, chiama prima le funzioni phone_login e complete_phone_login!', '2fa_uncalled' => 'Non sto aspettando la password, chiama prima le funzioni phone_login e complete_phone_login!',
'getting_dialogs' => 'Sto ottenendo la lista delle chat...', 'getting_dialogs' => 'Sto ottenendo la lista delle chat...',
'libtgvoip_required' => 'È necessario installare l\'estensione php-libtgvoip per accettare e gestire chiamate vocali, vistate https://docs.madelineproto.xyz per più info.', 'libtgvoip_required' => 'È necessario installare l\'estensione php-libtgvoip per accettare e gestire chiamate vocali, vistate https://docs.madelineproto.xyz per più info.',
'peer_not_in_db' => 'Questo utente/gruppo/canale non è presente nel database interno MadelineProto', 'peer_not_in_db' => 'Questo utente/gruppo/canale non è presente nel database interno MadelineProto',
'calling_user' => 'Sto chiamando %s...', 'calling_user' => 'Sto chiamando %s...',
'generating_a' => 'Sto generando a...', 'generating_a' => 'Sto generando a...',
'generating_g_a' => 'Sto generando g_a...', 'generating_g_a' => 'Sto generando g_a...',
'call_error_1' => 'Impossibile trovare ed accettare la chiamata %s', 'call_error_1' => 'Impossibile trovare ed accettare la chiamata %s',
'accepting_call' => 'Sto accettando una chiamata da %s...', 'accepting_call' => 'Sto accettando una chiamata da %s...',
'generating_b' => 'Sto generando b...', 'generating_b' => 'Sto generando b...',
'call_already_accepted' => 'La chiamata %s è già stata accettata.', 'call_already_accepted' => 'La chiamata %s è già stata accettata.',
'call_already_declined' => 'La chiamata %s è già stata annullata.', 'call_already_declined' => 'La chiamata %s è già stata annullata.',
'call_error_2' => 'Impossibile trovare e confermare la chiamata %s', 'call_error_2' => 'Impossibile trovare e confermare la chiamata %s',
'call_confirming' => 'Sto confermando una chiamata da %s', 'call_confirming' => 'Sto confermando una chiamata da %s',
'call_error_3' => 'Impossibile trovare e completare la chiamata %s', 'call_error_3' => 'Impossibile trovare e completare la chiamata %s',
'call_completing' => 'Sto completando una chiamata da %s...', 'call_completing' => 'Sto completando una chiamata da %s...',
'invalid_g_a' => 'g_a non valido!', 'invalid_g_a' => 'g_a non valido!',
'fingerprint_invalid' => 'fingerprint della chiave non valido!', 'fingerprint_invalid' => 'fingerprint della chiave non valido!',
'call_discarding' => 'Sto rifiutando la chiamata %s...', 'call_discarding' => 'Sto rifiutando la chiamata %s...',
'call_set_rating' => 'Sto inviando la recensione della chiamata %s...', 'call_set_rating' => 'Sto inviando la recensione della chiamata %s...',
'call_debug_saving' => 'Sto inviando i dati di debug della chiamata %s...', 'call_debug_saving' => 'Sto inviando i dati di debug della chiamata %s...',
'TL_loading' => 'Sto caricando gli schemi TL...', 'TL_loading' => 'Sto caricando gli schemi TL...',
'file_parsing' => 'Leggendo %s...', 'file_parsing' => 'Leggendo %s...',
'crc32_mismatch' => 'CRC32 non valido (%s diverso da %s) per %s', 'crc32_mismatch' => 'CRC32 non valido (%s diverso da %s) per %s',
'src_file_invalid' => 'È stato fornito un file sorgente non valido: ', 'src_file_invalid' => 'È stato fornito un file sorgente non valido: ',
'translating_obj' => 'Traducendo gli oggetti...', 'translating_obj' => 'Traducendo gli oggetti...',
'translating_methods' => 'Traducendo i metodi...', 'translating_methods' => 'Traducendo i metodi...',
'bool_error' => 'Non sono riuscito ad estrarre un booleano', 'bool_error' => 'Non sono riuscito ad estrarre un booleano',
'not_numeric' => 'Il valore fornito non è numerico', 'not_numeric' => 'Il valore fornito non è numerico',
'long_not_16' => 'Il valore fornito non è lungo 16 byte', 'long_not_16' => 'Il valore fornito non è lungo 16 byte',
'long_not_32' => 'Il valore fornito non è lungo 32 byte', 'long_not_32' => 'Il valore fornito non è lungo 32 byte',
'long_not_64' => 'Il valore fornito non è lungo 64 byte', 'long_not_64' => 'Il valore fornito non è lungo 64 byte',
'array_invalid' => 'Il valore fornito non è un array', 'array_invalid' => 'Il valore fornito non è un array',
'predicate_not_set' => 'Il predicato (valore sotto chiave _, esempio [\'_\' => \'inputPeer\']) non è impostato!', 'predicate_not_set' => 'Il predicato (valore sotto chiave _, esempio [\'_\' => \'inputPeer\']) non è impostato!',
'type_extract_error' => 'Impossibile estrarre il tipo "%s"', 'type_extract_error' => 'Impossibile estrarre il tipo "%s"',
'method_not_found' => 'Impossibile trovare il seguente metodo: ', 'method_not_found' => 'Impossibile trovare il seguente metodo: ',
'params_missing' => 'Non hai fornito un parametro obbligatorio, rileggi la documentazione API', 'params_missing' => 'Non hai fornito un parametro obbligatorio, rileggi la documentazione API',
'sec_peer_not_in_db' => 'La chat segreta non è presente nel database interno MadelineProto', 'sec_peer_not_in_db' => 'La chat segreta non è presente nel database interno MadelineProto',
'stream_handle_invalid' => 'Il valore fornito non è uno stream', 'stream_handle_invalid' => 'Il valore fornito non è uno stream',
'length_too_big' => 'Il valore fornito è troppo lungo', 'length_too_big' => 'Il valore fornito è troppo lungo',
'deserialize_not_str' => 'Il valore generato non è una stringa', 'deserialize_not_str' => 'Il valore generato non è una stringa',
'type_extract_error_id' => 'Non sono riuscito ad estrarre il tipo %s con ID %s', 'type_extract_error_id' => 'Non sono riuscito ad estrarre il tipo %s con ID %s',
'vector_invalid' => 'ID vettore non valido: ', 'vector_invalid' => 'ID vettore non valido: ',
'constructor_not_found' => 'Costruttore non trovato per tipo: ', 'constructor_not_found' => 'Costruttore non trovato per tipo: ',
'rand_bytes_too_small' => 'random_bytes è troppo corto!', 'rand_bytes_too_small' => 'random_bytes è troppo corto!',
'botapi_conversion_error' => 'NOn sono risucito a convertire %s in un oggetto bot API', 'botapi_conversion_error' => 'NOn sono risucito a convertire %s in un oggetto bot API',
'non_text_conversion' => 'Non posso ancora convertire messaggi media', 'non_text_conversion' => 'Non posso ancora convertire messaggi media',
'last_byte_invalid' => 'L\'ultimo byte non è valido', 'last_byte_invalid' => 'L\'ultimo byte non è valido',
'file_type_invalid' => 'È stato fornito un tipo file errato', 'file_type_invalid' => 'È stato fornito un tipo file errato',
'recreate_temp_auth_key' => 'Sono stato costretto a rigenerare la chiave di autorizzazione temporanea', 'recreate_temp_auth_key' => 'Sono stato costretto a rigenerare la chiave di autorizzazione temporanea',
'resetting_auth_key' => 'ATTENZIONE: Sto resettando la chiave temporanea...', 'resetting_auth_key' => 'ATTENZIONE: Sto resettando la chiave temporanea...',
'shutting_down_reader_pool' => 'Chisura pool di lettura', 'shutting_down_reader_pool' => 'Chisura pool di lettura',
'shutting_down_handler_pool' => 'Chiusura pool di gestione per DC %s, %d thread rimasti', 'shutting_down_handler_pool' => 'Chiusura pool di gestione per DC %s, %d thread rimasti',
'secret_chat_skipping' => 'Non ho la chat segreta %s nel database, ignorando messaggio', 'secret_chat_skipping' => 'Non ho la chat segreta %s nel database, ignorando messaggio',
'fingerprint_mismatch' => 'Fingerprint della chiave non valido', 'fingerprint_mismatch' => 'Fingerprint della chiave non valido',
'msg_data_length_too_big' => 'message_data_length è troppo grande', 'msg_data_length_too_big' => 'message_data_length è troppo grande',
'length_not_divisible_16' => 'La lunghezza dei dati decifrati non è divisibile per 16', 'length_not_divisible_16' => 'La lunghezza dei dati decifrati non è divisibile per 16',
'msg_key_mismatch' => 'msg_key non valido', 'msg_key_mismatch' => 'msg_key non valido',
'rand_bytes_too_short' => 'random_bytes è troppo corto!', 'rand_bytes_too_short' => 'random_bytes è troppo corto!',
'resending_unsupported' => 'IL riinvio di messaggi non è ancora supportato', 'resending_unsupported' => 'IL riinvio di messaggi non è ancora supportato',
'unrecognized_dec_msg' => 'È stato ricevuto un messaggio decifrato sconosciuto: ', 'unrecognized_dec_msg' => 'È stato ricevuto un messaggio decifrato sconosciuto: ',
'serializing_madelineproto' => 'Sto serializzando MadelineProto...', 'serializing_madelineproto' => 'Sto serializzando MadelineProto...',
'req_pq' => 'Sto richiedendo pq...', 'req_pq' => 'Sto richiedendo pq...',
'done' => 'Fatto!', 'done' => 'Fatto!',
'cdn_reupload' => 'Il file non è disponibile sul nostro CDN, richiedo la copia!', 'cdn_reupload' => 'Il file non è disponibile sul nostro CDN, richiedo la copia!',
'stored_on_cdn' => 'Il file è scaricabile tramite CDN!', 'stored_on_cdn' => 'Il file è scaricabile tramite CDN!',
), ],
'en' => 'en' => [
array ( 'req_pq' => 'Requesting pq...',
'req_pq' => 'Requesting pq...', 'done' => 'Done!',
'done' => 'Done!', 'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!', 'stored_on_cdn' => 'File is stored on CDN!',
'stored_on_cdn' => 'File is stored on CDN!', 'serializing_madelineproto' => 'Serializing MadelineProto...',
'serializing_madelineproto' => 'Serializing MadelineProto...', 'phpseclib_fork' => 'Please install this fork of phpseclib: https://github.com/danog/phpseclib',
'phpseclib_fork' => 'Please install this fork of phpseclib: https://github.com/danog/phpseclib', 'inst_dc' => 'Istantiating DataCenter...',
'inst_dc' => 'Istantiating DataCenter...', 'load_rsa' => 'Loading RSA keys...',
'load_rsa' => 'Loading RSA keys...', 'TL_translation' => 'Translating TL schemas...',
'TL_translation' => 'Translating TL schemas...', 'dh_prime_check_0' => 'Executing dh_prime checks (0/3)...',
'dh_prime_check_0' => 'Executing dh_prime checks (0/3)...', 'nearest_dc' => 'We\'re in %s, nearest DC is %d.',
'nearest_dc' => 'We\'re in %s, nearest DC is %d.', 'serialization_ofd' => 'Serialization is out of date, reconstructing object!',
'serialization_ofd' => 'Serialization is out of date, reconstructing object!', 'getupdates_deserialization' => 'Getting updates after deserialization...',
'getupdates_deserialization' => 'Getting updates after deserialization...', 'shutdown_reader_pool' => 'Shutting down reader pool, %d jobs left',
'shutdown_reader_pool' => 'Shutting down reader pool, %d jobs left', 'threading_on' => 'THREADING IS ENABLED',
'threading_on' => 'THREADING IS ENABLED', 'socket_reader' => 'Socket reader on DC %s: ',
'socket_reader' => 'Socket reader on DC %s: ', 'socket_status_1' => 'CREATING',
'socket_status_1' => 'CREATING', 'socket_status_2' => 'SUBMITTING',
'socket_status_2' => 'SUBMITTING', 'socket_status_3' => 'WAITING',
'socket_status_3' => 'WAITING', 'socket_status_4' => 'READY',
'socket_status_4' => 'READY', 'socket_status_5' => 'WORKING',
'socket_status_5' => 'WORKING', 'api_not_set' => 'You must provide an api key and an api id, get your own @ my.telegram.org',
'api_not_set' => 'You must provide an api key and an api id, get your own @ my.telegram.org', 'session_corrupted' => 'The session is corrupted!',
'session_corrupted' => 'The session is corrupted!', 'reset_session_seqno' => 'Resetting session id and seq_no in DC %s...',
'reset_session_seqno' => 'Resetting session id and seq_no in DC %s...', 'gen_perm_auth_key' => 'Generating permanent authorization key for DC %s...',
'gen_perm_auth_key' => 'Generating permanent authorization key for DC %s...', 'gen_temp_auth_key' => 'Generating temporary authorization key for DC %s...',
'gen_temp_auth_key' => 'Generating temporary authorization key for DC %s...', 'copy_auth_dcs' => 'Copying authorization from DC %s to DC %s...',
'copy_auth_dcs' => 'Copying authorization from DC %s to DC %s...', 'write_client_info' => 'Writing client info (also executing %s)...',
'write_client_info' => 'Writing client info (also executing %s)...', 'config_updated' => 'Updated config!',
'config_updated' => 'Updated config!', 'length_not_4' => 'Length is not equal to 4',
'length_not_4' => 'Length is not equal to 4', 'length_not_8' => 'Length is not equal to 8',
'length_not_8' => 'Length is not equal to 8', 'value_bigger_than_2147483647' => 'Provided value %s is bigger than 2147483647',
'value_bigger_than_2147483647' => 'Provided value %s is bigger than 2147483647', 'value_smaller_than_2147483648' => 'Provided value %s is smaller than -2147483648',
'value_smaller_than_2147483648' => 'Provided value %s is smaller than -2147483648', 'value_bigger_than_9223372036854775807' => 'Provided value %s is bigger than 9223372036854775807',
'value_bigger_than_9223372036854775807' => 'Provided value %s is bigger than 9223372036854775807', 'value_smaller_than_9223372036854775808' => 'Provided value %s is smaller than -9223372036854775808',
'value_smaller_than_9223372036854775808' => 'Provided value %s is smaller than -9223372036854775808', 'value_bigger_than_4294967296' => 'Provided value %s is bigger than 4294967296',
'value_bigger_than_4294967296' => 'Provided value %s is bigger than 4294967296', 'value_smaller_than_0' => 'Provided value %s is smaller than 0',
'value_smaller_than_0' => 'Provided value %s is smaller than 0', 'encode_double_error' => 'Could not properly encode double',
'encode_double_error' => 'Could not properly encode double', 'file_not_exist' => 'File does not exist',
'file_not_exist' => 'File does not exist', 'deserialization_error' => 'An error occurred on deserialization',
'deserialization_error' => 'An error occurred on deserialization', 'rsa_init' => 'Istantiating \\phpseclib\\Crypt\\RSA...',
'rsa_init' => 'Istantiating \\phpseclib\\Crypt\\RSA...', 'loading_key' => 'Loading key...',
'loading_key' => 'Loading key...', 'computing_fingerprint' => 'Computing fingerprint...',
'computing_fingerprint' => 'Computing fingerprint...', 'rsa_encrypting' => 'Encrypting with rsa key...',
'rsa_encrypting' => 'Encrypting with rsa key...', 'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:',
'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:', 'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e', 'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970', 'no_mode_specified' => 'No mode was specified!',
'no_mode_specified' => 'No mode was specified!', 'constructor_function_uncalled' => 'The constructor function wasn\'t called! Please call the constructor function before using this method.',
'constructor_function_uncalled' => 'The constructor function wasn\'t called! Please call the constructor function before using this method.', 'proxy_class_invalid' => 'Invalid proxy class provided!',
'proxy_class_invalid' => 'Invalid proxy class provided!', 'socket_con_error' => 'Connection: couldn\'t connect to socket.',
'socket_con_error' => 'Connection: couldn\'t connect to socket.', 'protocol_not_implemented' => 'Connection: This protocol isn\'t implemented yet.',
'protocol_not_implemented' => 'Connection: This protocol isn\'t implemented yet.', 'protocol_invalid' => 'Connection: invalid protocol specified.',
'protocol_invalid' => 'Connection: invalid protocol specified.', 'nothing_in_socket' => 'Nothing in the socket!',
'nothing_in_socket' => 'Nothing in the socket!', 'wrong_length_read' => 'WARNING: Wrong length was read (should\'ve read %s, read %s)!',
'wrong_length_read' => 'WARNING: Wrong length was read (should\'ve read %s, read %s)!', 'no_data_in_socket' => 'No data in the socket!',
'no_data_in_socket' => 'No data in the socket!', 'dc_con_start' => 'Connecting to DC %s...',
'dc_con_start' => 'Connecting to DC %s...', 'dc_con_stop' => 'Disconnecting from DC %s...',
'dc_con_stop' => 'Disconnecting from DC %s...', 'dc_con_test_start' => 'Connecting to DC %s (%s server, %s, %s)...',
'dc_con_test_start' => 'Connecting to DC %s (%s server, %s, %s)...', 'script_not_exist' => 'Provided script does not exist',
'script_not_exist' => 'Provided script does not exist', 'apifactory_start' => 'Running APIFactory...',
'apifactory_start' => 'Running APIFactory...', 'madelineproto_ready' => 'MadelineProto is ready!',
'madelineproto_ready' => 'MadelineProto is ready!', 'logout_error' => 'An error occurred while logging out!',
'logout_error' => 'An error occurred while logging out!', 'logout_ok' => 'Logged out successfully!',
'logout_ok' => 'Logged out successfully!', 'already_logged_in' => 'This instance of MadelineProto is already logged in. Logging out first...',
'already_logged_in' => 'This instance of MadelineProto is already logged in. Logging out first...', 'login_ok' => 'Logged in successfully!',
'login_ok' => 'Logged in successfully!', 'login_user' => 'Logging in as a normal user...',
'login_user' => 'Logging in as a normal user...', 'login_bot' => 'Logging in as a bot...',
'login_bot' => 'Logging in as a bot...', 'login_code_sending' => 'Sending code...',
'login_code_sending' => 'Sending code...', 'login_code_sent' => 'Code sent successfully! Once you receive the code you should use the complete_phone_login function.',
'login_code_sent' => 'Code sent successfully! Once you receive the code you should use the complete_phone_login function.', 'login_code_uncalled' => 'I\'m not waiting for the code! Please call the phone_login method first',
'login_code_uncalled' => 'I\'m not waiting for the code! Please call the phone_login method first', 'login_2fa_enabled' => '2FA enabled, you will have to call the complete_2fa_login function...',
'login_2fa_enabled' => '2FA enabled, you will have to call the complete_2fa_login function...', 'login_need_signup' => 'An account has not been created for this number, you will have to call the complete_signup function...',
'login_need_signup' => 'An account has not been created for this number, you will have to call the complete_signup function...', 'login_auth_key' => 'Logging in using auth key...',
'login_auth_key' => 'Logging in using auth key...', 'not_logged_in' => 'I\'m not logged in!',
'not_logged_in' => 'I\'m not logged in!', 'signup_uncalled' => 'I\'m not waiting to signup! Please call the phone_login and the complete_phone_login methods first!',
'signup_uncalled' => 'I\'m not waiting to signup! Please call the phone_login and the complete_phone_login methods first!', 'signing_up' => 'Signing up as a normal user...',
'signing_up' => 'Signing up as a normal user...', 'signup_ok' => 'Signed up in successfully!',
'signup_ok' => 'Signed up in successfully!', '2fa_uncalled' => 'I\'m not waiting for the password! Please call the phone_login and the complete_phone_login methods first!',
'2fa_uncalled' => 'I\'m not waiting for the password! Please call the phone_login and the complete_phone_login methods first!', 'getting_dialogs' => 'Getting dialogs...',
'getting_dialogs' => 'Getting dialogs...', 'libtgvoip_required' => 'The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.',
'libtgvoip_required' => 'The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.', 'peer_not_in_db' => 'This peer is not present in the internal peer database',
'peer_not_in_db' => 'This peer is not present in the internal peer database', 'calling_user' => 'Calling %s...',
'calling_user' => 'Calling %s...', 'generating_a' => 'Generating a...',
'generating_a' => 'Generating a...', 'generating_g_a' => 'Generating g_a...',
'generating_g_a' => 'Generating g_a...', 'call_error_1' => 'Could not find and accept call %s',
'call_error_1' => 'Could not find and accept call %s', 'accepting_call' => 'Accepting call from %s...',
'accepting_call' => 'Accepting call from %s...', 'generating_b' => 'Generating b...',
'generating_b' => 'Generating b...', 'call_already_accepted' => 'Call %s already accepted',
'call_already_accepted' => 'Call %s already accepted', 'call_already_declined' => 'Call %s already declined',
'call_already_declined' => 'Call %s already declined', 'call_error_2' => 'Could not find and confirm call %s',
'call_error_2' => 'Could not find and confirm call %s', 'call_confirming' => 'Confirming call from %s...',
'call_confirming' => 'Confirming call from %s...', 'call_error_3' => 'Could not find and complete call %s',
'call_error_3' => 'Could not find and complete call %s', 'call_completing' => 'Completing call from %s...',
'call_completing' => 'Completing call from %s...', 'invalid_g_a' => 'Invalid g_a!',
'invalid_g_a' => 'Invalid g_a!', 'fingerprint_invalid' => 'Invalid key fingerprint!',
'fingerprint_invalid' => 'Invalid key fingerprint!', 'call_discarding' => 'Discarding call %s...',
'call_discarding' => 'Discarding call %s...', 'call_set_rating' => 'Setting rating for call %s...',
'call_set_rating' => 'Setting rating for call %s...', 'call_debug_saving' => 'Saving debug data for call %s...',
'call_debug_saving' => 'Saving debug data for call %s...', 'TL_loading' => 'Loading TL schemes...',
'TL_loading' => 'Loading TL schemes...', 'file_parsing' => 'Parsing %s...',
'file_parsing' => 'Parsing %s...', 'crc32_mismatch' => 'CRC32 mismatch (%s, %s) for %s',
'crc32_mismatch' => 'CRC32 mismatch (%s, %s) for %s', 'src_file_invalid' => 'Invalid source file was provided: ',
'src_file_invalid' => 'Invalid source file was provided: ', 'translating_obj' => 'Translating objects...',
'translating_obj' => 'Translating objects...', 'translating_methods' => 'Translating methods...',
'translating_methods' => 'Translating methods...', 'bool_error' => 'Could not extract boolean',
'bool_error' => 'Could not extract boolean', 'not_numeric' => 'Given value isn\'t numeric',
'not_numeric' => 'Given value isn\'t numeric', 'long_not_16' => 'Given value is not 16 bytes long',
'long_not_16' => 'Given value is not 16 bytes long', 'long_not_32' => 'Given value is not 32 bytes long',
'long_not_32' => 'Given value is not 32 bytes long', 'long_not_64' => 'Given value is not 64 bytes long',
'long_not_64' => 'Given value is not 64 bytes long', 'array_invalid' => 'You didn\'t provide a valid array',
'array_invalid' => 'You didn\'t provide a valid array', 'predicate_not_set' => 'Predicate (value under _) was not set!',
'predicate_not_set' => 'Predicate (value under _) was not set!', 'type_extract_error' => 'Could not extract type "%s"',
'type_extract_error' => 'Could not extract type "%s"', 'method_not_found' => 'Could not find method: ',
'method_not_found' => 'Could not find method: ', 'params_missing' => 'Missing required parameter',
'params_missing' => 'Missing required parameter', 'sec_peer_not_in_db' => 'This secret peer is not present in the internal peer database',
'sec_peer_not_in_db' => 'This secret peer is not present in the internal peer database', 'stream_handle_invalid' => 'An invalid stream handle was provided.',
'stream_handle_invalid' => 'An invalid stream handle was provided.', 'length_too_big' => 'Length is too big',
'length_too_big' => 'Length is too big', 'deserialize_not_str' => 'Deserialize: Generated value isn\'t a string',
'deserialize_not_str' => 'Deserialize: Generated value isn\'t a string', 'type_extract_error_id' => 'Could not extract type: %s with id %s',
'type_extract_error_id' => 'Could not extract type: %s with id %s', 'vector_invalid' => 'Invalid vector constructor: ',
'vector_invalid' => 'Invalid vector constructor: ', 'constructor_not_found' => 'Constructor not found for type: ',
'constructor_not_found' => 'Constructor not found for type: ', 'rand_bytes_too_small' => 'random_bytes is too small!',
'rand_bytes_too_small' => 'random_bytes is too small!', 'botapi_conversion_error' => 'Can\'t convert %s to a bot API object',
'botapi_conversion_error' => 'Can\'t convert %s to a bot API object', 'non_text_conversion' => 'Can\'t convert non text messages yet!',
'non_text_conversion' => 'Can\'t convert non text messages yet!', 'last_byte_invalid' => 'Invalid last byte',
'last_byte_invalid' => 'Invalid last byte', 'file_type_invalid' => 'Invalid file type detected (%s)',
'file_type_invalid' => 'Invalid file type detected (%s)', 'recreate_temp_auth_key' => 'I had to recreate the temporary authorization key',
'recreate_temp_auth_key' => 'I had to recreate the temporary authorization key', 'resetting_auth_key' => 'WARNING: Resetting auth key...',
'resetting_auth_key' => 'WARNING: Resetting auth key...', 'shutting_down_reader_pool' => 'Shutting down reader pool ',
'shutting_down_reader_pool' => 'Shutting down reader pool ', 'shutting_down_handler_pool' => 'Shutting down handler pool for dc %s, %d jobs left',
'shutting_down_handler_pool' => 'Shutting down handler pool for dc %s, %d jobs left', 'secret_chat_skipping' => 'I do not have the secret chat %s in the database, skipping message...',
'secret_chat_skipping' => 'I do not have the secret chat %s in the database, skipping message...', 'fingerprint_mismatch' => 'Key fingerprint mismatch',
'fingerprint_mismatch' => 'Key fingerprint mismatch', 'msg_data_length_too_big' => 'message_data_length is too big',
'msg_data_length_too_big' => 'message_data_length is too big', 'length_not_divisible_16' => 'Length of decrypted data is not divisible by 16',
'length_not_divisible_16' => 'Length of decrypted data is not divisible by 16', 'msg_key_mismatch' => 'msg_key mismatch',
'msg_key_mismatch' => 'msg_key mismatch', 'rand_bytes_too_short' => 'random_bytes is too short!',
'rand_bytes_too_short' => 'random_bytes is too short!', 'resending_unsupported' => 'Resending of messages is not yet supported',
'resending_unsupported' => 'Resending of messages is not yet supported', 'unrecognized_dec_msg' => 'Unrecognized decrypted message received: ',
'unrecognized_dec_msg' => 'Unrecognized decrypted message received: ', 'method_req_pq' => '',
'method_req_pq' => '', 'method_req_pq_param_nonce' => '',
'method_req_pq_param_nonce' => '', 'method_req_pq_multi' => '',
'method_req_pq_multi' => '', 'method_req_pq_multi_param_nonce' => '',
'method_req_pq_multi_param_nonce' => '', 'method_req_DH_params' => '',
'method_req_DH_params' => '', 'method_req_DH_params_param_nonce' => '',
'method_req_DH_params_param_nonce' => '', 'method_req_DH_params_param_server_nonce' => '',
'method_req_DH_params_param_server_nonce' => '', 'method_req_DH_params_param_p' => '',
'method_req_DH_params_param_p' => '', 'method_req_DH_params_param_q' => '',
'method_req_DH_params_param_q' => '', 'method_req_DH_params_param_public_key_fingerprint' => '',
'method_req_DH_params_param_public_key_fingerprint' => '', 'method_req_DH_params_param_encrypted_data' => '',
'method_req_DH_params_param_encrypted_data' => '', 'method_set_client_DH_params' => '',
'method_set_client_DH_params' => '', 'method_set_client_DH_params_param_nonce' => '',
'method_set_client_DH_params_param_nonce' => '', 'method_set_client_DH_params_param_server_nonce' => '',
'method_set_client_DH_params_param_server_nonce' => '', 'method_set_client_DH_params_param_encrypted_data' => '',
'method_set_client_DH_params_param_encrypted_data' => '', 'method_rpc_drop_answer' => '',
'method_rpc_drop_answer' => '', 'method_rpc_drop_answer_param_req_msg_id' => '',
'method_rpc_drop_answer_param_req_msg_id' => '', 'method_get_future_salts' => '',
'method_get_future_salts' => '', 'method_get_future_salts_param_num' => '',
'method_get_future_salts_param_num' => '', 'method_ping' => '',
'method_ping' => '', 'method_ping_param_ping_id' => '',
'method_ping_param_ping_id' => '', 'method_ping_delay_disconnect' => '',
'method_ping_delay_disconnect' => '', 'method_ping_delay_disconnect_param_ping_id' => '',
'method_ping_delay_disconnect_param_ping_id' => '',
'method_ping_delay_disconnect_param_disconnect_delay' => '', 'method_ping_delay_disconnect_param_disconnect_delay' => '',
'method_destroy_session' => '', 'method_destroy_session' => '',
'method_destroy_session_param_session_id' => '', 'method_destroy_session_param_session_id' => '',
'method_http_wait' => '', 'method_http_wait' => '',
'method_http_wait_param_max_delay' => '', 'method_http_wait_param_max_delay' => '',
'method_http_wait_param_wait_after' => '', 'method_http_wait_param_wait_after' => '',
'method_http_wait_param_max_wait' => '', 'method_http_wait_param_max_wait' => '',
), ],
); ];
// THIS WILL BE OVERWRITTEN BY $lang["en"] // THIS WILL BE OVERWRITTEN BY $lang["en"]
public static $current_lang = array ( public static $current_lang = [
'req_pq' => 'Requesting pq...', 'req_pq' => 'Requesting pq...',
'done' => 'Done!', 'done' => 'Done!',
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!', 'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
'stored_on_cdn' => 'File is stored on CDN!', 'stored_on_cdn' => 'File is stored on CDN!',
'serializing_madelineproto' => 'Serializing MadelineProto...', 'serializing_madelineproto' => 'Serializing MadelineProto...',
'phpseclib_fork' => 'Please install this fork of phpseclib: https://github.com/danog/phpseclib', 'phpseclib_fork' => 'Please install this fork of phpseclib: https://github.com/danog/phpseclib',
'inst_dc' => 'Istantiating DataCenter...', 'inst_dc' => 'Istantiating DataCenter...',
'load_rsa' => 'Loading RSA keys...', 'load_rsa' => 'Loading RSA keys...',
'TL_translation' => 'Translating TL schemas...', 'TL_translation' => 'Translating TL schemas...',
'dh_prime_check_0' => 'Executing dh_prime checks (0/3)...', 'dh_prime_check_0' => 'Executing dh_prime checks (0/3)...',
'nearest_dc' => 'We\'re in %s, nearest DC is %d.', 'nearest_dc' => 'We\'re in %s, nearest DC is %d.',
'serialization_ofd' => 'Serialization is out of date, reconstructing object!', 'serialization_ofd' => 'Serialization is out of date, reconstructing object!',
'getupdates_deserialization' => 'Getting updates after deserialization...', 'getupdates_deserialization' => 'Getting updates after deserialization...',
'shutdown_reader_pool' => 'Shutting down reader pool, %d jobs left', 'shutdown_reader_pool' => 'Shutting down reader pool, %d jobs left',
'threading_on' => 'THREADING IS ENABLED', 'threading_on' => 'THREADING IS ENABLED',
'socket_reader' => 'Socket reader on DC %s: ', 'socket_reader' => 'Socket reader on DC %s: ',
'socket_status_1' => 'CREATING', 'socket_status_1' => 'CREATING',
'socket_status_2' => 'SUBMITTING', 'socket_status_2' => 'SUBMITTING',
'socket_status_3' => 'WAITING', 'socket_status_3' => 'WAITING',
'socket_status_4' => 'READY', 'socket_status_4' => 'READY',
'socket_status_5' => 'WORKING', 'socket_status_5' => 'WORKING',
'api_not_set' => 'You must provide an api key and an api id, get your own @ my.telegram.org', 'api_not_set' => 'You must provide an api key and an api id, get your own @ my.telegram.org',
'session_corrupted' => 'The session is corrupted!', 'session_corrupted' => 'The session is corrupted!',
'reset_session_seqno' => 'Resetting session id and seq_no in DC %s...', 'reset_session_seqno' => 'Resetting session id and seq_no in DC %s...',
'gen_perm_auth_key' => 'Generating permanent authorization key for DC %s...', 'gen_perm_auth_key' => 'Generating permanent authorization key for DC %s...',
'gen_temp_auth_key' => 'Generating temporary authorization key for DC %s...', 'gen_temp_auth_key' => 'Generating temporary authorization key for DC %s...',
'copy_auth_dcs' => 'Copying authorization from DC %s to DC %s...', 'copy_auth_dcs' => 'Copying authorization from DC %s to DC %s...',
'write_client_info' => 'Writing client info (also executing %s)...', 'write_client_info' => 'Writing client info (also executing %s)...',
'config_updated' => 'Updated config!', 'config_updated' => 'Updated config!',
'length_not_4' => 'Length is not equal to 4', 'length_not_4' => 'Length is not equal to 4',
'length_not_8' => 'Length is not equal to 8', 'length_not_8' => 'Length is not equal to 8',
'value_bigger_than_2147483647' => 'Provided value %s is bigger than 2147483647', 'value_bigger_than_2147483647' => 'Provided value %s is bigger than 2147483647',
'value_smaller_than_2147483648' => 'Provided value %s is smaller than -2147483648', 'value_smaller_than_2147483648' => 'Provided value %s is smaller than -2147483648',
'value_bigger_than_9223372036854775807' => 'Provided value %s is bigger than 9223372036854775807', 'value_bigger_than_9223372036854775807' => 'Provided value %s is bigger than 9223372036854775807',
'value_smaller_than_9223372036854775808' => 'Provided value %s is smaller than -9223372036854775808', 'value_smaller_than_9223372036854775808' => 'Provided value %s is smaller than -9223372036854775808',
'value_bigger_than_4294967296' => 'Provided value %s is bigger than 4294967296', 'value_bigger_than_4294967296' => 'Provided value %s is bigger than 4294967296',
'value_smaller_than_0' => 'Provided value %s is smaller than 0', 'value_smaller_than_0' => 'Provided value %s is smaller than 0',
'encode_double_error' => 'Could not properly encode double', 'encode_double_error' => 'Could not properly encode double',
'file_not_exist' => 'File does not exist', 'file_not_exist' => 'File does not exist',
'deserialization_error' => 'An error occurred on deserialization', 'deserialization_error' => 'An error occurred on deserialization',
'rsa_init' => 'Istantiating \\phpseclib\\Crypt\\RSA...', 'rsa_init' => 'Istantiating \\phpseclib\\Crypt\\RSA...',
'loading_key' => 'Loading key...', 'loading_key' => 'Loading key...',
'computing_fingerprint' => 'Computing fingerprint...', 'computing_fingerprint' => 'Computing fingerprint...',
'rsa_encrypting' => 'Encrypting with rsa key...', 'rsa_encrypting' => 'Encrypting with rsa key...',
'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:', 'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:',
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e', 'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970', 'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
'no_mode_specified' => 'No mode was specified!', 'no_mode_specified' => 'No mode was specified!',
'constructor_function_uncalled' => 'The constructor function wasn\'t called! Please call the constructor function before using this method.', 'constructor_function_uncalled' => 'The constructor function wasn\'t called! Please call the constructor function before using this method.',
'proxy_class_invalid' => 'Invalid proxy class provided!', 'proxy_class_invalid' => 'Invalid proxy class provided!',
'socket_con_error' => 'Connection: couldn\'t connect to socket.', 'socket_con_error' => 'Connection: couldn\'t connect to socket.',
'protocol_not_implemented' => 'Connection: This protocol isn\'t implemented yet.', 'protocol_not_implemented' => 'Connection: This protocol isn\'t implemented yet.',
'protocol_invalid' => 'Connection: invalid protocol specified.', 'protocol_invalid' => 'Connection: invalid protocol specified.',
'nothing_in_socket' => 'Nothing in the socket!', 'nothing_in_socket' => 'Nothing in the socket!',
'wrong_length_read' => 'WARNING: Wrong length was read (should\'ve read %s, read %s)!', 'wrong_length_read' => 'WARNING: Wrong length was read (should\'ve read %s, read %s)!',
'no_data_in_socket' => 'No data in the socket!', 'no_data_in_socket' => 'No data in the socket!',
'dc_con_start' => 'Connecting to DC %s...', 'dc_con_start' => 'Connecting to DC %s...',
'dc_con_stop' => 'Disconnecting from DC %s...', 'dc_con_stop' => 'Disconnecting from DC %s...',
'dc_con_test_start' => 'Connecting to DC %s (%s server, %s, %s)...', 'dc_con_test_start' => 'Connecting to DC %s (%s server, %s, %s)...',
'script_not_exist' => 'Provided script does not exist', 'script_not_exist' => 'Provided script does not exist',
'apifactory_start' => 'Running APIFactory...', 'apifactory_start' => 'Running APIFactory...',
'madelineproto_ready' => 'MadelineProto is ready!', 'madelineproto_ready' => 'MadelineProto is ready!',
'logout_error' => 'An error occurred while logging out!', 'logout_error' => 'An error occurred while logging out!',
'logout_ok' => 'Logged out successfully!', 'logout_ok' => 'Logged out successfully!',
'already_logged_in' => 'This instance of MadelineProto is already logged in. Logging out first...', 'already_logged_in' => 'This instance of MadelineProto is already logged in. Logging out first...',
'login_ok' => 'Logged in successfully!', 'login_ok' => 'Logged in successfully!',
'login_user' => 'Logging in as a normal user...', 'login_user' => 'Logging in as a normal user...',
'login_bot' => 'Logging in as a bot...', 'login_bot' => 'Logging in as a bot...',
'login_code_sending' => 'Sending code...', 'login_code_sending' => 'Sending code...',
'login_code_sent' => 'Code sent successfully! Once you receive the code you should use the complete_phone_login function.', 'login_code_sent' => 'Code sent successfully! Once you receive the code you should use the complete_phone_login function.',
'login_code_uncalled' => 'I\'m not waiting for the code! Please call the phone_login method first', 'login_code_uncalled' => 'I\'m not waiting for the code! Please call the phone_login method first',
'login_2fa_enabled' => '2FA enabled, you will have to call the complete_2fa_login function...', 'login_2fa_enabled' => '2FA enabled, you will have to call the complete_2fa_login function...',
'login_need_signup' => 'An account has not been created for this number, you will have to call the complete_signup function...', 'login_need_signup' => 'An account has not been created for this number, you will have to call the complete_signup function...',
'login_auth_key' => 'Logging in using auth key...', 'login_auth_key' => 'Logging in using auth key...',
'not_logged_in' => 'I\'m not logged in!', 'not_logged_in' => 'I\'m not logged in!',
'signup_uncalled' => 'I\'m not waiting to signup! Please call the phone_login and the complete_phone_login methods first!', 'signup_uncalled' => 'I\'m not waiting to signup! Please call the phone_login and the complete_phone_login methods first!',
'signing_up' => 'Signing up as a normal user...', 'signing_up' => 'Signing up as a normal user...',
'signup_ok' => 'Signed up in successfully!', 'signup_ok' => 'Signed up in successfully!',
'2fa_uncalled' => 'I\'m not waiting for the password! Please call the phone_login and the complete_phone_login methods first!', '2fa_uncalled' => 'I\'m not waiting for the password! Please call the phone_login and the complete_phone_login methods first!',
'getting_dialogs' => 'Getting dialogs...', 'getting_dialogs' => 'Getting dialogs...',
'libtgvoip_required' => 'The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.', 'libtgvoip_required' => 'The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.',
'peer_not_in_db' => 'This peer is not present in the internal peer database', 'peer_not_in_db' => 'This peer is not present in the internal peer database',
'calling_user' => 'Calling %s...', 'calling_user' => 'Calling %s...',
'generating_a' => 'Generating a...', 'generating_a' => 'Generating a...',
'generating_g_a' => 'Generating g_a...', 'generating_g_a' => 'Generating g_a...',
'call_error_1' => 'Could not find and accept call %s', 'call_error_1' => 'Could not find and accept call %s',
'accepting_call' => 'Accepting call from %s...', 'accepting_call' => 'Accepting call from %s...',
'generating_b' => 'Generating b...', 'generating_b' => 'Generating b...',
'call_already_accepted' => 'Call %s already accepted', 'call_already_accepted' => 'Call %s already accepted',
'call_already_declined' => 'Call %s already declined', 'call_already_declined' => 'Call %s already declined',
'call_error_2' => 'Could not find and confirm call %s', 'call_error_2' => 'Could not find and confirm call %s',
'call_confirming' => 'Confirming call from %s...', 'call_confirming' => 'Confirming call from %s...',
'call_error_3' => 'Could not find and complete call %s', 'call_error_3' => 'Could not find and complete call %s',
'call_completing' => 'Completing call from %s...', 'call_completing' => 'Completing call from %s...',
'invalid_g_a' => 'Invalid g_a!', 'invalid_g_a' => 'Invalid g_a!',
'fingerprint_invalid' => 'Invalid key fingerprint!', 'fingerprint_invalid' => 'Invalid key fingerprint!',
'call_discarding' => 'Discarding call %s...', 'call_discarding' => 'Discarding call %s...',
'call_set_rating' => 'Setting rating for call %s...', 'call_set_rating' => 'Setting rating for call %s...',
'call_debug_saving' => 'Saving debug data for call %s...', 'call_debug_saving' => 'Saving debug data for call %s...',
'TL_loading' => 'Loading TL schemes...', 'TL_loading' => 'Loading TL schemes...',
'file_parsing' => 'Parsing %s...', 'file_parsing' => 'Parsing %s...',
'crc32_mismatch' => 'CRC32 mismatch (%s, %s) for %s', 'crc32_mismatch' => 'CRC32 mismatch (%s, %s) for %s',
'src_file_invalid' => 'Invalid source file was provided: ', 'src_file_invalid' => 'Invalid source file was provided: ',
'translating_obj' => 'Translating objects...', 'translating_obj' => 'Translating objects...',
'translating_methods' => 'Translating methods...', 'translating_methods' => 'Translating methods...',
'bool_error' => 'Could not extract boolean', 'bool_error' => 'Could not extract boolean',
'not_numeric' => 'Given value isn\'t numeric', 'not_numeric' => 'Given value isn\'t numeric',
'long_not_16' => 'Given value is not 16 bytes long', 'long_not_16' => 'Given value is not 16 bytes long',
'long_not_32' => 'Given value is not 32 bytes long', 'long_not_32' => 'Given value is not 32 bytes long',
'long_not_64' => 'Given value is not 64 bytes long', 'long_not_64' => 'Given value is not 64 bytes long',
'array_invalid' => 'You didn\'t provide a valid array', 'array_invalid' => 'You didn\'t provide a valid array',
'predicate_not_set' => 'Predicate (value under _) was not set!', 'predicate_not_set' => 'Predicate (value under _) was not set!',
'type_extract_error' => 'Could not extract type "%s"', 'type_extract_error' => 'Could not extract type "%s"',
'method_not_found' => 'Could not find method: ', 'method_not_found' => 'Could not find method: ',
'params_missing' => 'Missing required parameter', 'params_missing' => 'Missing required parameter',
'sec_peer_not_in_db' => 'This secret peer is not present in the internal peer database', 'sec_peer_not_in_db' => 'This secret peer is not present in the internal peer database',
'stream_handle_invalid' => 'An invalid stream handle was provided.', 'stream_handle_invalid' => 'An invalid stream handle was provided.',
'length_too_big' => 'Length is too big', 'length_too_big' => 'Length is too big',
'deserialize_not_str' => 'Deserialize: Generated value isn\'t a string', 'deserialize_not_str' => 'Deserialize: Generated value isn\'t a string',
'type_extract_error_id' => 'Could not extract type: %s with id %s', 'type_extract_error_id' => 'Could not extract type: %s with id %s',
'vector_invalid' => 'Invalid vector constructor: ', 'vector_invalid' => 'Invalid vector constructor: ',
'constructor_not_found' => 'Constructor not found for type: ', 'constructor_not_found' => 'Constructor not found for type: ',
'rand_bytes_too_small' => 'random_bytes is too small!', 'rand_bytes_too_small' => 'random_bytes is too small!',
'botapi_conversion_error' => 'Can\'t convert %s to a bot API object', 'botapi_conversion_error' => 'Can\'t convert %s to a bot API object',
'non_text_conversion' => 'Can\'t convert non text messages yet!', 'non_text_conversion' => 'Can\'t convert non text messages yet!',
'last_byte_invalid' => 'Invalid last byte', 'last_byte_invalid' => 'Invalid last byte',
'file_type_invalid' => 'Invalid file type detected (%s)', 'file_type_invalid' => 'Invalid file type detected (%s)',
'recreate_temp_auth_key' => 'I had to recreate the temporary authorization key', 'recreate_temp_auth_key' => 'I had to recreate the temporary authorization key',
'resetting_auth_key' => 'WARNING: Resetting auth key...', 'resetting_auth_key' => 'WARNING: Resetting auth key...',
'shutting_down_reader_pool' => 'Shutting down reader pool ', 'shutting_down_reader_pool' => 'Shutting down reader pool ',
'shutting_down_handler_pool' => 'Shutting down handler pool for dc %s, %d jobs left', 'shutting_down_handler_pool' => 'Shutting down handler pool for dc %s, %d jobs left',
'secret_chat_skipping' => 'I do not have the secret chat %s in the database, skipping message...', 'secret_chat_skipping' => 'I do not have the secret chat %s in the database, skipping message...',
'fingerprint_mismatch' => 'Key fingerprint mismatch', 'fingerprint_mismatch' => 'Key fingerprint mismatch',
'msg_data_length_too_big' => 'message_data_length is too big', 'msg_data_length_too_big' => 'message_data_length is too big',
'length_not_divisible_16' => 'Length of decrypted data is not divisible by 16', 'length_not_divisible_16' => 'Length of decrypted data is not divisible by 16',
'msg_key_mismatch' => 'msg_key mismatch', 'msg_key_mismatch' => 'msg_key mismatch',
'rand_bytes_too_short' => 'random_bytes is too short!', 'rand_bytes_too_short' => 'random_bytes is too short!',
'resending_unsupported' => 'Resending of messages is not yet supported', 'resending_unsupported' => 'Resending of messages is not yet supported',
'unrecognized_dec_msg' => 'Unrecognized decrypted message received: ', 'unrecognized_dec_msg' => 'Unrecognized decrypted message received: ',
'method_req_pq' => '', 'method_req_pq' => '',
'method_req_pq_param_nonce' => '', 'method_req_pq_param_nonce' => '',
'method_req_pq_multi' => '', 'method_req_pq_multi' => '',
'method_req_pq_multi_param_nonce' => '', 'method_req_pq_multi_param_nonce' => '',
'method_req_DH_params' => '', 'method_req_DH_params' => '',
'method_req_DH_params_param_nonce' => '', 'method_req_DH_params_param_nonce' => '',
'method_req_DH_params_param_server_nonce' => '', 'method_req_DH_params_param_server_nonce' => '',
'method_req_DH_params_param_p' => '', 'method_req_DH_params_param_p' => '',
'method_req_DH_params_param_q' => '', 'method_req_DH_params_param_q' => '',
'method_req_DH_params_param_public_key_fingerprint' => '', 'method_req_DH_params_param_public_key_fingerprint' => '',
'method_req_DH_params_param_encrypted_data' => '', 'method_req_DH_params_param_encrypted_data' => '',
'method_set_client_DH_params' => '', 'method_set_client_DH_params' => '',
'method_set_client_DH_params_param_nonce' => '', 'method_set_client_DH_params_param_nonce' => '',
'method_set_client_DH_params_param_server_nonce' => '', 'method_set_client_DH_params_param_server_nonce' => '',
'method_set_client_DH_params_param_encrypted_data' => '', 'method_set_client_DH_params_param_encrypted_data' => '',
'method_rpc_drop_answer' => '', 'method_rpc_drop_answer' => '',
'method_rpc_drop_answer_param_req_msg_id' => '', 'method_rpc_drop_answer_param_req_msg_id' => '',
'method_get_future_salts' => '', 'method_get_future_salts' => '',
'method_get_future_salts_param_num' => '', 'method_get_future_salts_param_num' => '',
'method_ping' => '', 'method_ping' => '',
'method_ping_param_ping_id' => '', 'method_ping_param_ping_id' => '',
'method_ping_delay_disconnect' => '', 'method_ping_delay_disconnect' => '',
'method_ping_delay_disconnect_param_ping_id' => '', 'method_ping_delay_disconnect_param_ping_id' => '',
'method_ping_delay_disconnect_param_disconnect_delay' => '', 'method_ping_delay_disconnect_param_disconnect_delay' => '',
'method_destroy_session' => '', 'method_destroy_session' => '',
'method_destroy_session_param_session_id' => '', 'method_destroy_session_param_session_id' => '',
'method_http_wait' => '', 'method_http_wait' => '',
'method_http_wait_param_max_delay' => '', 'method_http_wait_param_max_delay' => '',
'method_http_wait_param_wait_after' => '', 'method_http_wait_param_wait_after' => '',
'method_http_wait_param_max_wait' => '', 'method_http_wait_param_max_wait' => '',
); ];
} }

View File

@ -2,10 +2,9 @@
require 'vendor/autoload.php'; require 'vendor/autoload.php';
$MadelineProto = new \danog\MadelineProto\API('session.madeline');//, ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e']]); $MadelineProto = new \danog\MadelineProto\API('session.madeline'); //, ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e']]);
$me = $MadelineProto->start(); $me = $MadelineProto->start();
$me = $MadelineProto->get_self(); $me = $MadelineProto->get_self();
\danog\MadelineProto\Logger::log($me); \danog\MadelineProto\Logger::log($me);

View File

@ -12,7 +12,7 @@ If not, see <http://www.gnu.org/licenses/>.
*/ */
set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/')); set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/'));
/** /*
* Various ways to load MadelineProto * Various ways to load MadelineProto
*/ */
if (!file_exists(__DIR__.'/vendor/autoload.php')) { if (!file_exists(__DIR__.'/vendor/autoload.php')) {
@ -31,6 +31,7 @@ class EventHandler extends \danog\MadelineProto\EventHandler
{ {
$this->onUpdateNewMessage($update); $this->onUpdateNewMessage($update);
} }
public function onUpdateNewMessage($update) public function onUpdateNewMessage($update)
{ {
if (isset($update['message']['out']) && $update['message']['out']) { if (isset($update['message']['out']) && $update['message']['out']) {
@ -59,7 +60,6 @@ class EventHandler extends \danog\MadelineProto\EventHandler
} }
} }
$settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'updates' => ['handle_updates' => true]]; //, 'connection_settings' => ['all' => ['test_mode' => true]]]; $settings = ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'updates' => ['handle_updates' => true]]; //, 'connection_settings' => ['all' => ['test_mode' => true]]];
try { try {

View File

@ -12,7 +12,7 @@ If not, see <http://www.gnu.org/licenses/>.
*/ */
set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/')); set_include_path(get_include_path().':'.realpath(dirname(__FILE__).'/MadelineProto/'));
/** /*
* Various ways to load MadelineProto * Various ways to load MadelineProto
*/ */
if (!file_exists(__DIR__.'/vendor/autoload.php')) { if (!file_exists(__DIR__.'/vendor/autoload.php')) {
@ -25,13 +25,16 @@ if (!file_exists(__DIR__.'/vendor/autoload.php')) {
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
} }
class EventHandler extends \danog\MadelineProto\EventHandler class EventHandler extends \danog\MadelineProto\EventHandler
{ {
private $sent = [-440592694 => true]; private $sent = [-440592694 => true];
public function onUpdateNewEncryptedMessage($update) {
public function onUpdateNewEncryptedMessage($update)
{
try { try {
if (isset($update['message']['decrypted_message']['media'])) \danog\MadelineProto\Logger::log($this->download_to_dir($update, '.')); if (isset($update['message']['decrypted_message']['media'])) {
\danog\MadelineProto\Logger::log($this->download_to_dir($update, '.'));
}
if (isset($this->sent[$update['message']['chat_id']])) { if (isset($this->sent[$update['message']['chat_id']])) {
return; return;
} }
@ -87,9 +90,6 @@ class EventHandler extends \danog\MadelineProto\EventHandler
} }
} }
if (file_exists('.env')) { if (file_exists('.env')) {
echo 'Loading .env...'.PHP_EOL; echo 'Loading .env...'.PHP_EOL;
$dotenv = new Dotenv\Dotenv(getcwd()); $dotenv = new Dotenv\Dotenv(getcwd());
@ -99,7 +99,6 @@ if (file_exists('.env')) {
echo 'Loading settings...'.PHP_EOL; echo 'Loading settings...'.PHP_EOL;
$settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: []; $settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: [];
try { try {
$MadelineProto = new \danog\MadelineProto\API('s.madeline', $settings); $MadelineProto = new \danog\MadelineProto\API('s.madeline', $settings);
} catch (\danog\MadelineProto\Exception $e) { } catch (\danog\MadelineProto\Exception $e) {

View File

@ -10,7 +10,6 @@ You should have received a copy of the GNU General Public License along with Mad
If not, see <http://www.gnu.org/licenses/>. If not, see <http://www.gnu.org/licenses/>.
*/ */
class HttpProxy implements \danog\MadelineProto\Proxy class HttpProxy implements \danog\MadelineProto\Proxy
{ {
private $domain; private $domain;
@ -18,7 +17,9 @@ class HttpProxy implements \danog\MadelineProto\Proxy
private $protocol; private $protocol;
private $extra; private $extra;
private $sock; private $sock;
public function __construct($domain, $type, $protocol) {
public function __construct($domain, $type, $protocol)
{
if (!in_array($domain, [AF_INET, AF_INET6])) { if (!in_array($domain, [AF_INET, AF_INET6])) {
throw new \danog\MadelineProto\Exception('Wrong protocol family provided'); throw new \danog\MadelineProto\Exception('Wrong protocol family provided');
} }
@ -32,39 +33,51 @@ class HttpProxy implements \danog\MadelineProto\Proxy
$this->type = $type; $this->type = $type;
$this->protocol = $protocol; $this->protocol = $protocol;
} }
public function setExtra(array $extra = []) {
public function setExtra(array $extra = [])
{
$this->extra = $extra; $this->extra = $extra;
$name = $this->protocol === PHP_INT_MAX ? '\\FSocket' : '\\Socket'; $name = $this->protocol === PHP_INT_MAX ? '\\FSocket' : '\\Socket';
$this->sock = new $name(strlen(@inet_pton($this->extra['address'])) !== 4 ? \AF_INET6 : \AF_INET, \SOCK_STREAM, $this->protocol); $this->sock = new $name(strlen(@inet_pton($this->extra['address'])) !== 4 ? \AF_INET6 : \AF_INET, \SOCK_STREAM, $this->protocol);
} }
public function setOption($level, $name, $value) {
public function setOption($level, $name, $value)
{
return $this->sock->setOption($level, $name, $value); return $this->sock->setOption($level, $name, $value);
} }
public function getOption($level, $name) { public function getOption($level, $name)
{
return $this->sock->getOption($level, $name); return $this->sock->getOption($level, $name);
} }
public function setBlocking($blocking) { public function setBlocking($blocking)
{
return $this->sock->setBlocking($blocking); return $this->sock->setBlocking($blocking);
} }
public function bind($address, $port = 0) { public function bind($address, $port = 0)
{
throw new \danog\MadelineProto\Exception('Not Implemented'); throw new \danog\MadelineProto\Exception('Not Implemented');
} }
public function listen($backlog = 0) { public function listen($backlog = 0)
throw new \danog\MadelineProto\Exception('Not Implemented'); {
}
public function accept() {
throw new \danog\MadelineProto\Exception('Not Implemented'); throw new \danog\MadelineProto\Exception('Not Implemented');
} }
public function accept()
public function select(array &$read, array &$write, array &$except, $tv_sec, $tv_usec = 0) { {
throw new \danog\MadelineProto\Exception('Not Implemented'); throw new \danog\MadelineProto\Exception('Not Implemented');
} }
public function connect($address, $port = 0) {
public function select(array &$read, array &$write, array &$except, $tv_sec, $tv_usec = 0)
{
throw new \danog\MadelineProto\Exception('Not Implemented');
}
public function connect($address, $port = 0)
{
$this->sock->connect($this->extra['address'], $this->extra['port']); $this->sock->connect($this->extra['address'], $this->extra['port']);
try { try {
@ -77,12 +90,16 @@ class HttpProxy implements \danog\MadelineProto\Proxy
$response = $this->read_http_payload(); $response = $this->read_http_payload();
if ($response['code'] !== 200) { if ($response['code'] !== 200) {
\danog\MadelineProto\Logger::log(trim($response['body'])); \danog\MadelineProto\Logger::log(trim($response['body']));
throw new \danog\MadelineProto\Exception($response['description'], $response['code']); throw new \danog\MadelineProto\Exception($response['description'], $response['code']);
} }
\danog\MadelineProto\Logger::log('Connected to '.$address.':'.$port.' via http'); \danog\MadelineProto\Logger::log('Connected to '.$address.':'.$port.' via http');
return true; return true;
} }
private function http_read($length) {
private function http_read($length)
{
$packet = ''; $packet = '';
while (strlen($packet) < $length) { while (strlen($packet) < $length) {
$packet .= $this->sock->read($length - strlen($packet)); $packet .= $this->sock->read($length - strlen($packet));
@ -90,8 +107,10 @@ class HttpProxy implements \danog\MadelineProto\Proxy
throw new \danog\MadelineProto\NothingInTheSocketException(\danog\MadelineProto\Lang::$current_lang['nothing_in_socket']); throw new \danog\MadelineProto\NothingInTheSocketException(\danog\MadelineProto\Lang::$current_lang['nothing_in_socket']);
} }
} }
return $packet; return $packet;
} }
public function read_http_line() public function read_http_line()
{ {
$line = ''; $line = '';
@ -128,34 +147,42 @@ class HttpProxy implements \danog\MadelineProto\Proxy
return ['protocol' => $protocol, 'code' => $code, 'description' => $description, 'body' => $read, 'headers' => $headers]; return ['protocol' => $protocol, 'code' => $code, 'description' => $description, 'body' => $read, 'headers' => $headers];
} }
public function read($length, $flags = 0) { public function read($length, $flags = 0)
{
$read = $this->sock->read($length, $flags); $read = $this->sock->read($length, $flags);
if ($read === 0) { if ($read === 0) {
throw new \danog\MadelineProto\Exception('pls reconnect'); throw new \danog\MadelineProto\Exception('pls reconnect');
} }
return $read; return $read;
} }
public function write($buffer, $length = -1) { public function write($buffer, $length = -1)
{
return $this->sock->write($buffer, $length); return $this->sock->write($buffer, $length);
} }
public function send($data, $length, $flags) { public function send($data, $length, $flags)
{
throw new \danog\MadelineProto\Exception('Not Implemented'); throw new \danog\MadelineProto\Exception('Not Implemented');
} }
public function close() { public function close()
{
$this->sock->close(); $this->sock->close();
} }
public function getPeerName($port = true) { public function getPeerName($port = true)
{
throw new \danog\MadelineProto\Exception('Not Implemented'); throw new \danog\MadelineProto\Exception('Not Implemented');
} }
public function getSockName($port = true) { public function getSockName($port = true)
{
throw new \danog\MadelineProto\Exception('Not Implemented'); throw new \danog\MadelineProto\Exception('Not Implemented');
} }
public function getProxyHeaders() {
public function getProxyHeaders()
{
} }
} }

View File

@ -82,6 +82,7 @@ class API extends APIFactory
if (isset($unserialized->API)) { if (isset($unserialized->API)) {
$this->API = $unserialized->API; $this->API = $unserialized->API;
$this->APIFactory(); $this->APIFactory();
return; return;
} }
} }
@ -178,6 +179,7 @@ class API extends APIFactory
if (is_null($this->session)) { if (is_null($this->session)) {
return; return;
} }
return Serialization::serialize($params, $this); return Serialization::serialize($params, $this);
} }
} }

View File

@ -572,6 +572,7 @@ Any json-encodable data.
'); ');
\danog\MadelineProto\Logger::log('Done!', \danog\MadelineProto\Logger::NOTICE); \danog\MadelineProto\Logger::log('Done!', \danog\MadelineProto\Logger::NOTICE);
} }
public $template = '<?php public $template = '<?php
/* /*
Copyright 2016-2018 Daniil Gentili Copyright 2016-2018 Daniil Gentili
@ -594,11 +595,11 @@ class Lang
public static $current_lang = %s; public static $current_lang = %s;
}'; }';
public function add_to_lang($key) { public function add_to_lang($key)
{
if (!isset(\danog\MadelineProto\Lang::$lang['en'][$key])) { if (!isset(\danog\MadelineProto\Lang::$lang['en'][$key])) {
\danog\MadelineProto\Lang::$lang['en'][$key] = ''; \danog\MadelineProto\Lang::$lang['en'][$key] = '';
file_put_contents(__DIR__.'/Lang.php', sprintf($this->template, var_export(\danog\MadelineProto\Lang::$lang, true), var_export(\danog\MadelineProto\Lang::$lang['en'], true))); file_put_contents(__DIR__.'/Lang.php', sprintf($this->template, var_export(\danog\MadelineProto\Lang::$lang, true), var_export(\danog\MadelineProto\Lang::$lang['en'], true)));
} }
} }
} }

View File

@ -130,22 +130,22 @@ trait Constructors
$ptype = 'Bool'; $ptype = 'Bool';
} }
$human_ptype = $ptype; $human_ptype = $ptype;
if (strpos($type, 'Input') === 0 && in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'])&& !isset($this->settings['td'])) { if (strpos($type, 'Input') === 0 && in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer']) && !isset($this->settings['td'])) {
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype; $human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
} }
if (strpos($type, 'Input') === 0 && in_array($ptype, ['InputMedia', 'InputDocument', 'InputPhoto'])&& !isset($this->settings['td'])) { if (strpos($type, 'Input') === 0 && in_array($ptype, ['InputMedia', 'InputDocument', 'InputPhoto']) && !isset($this->settings['td'])) {
$human_ptype = 'MessageMedia, Message, Update or '.$ptype; $human_ptype = 'MessageMedia, Message, Update or '.$ptype;
} }
if (in_array($ptype, ['InputMessage'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputMessage']) && !isset($this->settings['td'])) {
$human_ptype = 'Message ID or '.$ptype; $human_ptype = 'Message ID or '.$ptype;
} }
if (in_array($ptype, ['InputEncryptedChat'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputEncryptedChat']) && !isset($this->settings['td'])) {
$human_ptype = 'Secret chat ID, Update, EncryptedMessage or '.$ptype; $human_ptype = 'Secret chat ID, Update, EncryptedMessage or '.$ptype;
} }
if (in_array($ptype, ['InputFile'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputFile']) && !isset($this->settings['td'])) {
$human_ptype = 'File path or '.$ptype; $human_ptype = 'File path or '.$ptype;
} }
if (in_array($ptype, ['InputEncryptedFile'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputEncryptedFile']) && !isset($this->settings['td'])) {
$human_ptype = 'File path or '.$ptype; $human_ptype = 'File path or '.$ptype;
} }
$table .= '|'.str_replace('_', '\\_', $param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.str_replace('_', '\\_', $human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.(isset($param['pow']) || $this->constructors->find_by_predicate(lcfirst($param['type']).'Empty') || ($data['type'] === 'InputMedia' && $param['name'] === 'mime_type') || ($data['type'] === 'DocumentAttribute' && in_array($param['name'], ['w', 'h', 'duration'])) ? 'Optional' : 'Yes').'|'; $table .= '|'.str_replace('_', '\\_', $param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.str_replace('_', '\\_', $human_ptype).'](../'.$type_or_bare_type.'/'.$ptype.'.md) | '.(isset($param['pow']) || $this->constructors->find_by_predicate(lcfirst($param['type']).'Empty') || ($data['type'] === 'InputMedia' && $param['name'] === 'mime_type') || ($data['type'] === 'DocumentAttribute' && in_array($param['name'], ['w', 'h', 'duration'])) ? 'Optional' : 'Yes').'|';

View File

@ -106,19 +106,19 @@ trait Methods
$ptype = 'Bool'; $ptype = 'Bool';
} }
$human_ptype = 'CLICK ME '.$ptype; $human_ptype = 'CLICK ME '.$ptype;
if (in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer']) && !isset($this->settings['td'])) {
$human_ptype = 'Username, chat ID, Update, Message or '.$ptype; $human_ptype = 'Username, chat ID, Update, Message or '.$ptype;
} }
if (in_array($ptype, ['InputMedia', 'InputPhoto', 'InputDocument'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputMedia', 'InputPhoto', 'InputDocument']) && !isset($this->settings['td'])) {
$human_ptype = 'MessageMedia, Update, Message or '.$ptype; $human_ptype = 'MessageMedia, Update, Message or '.$ptype;
} }
if (in_array($ptype, ['InputMessage'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputMessage']) && !isset($this->settings['td'])) {
$human_ptype = 'Message ID or '.$ptype; $human_ptype = 'Message ID or '.$ptype;
} }
if (in_array($ptype, ['InputEncryptedChat'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputEncryptedChat']) && !isset($this->settings['td'])) {
$human_ptype = 'Secret chat ID, Update, EncryptedMessage or '.$ptype; $human_ptype = 'Secret chat ID, Update, EncryptedMessage or '.$ptype;
} }
if (in_array($ptype, ['InputFile'])&& !isset($this->settings['td'])) { if (in_array($ptype, ['InputFile']) && !isset($this->settings['td'])) {
$human_ptype = 'File path or '.$ptype; $human_ptype = 'File path or '.$ptype;
} }
if (in_array($ptype, ['InputEncryptedFile']) && !isset($this->settings['td'])) { if (in_array($ptype, ['InputEncryptedFile']) && !isset($this->settings['td'])) {

View File

@ -15,12 +15,14 @@ namespace danog\MadelineProto;
class EventHandler extends APIFactory class EventHandler extends APIFactory
{ {
public function __construct($MadelineProto) { public function __construct($MadelineProto)
{
$this->API = $MadelineProto; $this->API = $MadelineProto;
foreach ($this->API->get_method_namespaces() as $namespace) { foreach ($this->API->get_method_namespaces() as $namespace) {
$this->{$namespace} = new APIFactory($namespace, $this->API); $this->{$namespace} = new APIFactory($namespace, $this->API);
} }
} }
public function &__get($name) public function &__get($name)
{ {
if ($name === 'settings') { if ($name === 'settings') {

View File

@ -17,14 +17,20 @@ class FileCallback implements FileCallbackInterface
{ {
private $file; private $file;
private $callback; private $callback;
public function __construct($file, $callback) {
public function __construct($file, $callback)
{
$this->file = $file; $this->file = $file;
$this->callback = $callback; $this->callback = $callback;
} }
public function getFile() {
public function getFile()
{
return $this->file; return $this->file;
} }
public function __invoke($percent) {
public function __invoke($percent)
{
$this->callback($percent); $this->callback($percent);
} }
} }

View File

@ -16,5 +16,6 @@ namespace danog\MadelineProto;
interface FileCallbackInterface interface FileCallbackInterface
{ {
public function getFile(); public function getFile();
public function __invoke($percent); public function __invoke($percent);
} }

View File

@ -130,7 +130,11 @@ class Logger
} }
if (!is_string($param)) { if (!is_string($param)) {
$parame = json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); $parame = json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
if ($parame == '') $param = var_export($param, true); else $param = $parame; if ($parame == '') {
$param = var_export($param, true);
} else {
$param = $parame;
}
} }
$param = str_pad(basename(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php').$prefix.': ', 16 + strlen($prefix))."\t".$param; $param = str_pad(basename(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php').$prefix.': ', 16 + strlen($prefix))."\t".$param;
/*if (self::$isatty) { /*if (self::$isatty) {

File diff suppressed because one or more lines are too long

View File

@ -198,7 +198,9 @@ trait CallHandler
$only_updates = false; $only_updates = false;
if ($last_recv === $this->datacenter->sockets[$aargs['datacenter']]->last_recv) { // the socket is dead, resend request if ($last_recv === $this->datacenter->sockets[$aargs['datacenter']]->last_recv) { // the socket is dead, resend request
$this->close_and_reopen($aargs['datacenter']); $this->close_and_reopen($aargs['datacenter']);
if ($this->altervista) continue 2; if ($this->altervista) {
continue 2;
}
} }
//if ($this->datacenter->sockets[$aargs['datacenter']]->last_recv < time() - 1 && $this->is_http($aargs['datacenter'])) { //if ($this->datacenter->sockets[$aargs['datacenter']]->last_recv < time() - 1 && $this->is_http($aargs['datacenter'])) {
// $this->close_and_reopen($aargs['datacenter']); // $this->close_and_reopen($aargs['datacenter']);

View File

@ -87,7 +87,9 @@ trait Files
{ {
return $this->upload($file, $file_name, $cb, true); return $this->upload($file, $file_name, $cb, true);
} }
public function gen_all_file($media) {
public function gen_all_file($media)
{
$res = [$this->constructors->find_by_predicate($media['_'])['type'] => $media]; $res = [$this->constructors->find_by_predicate($media['_'])['type'] => $media];
switch ($media['_']) { switch ($media['_']) {
case 'messageMediaPhoto': case 'messageMediaPhoto':
@ -131,10 +133,12 @@ trait Files
default: default:
throw new \danog\MadelineProto\Exception('Could not convert media object'); throw new \danog\MadelineProto\Exception('Could not convert media object');
} }
return $res;
return $res;
} }
public function get_file_info($constructor) {
public function get_file_info($constructor)
{
if (is_string($constructor)) { if (is_string($constructor)) {
$constructor = $this->unpack_file_id($constructor)['MessageMedia']; $constructor = $this->unpack_file_id($constructor)['MessageMedia'];
} }
@ -146,8 +150,10 @@ trait Files
case 'message': case 'message':
$constructor = $constructor['media']; $constructor = $constructor['media'];
} }
return $this->gen_all_file($constructor); return $this->gen_all_file($constructor);
} }
public function get_download_info($message_media) public function get_download_info($message_media)
{ {
if (is_string($message_media)) { if (is_string($message_media)) {

View File

@ -41,7 +41,7 @@ trait MessageHandler
\danog\MadelineProto\Logger::log("Inside of msg_container, sending {$message['_']} as encrypted message to DC $datacenter", \danog\MadelineProto\Logger::ULTRA_VERBOSE); \danog\MadelineProto\Logger::log("Inside of msg_container, sending {$message['_']} as encrypted message to DC $datacenter", \danog\MadelineProto\Logger::ULTRA_VERBOSE);
$message['_'] = 'MTmessage'; $message['_'] = 'MTmessage';
$messages[] = $message; $messages[] = $message;
$this->datacenter->sockets[$datacenter]->outgoing_messages[$message['msg_id']] = ['seq_no' => $message['seqno'], 'response' => -1];//, 'content' => $this->deserialize($message['body'], ['type' => '', 'datacenter' => $datacenter])]; $this->datacenter->sockets[$datacenter]->outgoing_messages[$message['msg_id']] = ['seq_no' => $message['seqno'], 'response' => -1]; //, 'content' => $this->deserialize($message['body'], ['type' => '', 'datacenter' => $datacenter])];
} }
$message_data = $this->serialize_object(['type' => ''], ['_' => 'msg_container', 'messages' => $messages], 'lol'); $message_data = $this->serialize_object(['type' => ''], ['_' => 'msg_container', 'messages' => $messages], 'lol');
$message_id = $this->generate_message_id($datacenter); $message_id = $this->generate_message_id($datacenter);

View File

@ -267,6 +267,7 @@ trait PeerHandler
if (!isset($this->secret_chats[$id])) { if (!isset($this->secret_chats[$id])) {
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['sec_peer_not_in_db']); throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['sec_peer_not_in_db']);
} }
return $this->secret_chats[$id]; return $this->secret_chats[$id];
case 'updateNewMessage': case 'updateNewMessage':
case 'updateNewChannelMessage': case 'updateNewChannelMessage':
@ -753,6 +754,7 @@ trait PeerHandler
if (strpos($e->rpc, 'FLOOD_WAIT_') === 0 || $e->rpc === 'AUTH_KEY_UNREGISTERED' || $e->rpc === 'USERNAME_INVALID') { if (strpos($e->rpc, 'FLOOD_WAIT_') === 0 || $e->rpc === 'AUTH_KEY_UNREGISTERED' || $e->rpc === 'USERNAME_INVALID') {
throw $e; throw $e;
} }
return false; return false;
} }
if ($res['_'] === 'contacts.resolvedPeer') { if ($res['_'] === 'contacts.resolvedPeer') {

View File

@ -13,77 +13,85 @@ If not, see <http://www.gnu.org/licenses/>.
namespace danog\MadelineProto; namespace danog\MadelineProto;
/** /**
* Wrapper for my.telegram.org * Wrapper for my.telegram.org.
*/ */
class MyTelegramOrgWrapper class MyTelegramOrgWrapper
{ {
private $logged = false; private $logged = false;
public function __construct($number) {
public function __construct($number)
{
if (!extension_loaded('curl')) { if (!extension_loaded('curl')) {
throw new Exception(['extension', 'curl']); throw new Exception(['extension', 'curl']);
} }
$this->number = $number; $this->number = $number;
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my.telegram.org/auth/send_password"); curl_setopt($ch, CURLOPT_URL, 'https://my.telegram.org/auth/send_password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(["phone" => $number])); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['phone' => $number]));
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array(); $headers = [];
$headers[] = "Origin: https://my.telegram.org"; $headers[] = 'Origin: https://my.telegram.org';
$headers[] = "Accept-Encoding: gzip, deflate, br"; $headers[] = 'Accept-Encoding: gzip, deflate, br';
$headers[] = "Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4"; $headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4';
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"; $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36';
$headers[] = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"; $headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$headers[] = "Accept: application/json, text/javascript, */*; q=0.01"; $headers[] = 'Accept: application/json, text/javascript, */*; q=0.01';
$headers[] = "Referer: https://my.telegram.org/auth"; $headers[] = 'Referer: https://my.telegram.org/auth';
$headers[] = "X-Requested-With: XMLHttpRequest"; $headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = "Connection: keep-alive"; $headers[] = 'Connection: keep-alive';
$headers[] = "Dnt: 1"; $headers[] = 'Dnt: 1';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch); $result = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
throw new Exception('Curl error: ' . curl_error($ch)); throw new Exception('Curl error: '.curl_error($ch));
} }
curl_close ($ch); curl_close($ch);
$resulta = json_decode($result, true); $resulta = json_decode($result, true);
if (!isset($resulta['random_hash'])) throw new Exception($result); if (!isset($resulta['random_hash'])) {
$this->hash = $resulta["random_hash"]; throw new Exception($result);
}
$this->hash = $resulta['random_hash'];
} }
public function complete_login($password) {
if ($this->logged) throw new Exception('Already logged in!'); public function complete_login($password)
{
if ($this->logged) {
throw new Exception('Already logged in!');
}
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my.telegram.org/auth/login"); curl_setopt($ch, CURLOPT_URL, 'https://my.telegram.org/auth/login');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(["phone" => $this->number, "random_hash" => $this->hash, "password" => $password])); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['phone' => $this->number, 'random_hash' => $this->hash, 'password' => $password]));
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array(); $headers = [];
$headers[] = "Origin: https://my.telegram.org"; $headers[] = 'Origin: https://my.telegram.org';
$headers[] = "Accept-Encoding: gzip, deflate, br"; $headers[] = 'Accept-Encoding: gzip, deflate, br';
$headers[] = "Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4"; $headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4';
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"; $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36';
$headers[] = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"; $headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$headers[] = "Accept: application/json, text/javascript, */*; q=0.01"; $headers[] = 'Accept: application/json, text/javascript, */*; q=0.01';
$headers[] = "Referer: https://my.telegram.org/auth"; $headers[] = 'Referer: https://my.telegram.org/auth';
$headers[] = "X-Requested-With: XMLHttpRequest"; $headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = "Connection: keep-alive"; $headers[] = 'Connection: keep-alive';
$headers[] = "Dnt: 1"; $headers[] = 'Dnt: 1';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec($ch); $result = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
throw new Exception('Curl error: ' . curl_error($ch)); throw new Exception('Curl error: '.curl_error($ch));
} }
curl_close ($ch); curl_close($ch);
list($response_headers, $response_content) = preg_split('/(\r\n){2}/', $result, 2); list($response_headers, $response_content) = preg_split('/(\r\n){2}/', $result, 2);
switch ($response_content) { switch ($response_content) {
@ -93,146 +101,168 @@ class MyTelegramOrgWrapper
default: default:
throw new Exception($response_content); throw new Exception($response_content);
} }
$this->token = explode(";", explode("stel_token=", $response_headers)[1])[0]; $this->token = explode(';', explode('stel_token=', $response_headers)[1])[0];
return $this->logged = true; return $this->logged = true;
} }
public function logged_in() { return $this->logged; }
public function has_app() { public function logged_in()
if (!$this->logged) throw new Exception('Not logged in!'); {
return $this->logged;
}
public function has_app()
{
if (!$this->logged) {
throw new Exception('Not logged in!');
}
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my.telegram.org/apps"); curl_setopt($ch, CURLOPT_URL, 'https://my.telegram.org/apps');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array(); $headers = [];
$headers[] = "Dnt: 1"; $headers[] = 'Dnt: 1';
$headers[] = "Accept-Encoding: gzip, deflate, sdch, br"; $headers[] = 'Accept-Encoding: gzip, deflate, sdch, br';
$headers[] = "Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4"; $headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4';
$headers[] = "Upgrade-Insecure-Requests: 1"; $headers[] = 'Upgrade-Insecure-Requests: 1';
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"; $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36';
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
$headers[] = "Referer: https://my.telegram.org/"; $headers[] = 'Referer: https://my.telegram.org/';
$headers[] = "Cookie: stel_token=".$this->token; $headers[] = 'Cookie: stel_token='.$this->token;
$headers[] = "Connection: keep-alive"; $headers[] = 'Connection: keep-alive';
$headers[] = "Cache-Control: max-age=0"; $headers[] = 'Cache-Control: max-age=0';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch); $result = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
throw new Exception('Curl error: ' . curl_error($ch)); throw new Exception('Curl error: '.curl_error($ch));
} }
curl_close ($ch); curl_close($ch);
$title = explode('</title>', explode('<title>', $result)[1])[0]; $title = explode('</title>', explode('<title>', $result)[1])[0];
switch ($title) { switch ($title) {
case 'App configuration': return true; case 'App configuration': return true;
case 'Create new application': $this->creation_hash = explode('"/>', explode('<input type="hidden" name="hash" value="', $result)[1])[0]; return false; case 'Create new application': $this->creation_hash = explode('"/>', explode('<input type="hidden" name="hash" value="', $result)[1])[0];
return false;
} }
throw new Exception($title); throw new Exception($title);
} }
public function get_app() {
if (!$this->logged) throw new Exception('Not logged in!'); public function get_app()
{
if (!$this->logged) {
throw new Exception('Not logged in!');
}
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my.telegram.org/apps"); curl_setopt($ch, CURLOPT_URL, 'https://my.telegram.org/apps');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array(); $headers = [];
$headers[] = "Dnt: 1"; $headers[] = 'Dnt: 1';
$headers[] = "Accept-Encoding: gzip, deflate, sdch, br"; $headers[] = 'Accept-Encoding: gzip, deflate, sdch, br';
$headers[] = "Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4"; $headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4';
$headers[] = "Upgrade-Insecure-Requests: 1"; $headers[] = 'Upgrade-Insecure-Requests: 1';
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"; $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36';
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
$headers[] = "Referer: https://my.telegram.org/"; $headers[] = 'Referer: https://my.telegram.org/';
$headers[] = "Cookie: stel_token=".$this->token; $headers[] = 'Cookie: stel_token='.$this->token;
$headers[] = "Connection: keep-alive"; $headers[] = 'Connection: keep-alive';
$headers[] = "Cache-Control: max-age=0"; $headers[] = 'Cache-Control: max-age=0';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch); $result = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
throw new Exception('Curl error: ' . curl_error($ch)); throw new Exception('Curl error: '.curl_error($ch));
} }
curl_close ($ch); curl_close($ch);
$cose = explode('<label for="app_id" class="col-md-4 text-right control-label">App api_id:</label> $cose = explode('<label for="app_id" class="col-md-4 text-right control-label">App api_id:</label>
<div class="col-md-7"> <div class="col-md-7">
<span class="form-control input-xlarge uneditable-input" onclick="this.select();"><strong>', $result); <span class="form-control input-xlarge uneditable-input" onclick="this.select();"><strong>', $result);
$asd = explode("</strong></span>", $cose["1"]); $asd = explode('</strong></span>', $cose['1']);
$api_id = $asd["0"]; $api_id = $asd['0'];
$cose = explode('<label for="app_hash" class="col-md-4 text-right control-label">App api_hash:</label> $cose = explode('<label for="app_hash" class="col-md-4 text-right control-label">App api_hash:</label>
<div class="col-md-7"> <div class="col-md-7">
<span class="form-control input-xlarge uneditable-input" onclick="this.select();">', $result); <span class="form-control input-xlarge uneditable-input" onclick="this.select();">', $result);
$asd = explode("</span>", $cose["1"]); $asd = explode('</span>', $cose['1']);
$api_hash = $asd["0"]; $api_hash = $asd['0'];
return ['api_id' => (int) $api_id, 'api_hash' => $api_hash]; return ['api_id' => (int) $api_id, 'api_hash' => $api_hash];
} }
public function create_app($settings) {
if (!$this->logged) throw new Exception('Not logged in!'); public function create_app($settings)
if ($this->has_app()) throw new Exception('The app was already created!'); {
if (!$this->logged) {
throw new Exception('Not logged in!');
}
if ($this->has_app()) {
throw new Exception('The app was already created!');
}
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my.telegram.org/apps/create"); curl_setopt($ch, CURLOPT_URL, 'https://my.telegram.org/apps/create');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(["hash" => $this->creation_hash, "app_title" => $settings['app_title'], "app_shortname" => $settings['app_shortname'], "app_url" => $settings['app_url'], 'app_platform' => $settings['app_platform'], 'app_desc' => $settings['app_desc']])); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['hash' => $this->creation_hash, 'app_title' => $settings['app_title'], 'app_shortname' => $settings['app_shortname'], 'app_url' => $settings['app_url'], 'app_platform' => $settings['app_platform'], 'app_desc' => $settings['app_desc']]));
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array(); $headers = [];
$headers[] = "Cookie: stel_token=$token"; $headers[] = "Cookie: stel_token=$token";
$headers[] = "Origin: https://my.telegram.org"; $headers[] = 'Origin: https://my.telegram.org';
$headers[] = "Accept-Encoding: gzip, deflate, br"; $headers[] = 'Accept-Encoding: gzip, deflate, br';
$headers[] = "Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4"; $headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4';
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"; $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36';
$headers[] = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"; $headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
$headers[] = "Accept: */*"; $headers[] = 'Accept: */*';
$headers[] = "Referer: https://my.telegram.org/apps"; $headers[] = 'Referer: https://my.telegram.org/apps';
$headers[] = "X-Requested-With: XMLHttpRequest"; $headers[] = 'X-Requested-With: XMLHttpRequest';
$headers[] = "Connection: keep-alive"; $headers[] = 'Connection: keep-alive';
$headers[] = "Dnt: 1"; $headers[] = 'Dnt: 1';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch); $result = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
throw new Exception('Curl error:' . curl_error($ch)); throw new Exception('Curl error:'.curl_error($ch));
} }
curl_close ($ch); curl_close($ch);
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my.telegram.org/apps"); curl_setopt($ch, CURLOPT_URL, 'https://my.telegram.org/apps');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array(); $headers = [];
$headers[] = "Dnt: 1"; $headers[] = 'Dnt: 1';
$headers[] = "Accept-Encoding: gzip, deflate, sdch, br"; $headers[] = 'Accept-Encoding: gzip, deflate, sdch, br';
$headers[] = "Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4"; $headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4';
$headers[] = "Upgrade-Insecure-Requests: 1"; $headers[] = 'Upgrade-Insecure-Requests: 1';
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"; $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36';
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
$headers[] = "Referer: https://my.telegram.org/"; $headers[] = 'Referer: https://my.telegram.org/';
$headers[] = "Cookie: stel_token=$token"; $headers[] = "Cookie: stel_token=$token";
$headers[] = "Connection: keep-alive"; $headers[] = 'Connection: keep-alive';
$headers[] = "Cache-Control: max-age=0"; $headers[] = 'Cache-Control: max-age=0';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch); $result = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
throw new Exception('Curl error:' . curl_error($ch)); throw new Exception('Curl error:'.curl_error($ch));
} }
curl_close ($ch); curl_close($ch);
$cose = explode('<label for="app_id" class="col-md-4 text-right control-label">App api_id:</label> $cose = explode('<label for="app_id" class="col-md-4 text-right control-label">App api_id:</label>
<div class="col-md-7"> <div class="col-md-7">
<span class="form-control input-xlarge uneditable-input" onclick="this.select();"><strong>', $result); <span class="form-control input-xlarge uneditable-input" onclick="this.select();"><strong>', $result);
$asd = explode("</strong></span>", $cose["1"]); $asd = explode('</strong></span>', $cose['1']);
$api_id = $asd["0"]; $api_id = $asd['0'];
$cose = explode('<label for="app_hash" class="col-md-4 text-right control-label">App api_hash:</label> $cose = explode('<label for="app_hash" class="col-md-4 text-right control-label">App api_hash:</label>
<div class="col-md-7"> <div class="col-md-7">
<span class="form-control input-xlarge uneditable-input" onclick="this.select();">', $result); <span class="form-control input-xlarge uneditable-input" onclick="this.select();">', $result);
$asd = explode("</span>", $cose["1"]); $asd = explode('</span>', $cose['1']);
$api_hash = $asd["0"]; $api_hash = $asd['0'];
} }
} }

View File

@ -81,7 +81,7 @@ class Serialization
return $wrote; return $wrote;
} }
/** /*
* Deserialize API class. * Deserialize API class.
* *
* @param string $filename * @param string $filename

View File

@ -170,9 +170,9 @@ class Handler extends \danog\MadelineProto\Connection
$exception['rpc_message'] = $e->rpc; $exception['rpc_message'] = $e->rpc;
$exception['message'] = $e->getMessage(); $exception['message'] = $e->getMessage();
} }
} else if ($e instanceof \danog\MadelineProto\TL\Exception) { } elseif ($e instanceof \danog\MadelineProto\TL\Exception) {
$exception = ['_' => 'socketTLException', 'message' => $e->getMessage()]; $exception = ['_' => 'socketTLException', 'message' => $e->getMessage()];
} else if ($e instanceof \DOMException) { } elseif ($e instanceof \DOMException) {
$exception = ['_' => 'socketDOMException', 'message' => $e->getMessage()]; $exception = ['_' => 'socketDOMException', 'message' => $e->getMessage()];
} else { } else {
$exception = ['_' => 'socketException', 'message' => $e->getMessage()]; $exception = ['_' => 'socketException', 'message' => $e->getMessage()];

View File

@ -17,7 +17,8 @@ namespace danog\MadelineProto;
*/ */
trait Tools trait Tools
{ {
public function gen_vector_hash($ints) { public function gen_vector_hash($ints)
{
if (\danog\MadelineProto\Logger::$bigint) { if (\danog\MadelineProto\Logger::$bigint) {
$hash = new \phpseclib\Math\BigInteger(0); $hash = new \phpseclib\Math\BigInteger(0);
foreach ($ints as $int) { foreach ($ints as $int) {
@ -30,8 +31,10 @@ trait Tools
$hash = (($hash * 20261) + 0x80000000 + $int) % 0x80000000; $hash = (($hash * 20261) + 0x80000000 + $int) % 0x80000000;
} }
} }
return $hash; return $hash;
} }
public function random($length) public function random($length)
{ {
return $length === 0 ? '' : \phpseclib\Crypt\Random::string($length); return $length === 0 ? '' : \phpseclib\Crypt\Random::string($length);

View File

@ -44,6 +44,7 @@ trait ApiStart
4) Click on create application'.PHP_EOL; 4) Click on create application'.PHP_EOL;
$app['api_id'] = readline('5) Enter your API ID: '); $app['api_id'] = readline('5) Enter your API ID: ');
$app['api_hash'] = readline('6) Enter your API hash: '); $app['api_hash'] = readline('6) Enter your API hash: ');
return $app; return $app;
} else { } else {
$this->my_telegram_org_wrapper = new \danog\MadelineProto\MyTelegramOrgWrapper(readline('Enter a phone number that is already registered on Telegram: ')); $this->my_telegram_org_wrapper = new \danog\MadelineProto\MyTelegramOrgWrapper(readline('Enter a phone number that is already registered on Telegram: '));
@ -53,6 +54,7 @@ trait ApiStart
} else { } else {
$app = $this->my_telegram_org_wrapper->get_app(); $app = $this->my_telegram_org_wrapper->get_app();
} }
return $app; return $app;
} }
} else { } else {
@ -62,16 +64,18 @@ trait ApiStart
$app['api_id'] = (int) $_POST['api_id']; $app['api_id'] = (int) $_POST['api_id'];
$app['api_hash'] = $_POST['api_hash']; $app['api_hash'] = $_POST['api_hash'];
$this->getting_api_id = false; $this->getting_api_id = false;
return $app; return $app;
} else if (isset($_POST['phone_number'])) { } elseif (isset($_POST['phone_number'])) {
$this->web_api_phone_login(); $this->web_api_phone_login();
} else { } else {
$this->web_api_echo(); $this->web_api_echo();
} }
} else if (!$this->my_telegram_org_wrapper->logged_in()) { } elseif (!$this->my_telegram_org_wrapper->logged_in()) {
if (isset($_POST['code'])) { if (isset($_POST['code'])) {
$app = $this->web_api_complete_login(); $app = $this->web_api_complete_login();
$this->getting_api_id = false; $this->getting_api_id = false;
return $app; return $app;
} else { } else {
$this->web_api_echo("You didn't provide a phone code!"); $this->web_api_echo("You didn't provide a phone code!");
@ -80,6 +84,7 @@ trait ApiStart
exit; exit;
} }
} }
public function web_api_phone_login() public function web_api_phone_login()
{ {
try { try {
@ -101,6 +106,7 @@ trait ApiStart
} else { } else {
$app = $this->my_telegram_org_wrapper->get_app(); $app = $this->my_telegram_org_wrapper->get_app();
} }
return $app; return $app;
} catch (\danog\MadelineProto\RPCErrorException $e) { } catch (\danog\MadelineProto\RPCErrorException $e) {
$this->web_api_echo('ERROR: '.$e->getMessage().'. Try again.'); $this->web_api_echo('ERROR: '.$e->getMessage().'. Try again.');

View File

@ -34,14 +34,17 @@ trait ApiTemplates
{ {
return sprintf($this->web_api_template, $form, $message); return sprintf($this->web_api_template, $form, $message);
} }
public function get_web_api_template() {
public function get_web_api_template()
{
return $this->web_template; return $this->web_template;
} }
public function set_web_api_template($template) {
public function set_web_api_template($template)
{
$this->web_template = $template; $this->web_template = $template;
} }
public function web_api_echo($message = '') public function web_api_echo($message = '')
{ {
if (!isset($this->my_telegram_org_wrapper)) { if (!isset($this->my_telegram_org_wrapper)) {
@ -58,5 +61,4 @@ trait ApiTemplates
echo $this->web_api_echo_template('Enter your code<br><b>'.$message.'</b>', '<input type="text" name="code" placeholder="Code" required/>'); echo $this->web_api_echo_template('Enter your code<br><b>'.$message.'</b>', '<input type="text" name="code" placeholder="Code" required/>');
} }
} }
} }

View File

@ -18,7 +18,8 @@ namespace danog\MadelineProto\Wrappers;
*/ */
trait Callback trait Callback
{ {
public function setCallback($callback) { public function setCallback($callback)
{
$this->settings['updates']['callback'] = $callback; $this->settings['updates']['callback'] = $callback;
$this->settings['updates']['handle_updates'] = true; $this->settings['updates']['handle_updates'] = true;
} }

View File

@ -21,13 +21,15 @@ trait Events
public $event_handler; public $event_handler;
private $event_handler_instance; private $event_handler_instance;
public function setEventHandler($event_handler) { public function setEventHandler($event_handler)
{
$this->event_handler = $event_handler; $this->event_handler = $event_handler;
$this->settings['updates']['callback'] = [$this, 'event_update_handler']; $this->settings['updates']['callback'] = [$this, 'event_update_handler'];
$this->settings['updates']['handle_updates'] = true; $this->settings['updates']['handle_updates'] = true;
} }
public function event_update_handler($update) { public function event_update_handler($update)
{
if (!class_exists($this->event_handler) || !is_subclass_of($this->event_handler, '\danog\MadelineProto\EventHandler')) { if (!class_exists($this->event_handler) || !is_subclass_of($this->event_handler, '\danog\MadelineProto\EventHandler')) {
throw new \danog\MadelineProto\Exception('Wrong event handler was defined'); throw new \danog\MadelineProto\Exception('Wrong event handler was defined');
} }
@ -38,7 +40,7 @@ trait Events
$method_name = 'on'.ucfirst($update['_']); $method_name = 'on'.ucfirst($update['_']);
if (method_exists($this->event_handler_instance, $method_name)) { if (method_exists($this->event_handler_instance, $method_name)) {
$this->event_handler_instance->$method_name($update); $this->event_handler_instance->$method_name($update);
} else if (method_exists($this->event_handler_instance, 'onAny')) { } elseif (method_exists($this->event_handler_instance, 'onAny')) {
$this->event_handler_instance->onAny($update); $this->event_handler_instance->onAny($update);
} }
} }

View File

@ -23,18 +23,18 @@ trait Loop
if (in_array($this->settings['updates']['callback'], [['danog\\MadelineProto\\API', 'get_updates_update_handler'], 'get_updates_update_handler'])) { if (in_array($this->settings['updates']['callback'], [['danog\\MadelineProto\\API', 'get_updates_update_handler'], 'get_updates_update_handler'])) {
return true; return true;
} }
if (php_sapi_name() !== "cli") { if (php_sapi_name() !== 'cli') {
try { try {
set_time_limit(-1); set_time_limit(-1);
} catch (\danog\MadelineProto\Exception $e) { } catch (\danog\MadelineProto\Exception $e) {
register_shutdown_function(function() { register_shutdown_function(function () {
\danog\MadelineProto\Logger::log(['Restarting script...']); \danog\MadelineProto\Logger::log(['Restarting script...']);
$a = fsockopen((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'tls' : 'tcp').'://'.$_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']); $a = fsockopen((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'tls' : 'tcp').'://'.$_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']);
fwrite($a, $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL']."\r\n"."Host: ".$_SERVER['SERVER_NAME']."\r\n\r\n"); fwrite($a, $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL']."\r\n".'Host: '.$_SERVER['SERVER_NAME']."\r\n\r\n");
}); });
} }
} }
\danog\MadelineProto\Logger::log("Started update loop", \danog\MadelineProto\Logger::NOTICE); \danog\MadelineProto\Logger::log('Started update loop', \danog\MadelineProto\Logger::NOTICE);
$offset = 0; $offset = 0;
if ($max_forks === -1) { if ($max_forks === -1) {
while (true) { while (true) {

View File

@ -88,7 +88,6 @@ trait Start
} }
} }
public function web_phone_login() public function web_phone_login()
{ {
try { try {
@ -148,5 +147,4 @@ trait Start
$this->web_echo('ERROR: '.$e->getMessage().'. Try again.'); $this->web_echo('ERROR: '.$e->getMessage().'. Try again.');
} }
} }
} }

View File

@ -43,6 +43,7 @@ trait Templates
break; break;
} }
} }
private $web_template = '<!DOCTYPE html> private $web_template = '<!DOCTYPE html>
<html> <html>
<head> <head>
@ -62,10 +63,14 @@ trait Templates
{ {
return sprintf($this->web_template, $form, $message); return sprintf($this->web_template, $form, $message);
} }
public function get_web_template() {
public function get_web_template()
{
return $this->web_template; return $this->web_template;
} }
public function set_web_template($template) {
public function set_web_template($template)
{
$this->web_template = $template; $this->web_template = $template;
} }
} }

View File

@ -18,8 +18,8 @@ namespace danog\MadelineProto\Wrappers;
*/ */
trait Webhook trait Webhook
{ {
public function setWebhook($hook_url, $pem_path = null)
public function setWebhook($hook_url, $pem_path = null) { {
$this->pem_path = $pem_path; $this->pem_path = $pem_path;
$this->hook_url = $hook_url; $this->hook_url = $hook_url;
$this->settings['updates']['callback'] = [$this, 'pwr_webhook']; $this->settings['updates']['callback'] = [$this, 'pwr_webhook'];

View File

@ -12,7 +12,7 @@ If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* Various ways to load MadelineProto * Various ways to load MadelineProto.
*/ */
if (!file_exists(__DIR__.'/../vendor/autoload.php')) { if (!file_exists(__DIR__.'/../vendor/autoload.php')) {
echo 'You did not run composer update, using madeline.php'.PHP_EOL; echo 'You did not run composer update, using madeline.php'.PHP_EOL;
@ -24,7 +24,7 @@ if (!file_exists(__DIR__.'/../vendor/autoload.php')) {
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
} }
/** /*
* Load .env for settings * Load .env for settings
*/ */
if (file_exists('.env')) { if (file_exists('.env')) {
@ -38,10 +38,11 @@ if (getenv('TEST_SECRET_CHAT') == '') {
echo 'Loading settings...'.PHP_EOL; echo 'Loading settings...'.PHP_EOL;
$settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: []; $settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: [];
/** /*
* Load MadelineProto * Load MadelineProto
*/ */
echo 'Loading MadelineProto...'.PHP_EOL; echo 'Loading MadelineProto...'.PHP_EOL;
try { try {
$MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings); $MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings);
} catch (\danog\MadelineProto\Exception $e) { } catch (\danog\MadelineProto\Exception $e) {
@ -50,11 +51,11 @@ try {
$MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings); $MadelineProto = new \danog\MadelineProto\API(getcwd().'/testing.madeline', $settings);
} }
/** /*
* If this session is not logged in, login * If this session is not logged in, login
*/ */
if ($MadelineProto->get_self() === false) { if ($MadelineProto->get_self() === false) {
/** /*
* If a BOT_TOKEN is defined in .env, use it to login, else prompt for login info * If a BOT_TOKEN is defined in .env, use it to login, else prompt for login info
*/ */
if (getenv('BOT_TOKEN') == '') { if (getenv('BOT_TOKEN') == '') {
@ -64,7 +65,7 @@ if ($MadelineProto->get_self() === false) {
} }
} }
/** /*
* Test logging * Test logging
*/ */
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ULTRA_VERBOSE); \danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
@ -75,11 +76,11 @@ if ($MadelineProto->get_self() === false) {
\danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::FATAL_ERROR); \danog\MadelineProto\Logger::log('hey', \danog\MadelineProto\Logger::FATAL_ERROR);
/** /**
* A small example message to use for tests * A small example message to use for tests.
*/ */
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION')); $message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
/** /*
* Try making a phone call * Try making a phone call
*/ */
if (stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) { if (stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) {
@ -93,7 +94,7 @@ if (stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) {
} }
} }
/** /*
* Try receiving a phone call * Try receiving a phone call
*/ */
if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !== false) { if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !== false) {
@ -115,17 +116,17 @@ if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !==
} }
} }
/** /*
* Secret chat usage * Secret chat usage
*/ */
if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) { if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) {
/** /**
* Request a secret chat * Request a secret chat.
*/ */
$secret_chat_id = $MadelineProto->API->request_secret_chat(getenv('TEST_SECRET_CHAT')); $secret_chat_id = $MadelineProto->API->request_secret_chat(getenv('TEST_SECRET_CHAT'));
echo 'Waiting for '.getenv('TEST_SECRET_CHAT').' (secret chat id '.$secret_chat_id.') to accept the secret chat...'.PHP_EOL; echo 'Waiting for '.getenv('TEST_SECRET_CHAT').' (secret chat id '.$secret_chat_id.') to accept the secret chat...'.PHP_EOL;
/** /*
* Wait until the other party accepts it * Wait until the other party accepts it
*/ */
while ($MadelineProto->secret_chat_status($secret_chat_id) !== 2) { while ($MadelineProto->secret_chat_status($secret_chat_id) !== 2) {
@ -133,68 +134,68 @@ if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y')
} }
/** /**
* Send a markdown-formatted text message with expiration after 10 seconds * Send a markdown-formatted text message with expiration after 10 seconds.
*/ */
$sentMessage = $MadelineProto->messages->sendEncrypted([ $sentMessage = $MadelineProto->messages->sendEncrypted([
'peer' => $secret_chat_id, 'peer' => $secret_chat_id,
'message' => [ 'message' => [
'_' => 'decryptedMessage', '_' => 'decryptedMessage',
'media' => ['_' => 'decryptedMessageMediaEmpty'], // No media 'media' => ['_' => 'decryptedMessageMediaEmpty'], // No media
'ttl' => 10, // This message self-destructs 10 seconds after reception 'ttl' => 10, // This message self-destructs 10 seconds after reception
'message' => '```'.$message.'```', // Code Markdown 'message' => '```'.$message.'```', // Code Markdown
'parse_mode' => 'Markdown' 'parse_mode' => 'Markdown',
] ],
]); ]);
\danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE); \danog\MadelineProto\Logger::log($sentMessage, \danog\MadelineProto\Logger::NOTICE);
/** /**
* Send secret media * Send secret media.
*/ */
$secret_media = []; $secret_media = [];
// Photo uploaded as document, secret chat // Photo uploaded as document, secret chat
$secret_media['document_photo'] = [ $secret_media['document_photo'] = [
'peer' => $secret_chat_id, 'peer' => $secret_chat_id,
'file' => 'tests/faust.jpg', // The file to send 'file' => 'tests/faust.jpg', // The file to send
'message' => [ 'message' => [
'_' => 'decryptedMessage', '_' => 'decryptedMessage',
'ttl' => 0, // This message does not self-destruct 'ttl' => 0, // This message does not self-destruct
'message' => '', // No text message, only media 'message' => '', // No text message, only media
'media' => [ 'media' => [
'_' => 'decryptedMessageMediaDocument', '_' => 'decryptedMessageMediaDocument',
'thumb' => file_get_contents('tests/faust.preview.jpg'), // The thumbnail must be generated manually, it must be in jpg format, 90x90 'thumb' => file_get_contents('tests/faust.preview.jpg'), // The thumbnail must be generated manually, it must be in jpg format, 90x90
'thumb_w' => 90, 'thumb_w' => 90,
'thumb_h' => 90, 'thumb_h' => 90,
'mime_type' => mime_content_type('tests/faust.jpg'), // The file's mime type 'mime_type' => mime_content_type('tests/faust.jpg'), // The file's mime type
'caption' => 'This file was uploaded using @MadelineProto', // The caption 'caption' => 'This file was uploaded using @MadelineProto', // The caption
'file_name' => 'faust.jpg', // The file's name 'file_name' => 'faust.jpg', // The file's name
'size' => filesize('tests/faust.jpg'), // The file's size 'size' => filesize('tests/faust.jpg'), // The file's size
'attributes' => [ 'attributes' => [
['_' => 'documentAttributeImageSize', 'w' => 1280, 'h' => 914] // Image's resolution ['_' => 'documentAttributeImageSize', 'w' => 1280, 'h' => 914], // Image's resolution
] ],
] ],
] ],
]; ];
// Photo, secret chat // Photo, secret chat
$secret_media['photo'] = [ $secret_media['photo'] = [
'peer' => $secret_chat_id, 'peer' => $secret_chat_id,
'file' => 'tests/faust.jpg', 'file' => 'tests/faust.jpg',
'message' => [ 'message' => [
'_' => 'decryptedMessage', '_' => 'decryptedMessage',
'ttl' => 0, 'ttl' => 0,
'message' => '', 'message' => '',
'media' => [ 'media' => [
'_' => 'decryptedMessageMediaPhoto', '_' => 'decryptedMessageMediaPhoto',
'thumb' => file_get_contents('tests/faust.preview.jpg'), 'thumb' => file_get_contents('tests/faust.preview.jpg'),
'thumb_w' => 90, 'thumb_w' => 90,
'thumb_h' => 90, 'thumb_h' => 90,
'caption' => 'This file was uploaded using @MadelineProto', 'caption' => 'This file was uploaded using @MadelineProto',
'size' => filesize('tests/faust.jpg'), 'size' => filesize('tests/faust.jpg'),
'w' => 1280, 'w' => 1280,
'h' => 914 'h' => 914,
] ],
] ],
]; ];
// GIF, secret chat // GIF, secret chat

View File

@ -52,11 +52,11 @@ foreach (\danog\MadelineProto\Lang::$current_lang as $key => $value) {
$param_type = isset($matches[2]) ? $matches[2] : ''; $param_type = isset($matches[2]) ? $matches[2] : '';
if ($param_name === 'nonce' && $param_type === 'int128') { if ($param_name === 'nonce' && $param_type === 'int128') {
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = 'Random number for cryptographic security'; \danog\MadelineProto\Lang::$lang[$lang_code][$key] = 'Random number for cryptographic security';
} else if ($param_name === 'server_nonce' && $param_type === 'int128') { } elseif ($param_name === 'server_nonce' && $param_type === 'int128') {
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = 'Random number for cryptographic security, given by server'; \danog\MadelineProto\Lang::$lang[$lang_code][$key] = 'Random number for cryptographic security, given by server';
} else if ($param_name === 'random_id' && $param_type === 'long') { } elseif ($param_name === 'random_id' && $param_type === 'long') {
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = 'Random number for cryptographic security'; \danog\MadelineProto\Lang::$lang[$lang_code][$key] = 'Random number for cryptographic security';
} else if (isset(\danog\MadelineProto\MTProto::DISALLOWED_METHODS[$method_name])) { } elseif (isset(\danog\MadelineProto\MTProto::DISALLOWED_METHODS[$method_name])) {
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = \danog\MadelineProto\MTProto::DISALLOWED_METHODS[$method_name]; \danog\MadelineProto\Lang::$lang[$lang_code][$key] = \danog\MadelineProto\MTProto::DISALLOWED_METHODS[$method_name];
} else { } else {
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = readline($value.' => '); \danog\MadelineProto\Lang::$lang[$lang_code][$key] = readline($value.' => ');