Localization (#195)

* Added localization

* Translate shiz

* Apply fixes from StyleCI

* Localized MadelineProto in italian, wrote translation script

* Apply fixes from StyleCI

* fixes

* Fixes

* Apply fixes from StyleCI

* Just in case

* Apply fixes from StyleCI
This commit is contained in:
Daniil Gentili 2017-10-01 18:37:24 +02:00 committed by GitHub
parent d47160d839
commit a0b1395229
69 changed files with 747 additions and 183 deletions

3
.babelrc Normal file
View File

@ -0,0 +1,3 @@
{
"presets": ["php"]
}

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -24,6 +24,7 @@ description: invokeWithLayer parameters, return type and example
| Error | Description |
|----------|---------------|
|AUTH_BYTES_INVALID|The provided authorization is invalid|
|CDN_METHOD_INVALID|You can't call this method in a CDN DC|
|CONNECTION_API_ID_INVALID|The provided API id is invalid|
|INPUT_LAYER_INVALID|The provided layer is invalid|

View File

@ -25,6 +25,7 @@ description: messages.forwardMessage parameters, return type and example
|----------|---------------|
|MESSAGE_ID_INVALID|The provided message id is invalid|
|PEER_ID_INVALID|The provided peer id is invalid|
|YOU_BLOCKED_USER|You blocked this user|
### Example:

View File

@ -22,7 +22,7 @@ class API extends APIFactory
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
$this->API = new MTProto($params);
\danog\MadelineProto\Logger::log(['Running APIFactory...'], Logger::VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['apifactory_start']], Logger::VERBOSE);
$this->APIFactory();
\danog\MadelineProto\Logger::log(['Ping...'], Logger::ULTRA_VERBOSE);
@ -30,7 +30,7 @@ class API extends APIFactory
\danog\MadelineProto\Logger::log(['Pong: '.$pong['ping_id']], Logger::ULTRA_VERBOSE);
//\danog\MadelineProto\Logger::log(['Getting future salts...'], Logger::ULTRA_VERBOSE);
//$this->future_salts = $this->get_future_salts(['num' => 3]);
\danog\MadelineProto\Logger::log(['MadelineProto is ready!'], Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['madelineproto_ready']], Logger::NOTICE);
}
public function __wakeup()
@ -95,7 +95,7 @@ class API extends APIFactory
public function serialize($filename)
{
Logger::log(['Serializing MadelineProto...']);
Logger::log([\danog\MadelineProto\Lang::$current_lang['serializing_madelineproto']]);
return Serialization::serialize($filename, $this);
}

View File

@ -75,7 +75,7 @@ class Connection
$this->extra = $extra;
if (($has_proxy = $proxy !== '\Socket') && !isset(class_implements($proxy)['\danog\MadelineProto\Proxy'])) {
throw new \danog\MadelineProto\Exception('Invalid proxy class provided!');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['proxy_class_invalid']);
}
switch ($this->protocol) {
case 'tcp_abridged':
@ -89,7 +89,7 @@ class Connection
}
$this->sock->setBlocking(true);
if (!$this->sock->connect($ip, $port)) {
throw new Exception("Connection: couldn't connect to socket.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['socket_con_error']);
}
$this->write(chr(239));
break;
@ -101,7 +101,7 @@ class Connection
$this->sock->setOption(\SOL_SOCKET, \SO_RCVTIMEO, $timeout);
$this->sock->setOption(\SOL_SOCKET, \SO_SNDTIMEO, $timeout);
if (!$this->sock->connect($ip, $port)) {
throw new Exception("Connection: couldn't connect to socket.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['socket_con_error']);
}
if (!\danog\MadelineProto\Logger::$has_thread) {
$this->sock->setOption(\SOL_SOCKET, \SO_RCVTIMEO, $timeout);
@ -117,7 +117,7 @@ class Connection
$this->sock->setExtra($this->extra);
}
if (!$this->sock->connect($ip, $port)) {
throw new Exception("Connection: couldn't connect to socket.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['socket_con_error']);
}
if (!\danog\MadelineProto\Logger::$has_thread) {
$this->sock->setOption(\SOL_SOCKET, \SO_RCVTIMEO, $timeout);
@ -134,7 +134,7 @@ class Connection
$this->sock->setExtra($this->extra);
}
if (!$this->sock->connect($ip, $port)) {
throw new Exception("Connection: couldn't connect to socket.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['socket_con_error']);
}
if (!\danog\MadelineProto\Logger::$has_thread) {
$this->sock->setOption(\SOL_SOCKET, \SO_RCVTIMEO, $timeout);
@ -180,7 +180,7 @@ class Connection
$this->sock->setExtra($this->extra);
}
if (!$this->sock->connect($this->parsed['host'], $port)) {
throw new Exception("Connection: couldn't connect to socket.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['socket_con_error']);
}
if (!\danog\MadelineProto\Logger::$has_thread) {
$this->sock->setOption(\SOL_SOCKET, \SO_RCVTIMEO, $timeout);
@ -189,9 +189,9 @@ class Connection
$this->sock->setBlocking(true);
break;
case 'udp':
throw new Exception("Connection: This protocol isn't implemented yet.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
default:
throw new Exception('Connection: invalid protocol specified.');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_invalid']);
break;
}
}
@ -214,9 +214,9 @@ class Connection
}
break;
case 'udp':
throw new Exception("Connection: This protocol wasn't implemented yet.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
default:
throw new Exception('Connection: invalid protocol specified.');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_invalid']);
break;
}
}
@ -269,10 +269,10 @@ class Connection
return $wrote;
break;
case 'udp':
throw new Exception("Connection: This protocol wasn't implemented yet.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
break;
default:
throw new Exception('Connection: invalid protocol specified.');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_invalid']);
break;
}
}
@ -285,13 +285,13 @@ class Connection
while (strlen($packet) < $length) {
$packet .= $this->sock->read($length - strlen($packet));
if ($packet === false || strlen($packet) === 0) {
throw new \danog\MadelineProto\NothingInTheSocketException('Nothing in the socket!');
throw new \danog\MadelineProto\NothingInTheSocketException(\danog\MadelineProto\Lang::$current_lang['nothing_in_socket']);
}
}
if (strlen($packet) !== $length) {
$this->close_and_reopen();
throw new Exception("WARNING: Wrong length was read (should've read ".($length).', read '.strlen($packet).')!');
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['wrong_length_read'], $length, strlen($packet)));
}
return $this->obfuscated['decryption']->encrypt($packet);
@ -305,20 +305,20 @@ class Connection
while (strlen($packet) < $length) {
$packet .= $this->sock->read($length - strlen($packet));
if ($packet === false || strlen($packet) === 0) {
throw new \danog\MadelineProto\NothingInTheSocketException('Nothing in the socket!');
throw new \danog\MadelineProto\NothingInTheSocketException(\danog\MadelineProto\Lang::$current_lang['nothing_in_socket']);
}
}
if (strlen($packet) !== $length) {
$this->close_and_reopen();
throw new Exception("WARNING: Wrong length was read (should've read ".($length).', read '.strlen($packet).')!');
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['wrong_length_read'], $length, strlen($packet)));
}
return $packet;
case 'udp':
throw new Exception("Connection: This protocol wasn't implemented yet.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
default:
throw new Exception('Connection: invalid protocol specified.');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_invalid']);
break;
}
}
@ -364,7 +364,7 @@ class Connection
break;
}
if ($current_header === false) {
throw new Exception('No data in the socket!');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['no_data_in_socket']);
}
if (preg_match('|^Content-Length: |i', $current_header)) {
$length = (int) preg_replace('|Content-Length: |i', '', $current_header);
@ -384,7 +384,7 @@ class Connection
return $read;
case 'udp':
throw new Exception("Connection: This protocol wasn't implemented yet.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
}
}
@ -416,7 +416,7 @@ class Connection
break;
case 'udp':
throw new Exception("Connection: This protocol wasn't implemented yet.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
default:
break;
}

View File

@ -46,7 +46,7 @@ class DataCenter
$this->settings = $settings;
foreach ($this->sockets as $key => $socket) {
if ($socket instanceof Connection) {
\danog\MadelineProto\Logger::log(['Connecting to DC '.$key.'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_start'], $key)], \danog\MadelineProto\Logger::VERBOSE);
$socket->old = true;
$socket->close_and_reopen();
} else {
@ -61,7 +61,7 @@ class DataCenter
$this->curdc = 0;
}
if (isset($this->sockets[$dc_number])) {
\danog\MadelineProto\Logger::log(['Disconnecting from DC '.$dc_number.'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_stop'], $dc_number)], \danog\MadelineProto\Logger::VERBOSE);
unset($this->sockets[$dc_number]);
}
}
@ -88,7 +88,7 @@ class DataCenter
$address = $this->settings[$dc_config_number]['protocol'].'://'.$address.'/api';
$port = 80;
}
\danog\MadelineProto\Logger::log(['Connecting to DC '.$dc_number.' ('.$test.' server, '.$ipv6.', '.$this->settings[$dc_config_number]['protocol'].')...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_test_start'], $dc_number, $test, $ipv6, $this->settings[$dc_config_number]['protocol'])], \danog\MadelineProto\Logger::VERBOSE);
if (isset($this->sockets[$dc_number]->old)) {
$this->sockets[$dc_number]->__construct($this->settings[$dc_config_number]['proxy'], $this->settings[$dc_config_number]['proxy_extra'], $address, $port, $this->settings[$dc_config_number]['protocol'], $this->settings[$dc_config_number]['timeout'], $this->settings[$dc_config_number]['ipv6']);

View File

@ -0,0 +1,444 @@
<?php
/*
Copyright 2016-2017 Daniil Gentili
(https://daniil.it)
This file is part of MadelineProto.
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with MadelineProto.
If not, see <http://www.gnu.org/licenses/>.
*/
namespace danog\MadelineProto;
class Lang
{
public static $lang = [
'it' => [
'phpseclib_fork' => 'Per favore installa questo fork di phpseclib: https://github.com/danog/phpseclib',
'inst_dc' => 'Istanziamento dei DataCenter...',
'load_rsa' => 'Caricamento delle chiavi RSA...',
'TL_translation' => 'Translazione degli schemi TL...',
'dh_prime_check_0' => 'Esecuzione dei check dh_prime (0/3)...',
'nearest_dc' => 'Siamo in %s, il DC corrente è %d, il DC più vicino è %d.',
'serialization_ofd' => 'La serializzazione non è aggiornata, reistanziamento dell\'oggetto in corso!',
'getupdates_deserialization' => 'Ottenimento aggiornamenti dopo deserializzazione...',
'shutdown_reader_pool' => 'Chiusura pool di lettura, %d thread rimasti',
'threading_on' => 'IL THREADING È ABILITATO',
'socket_reader' => 'Lettore socket su DC %s: ',
'socket_status_1' => 'CREAZIONE',
'socket_status_2' => 'INVIO',
'socket_status_3' => 'ATTESA',
'socket_status_4' => 'PRONTO',
'socket_status_5' => 'AVVIATO',
'api_not_set' => 'Devi specificare una chiave ed un ID API, ottienili su https://my.telegram.org',
'session_corrupted' => 'La sessione si è corrotta!',
'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_temp_auth_key' => 'Generando chiave di autorizzazione temporanea per il 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)...',
'config_updated' => 'La configurazione è stata aggiornata!',
'length_not_4' => 'La lunghezza non è uguale a 4',
'length_not_8' => 'La lunghezza non è uguale a 8',
'value_bigger_than_2147483647' => 'Il valore fornito (%s) è maggiore di 2147483647',
'value_smaller_than_2147483648' => 'Il valore fornito (%s) è minore di -2147483648',
'value_bigger_than_9223372036854775807' => 'Il valore fornito (%s) è maggiore di 9223372036854775807',
'value_smaller_than_9223372036854775808' => 'Il valore fornito (%s) è minore di -9223372036854775808',
'value_bigger_than_4294967296' => 'Il valore fornito (%s) è maggiore di 4294967296',
'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',
'file_not_exist' => 'Il file specificato non esiste',
'deserialization_error' => 'C\'è stato un errore durante la deserializzazione',
'rsa_init' => 'Istanziamento di \\phpseclib\\Crypt\\RSA in corso...',
'loading_key' => 'Caricamento della chiave in corso...',
'computing_fingerprint' => 'Calcolo del fingerprint in corso...',
'rsa_encrypting' => 'Criptando con chiave RSA...',
'rpc_tg_error' => 'Telegram ha ritornato un errore RPC: %s (%s), causato da %s:%sTL trace:',
'v_error' => '506572206661766f726520616767696f726e612071756573746120696e7374616c6c617a696f6e65206469204d6164656c696e6550726f746f20636f6e206769742070756c6c206520636f6d706f73657220757064617465',
'v_tgerror' => '506572206661766f726520616767696f726e61207068702d6c69627467766f6970',
'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.',
'proxy_class_invalid' => 'È stata specificata una classe proxy errata!',
'socket_con_error' => 'Connessione fallita.',
'protocol_not_implemented' => 'Questo protocollo non è stato ancora implementato.',
'protocol_invalid' => 'È stato fornito un protocollo non valido',
'nothing_in_socket' => 'Non c\'è niente nel socket!',
'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!',
'dc_con_start' => 'Connessione al 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)...',
'script_not_exist' => 'Lo script fornito non esiste',
'apifactory_start' => 'Sto avviando la fabbrica di API...',
'madelineproto_ready' => 'MadelineProto è pronto!',
'logout_error' => 'C\'è stato un errore durante il logout!',
'logout_ok' => 'Il logout è stato eseguito correttamente!',
'already_logged_in' => 'Questa istanza di MadelineProto è già loggata, prima faccio il logout...',
'login_ok' => 'Il login è stato eseguito correttamente!',
'login_user' => 'Sto eseguendo il login come utente normale...',
'login_bot' => 'Sto eseguendo il login come bot...',
'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_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_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...',
'not_logged_in' => 'Non ho ancora fatto il login!',
'signup_uncalled' => 'Chiama prima le funzioni phone_login e complete_phone_login.',
'signing_up' => 'Mi sto registrando su telegram come utente normale...',
'signup_ok' => 'Mi sono registrato su Telegram!',
'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...',
'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',
'calling_user' => 'Sto chiamando %s...',
'generating_a' => 'Sto generando a...',
'generating_g_a' => 'Sto generando g_a...',
'call_error_1' => 'Impossibile trovare ed accettare la chiamata %s',
'accepting_call' => 'Sto accettando una chiamata da %s...',
'generating_b' => 'Sto generando b...',
'call_already_accepted' => 'La chiamata %s è già stata accettata.',
'call_already_declined' => 'La chiamata %s è già stata annullata.',
'call_error_2' => 'Impossibile trovare e confermare la chiamata %s',
'call_confirming' => 'Sto confermando una chiamata da %s',
'call_error_3' => 'Impossibile trovare e completare la chiamata %s',
'call_completing' => 'Sto completando una chiamata da %s...',
'invalid_g_a' => 'g_a non valido!',
'fingerprint_invalid' => 'fingerprint della chiave non valido!',
'call_discarding' => 'Sto rifiutando la chiamata %s...',
'call_set_rating' => 'Sto inviando la recensione della chiamata %s...',
'call_debug_saving' => 'Sto inviando i dati di debug della chiamata %s...',
'TL_loading' => 'Sto caricando gli schemi TL...',
'file_parsing' => 'Leggendo %s...',
'crc32_mismatch' => 'CRC32 non valido (%s diverso da %s) per %s',
'src_file_invalid' => 'È stato fornito un file sorgente non valido: ',
'translating_obj' => 'Traducendo gli oggetti...',
'translating_methods' => 'Traducendo i metodi...',
'bool_error' => 'Non sono riuscito ad estrarre un booleano',
'not_numeric' => 'Il valore fornito non è numerico',
'long_not_16' => 'Il valore fornito non è lungo 16 byte',
'long_not_32' => 'Il valore fornito non è lungo 32 byte',
'long_not_64' => 'Il valore fornito non è lungo 64 byte',
'array_invalid' => 'Il valore fornito non è un array',
'predicate_not_set' => 'Il predicato (valore sotto chiave _, esempio [\'_\' => \'inputPeer\']) non è impostato!',
'type_extract_error' => 'Impossibile estrarre il tipo "%s"',
'method_not_found' => 'Impossibile trovare il seguente metodo: ',
'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',
'stream_handle_invalid' => 'Il valore fornito non è uno stream',
'length_too_big' => 'Il valore fornito è troppo lungo',
'deserialize_not_str' => 'Il valore generato non è una stringa',
'type_extract_error_id' => 'Non sono riuscito ad estrarre il tipo %s con ID %s',
'vector_invalid' => 'ID vettore non valido: ',
'constructor_not_found' => 'Costruttore non trovato per tipo: ',
'rand_bytes_too_small' => 'random_bytes è troppo corto!',
'botapi_conversion_error' => 'NOn sono risucito a convertire %s in un oggetto bot API',
'non_text_conversion' => 'Non posso ancora convertire messaggi media',
'last_byte_invalid' => 'L\'ultimo byte non è valido',
'file_type_invalid' => 'È stato fornito un tipo file errato',
'recreate_temp_auth_key' => 'Sono stato costretto a rigenerare la chiave di autorizzazione temporanea',
'resetting_auth_key' => 'ATTENZIONE: Sto resettando la chiave temporanea...',
'shutting_down_reader_pool' => 'Chisura pool di lettura',
'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',
'fingerprint_mismatch' => 'Fingerprint della chiave non valido',
'msg_data_length_too_big' => 'message_data_length è troppo grande',
'length_not_divisible_16' => 'La lunghezza dei dati decifrati non è divisibile per 16',
'msg_key_mismatch' => 'msg_key non valido',
'rand_bytes_too_short' => 'random_bytes è troppo corto!',
'resending_unsupported' => 'IL riinvio di messaggi non è ancora supportato',
'unrecognized_dec_msg' => 'È stato ricevuto un messaggio decifrato sconosciuto: ',
'serializing_madelineproto' => 'Sto serializzando MadelineProto...',
'req_pq' => 'Sto richiedendo p_q...',
'done' => 'Fatto!',
'cdn_reupload' => 'Il file non è disponibile sul nostro CDN, richiedo la copia!',
'stored_on_cdn' => 'Il file è scaricabile tramite CDN!',
],
'en' => [
'req_pq' => 'Requesting p_q...',
'done' => 'Done!',
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
'stored_on_cdn' => 'File is stored on CDN!',
'serializing_madelineproto' => 'Serializing MadelineProto...',
'phpseclib_fork' => 'Please install this fork of phpseclib: https://github.com/danog/phpseclib',
'inst_dc' => 'Istantiating DataCenter...',
'load_rsa' => 'Loading RSA keys...',
'TL_translation' => 'Translating TL schemas...',
'dh_prime_check_0' => 'Executing dh_prime checks (0/3)...',
'nearest_dc' => 'We\'re in %s, current DC is %d, nearest DC is %d.',
'serialization_ofd' => 'Serialization is out of date, reconstructing object!',
'getupdates_deserialization' => 'Getting updates after deserialization...',
'shutdown_reader_pool' => 'Shutting down reader pool, %d jobs left',
'threading_on' => 'THREADING IS ENABLED',
'socket_reader' => 'Socket reader on DC %s: ',
'socket_status_1' => 'CREATING',
'socket_status_2' => 'SUBMITTING',
'socket_status_3' => 'WAITING',
'socket_status_4' => 'READY',
'socket_status_5' => 'WORKING',
'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!',
'reset_session_seqno' => 'Resetting session id and seq_no in DC %s...',
'gen_perm_auth_key' => 'Generating permanent 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...',
'write_client_info' => 'Writing client info (also executing %s)...',
'config_updated' => 'Updated config!',
'length_not_4' => 'Length is not equal to 4',
'length_not_8' => 'Length is not equal to 8',
'value_bigger_than_2147483647' => 'Provided value %s is bigger than 2147483647',
'value_smaller_than_2147483648' => 'Provided value %s is smaller than -2147483648',
'value_bigger_than_9223372036854775807' => 'Provided value %s is bigger than 9223372036854775807',
'value_smaller_than_9223372036854775808' => 'Provided value %s is smaller than -9223372036854775808',
'value_bigger_than_4294967296' => 'Provided value %s is bigger than 4294967296',
'value_smaller_than_0' => 'Provided value %s is smaller than 0',
'encode_double_error' => 'Could not properly encode double',
'file_not_exist' => 'File does not exist',
'deserialization_error' => 'An error occurred on deserialization',
'rsa_init' => 'Istantiating \\phpseclib\\Crypt\\RSA...',
'loading_key' => 'Loading key...',
'computing_fingerprint' => 'Computing fingerprint...',
'rsa_encrypting' => 'Encrypting with rsa key...',
'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:',
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
'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.',
'proxy_class_invalid' => 'Invalid proxy class provided!',
'socket_con_error' => 'Connection: couldn\'t connect to socket.',
'protocol_not_implemented' => 'Connection: This protocol isn\'t implemented yet.',
'protocol_invalid' => 'Connection: invalid protocol specified.',
'nothing_in_socket' => 'Nothing in the socket!',
'wrong_length_read' => 'WARNING: Wrong length was read (should\'ve read %s, read %s)!',
'no_data_in_socket' => 'No data in the socket!',
'dc_con_start' => 'Connecting to DC %s...',
'dc_con_stop' => 'Disconnecting from DC %s...',
'dc_con_test_start' => 'Connecting to DC %s (%s server, %s, %s)...',
'script_not_exist' => 'Provided script does not exist',
'apifactory_start' => 'Running APIFactory...',
'madelineproto_ready' => 'MadelineProto is ready!',
'logout_error' => 'An error occurred while logging out!',
'logout_ok' => 'Logged out successfully!',
'already_logged_in' => 'This instance of MadelineProto is already logged in. Logging out first...',
'login_ok' => 'Logged in successfully!',
'login_user' => 'Logging in as a normal user...',
'login_bot' => 'Logging in as a bot...',
'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_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_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...',
'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!',
'signing_up' => 'Signing up as a normal user...',
'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!',
'getting_dialogs' => 'Getting dialogs...',
'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',
'calling_user' => 'Calling %s...',
'generating_a' => 'Generating a...',
'generating_g_a' => 'Generating g_a...',
'call_error_1' => 'Could not find and accept call %s',
'accepting_call' => 'Accepting call from %s...',
'generating_b' => 'Generating b...',
'call_already_accepted' => 'Call %s already accepted',
'call_already_declined' => 'Call %s already declined',
'call_error_2' => 'Could not find and confirm call %s',
'call_confirming' => 'Confirming call from %s...',
'call_error_3' => 'Could not find and complete call %s',
'call_completing' => 'Completing call from %s...',
'invalid_g_a' => 'Invalid g_a!',
'fingerprint_invalid' => 'Invalid key fingerprint!',
'call_discarding' => 'Discarding call %s...',
'call_set_rating' => 'Setting rating for call %s...',
'call_debug_saving' => 'Saving debug data for call %s...',
'TL_loading' => 'Loading TL schemes...',
'file_parsing' => 'Parsing %s...',
'crc32_mismatch' => 'CRC32 mismatch (%s, %s) for %s',
'src_file_invalid' => 'Invalid source file was provided: ',
'translating_obj' => 'Translating objects...',
'translating_methods' => 'Translating methods...',
'bool_error' => 'Could not extract boolean',
'not_numeric' => 'Given value isn\'t numeric',
'long_not_16' => 'Given value is not 16 bytes long',
'long_not_32' => 'Given value is not 32 bytes long',
'long_not_64' => 'Given value is not 64 bytes long',
'array_invalid' => 'You didn\'t provide a valid array',
'predicate_not_set' => 'Predicate (value under _) was not set!',
'type_extract_error' => 'Could not extract type "%s"',
'method_not_found' => 'Could not find method: ',
'params_missing' => 'Missing required parameter',
'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.',
'length_too_big' => 'Length is too big',
'deserialize_not_str' => 'Deserialize: Generated value isn\'t a string',
'type_extract_error_id' => 'Could not extract type: %s with id %s',
'vector_invalid' => 'Invalid vector constructor: ',
'constructor_not_found' => 'Constructor not found for type: ',
'rand_bytes_too_small' => 'random_bytes is too small!',
'botapi_conversion_error' => 'Can\'t convert %s to a bot API object',
'non_text_conversion' => 'Can\'t convert non text messages yet!',
'last_byte_invalid' => 'Invalid last byte',
'file_type_invalid' => 'Invalid file type detected (%s)',
'recreate_temp_auth_key' => 'I had to recreate the temporary authorization key',
'resetting_auth_key' => 'WARNING: Resetting auth key...',
'shutting_down_reader_pool' => 'Shutting down reader pool ',
'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...',
'fingerprint_mismatch' => 'Key fingerprint mismatch',
'msg_data_length_too_big' => 'message_data_length is too big',
'length_not_divisible_16' => 'Length of decrypted data is not divisible by 16',
'msg_key_mismatch' => 'msg_key mismatch',
'rand_bytes_too_short' => 'random_bytes is too short!',
'resending_unsupported' => 'Resending of messages is not yet supported',
'unrecognized_dec_msg' => 'Unrecognized decrypted message received: ',
],
];
// THIS WILL BE OVERWRITTEN BY $lang["en"]
public static $current_lang = [
'req_pq' => 'Requesting p_q...',
'done' => 'Done!',
'cdn_reupload' => 'File is not stored on CDN, requesting reupload!',
'stored_on_cdn' => 'File is stored on CDN!',
'serializing_madelineproto' => 'Serializing MadelineProto...',
'phpseclib_fork' => 'Please install this fork of phpseclib: https://github.com/danog/phpseclib',
'inst_dc' => 'Istantiating DataCenter...',
'load_rsa' => 'Loading RSA keys...',
'TL_translation' => 'Translating TL schemas...',
'dh_prime_check_0' => 'Executing dh_prime checks (0/3)...',
'nearest_dc' => 'We\'re in %s, current DC is %d, nearest DC is %d.',
'serialization_ofd' => 'Serialization is out of date, reconstructing object!',
'getupdates_deserialization' => 'Getting updates after deserialization...',
'shutdown_reader_pool' => 'Shutting down reader pool, %d jobs left',
'threading_on' => 'THREADING IS ENABLED',
'socket_reader' => 'Socket reader on DC %s: ',
'socket_status_1' => 'CREATING',
'socket_status_2' => 'SUBMITTING',
'socket_status_3' => 'WAITING',
'socket_status_4' => 'READY',
'socket_status_5' => 'WORKING',
'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!',
'reset_session_seqno' => 'Resetting session id and seq_no in DC %s...',
'gen_perm_auth_key' => 'Generating permanent 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...',
'write_client_info' => 'Writing client info (also executing %s)...',
'config_updated' => 'Updated config!',
'length_not_4' => 'Length is not equal to 4',
'length_not_8' => 'Length is not equal to 8',
'value_bigger_than_2147483647' => 'Provided value %s is bigger than 2147483647',
'value_smaller_than_2147483648' => 'Provided value %s is smaller than -2147483648',
'value_bigger_than_9223372036854775807' => 'Provided value %s is bigger than 9223372036854775807',
'value_smaller_than_9223372036854775808' => 'Provided value %s is smaller than -9223372036854775808',
'value_bigger_than_4294967296' => 'Provided value %s is bigger than 4294967296',
'value_smaller_than_0' => 'Provided value %s is smaller than 0',
'encode_double_error' => 'Could not properly encode double',
'file_not_exist' => 'File does not exist',
'deserialization_error' => 'An error occurred on deserialization',
'rsa_init' => 'Istantiating \\phpseclib\\Crypt\\RSA...',
'loading_key' => 'Loading key...',
'computing_fingerprint' => 'Computing fingerprint...',
'rsa_encrypting' => 'Encrypting with rsa key...',
'rpc_tg_error' => 'Telegram returned an RPC error: %s (%s), caused by %s:%sTL trace:',
'v_error' => '506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e',
'v_tgerror' => '506c6561736520757064617465207068702d6c69627467766f6970',
'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.',
'proxy_class_invalid' => 'Invalid proxy class provided!',
'socket_con_error' => 'Connection: couldn\'t connect to socket.',
'protocol_not_implemented' => 'Connection: This protocol isn\'t implemented yet.',
'protocol_invalid' => 'Connection: invalid protocol specified.',
'nothing_in_socket' => 'Nothing in the socket!',
'wrong_length_read' => 'WARNING: Wrong length was read (should\'ve read %s, read %s)!',
'no_data_in_socket' => 'No data in the socket!',
'dc_con_start' => 'Connecting to DC %s...',
'dc_con_stop' => 'Disconnecting from DC %s...',
'dc_con_test_start' => 'Connecting to DC %s (%s server, %s, %s)...',
'script_not_exist' => 'Provided script does not exist',
'apifactory_start' => 'Running APIFactory...',
'madelineproto_ready' => 'MadelineProto is ready!',
'logout_error' => 'An error occurred while logging out!',
'logout_ok' => 'Logged out successfully!',
'already_logged_in' => 'This instance of MadelineProto is already logged in. Logging out first...',
'login_ok' => 'Logged in successfully!',
'login_user' => 'Logging in as a normal user...',
'login_bot' => 'Logging in as a bot...',
'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_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_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...',
'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!',
'signing_up' => 'Signing up as a normal user...',
'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!',
'getting_dialogs' => 'Getting dialogs...',
'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',
'calling_user' => 'Calling %s...',
'generating_a' => 'Generating a...',
'generating_g_a' => 'Generating g_a...',
'call_error_1' => 'Could not find and accept call %s',
'accepting_call' => 'Accepting call from %s...',
'generating_b' => 'Generating b...',
'call_already_accepted' => 'Call %s already accepted',
'call_already_declined' => 'Call %s already declined',
'call_error_2' => 'Could not find and confirm call %s',
'call_confirming' => 'Confirming call from %s...',
'call_error_3' => 'Could not find and complete call %s',
'call_completing' => 'Completing call from %s...',
'invalid_g_a' => 'Invalid g_a!',
'fingerprint_invalid' => 'Invalid key fingerprint!',
'call_discarding' => 'Discarding call %s...',
'call_set_rating' => 'Setting rating for call %s...',
'call_debug_saving' => 'Saving debug data for call %s...',
'TL_loading' => 'Loading TL schemes...',
'file_parsing' => 'Parsing %s...',
'crc32_mismatch' => 'CRC32 mismatch (%s, %s) for %s',
'src_file_invalid' => 'Invalid source file was provided: ',
'translating_obj' => 'Translating objects...',
'translating_methods' => 'Translating methods...',
'bool_error' => 'Could not extract boolean',
'not_numeric' => 'Given value isn\'t numeric',
'long_not_16' => 'Given value is not 16 bytes long',
'long_not_32' => 'Given value is not 32 bytes long',
'long_not_64' => 'Given value is not 64 bytes long',
'array_invalid' => 'You didn\'t provide a valid array',
'predicate_not_set' => 'Predicate (value under _) was not set!',
'type_extract_error' => 'Could not extract type "%s"',
'method_not_found' => 'Could not find method: ',
'params_missing' => 'Missing required parameter',
'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.',
'length_too_big' => 'Length is too big',
'deserialize_not_str' => 'Deserialize: Generated value isn\'t a string',
'type_extract_error_id' => 'Could not extract type: %s with id %s',
'vector_invalid' => 'Invalid vector constructor: ',
'constructor_not_found' => 'Constructor not found for type: ',
'rand_bytes_too_small' => 'random_bytes is too small!',
'botapi_conversion_error' => 'Can\'t convert %s to a bot API object',
'non_text_conversion' => 'Can\'t convert non text messages yet!',
'last_byte_invalid' => 'Invalid last byte',
'file_type_invalid' => 'Invalid file type detected (%s)',
'recreate_temp_auth_key' => 'I had to recreate the temporary authorization key',
'resetting_auth_key' => 'WARNING: Resetting auth key...',
'shutting_down_reader_pool' => 'Shutting down reader pool ',
'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...',
'fingerprint_mismatch' => 'Key fingerprint mismatch',
'msg_data_length_too_big' => 'message_data_length is too big',
'length_not_divisible_16' => 'Length of decrypted data is not divisible by 16',
'msg_key_mismatch' => 'msg_key mismatch',
'rand_bytes_too_short' => 'random_bytes is too short!',
'resending_unsupported' => 'Resending of messages is not yet supported',
'unrecognized_dec_msg' => 'Unrecognized decrypted message received: ',
];
}

View File

@ -108,11 +108,11 @@ class Logger
preg_match('/const V = (\d+);/', file_get_contents('https://raw.githubusercontent.com/danog/MadelineProto/master/src/danog/MadelineProto/MTProto.php'), $matches);
if (isset($matches[1]) && \danog\MadelineProto\MTProto::V < (int) $matches[1]) {
throw new \danog\MadelineProto\Exception(hex2bin('506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e'), 0, null, 'MadelineProto', 1);
throw new \danog\MadelineProto\Exception(hex2bin(\danog\MadelineProto\Lang::$current_lang['v_error']), 0, null, 'MadelineProto', 1);
}
if (class_exists('\danog\MadelineProto\VoIP')) {
if (!defined('\danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION') || \danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION !== '1.1.2') {
throw new \danog\MadelineProto\Exception(hex2bin('506c6561736520757064617465207068702d6c69627467766f6970'), 0, null, 'MadelineProto', 1);
throw new \danog\MadelineProto\Exception(hex2bin(\danog\MadelineProto\Lang::$current_lang['v_tgerror']), 0, null, 'MadelineProto', 1);
}
try {
@ -146,7 +146,7 @@ class Logger
public static function constructor($mode, $optional = null, $prefix = '', $level = self::NOTICE)
{
if ($mode === null) {
throw new Exception('No mode was specified!');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['no_mode_specified']);
}
self::$mode = $mode;
self::$optional = $optional;
@ -165,7 +165,7 @@ class Logger
return false;
}
if (!self::$constructed) {
throw new Exception("The constructor function wasn't called! Please call the constructor function before using this method.");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['constructor_function_uncalled']);
}
$prefix = self::$prefix;
if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) {

View File

@ -22,7 +22,7 @@ class Lua
public function ___construct($script, $MadelineProto)
{
if (!file_exists($script)) {
throw new Exception('Provided script does not exist');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['script_not_exist']);
}
$this->MadelineProto = $MadelineProto;
$this->MadelineProto->settings['updates']['handle_updates'] = true;
@ -63,7 +63,6 @@ class Lua
}
$this->MadelineProto->lua = true;
foreach ($this->MadelineProto->get_methods_namespaced() as $method => $namespace) {
$namespace = key($pair);
$this->MadelineProto->{$namespace}->lua = true;
}
}

View File

@ -193,8 +193,11 @@ class MTProto
public function ___construct($settings = [])
{
// Parse settings
$this->parse_settings($settings);
if (!defined('\phpseclib\Crypt\AES::MODE_IGE')) {
throw new Exception('Please install this fork of phpseclib: https://github.com/danog/phpseclib');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['phpseclib_fork']);
}
$this->emojis = json_decode(self::JSON_EMOJIS);
\danog\MadelineProto\Logger::class_exists();
@ -202,31 +205,28 @@ class MTProto
// Detect ipv6
$this->ipv6 = (bool) strlen(@file_get_contents('http://ipv6.test-ipv6.com/', false, stream_context_create(['http' => ['timeout' => 1]]))) > 0;
// Parse settings
$this->parse_settings($settings);
// Connect to servers
\danog\MadelineProto\Logger::log(['Istantiating DataCenter...'], Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['inst_dc']], Logger::ULTRA_VERBOSE);
if (isset($this->datacenter)) {
$this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']);
} else {
$this->datacenter = new DataCenter($this->settings['connection'], $this->settings['connection_settings']);
}
// Load rsa keys
\danog\MadelineProto\Logger::log(['Loading RSA keys...'], Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['load_rsa']], Logger::ULTRA_VERBOSE);
foreach ($this->settings['authorization']['rsa_keys'] as $key) {
$key = new RSA($key);
$this->rsa_keys[$key->fp] = $key;
}
// Istantiate TL class
\danog\MadelineProto\Logger::log(['Translating tl schemas...'], Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['TL_translation']], Logger::ULTRA_VERBOSE);
$this->construct_TL($this->settings['tl_schema']['src']);
/*
* ***********************************************************************
* Define some needed numbers for BigInteger
*/
\danog\MadelineProto\Logger::log(['Executing dh_prime checks (0/3)...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['dh_prime_check_0']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
$this->zero = new \phpseclib\Math\BigInteger(0);
$this->one = new \phpseclib\Math\BigInteger(1);
@ -245,7 +245,7 @@ class MTProto
if (!isset($this->authorization['user']['bot']) || !$this->authorization['user']['bot']) {
try {
$nearest_dc = $this->method_call('help.getNearestDc', [], ['datacenter' => $this->datacenter->curdc]);
\danog\MadelineProto\Logger::log(["We're in ".$nearest_dc['country'].', current dc is '.$nearest_dc['this_dc'].', nearest dc is '.$nearest_dc['nearest_dc'].'.'], Logger::NOTICE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['nearest_dc'], $nearest_dc['country'], $nearest_dc['this_dc'], $nearest_dc['nearest_dc'])], Logger::NOTICE);
if ($nearest_dc['nearest_dc'] != $nearest_dc['this_dc']) {
$this->datacenter->curdc = (int) $nearest_dc['nearest_dc'];
@ -275,8 +275,13 @@ class MTProto
if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) {
return;
}
Lang::$current_lang = &Lang::$lang['en'];
if (isset($this->settings['app_info']['lang_code']) && isset(Lang::$lang[$this->settings['app_info']['lang_code']])) {
Lang::$current_lang = &Lang::$lang[$this->settings['app_info']['lang_code']];
}
if (!defined('\phpseclib\Crypt\AES::MODE_IGE')) {
throw new Exception('Please install this fork of phpseclib: https://github.com/danog/phpseclib');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['phpseclib_fork']);
}
foreach ($this->calls as $id => $controller) {
if (!is_object($controller)) {
@ -326,7 +331,7 @@ class MTProto
$force = false;
$this->reset_session();
if (!isset($this->v) || $this->v !== self::V) {
\danog\MadelineProto\Logger::log(['Serialization is out of date, reconstructing object!'], Logger::WARNING);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['serialization_ofd']], Logger::WARNING);
$settings = $this->settings;
if (isset($settings['updates']['callback'][0]) && $settings['updates']['callback'][0] === $this) {
$settings['updates']['callback'] = 'get_updates_update_handler';
@ -370,7 +375,7 @@ class MTProto
$this->get_dialogs($force);
}
if ($this->authorized === self::LOGGED_IN && $this->settings['updates']['handle_updates'] && !$this->updates_state['sync_loading']) {
\danog\MadelineProto\Logger::log(['Getting updates after deserialization...'], Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['getupdates_deserialization']], Logger::NOTICE);
$this->get_updates_difference();
}
}
@ -383,7 +388,7 @@ class MTProto
if (isset(Logger::$storage[spl_object_hash($this)])) {
$this->run_workers = false;
while ($number = Logger::$storage[spl_object_hash($this)]->collect()) {
\danog\MadelineProto\Logger::log(['Shutting down reader pool, '.$number.' jobs left'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['shutdown_reader_pool'], $number)], \danog\MadelineProto\Logger::NOTICE);
}
Logger::$storage[spl_object_hash($this)]->shutdown();
}
@ -392,7 +397,7 @@ class MTProto
public function setup_threads()
{
if ($this->threads = $this->run_workers = class_exists('\Pool') && in_array(php_sapi_name(), ['cli', 'phpdbg']) && $this->settings['threading']['allow_threading'] && extension_loaded('pthreads')) {
\danog\MadelineProto\Logger::log(['THREADING IS ENABLED'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['threading_on']], \danog\MadelineProto\Logger::NOTICE);
$this->start_threads();
}
}
@ -409,18 +414,18 @@ class MTProto
}
foreach ($dcs as $dc) {
if (!isset($this->readers[$dc])) {
Logger::log(['Socket reader on DC '.$dc.': CREATING'], Logger::WARNING);
Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['socket_reader'], $number).\danog\MadelineProto\Lang::$current_lang['socket_status_1']], Logger::WARNING);
$this->readers[$dc] = new \danog\MadelineProto\Threads\SocketReader($this, $dc);
}
if (!$this->readers[$dc]->isRunning()) {
Logger::log(['Socket reader on DC '.$dc.': SUBMITTING'], Logger::WARNING);
Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['socket_reader'], $number).\danog\MadelineProto\Lang::$current_lang['socket_status_2']], Logger::WARNING);
$this->readers[$dc]->garbage = false;
Logger::$storage[spl_object_hash($this)]->submit($this->readers[$dc]);
Logger::log(['Socket reader on DC '.$dc.': WAITING'], Logger::WARNING);
Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['socket_reader'], $number).\danog\MadelineProto\Lang::$current_lang['socket_status_3']], Logger::WARNING);
while (!$this->readers[$dc]->ready);
Logger::log(['Socket reader on DC '.$dc.': READY'], Logger::WARNING);
Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['socket_reader'], $number).\danog\MadelineProto\Lang::$current_lang['socket_status_4']], Logger::WARNING);
} else {
Logger::log(['Socket reader on DC '.$dc.': WORKING'], Logger::ULTRA_VERBOSE);
Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['socket_reader'], $number).\danog\MadelineProto\Lang::$current_lang['socket_status_5']], Logger::ULTRA_VERBOSE);
}
}
}
@ -444,6 +449,18 @@ class MTProto
$system_version = phpversion();
}
// Detect language
$lang_code = 'en';
Lang::$current_lang = &Lang::$lang[$lang_code];
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$lang_code = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
} elseif (isset($_SERVER['LANG'])) {
$lang_code = explode('_', $_SERVER['LANG'])[0];
}
if (isset(Lang::$lang[$lang_code])) {
Lang::$current_lang = &Lang::$lang[$lang_code];
}
// Set default settings
$default_settings = [
'authorization' => [ // Authorization settings
@ -511,13 +528,13 @@ class MTProto
],
],
'app_info' => [ // obtained in https://my.telegram.org
//'api_id' => 6,
//'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e',
//'api_id' => you should put an API id in the settings array you provide
//'api_hash' => you should put an API hash in the settings array you provide
'device_model' => $device_model,
'system_version' => $system_version,
'app_version' => 'Unicorn', // 🌚
// 'app_version' => self::V,
'lang_code' => 'en',
'lang_code' => $lang_code,
],
'tl_schema' => [ // TL scheme files
'layer' => 71, // layer version
@ -582,8 +599,11 @@ class MTProto
],
];
$settings = array_replace_recursive($this->array_cast_recursive($default_settings, true), $this->array_cast_recursive($settings, true));
if (isset(Lang::$lang[$settings['app_info']['lang_code']])) {
Lang::$current_lang = &Lang::$lang[$settings['app_info']['lang_code']];
}
if (!isset($settings['app_info']['api_id'])) {
throw new \danog\MadelineProto\Exception('You must provide an api key and an api id, get your own @ my.telegram.org', 0, null, 'MadelineProto', 1);
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['api_not_set'], 0, null, 'MadelineProto', 1);
}
if ($settings['app_info']['api_id'] < 20) {
@ -612,11 +632,11 @@ class MTProto
public function reset_session($de = true, $auth_key = false)
{
if (!is_object($this->datacenter)) {
throw new Exception('The session is corrupted!');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['session_corrupted']);
}
foreach ($this->datacenter->sockets as $id => $socket) {
if ($de) {
\danog\MadelineProto\Logger::log(['Resetting session id'.($auth_key ? ', authorization key' : '').' and seq_no in DC '.$id.'...'], Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['reset_session_seqno'], $id)], Logger::VERBOSE);
$socket->session_id = $this->random(8);
$socket->session_in_seq_no = 0;
$socket->session_out_seq_no = 0;
@ -665,10 +685,10 @@ class MTProto
}
if ($socket->temp_auth_key === null || $socket->auth_key === null) {
if ($socket->auth_key === null && !$cdn) {
\danog\MadelineProto\Logger::log(['Generating permanent authorization key for DC '.$id.'...'], Logger::NOTICE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['gen_perm_auth_key'], $id)], Logger::NOTICE);
$socket->auth_key = $this->create_auth_key(-1, $id);
}
\danog\MadelineProto\Logger::log(['Generating temporary authorization key for DC '.$id.'...'], Logger::NOTICE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['gen_temp_auth_key'], $id)], Logger::NOTICE);
$socket->temp_auth_key = $this->create_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
if (!$cdn) {
$this->bind_temp_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in'], $id);
@ -697,7 +717,7 @@ class MTProto
if (strpos($new_dc, '_') !== false) {
continue;
}
\danog\MadelineProto\Logger::log(['Copying authorization from dc '.$authorized_dc.' to dc '.$new_dc.'...'], Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['copy_auth_dcs'], $authorized_dc, $new_dc)], Logger::VERBOSE);
$exported_authorization = $this->method_call('auth.exportAuthorization', ['dc_id' => $new_dc], ['datacenter' => $authorized_dc]);
$this->method_call('auth.logOut', [], ['datacenter' => $new_dc]);
$authorization = $this->method_call('auth.importAuthorization', $exported_authorization, ['datacenter' => $new_dc]);
@ -709,7 +729,7 @@ class MTProto
public function write_client_info($method, $arguments = [], $options = [])
{
\danog\MadelineProto\Logger::log(['Writing client info (also executing '.$method.')...'], Logger::NOTICE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['write_client_info'], $method)], Logger::NOTICE);
return $this->method_call(
'invokeWithLayer',
@ -764,7 +784,7 @@ class MTProto
$this->parse_dc_options($this->config['dc_options']);
unset($this->config['dc_options']);
}
\danog\MadelineProto\Logger::log(['Updated config!', $this->config], Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['config_updated'], $this->config], Logger::NOTICE);
}
public function parse_dc_options($dc_options)

View File

@ -24,7 +24,7 @@ trait AuthKeyHandler
{
for ($retry_id_total = 1; $retry_id_total <= $this->settings['max_tries']['authorization']; $retry_id_total++) {
try {
\danog\MadelineProto\Logger::log(['Requesting pq'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['req_pq']], \danog\MadelineProto\Logger::VERBOSE);
/**
* ***********************************************************************

View File

@ -20,7 +20,7 @@ trait Files
public function upload($file, $file_name = '', $cb = null, $encrypted = false, $datacenter = null)
{
if (!file_exists($file)) {
throw new \danog\MadelineProto\Exception('Given file does not exist!');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['file_not_exist']);
}
if (empty($file_name)) {
$file_name = basename($file);
@ -312,11 +312,11 @@ trait Files
$this->config['expires'] = -1;
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
}
\danog\MadelineProto\Logger::log(['File is stored on CDN!'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['stored_on_cdn']], \danog\MadelineProto\Logger::NOTICE);
continue;
}
if ($res['_'] === 'upload.cdnFileReuploadNeeded') {
\danog\MadelineProto\Logger::log(['File is not stored on CDN, requesting reupload!'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['cdn_reupload']], \danog\MadelineProto\Logger::NOTICE);
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
try {
@ -347,10 +347,10 @@ trait Files
if (isset($message_media['cdn_key'])) {
$ivec = substr($message_media['cdn_iv'], 0, 12).pack('N', $offset >> 4);
$res['bytes'] = $this->ctr_encrypt($res['bytes'], $message_media['cdn_key'], $ivec);
$this->check_cdn_hash($message_media['file_token'], $offset, $res['bytes'], $datacenter);
}
if (isset($message_media['key'])) {
$res['bytes'] = $ige->decrypt($res['bytes']);
$this->check_cdn_hash($message_media['file_token'], $offset, $res['bytes'], $datacenter);
}
if ($start_at) {
$res['bytes'] = substr($res['bytes'], $start_at);

View File

@ -18,7 +18,7 @@ class RPCErrorException extends \Exception
public function __toString()
{
return 'Telegram returned an RPC error: '.$this->message.' ('.$this->rpc.'), caused by '.$this->file.':'.$this->line.PHP_EOL.PHP_EOL.'TL trace:'.PHP_EOL.$this->getTLTrace().PHP_EOL;
return sprintf(\danog\MadelineProto\Lang::$current_lang['rpc_tg_error'], $this->message, $this->rpc, $this->file, $this->line.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
}
public function __construct($message = null, $code = 0, Exception $previous = null)

View File

@ -25,15 +25,15 @@ class RSA
public function ___construct($rsa_key)
{
//if ($this->unserialized($rsa_key)) return true;
\danog\MadelineProto\Logger::log(['Istantiating \phpseclib\Crypt\RSA...'], Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['rsa_init']], Logger::ULTRA_VERBOSE);
$key = new \phpseclib\Crypt\RSA();
\danog\MadelineProto\Logger::log(['Loading key...'], Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['loading_key']], Logger::ULTRA_VERBOSE);
$key->load($rsa_key);
$this->n = \phpseclib\Common\Functions\Objects::getVar($key, 'modulus');
$this->e = \phpseclib\Common\Functions\Objects::getVar($key, 'exponent');
\danog\MadelineProto\Logger::log(['Computing fingerprint...'], Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['computing_fingerprint']], Logger::ULTRA_VERBOSE);
$this->fp = substr(
sha1(
$this->serialize_object(
@ -60,7 +60,7 @@ class RSA
public function encrypt($data)
{
\danog\MadelineProto\Logger::log(['Encrypting with rsa key...'], Logger::VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['rsa_encrypting']], Logger::VERBOSE);
return (new \phpseclib\Math\BigInteger($data, 256))->powMod($this->e, $this->n)->toBytes();
}

View File

@ -20,7 +20,7 @@ trait MessageHandler
public function encrypt_secret_message($chat_id, $message)
{
if (!isset($this->secret_chats[$chat_id])) {
\danog\MadelineProto\Logger::log('I do not have the secret chat '.$chat_id.' in the database, skipping message...');
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['secret_chat_skipping'], $chat_id));
return false;
}
@ -50,7 +50,7 @@ trait MessageHandler
public function handle_encrypted_update($message, $test = false)
{
if (!isset($this->secret_chats[$message['message']['chat_id']])) {
\danog\MadelineProto\Logger::log('I do not have the secret chat '.$message['message']['chat_id'].' in the database, skipping message...');
\danog\MadelineProto\Logger::log(sprintf(\danog\MadelineProto\Lang::$current_lang['secret_chat_skipping'], $message['message']['chat_id']));
return false;
}
@ -62,13 +62,13 @@ trait MessageHandler
if ($auth_key_id !== $this->secret_chats[$message['message']['chat_id']]['old_key']['fingerprint']) {
$this->discard_secret_chat($message['message']['chat_id']);
throw new \danog\MadelineProto\SecurityException('Key fingerprint mismatch');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['fingerprint_mismatch']);
}
$old = true;
} else {
$this->discard_secret_chat($message['message']['chat_id']);
throw new \danog\MadelineProto\SecurityException('Key fingerprint mismatch');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['fingerprint_mismatch']);
}
}
$message_key = substr($message['message']['bytes'], 8, 16);
@ -77,7 +77,7 @@ trait MessageHandler
$decrypted_data = $this->ige_decrypt($encrypted_data, $aes_key, $aes_iv);
$message_data_length = unpack('V', substr($decrypted_data, 0, 4))[1];
if ($message_data_length > strlen($decrypted_data)) {
throw new \danog\MadelineProto\SecurityException('message_data_length is too big');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['msg_data_length_too_big']);
}
if ((strlen($decrypted_data) - 4) - $message_data_length > 15) {
@ -85,11 +85,11 @@ trait MessageHandler
}
if (strlen($decrypted_data) % 16 != 0) {
throw new \danog\MadelineProto\SecurityException('length of decrypted data is not divisible by 16');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['length_not_divisible_16']);
}
$message_data = substr($decrypted_data, 4, $message_data_length);
if ($message_key != substr(sha1(substr($decrypted_data, 0, 4 + $message_data_length), true), -16)) {
throw new \danog\MadelineProto\SecurityException('msg_key mismatch');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['msg_key_mismatch']);
}
$deserialized = $this->deserialize($message_data, ['type' => '']);
$this->secret_chats[$message['message']['chat_id']]['ttr']--;

View File

@ -20,7 +20,7 @@ trait ResponseHandler
public function handle_decrypted_update($update)
{
if (isset($update['message']['decrypted_message']['random_bytes']) && strlen($update['message']['decrypted_message']['random_bytes']) < 15) {
throw new \danog\MadelineProto\ResponseException('random_bytes is too short!');
throw new \danog\MadelineProto\ResponseException(\danog\MadelineProto\Lang::$current_lang['rand_bytes_too_short']);
}
switch ($update['message']['decrypted_message']['_']) {
case 'decryptedMessageService':
@ -57,7 +57,7 @@ trait ResponseHandler
foreach ($this->secret_chats[$update['message']['chat_id']]['outgoing'] as $seq => $message) {
$seq--;
if ($seq >= $update['message']['decrypted_message']['action']['start_seq_no'] && $seq <= $update['message']['decrypted_message']['action']['end_seq_no']) {
throw new \danog\MadelineProto\ResponseException('Resending of messages is not yet supported');
throw new \danog\MadelineProto\ResponseException(\danog\MadelineProto\Lang::$current_lang['resending_unsupported']);
// $this->send_encrypted_message($update['message']['chat_id'], $update['message']['decrypted_message']);
}
}
@ -85,7 +85,7 @@ trait ResponseHandler
}
break;
default:
throw new \danog\MadelineProto\ResponseException('Unrecognized decrypted message received: '.var_export($update, true));
throw new \danog\MadelineProto\ResponseException(\danog\MadelineProto\Lang::$current_lang['unrecognized_dec_msg'].var_export($update, true));
break;
}
}

View File

@ -85,10 +85,10 @@ class Serialization
$unserialized = \danog\Serialization::unserialize($tounserialize);
}
} else {
throw new Exception('File does not exist');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['file_not_exist']);
}
if ($unserialized === false) {
throw new Exception('An error occurred on deserialization');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['deserialization_error']);
}
return $unserialized;

View File

@ -332,7 +332,7 @@ trait BotAPI
return [$type_name => $res, 'caption' => isset($data['caption']) ? $data['caption'] : ''];
default:
throw new Exception("Can't convert ".$data['_'].' to a bot API object');
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['botapi_conversion_error'], $data['_']));
}
}
@ -410,7 +410,7 @@ trait BotAPI
if (preg_match('|mention:|', $href)) {
$mention = $this->get_info(str_replace('mention:', '', $href));
if (!isset($mention['InputUser'])) {
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['peer_not_in_db']);
}
$entities[] = ['_' => 'inputMessageEntityMentionName', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text), 'user_id' => $mention['InputUser']];
} elseif (preg_match('|buttonurl:|', $href)) {

View File

@ -85,7 +85,7 @@ trait BotAPIFiles
{
$file_id = $this->rle_decode($this->base64url_decode($file_id));
if ($file_id[strlen($file_id) - 1] !== chr(2)) {
throw new Exception('Invalid last byte');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['last_byte_invalid']);
}
$deserialized = $this->deserialize($file_id);
$res = ['type' => str_replace('bot_', '', $deserialized['_'])];
@ -157,7 +157,7 @@ trait BotAPIFiles
return $res;
default:
throw new Exception('Invalid file type detected ('.$type.')');
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['file_type_invalid'], $type));
}
}
}

View File

@ -53,7 +53,7 @@ trait TD
}
$newparams = array_merge($params[$td], $newparams);
break;
default: throw new Exception("Can't convert non text messages yet!");
default: throw new Exception(\danog\MadelineProto\Lang::$current_lang['non_text_conversion']);
}
break;
default:
@ -137,7 +137,7 @@ trait TD
$newparams[$td]['entities'] = $params['entities'];
}
} else {
throw new Exception("Can't convert non text messages yet!");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['non_text_conversion']);
}
break;
default:

View File

@ -23,14 +23,14 @@ trait TL
public function construct_tl($files)
{
\danog\MadelineProto\Logger::log(['Loading TL schemes...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['TL_loading']], \danog\MadelineProto\Logger::VERBOSE);
$this->constructors = new TLConstructor();
$this->methods = new TLMethod();
$this->td_constructors = new TLConstructor();
$this->td_methods = new TLMethod();
$this->td_descriptions = ['types' => [], 'constructors' => [], 'methods' => []];
foreach ($files as $scheme_type => $file) {
\danog\MadelineProto\Logger::log(['Parsing '.basename($file).'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['file_parsing'], basename($file))], \danog\MadelineProto\Logger::VERBOSE);
$filec = file_get_contents($file);
$TL_dict = json_decode($filec, true);
if ($TL_dict === null) {
@ -128,7 +128,7 @@ trait TL
if (preg_match('/^[^\s]+#/', $line)) {
$nid = str_pad(preg_replace(['/^[^#]+#/', '/\s.+/'], '', $line), 8, '0', \STR_PAD_LEFT);
if ($id !== $nid && $scheme_type !== 'botAPI') {
\danog\MadelineProto\Logger::log(['CRC32 mismatch ('.$id.', '.$nid.') for '.$line], \danog\MadelineProto\Logger::ERROR);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['crc32_mismatch'], $id, $nid, $line)], \danog\MadelineProto\Logger::ERROR);
}
$id = $nid;
}
@ -165,10 +165,10 @@ trait TL
}
}
if (empty($TL_dict) || empty($TL_dict['constructors']) || !isset($TL_dict['methods'])) {
throw new Exception('Invalid source file was provided: '.$file);
throw new Exception(\danog\MadelineProto\Lang::$current_lang['src_file_invalid'].$file);
}
$orig = $this->encrypted_layer;
\danog\MadelineProto\Logger::log(['Translating objects...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['translating_obj']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
foreach ($TL_dict['constructors'] as $elem) {
if ($scheme_type === 'secret') {
$this->encrypted_layer = max($this->encrypted_layer, $elem['layer']);
@ -176,7 +176,7 @@ trait TL
$this->{($scheme_type === 'td' ? 'td_' : '').'constructors'}->add($elem, $scheme_type);
}
\danog\MadelineProto\Logger::log(['Translating methods...'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['translating_methods']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
foreach ($TL_dict['methods'] as $elem) {
$this->{($scheme_type === 'td' ? 'td_' : '').'methods'}->add($elem);
if ($scheme_type === 'secret') {
@ -236,7 +236,7 @@ trait TL
{
$tl_elem = $this->constructors->find_by_id($id);
if ($tl_elem === false) {
throw new Exception('Could not extract boolean');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['bool_error']);
}
return $tl_elem['predicate'] === 'boolTrue';
@ -247,13 +247,13 @@ trait TL
switch ($type['type']) {
case 'int':
if (!is_numeric($object)) {
throw new Exception("given value isn't numeric");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['not_numeric']);
}
return $this->pack_signed_int($object);
case '#':
if (!is_numeric($object)) {
throw new Exception("given value isn't numeric");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['not_numeric']);
}
return $this->pack_unsigned_int($object);
@ -269,25 +269,25 @@ trait TL
return substr($object, 1);
}
if (!is_numeric($object)) {
throw new Exception("given value isn't numeric");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['not_numeric']);
}
return $this->pack_signed_long($object);
case 'int128':
if (strlen($object) !== 16) {
throw new Exception('Given value is not 16 bytes long');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['long_not_16']);
}
return (string) $object;
case 'int256':
if (strlen($object) !== 32) {
throw new Exception('Given value is not 32 bytes long');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['long_not_32']);
}
return (string) $object;
case 'int512':
if (strlen($object) !== 64) {
throw new Exception('Given value is not 64 bytes long');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['long_not_64']);
}
return (string) $object;
@ -339,7 +339,7 @@ trait TL
return $object;
case 'Vector t':
if (!is_array($object)) {
throw new Exception("You didn't provide a valid array");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['array_invalid']);
}
$concat = $this->constructors->find_by_predicate('vector')['id'];
$concat .= $this->pack_unsigned_int(count($object));
@ -354,7 +354,7 @@ trait TL
if ((!is_array($object) || (isset($object['_']) && $this->constructors->find_by_predicate($object['_'])['type'] !== $type['type'])) && in_array($type['type'], ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputPeer'])) {
$object = $this->get_info($object);
if (!isset($object[$type['type']])) {
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['peer_not_in_db']);
}
$object = $object[$type['type']];
}
@ -362,7 +362,7 @@ trait TL
$constructorData = $this->constructors->find_by_predicate($type['type'], $layer);
if ($constructorData === false) {
throw new Exception('Predicate (value under _) was not set!');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['predicate_not_set']);
}
$auto = true;
$object['_'] = $constructorData['predicate'];
@ -373,7 +373,7 @@ trait TL
if ($constructorData === false) {
\danog\MadelineProto\Logger::log([$object], \danog\MadelineProto\Logger::FATAL_ERROR);
throw new Exception('Could not extract type "'.$predicate.'"');
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['type_extract_error'], $predicate));
}
if ($bare = ($type['type'] != '' && $type['type'][0] === '%')) {
@ -399,7 +399,7 @@ trait TL
{
$tl = $this->methods->find_by_method($method);
if ($tl === false) {
throw new Exception('Could not find method: '.$method);
throw new Exception(\danog\MadelineProto\Lang::$current_lang['method_not_found'].$method);
}
return $tl['id'].$this->serialize_params($tl, $arguments, $method);
@ -464,11 +464,11 @@ trait TL
}
}
throw new Exception('Missing required parameter', $current_argument['name']);
throw new Exception(\danog\MadelineProto\Lang::$current_lang['params_missing'], $current_argument['name']);
}
if (!is_array($arguments[$current_argument['name']]) && $current_argument['type'] === 'InputEncryptedChat') {
if (!isset($this->secret_chats[$arguments[$current_argument['name']]])) {
throw new \danog\MadelineProto\Exception('This secret peer is not present in the internal peer database');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['sec_peer_not_in_db']);
}
$arguments[$current_argument['name']] = $this->secret_chats[$arguments[$current_argument['name']]]['InputEncryptedChat'];
}
@ -491,7 +491,7 @@ trait TL
fseek($res, 0);
$stream = $res;
} elseif (!is_resource($stream)) {
throw new Exception('An invalid stream handle was provided.');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['stream_handle_invalid']);
}
$this->deserialize($stream, $type);
@ -509,7 +509,7 @@ trait TL
fseek($res, 0);
$stream = $res;
} elseif (!is_resource($stream)) {
throw new Exception('An invalid stream handle was provided.');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['stream_handle_invalid']);
}
switch ($type['type']) {
@ -537,7 +537,7 @@ trait TL
case 'bytes':
$l = ord(stream_get_contents($stream, 1));
if ($l > 254) {
throw new Exception('Length is too big');
throw new Exception(\danog\MadelineProto\Lang::$current_lang['length_too_big']);
}
if ($l === 254) {
$long_len = unpack('V', stream_get_contents($stream, 3).chr(0))[1];
@ -554,7 +554,7 @@ trait TL
}
}
if (!is_string($x)) {
throw new Exception("deserialize: generated value isn't a string");
throw new Exception(\danog\MadelineProto\Lang::$current_lang['deserialize_not_str']);
}
return $type['type'] === 'bytes' ? (new Types\Bytes($x)) : $x;
@ -562,7 +562,7 @@ trait TL
$id = stream_get_contents($stream, 4);
$constructorData = $this->constructors->find_by_id($id);
if ($constructorData === false) {
throw new Exception('Could not extract type: '.$type['type'].' with id '.bin2hex(strrev($id)));
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['type_extract_error_id'], $type['type'], bin2hex(strrev($id))));
}
switch ($constructorData['predicate']) {
case 'gzip_packed':
@ -571,7 +571,7 @@ trait TL
case 'vector':
break;
default:
throw new Exception('Invalid vector constructor: '.$constructorData['predicate']);
throw new Exception(\danog\MadelineProto\Lang::$current_lang['vector_invalid'].$constructorData['predicate']);
}
case 'vector':
$count = unpack('V', stream_get_contents($stream, 4))[1];
@ -587,7 +587,7 @@ trait TL
$checkType = substr($type['type'], 1);
$constructorData = $this->constructors->find_by_type($checkType);
if ($constructorData === false) {
throw new Exception('Constructor not found for type: '.$checkType);
throw new Exception(\danog\MadelineProto\Lang::$current_lang['constructor_not_found'].$checkType);
}
} else {
$constructorData = $this->constructors->find_by_predicate($type['type']);
@ -595,7 +595,7 @@ trait TL
$id = stream_get_contents($stream, 4);
$constructorData = $this->constructors->find_by_id($id);
if ($constructorData === false) {
throw new Exception('Could not extract type: '.$type['type'].' with id '.bin2hex(strrev($id)));
throw new Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['type_extract_error_id'], $type['type'], bin2hex(strrev($id))));
}
}
}
@ -655,7 +655,7 @@ trait TL
if ($arg['name'] === 'random_bytes') {
if (strlen($x[$arg['name']]) < 15) {
throw new \danog\MadelineProto\SecurityException('random_bytes is too small!');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['rand_bytes_too_small']);
} else {
unset($x[$arg['name']]);
}

View File

@ -33,11 +33,11 @@ class SocketHandler extends \Threaded implements \Collectable
if ($this->error !== true) {
if ($this->error === -404) {
if ($this->API->datacenter->sockets[$this->current]->temp_auth_key !== null) {
\danog\MadelineProto\Logger::log(['WARNING: Resetting auth key...'], \danog\MadelineProto\Logger::WARNING);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['resetting_auth_key']], \danog\MadelineProto\Logger::WARNING);
$this->API->datacenter->sockets[$this->current]->temp_auth_key = null;
$this->API->init_authorization();
throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['recreate_temp_auth_key']);
}
}

View File

@ -32,7 +32,7 @@ class SocketReader extends \Threaded implements \Collectable
public function __destruct()
{
\danog\MadelineProto\Logger::log(['Shutting down reader pool '.$this->current], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['shutting_down_reader_pool'].$this->current], \danog\MadelineProto\Logger::NOTICE);
}
/**
@ -60,7 +60,7 @@ class SocketReader extends \Threaded implements \Collectable
}
}
while ($number = $handler_pool->collect()) {
\danog\MadelineProto\Logger::log(['Shutting down handler pool for dc '.$this->current.', '.$number.' jobs left'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['shutting_down_handler_pool'], $this->current, $number)], \danog\MadelineProto\Logger::NOTICE);
}
$this->setGarbage();
}

View File

@ -53,7 +53,7 @@ trait Tools
public function unpack_signed_int($value)
{
if (strlen($value) !== 4) {
throw new TL\Exception('Length is not equal to 4');
throw new TL\Exception(\danog\MadelineProto\Lang::$current_lang['length_not_4']);
}
return unpack('l', \danog\MadelineProto\Logger::$BIG_ENDIAN ? strrev($value) : $value)[1];
@ -62,7 +62,7 @@ trait Tools
public function unpack_signed_long($value)
{
if (strlen($value) !== 8) {
throw new TL\Exception('Length is not equal to 8');
throw new TL\Exception(\danog\MadelineProto\Lang::$current_lang['length_not_8']);
}
return unpack('q', \danog\MadelineProto\Logger::$BIG_ENDIAN ? strrev($value) : $value)[1];
@ -71,10 +71,10 @@ trait Tools
public function pack_signed_int($value)
{
if ($value > 2147483647) {
throw new TL\Exception('Provided value '.$value.' is bigger than 2147483647');
throw new TL\Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['value_bigger_than_2147483647'], $value));
}
if ($value < -2147483648) {
throw new TL\Exception('Provided value '.$value.' is smaller than -2147483648');
throw new TL\Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['value_smaller_than_2147483648'], $value));
}
$res = pack('l', $value);
@ -84,10 +84,10 @@ trait Tools
public function pack_signed_long($value)
{
if ($value > 9223372036854775807) {
throw new TL\Exception('Provided value '.$value.' is bigger than 9223372036854775807');
throw new TL\Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['value_bigger_than_9223372036854775807'], $value));
}
if ($value < -9223372036854775808) {
throw new TL\Exception('Provided value '.$value.' is smaller than -9223372036854775808');
throw new TL\Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['value_smaller_than_9223372036854775808'], $value));
}
$res = \danog\MadelineProto\Logger::$bigint ? ($this->pack_signed_int($value)."\0\0\0\0") : (\danog\MadelineProto\Logger::$BIG_ENDIAN ? strrev(pack('q', $value)) : pack('q', $value));
@ -97,10 +97,10 @@ trait Tools
public function pack_unsigned_int($value)
{
if ($value > 4294967295) {
throw new TL\Exception('Provided value '.$value.' is bigger than 4294967296');
throw new TL\Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['value_bigger_than_4294967296'], $value));
}
if ($value < 0) {
throw new TL\Exception('Provided value '.$value.' is smaller than 0');
throw new TL\Exception(sprintf(\danog\MadelineProto\Lang::$current_lang['value_smaller_than_0'], $value));
}
return pack('V', $value);
@ -110,7 +110,7 @@ trait Tools
{
$res = pack('d', $value);
if (strlen($res) !== 8) {
throw new TL\Exception('Could not properly encode double');
throw new TL\Exception(\danog\MadelineProto\Lang::$current_lang['encode_double_error']);
}
return \danog\MadelineProto\Logger::$BIG_ENDIAN ? strrev($res) : $res;
@ -119,7 +119,7 @@ trait Tools
public function unpack_double($value)
{
if (strlen($value) !== 8) {
throw new TL\Exception('Length is not equal to 8');
throw new TL\Exception(\danog\MadelineProto\Lang::$current_lang['length_not_8']);
}
return unpack('d', \danog\MadelineProto\Logger::$BIG_ENDIAN ? strrev($value) : $value)[1];

View File

@ -25,7 +25,7 @@ trait AuthKeyHandler
public function request_call($user)
{
if (!class_exists('\danog\MadelineProto\VoIP')) {
throw new \danog\MadelineProto\Exception('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['libtgvoip_required']);
}
array_walk($this->calls, function ($controller, $id) {
if ($controller->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) {
@ -35,14 +35,14 @@ trait AuthKeyHandler
$user = $this->get_info($user);
if (!isset($user['InputUser']) || $user['InputUser']['_'] === 'inputUserSelf') {
throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['peer_not_in_db']);
}
$user = $user['InputUser'];
\danog\MadelineProto\Logger::log(['Calling '.$user['user_id'].'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['calling_user'], $user['user_id'])], \danog\MadelineProto\Logger::VERBOSE);
$dh_config = $this->get_dh_config();
\danog\MadelineProto\Logger::log(['Generating a...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['generating_a']], \danog\MadelineProto\Logger::VERBOSE);
$a = \phpseclib\Math\BigInteger::randomRange($this->two, $dh_config['p']->subtract($this->two));
\danog\MadelineProto\Logger::log(['Generating g_a...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['generating_g_a']], \danog\MadelineProto\Logger::VERBOSE);
$g_a = $dh_config['g']->powMod($a, $dh_config['p']);
$this->check_G($g_a, $dh_config['p']);
$res = $this->method_call('phone.requestCall', ['user_id' => $user, 'g_a_hash' => hash('sha256', $g_a->toBytes(), true), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_p2p' => true, 'udp_reflector' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
@ -58,7 +58,7 @@ trait AuthKeyHandler
public function accept_call($call)
{
if (!class_exists('\danog\MadelineProto\VoIP')) {
throw new \danog\MadelineProto\Exception('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['libtgvoip_required']);
}
array_walk($this->calls, function ($controller, $id) {
@ -67,14 +67,14 @@ trait AuthKeyHandler
}
});
if ($this->call_status($call['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_ACCEPTED) {
\danog\MadelineProto\Logger::log(['Could not find and accept call '.$call['id']]);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_1'], $call['id'])]);
return false;
}
\danog\MadelineProto\Logger::log(['Accepting call from '.$this->calls[$call['id']]->getOtherID().'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['accepting_call'], $this->calls[$call['id']]->getOtherID())], \danog\MadelineProto\Logger::VERBOSE);
$dh_config = $this->get_dh_config();
\danog\MadelineProto\Logger::log(['Generating b...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['generating_b']], \danog\MadelineProto\Logger::VERBOSE);
$b = \phpseclib\Math\BigInteger::randomRange($this->two, $dh_config['p']->subtract($this->two));
$g_b = $dh_config['g']->powMod($b, $dh_config['p']);
$this->check_G($g_b, $dh_config['p']);
@ -83,14 +83,13 @@ trait AuthKeyHandler
$res = $this->method_call('phone.acceptCall', ['peer' => $call, 'g_b' => $g_b->toBytes(), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_reflector' => true, 'udp_p2p' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
} catch (\danog\MadelineProto\RPCErrorException $e) {
if ($e->rpc === 'CALL_ALREADY_ACCEPTED') {
\danog\MadelineProto\Logger::log(['Call '.$call['id'].' already accepted']);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_already_accepted'], $call['id'])]);
return true;
}
if ($e->rpc === 'CALL_ALREADY_DECLINED') {
\danog\MadelineProto\Logger::log(['Call '.$call['id'].' already declined']);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['call_already_declined']]);
$this->discard_call($call['id'], 'phoneCallDiscardReasonHangup');
//$this->calls[$call['id']]->discard();
return false;
}
@ -108,7 +107,7 @@ trait AuthKeyHandler
public function confirm_call($params)
{
if (!class_exists('\danog\MadelineProto\VoIP')) {
throw new \danog\MadelineProto\Exception('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['libtgvoip_required']);
}
array_walk($this->calls, function ($controller, $id) {
@ -117,11 +116,11 @@ trait AuthKeyHandler
}
});
if ($this->call_status($params['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_REQUESTED) {
\danog\MadelineProto\Logger::log(['Could not find and confirm call '.$params['id']]);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_2'], $params['id'])]);
return false;
}
\danog\MadelineProto\Logger::log(['Confirming call from '.$this->calls[$params['id']]->getOtherID().'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_confirming'], $this->calls[$params['id']]->getOtherID())], \danog\MadelineProto\Logger::VERBOSE);
$dh_config = $this->get_dh_config();
$params['g_b'] = new \phpseclib\Math\BigInteger($params['g_b'], 256);
@ -161,7 +160,7 @@ trait AuthKeyHandler
public function complete_call($params)
{
if (!class_exists('\danog\MadelineProto\VoIP')) {
throw new \danog\MadelineProto\Exception('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['libtgvoip_required']);
}
array_walk($this->calls, function ($controller, $id) {
@ -170,22 +169,22 @@ trait AuthKeyHandler
}
});
if ($this->call_status($params['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_ACCEPTED || !isset($this->calls[$params['id']]->storage['b'])) {
\danog\MadelineProto\Logger::log(['Could not find and complete call '.$params['id']]);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_error_3'], $params['id'])]);
return false;
}
\danog\MadelineProto\Logger::log(['Completing call from '.$this->calls[$params['id']]->getOtherID().'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_completing'], $this->calls[$params['id']]->getOtherID())], \danog\MadelineProto\Logger::VERBOSE);
$dh_config = $this->get_dh_config();
if (hash('sha256', $params['g_a_or_b'], true) != $this->calls[$params['id']]->storage['g_a_hash']) {
throw new \danog\MadelineProto\SecurityException('Invalid g_a!');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['invalid_g_a']);
}
$params['g_a_or_b'] = new \phpseclib\Math\BigInteger($params['g_a_or_b'], 256);
$this->check_G($params['g_a_or_b'], $dh_config['p']);
$key = str_pad($params['g_a_or_b']->powMod($this->calls[$params['id']]->storage['b'], $dh_config['p'])->toBytes(), 256, chr(0), \STR_PAD_LEFT);
if (substr(sha1($key, true), -8) != $params['key_fingerprint']) {
throw new \danog\MadelineProto\SecurityException('Invalid key fingerprint!');
throw new \danog\MadelineProto\SecurityException(\danog\MadelineProto\Lang::$current_lang['fingerprint_invalid']);
}
$visualization = [];
$length = new \phpseclib\Math\BigInteger(count($this->emojis));
@ -219,7 +218,7 @@ trait AuthKeyHandler
public function call_status($id)
{
if (!class_exists('\danog\MadelineProto\VoIP')) {
throw new \danog\MadelineProto\Exception('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['libtgvoip_required']);
}
array_walk($this->calls, function ($controller, $id) {
@ -238,7 +237,7 @@ trait AuthKeyHandler
public function get_call($call)
{
if (!class_exists('\danog\MadelineProto\VoIP')) {
throw new \danog\MadelineProto\Exception('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['libtgvoip_required']);
}
array_walk($this->calls, function ($controller, $id) {
@ -253,12 +252,12 @@ trait AuthKeyHandler
public function discard_call($call, $reason, $rating = [], $need_debug = true)
{
if (!class_exists('\danog\MadelineProto\VoIP')) {
throw new \danog\MadelineProto\Exception('The php-libtgvoip extension is required to accept and manage calls. See daniil.it/MadelineProto for more info.');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['libtgvoip_required']);
}
if (!isset($this->calls[$call['id']])) {
return;
}
\danog\MadelineProto\Logger::log(['Discarding call '.$call['id'].'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_discarding'], $call['id'])], \danog\MadelineProto\Logger::VERBOSE);
try {
$res = $this->method_call('phone.discardCall', ['peer' => $call, 'duration' => time() - $this->calls[$call['id']]->whenCreated(), 'connection_id' => $this->calls[$call['id']]->getPreferredRelayID(), 'reason' => $reason], ['datacenter' => $this->datacenter->curdc]);
@ -268,11 +267,11 @@ trait AuthKeyHandler
}
}
if (!empty($rating)) {
\danog\MadelineProto\Logger::log(['Setting rating for call '.$call['id'].'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_set_rating'], $call['id'])], \danog\MadelineProto\Logger::VERBOSE);
$this->method_call('phone.setCallRating', ['peer' => $call, 'rating' => $rating['rating'], 'comment' => $rating['comment']], ['datacenter' => $this->datacenter->curdc]);
}
if ($need_debug) {//} && isset($this->calls[$call['id']]->storage['not_modified'])) {
\danog\MadelineProto\Logger::log(['Saving debug data for call '.$call['id'].'...'], \danog\MadelineProto\Logger::VERBOSE);
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['call_debug_saving'], $call['id'])], \danog\MadelineProto\Logger::VERBOSE);
$this->method_call('phone.saveCallDebug', ['peer' => $call, 'debug' => $this->calls[$call['id']]->getDebugLog()], ['datacenter' => $this->datacenter->curdc]);
}
$update = ['_' => 'updatePhoneCall', 'phone_call' => $this->calls[$call['id']]];

View File

@ -24,7 +24,7 @@ trait DialogHandler
$datacenter = $this->datacenter->curdc;
$peers = [];
while ($this->dialog_params['count'] < $res['count']) {
\danog\MadelineProto\Logger::log(['Getting dialogs...']);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['getting_dialogs']]);
$res = $this->method_call('messages.getDialogs', $this->dialog_params, ['datacenter' => $datacenter, 'FloodWaitLimit' => 100]);
foreach ($res['dialogs'] as $dialog) {
if (!in_array($dialog['peer'], $peers)) {

View File

@ -28,9 +28,9 @@ trait Login
$this->state = [];
if (!$this->method_call('auth.logOut', [], ['datacenter' => $this->datacenter->curdc])) {
throw new \danog\MadelineProto\Exception('An error occurred while logging out!');
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['logout_error']);
}
\danog\MadelineProto\Logger::log(['Logged out successfully!'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['logout_ok']], \danog\MadelineProto\Logger::NOTICE);
return true;
}
@ -38,10 +38,10 @@ trait Login
public function bot_login($token)
{
if ($this->authorized === self::LOGGED_IN) {
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['already_logged_in']], \danog\MadelineProto\Logger::NOTICE);
$this->logout();
}
\danog\MadelineProto\Logger::log(['Logging in as a bot...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_bot']], \danog\MadelineProto\Logger::NOTICE);
$this->authorization = $this->method_call(
'auth.importBotAuthorization',
[
@ -57,7 +57,7 @@ trait Login
if (!isset($this->settings['pwr']['pwr']) || !$this->settings['pwr']['pwr']) {
@file_get_contents('https://api.pwrtelegram.xyz/bot'.$token.'/getme');
}
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_ok']], \danog\MadelineProto\Logger::NOTICE);
return $this->authorization;
}
@ -65,10 +65,10 @@ trait Login
public function phone_login($number, $sms_type = 5)
{
if ($this->authorized === self::LOGGED_IN) {
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['already_logged_in']], \danog\MadelineProto\Logger::NOTICE);
$this->logout();
}
\danog\MadelineProto\Logger::log(['Sending code...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_code_sending']], \danog\MadelineProto\Logger::NOTICE);
$this->authorization = $this->method_call(
'auth.sendCode',
[
@ -85,7 +85,7 @@ trait Login
$this->updates = [];
$this->updates_key = 0;
\danog\MadelineProto\Logger::log(['Code sent successfully! Once you receive the code you should use the complete_phone_login function.'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_code_sent']], \danog\MadelineProto\Logger::NOTICE);
return $this->authorization;
}
@ -93,10 +93,10 @@ trait Login
public function complete_phone_login($code)
{
if ($this->authorized !== self::WAITING_CODE) {
throw new \danog\MadelineProto\Exception("I'm not waiting for the code! Please call the phone_login method first");
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['login_code_uncalled']);
}
$this->authorized = self::NOT_LOGGED_IN;
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_user']], \danog\MadelineProto\Logger::NOTICE);
try {
$authorization = $this->method_call(
@ -109,7 +109,7 @@ trait Login
);
} catch (\danog\MadelineProto\RPCErrorException $e) {
if ($e->rpc === 'SESSION_PASSWORD_NEEDED') {
\danog\MadelineProto\Logger::log(['2FA enabled, you will have to call the complete_2fa_login function...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_2fa_enabled']], \danog\MadelineProto\Logger::NOTICE);
$this->authorized = self::WAITING_PASSWORD;
$this->authorization = $this->method_call('account.getPassword', [], ['datacenter' => $this->datacenter->curdc]);
@ -117,7 +117,7 @@ trait Login
return $this->authorization;
}
if ($e->rpc === 'PHONE_NUMBER_UNOCCUPIED') {
\danog\MadelineProto\Logger::log(['An account has not been created for this number, you will have to call the complete_signup function...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_need_signup']], \danog\MadelineProto\Logger::NOTICE);
$this->authorized = self::WAITING_SIGNUP;
$this->authorization['phone_code'] = $code;
@ -130,7 +130,7 @@ trait Login
$this->authorization = $authorization;
$this->sync_authorization($this->datacenter->curdc);
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_ok']], \danog\MadelineProto\Logger::NOTICE);
return $this->authorization;
}
@ -138,10 +138,10 @@ trait Login
public function import_authorization($authorization)
{
if ($this->authorized === self::LOGGED_IN) {
\danog\MadelineProto\Logger::log(['This instance of MadelineProto is already logged in. Logging out first...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['already_logged_in']], \danog\MadelineProto\Logger::NOTICE);
$this->logout();
}
\danog\MadelineProto\Logger::log(['Logging in using auth key...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_auth_key']], \danog\MadelineProto\Logger::NOTICE);
list($dc_id, $auth_key) = $authorization;
$this->datacenter->sockets[$dc_id]->session_id = $this->random(8);
$this->datacenter->sockets[$dc_id]->session_in_seq_no = 0;
@ -162,7 +162,7 @@ trait Login
public function export_authorization()
{
if ($this->authorized !== self::LOGGED_IN) {
throw new \danog\MadelineProto\Exception("I'm not logged in!");
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['not_logged_in']);
}
return [$this->datacenter->curdc, $this->datacenter->sockets[$this->datacenter->curdc]->auth_key];
@ -171,10 +171,10 @@ trait Login
public function complete_signup($first_name, $last_name)
{
if ($this->authorized !== self::WAITING_SIGNUP) {
throw new \danog\MadelineProto\Exception("I'm not waiting to signup! Please call the phone_login and the complete_phone_login methods first!");
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['signup_uncalled']);
}
$this->authorized = self::NOT_LOGGED_IN;
\danog\MadelineProto\Logger::log(['Signing up as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['signing_up']], \danog\MadelineProto\Logger::NOTICE);
$this->authorization = $this->method_call(
'auth.signUp',
[
@ -188,7 +188,7 @@ trait Login
$this->authorized = self::LOGGED_IN;
$this->sync_authorization($this->datacenter->curdc);
\danog\MadelineProto\Logger::log(['Signed up in successfully!'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['signup_ok']], \danog\MadelineProto\Logger::NOTICE);
return $this->authorization;
}
@ -196,10 +196,10 @@ trait Login
public function complete_2fa_login($password)
{
if ($this->authorized !== self::WAITING_PASSWORD) {
throw new \danog\MadelineProto\Exception("I'm not waiting for the password! Please call the phone_login and the complete_phone_login methods first!");
throw new \danog\MadelineProto\Exception(\danog\MadelineProto\Lang::$current_lang['2fa_uncalled']);
}
$this->authorized = self::NOT_LOGGED_IN;
\danog\MadelineProto\Logger::log(['Logging in as a normal user...'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_user']], \danog\MadelineProto\Logger::NOTICE);
$this->authorization = $this->method_call(
'auth.checkPassword',
[
@ -208,7 +208,7 @@ trait Login
);
$this->authorized = self::LOGGED_IN;
$this->sync_authorization($this->datacenter->curdc);
\danog\MadelineProto\Logger::log(['Logged in successfully!'], \danog\MadelineProto\Logger::NOTICE);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['login_ok']], \danog\MadelineProto\Logger::NOTICE);
return $this->authorization;
}

56
translator.php Normal file
View File

@ -0,0 +1,56 @@
<?php
require 'vendor/autoload.php';
$template = '<?php
/*
Copyright 2016-2017 Daniil Gentili
(https://daniil.it)
This file is part of MadelineProto.
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with MadelineProto.
If not, see <http://www.gnu.org/licenses/>.
*/
namespace danog\MadelineProto;
class Lang
{
public static $lang = %s;
// THIS WILL BE OVERWRITTEN BY $lang["en"]
public static $current_lang = %s;
}';
$lang_code = readline('Enter the language you whish to localize: ');
if (!isset(\danog\MadelineProto\Lang::$lang[$lang_code])) {
\danog\MadelineProto\Lang::$lang[$lang_code] = \danog\MadelineProto\Lang::$current_lang;
echo 'New language detected!'.PHP_EOL.PHP_EOL;
} else {
echo 'Completing localization of existing language'.PHP_EOL.PHP_EOL;
}
$count = count(\danog\MadelineProto\Lang::$lang[$lang_code]);
$curcount = 0;
foreach (\danog\MadelineProto\Lang::$current_lang as $key => $value) {
if (!isset(\danog\MadelineProto\Lang::$lang[$lang_code][$key])) {
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = $value;
}
if (\danog\MadelineProto\Lang::$lang[$lang_code][$key] === $value) {
$value = \danog\MadelineProto\Lang::$lang[$lang_code][$key];
if (in_array($key, ['v_error', 'v_tgerror'])) {
$value = hex2bin($value);
}
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = readline($value.' => ');
if (in_array($key, ['v_error', 'v_tgerror'])) {
\danog\MadelineProto\Lang::$lang[$lang_code][$key] = bin2hex(\danog\MadelineProto\Lang::$lang[$lang_code][$key]);
}
file_put_contents('src/danog/MadelineProto/Lang.php', sprintf($template, var_export(\danog\MadelineProto\Lang::$lang, true), var_export(\danog\MadelineProto\Lang::$lang['en'], true)));
echo 'OK, '.($curcount * 100 / $count).'% done. edit src/danog/MadelineProto/Lang.php to fix mistakes.'.PHP_EOL;
}
$curcount++;
}
file_put_contents('src/danog/MadelineProto/Lang.php', sprintf($template, var_export(\danog\MadelineProto\Lang::$lang, true), var_export(\danog\MadelineProto\Lang::$lang['en'], true)));
echo 'OK. edit src/danog/MadelineProto/Lang.php to fix mistakes.'.PHP_EOL;