Translating...

This commit is contained in:
danogentili 2016-06-26 14:53:16 +02:00
parent cfa5f9c868
commit 8ddbfecc43
6 changed files with 28 additions and 22 deletions

BIN
TL.php

Binary file not shown.

1
classes/libpy2php Symbolic link
View File

@ -0,0 +1 @@
../libpy2php/

View File

@ -2,12 +2,12 @@
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
require_once ('libpy2php.php');
require_once ('os.php');
class TelepyShell extends Cmd {
class TelepyShell {
public $intro = 'Welcome to telepy interactive shell. Type help or ? for help.
';
public $prompt = '>';
function preloop() {
require_once ('classes.telepy.php');
require_once ('classes/telepy.php');
$this->_telepy = new Telepy();
}
function precmd($line) {

Binary file not shown.

View File

@ -6,13 +6,24 @@ require_once ('classes/shell.php');
if (($__name__ == '__main__')) {
$parser = py2php_kwargs_function_call('argparse::ArgumentParser', ['telepy'], ["description" => 'Python implementation of telegram API.']);
py2php_kwargs_method_call($parser, 'add_argument', ['command'], ["nargs" => '?', "choices" => (['cmd', 'dialog_list', 'contact_list'] + array_map(function($sub) { return "chat_" . $sub; }, ['info', 'add_user', 'add_user_to_chat', 'del_user', 'set_photo', 'rename'])
) ]);
py2php_kwargs_method_call($parser, 'add_argument', ['args'], ["nargs" => '*']);
$args = $parser->parse_args();
if (($args->command == null)) {
if (!debug_backtrace()) {
$clidata = [];
$clidata["description"] = 'MadelineProto: PHP implementation of telegram API. Translated from telepy by Daniil Gentili.';
$clidata['args']['commands'] = array_merge(['cmd', 'dialog_list', 'contact_list'], array_map(function($sub) { return "chat_" . $sub; }, ['info', 'add_user', 'add_user_to_chat', 'del_user', 'set_photo', 'rename']));
$clidata['args']['flags'] = "h";
$clidata["help"] = $clidata["description"] . PHP_EOL . PHP_EOL . "Flags: ";
foreach (str_split($clidata['args']['flags']) as $flag) {
$clidata["help"] .= "-" . $flag . ", ";
}
$clidata["help"] .= PHP_EOL . "Commands: ";
foreach ($clidata['args']['commands'] as $command) {
$clidata["help"] .= $command . ", ";
}
$clidata["help"] .= PHP_EOL;
if(isset(getopt($clidata['args']['flags'])["h"])) {
die($clidata["help"]);
}
if ($argc == 1) {
$newTelePyShell = new TelepyShell();
$newTelePyShell->cmdloop();
}

View File

@ -2,21 +2,15 @@
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
require_once ('libpy2php.php');
require_once ('os.php');
try {
require_once ('configparser.php');
}
catch(ImportError $e) {
require_once ('ConfigParser.php');
}
require_once ('mtproto.php');
$config = $configparser->ConfigParser();
if (!($config->read('credentials'))) {
$config = parse_ini_file('credentials', true);
if (!($config)) {
pyjslib_printnl('File \'credentials\' seems to not exist.');
$exit(-1);
}
$ip = $config->get('App data', 'ip_address');
$port = $config->getint('App data', 'port');
$Session = mtproto::Session($ip, $port);
Session::create_auth_key();
$future_salts = py2php_kwargs_function_call('Session::method_call', ['get_future_salts'], ["num" => 3]);
$ip = $config['App data']['ip_address'];
$port = $config['App data']['port'];
$Session = new Session($ip, $port);
$Session->create_auth_key();
$future_salts = $Session->method_call('get_future_salts', 3);
pyjslib_printnl($future_salts);