Translating...
This commit is contained in:
parent
cfa5f9c868
commit
8ddbfecc43
1
classes/libpy2php
Symbolic link
1
classes/libpy2php
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../libpy2php/
|
@ -2,12 +2,12 @@
|
|||||||
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
|
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
|
||||||
require_once ('libpy2php.php');
|
require_once ('libpy2php.php');
|
||||||
require_once ('os.php');
|
require_once ('os.php');
|
||||||
class TelepyShell extends Cmd {
|
class TelepyShell {
|
||||||
public $intro = 'Welcome to telepy interactive shell. Type help or ? for help.
|
public $intro = 'Welcome to telepy interactive shell. Type help or ? for help.
|
||||||
';
|
';
|
||||||
public $prompt = '>';
|
public $prompt = '>';
|
||||||
function preloop() {
|
function preloop() {
|
||||||
require_once ('classes.telepy.php');
|
require_once ('classes/telepy.php');
|
||||||
$this->_telepy = new Telepy();
|
$this->_telepy = new Telepy();
|
||||||
}
|
}
|
||||||
function precmd($line) {
|
function precmd($line) {
|
||||||
|
BIN
mtproto.php
BIN
mtproto.php
Binary file not shown.
25
telepy.php
25
telepy.php
@ -6,13 +6,24 @@ require_once ('classes/shell.php');
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (($__name__ == '__main__')) {
|
if (!debug_backtrace()) {
|
||||||
$parser = py2php_kwargs_function_call('argparse::ArgumentParser', ['telepy'], ["description" => 'Python implementation of telegram API.']);
|
$clidata = [];
|
||||||
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'])
|
$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']));
|
||||||
py2php_kwargs_method_call($parser, 'add_argument', ['args'], ["nargs" => '*']);
|
$clidata['args']['flags'] = "h";
|
||||||
$args = $parser->parse_args();
|
$clidata["help"] = $clidata["description"] . PHP_EOL . PHP_EOL . "Flags: ";
|
||||||
if (($args->command == null)) {
|
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 = new TelepyShell();
|
||||||
$newTelePyShell->cmdloop();
|
$newTelePyShell->cmdloop();
|
||||||
}
|
}
|
||||||
|
20
testing.php
20
testing.php
@ -2,21 +2,15 @@
|
|||||||
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
|
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'libpy2php');
|
||||||
require_once ('libpy2php.php');
|
require_once ('libpy2php.php');
|
||||||
require_once ('os.php');
|
require_once ('os.php');
|
||||||
try {
|
|
||||||
require_once ('configparser.php');
|
|
||||||
}
|
|
||||||
catch(ImportError $e) {
|
|
||||||
require_once ('ConfigParser.php');
|
|
||||||
}
|
|
||||||
require_once ('mtproto.php');
|
require_once ('mtproto.php');
|
||||||
$config = $configparser->ConfigParser();
|
$config = parse_ini_file('credentials', true);
|
||||||
if (!($config->read('credentials'))) {
|
if (!($config)) {
|
||||||
pyjslib_printnl('File \'credentials\' seems to not exist.');
|
pyjslib_printnl('File \'credentials\' seems to not exist.');
|
||||||
$exit(-1);
|
$exit(-1);
|
||||||
}
|
}
|
||||||
$ip = $config->get('App data', 'ip_address');
|
$ip = $config['App data']['ip_address'];
|
||||||
$port = $config->getint('App data', 'port');
|
$port = $config['App data']['port'];
|
||||||
$Session = mtproto::Session($ip, $port);
|
$Session = new Session($ip, $port);
|
||||||
Session::create_auth_key();
|
$Session->create_auth_key();
|
||||||
$future_salts = py2php_kwargs_function_call('Session::method_call', ['get_future_salts'], ["num" => 3]);
|
$future_salts = $Session->method_call('get_future_salts', 3);
|
||||||
pyjslib_printnl($future_salts);
|
pyjslib_printnl($future_salts);
|
||||||
|
Loading…
Reference in New Issue
Block a user