MadelineProto/telepy.php

34 lines
1.2 KiB
PHP
Raw Normal View History

2016-06-23 23:51:08 +02:00
<?php
2016-07-14 15:15:50 +02:00
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).DIRECTORY_SEPARATOR.'libpy2php');
require_once 'libpy2php.php';
require_once 'mtproto.php';
require_once 'classes/shell.php';
2016-06-24 23:47:10 +02:00
2016-06-26 14:53:16 +02:00
if (!debug_backtrace()) {
$clidata = [];
2016-07-14 15:15:50 +02:00
$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: ';
2016-06-26 14:53:16 +02:00
foreach (str_split($clidata['args']['flags']) as $flag) {
2016-07-14 15:15:50 +02:00
$clidata['help'] .= '-'.$flag.', ';
2016-06-26 14:53:16 +02:00
}
2016-07-14 15:15:50 +02:00
$clidata['help'] .= PHP_EOL.'Commands: ';
2016-06-26 14:53:16 +02:00
foreach ($clidata['args']['commands'] as $command) {
2016-07-14 15:15:50 +02:00
$clidata['help'] .= $command.', ';
2016-06-26 14:53:16 +02:00
}
2016-07-14 15:15:50 +02:00
$clidata['help'] .= PHP_EOL;
if (isset(getopt($clidata['args']['flags'])['h'])) {
die($clidata['help']);
2016-06-26 14:53:16 +02:00
}
if ($argc == 1) {
2016-06-24 23:47:10 +02:00
$newTelePyShell = new TelepyShell();
$newTelePyShell->cmdloop();
2016-06-23 23:51:08 +02:00
}
}