Skip to content

Commit

Permalink
edit installer
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirHkrg committed Jul 5, 2023
1 parent ba4075d commit e152fad
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 9 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ php bot serve
php bot serve --api-server
```

* start Bot OpenSwoole Server

```
php bot serve --openswoole
```
Or
```
php bot start:openswoole
```

* start Bot Api Server

```
Expand Down Expand Up @@ -97,6 +107,14 @@ php bot get:amphp
php bot remove:amphp
```

* OpenSwoole

```
php bot get:openswoole
php bot remove:openswoole
```

---

### Handler :
Expand Down
3 changes: 2 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Versions currently supported with security updates.
| Version | Supported |
|---------| ------------------ |
| 1.0.x | :x: |
| 1.1.x | :white_check_mark: |
| 1.1.x | :x: |
| 1.2.x | :white_check_mark: |
| 1.3.x | :white_check_mark: |

## Reporting a Vulnerability

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"vlucas/phpdotenv": "^5.5",
"symfony/process": "^6.3",
"bramus/ansi-php": "^3.1",
"ext-curl": "*",
"openswoole/core": "^22.1"
"ext-curl": "*"
}
}
22 changes: 16 additions & 6 deletions core/cli/action/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,24 @@ public function serve(): void
return;
}

$webServer = new Process(["php", "-S", "{$_ENV['SERVER_IP']}:{$_ENV['SERVER_PORT']}"]);
$webServer->setTimeout(108000);
$webServer->start();
if ($webServer->isStarted()) {
Logger::success("WebServer Started on {$_ENV['SERVER_IP']}:{$_ENV['SERVER_PORT']}");
if (isset($this->cmd[2]) && $this->cmd[2] === '--openswoole' || isset($this->cmd[3]) && $this->cmd[3] === '--openswoole'){
$null = (new Kernel())->checkEnvSet('OPENSWOOLE_IP', 'OPENSWOOLE_PORT');
if ($null !== []) {
Logger::status('ENV ERR', "Please set BOT_API_SERVER in .env file!", 'failed');
return;
}

Openswoole::connect();
}else{
$webServer = new Process(["php", "-S", "{$_ENV['SERVER_IP']}:{$_ENV['SERVER_PORT']}"]);
$webServer->setTimeout(108000);
$webServer->start();
if ($webServer->isStarted()) {
Logger::success("WebServer Started on {$_ENV['SERVER_IP']}:{$_ENV['SERVER_PORT']}");
}
}

if (isset($this->cmd[2]) && $this->cmd[2] === '--api-server') {
if (isset($this->cmd[2]) && $this->cmd[2] === '--api-server' || isset($this->cmd[3]) && $this->cmd[3] === '--api-server') {
$null = (new Kernel())->checkEnvSet('BOT_API_SERVER_DIR', 'API_ID', 'API_HASH');
if ($null !== []) {
Logger::title('ENV ERR');
Expand Down
5 changes: 5 additions & 0 deletions core/connect/amphp.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\Request;
use Amp\Promise;
use Bot\Core\Cli\Error\Logger;

class Amphp
{
Expand All @@ -14,6 +15,10 @@ class Amphp

public function __construct(string $url)
{
if (!file_exists('vendor/amphp')){
Logger::status('Failed', 'Please Install AMPHP!', 'failed', true);
}

$this->apiBaseUrl = $url;
$this->httpClient = HttpClientBuilder::buildDefault();
}
Expand Down
5 changes: 5 additions & 0 deletions core/connect/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

namespace Bot\Core\Connect;

use Bot\Core\Cli\Error\Logger;
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;

class Mysql {
public static function connect(): void
{
if (!file_exists('vendor/illuminate/database')){
Logger::status('Failed', 'Please Install Database Eloquent!', 'failed', true);
}

$capsule = new Capsule;
$capsule->addConnection([
'driver' => $_ENV['MYSQL_DRIVER'],
Expand Down
4 changes: 4 additions & 0 deletions core/connect/openswoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class Openswoole {
public static $openswoole;
public static function connect(): void
{
if (!file_exists('vendor/openswoole')){
Logger::status('Failed', 'Please Install Openswoole!', 'failed', true);
}

$server = new Server($_ENV['OPENSWOOLE_IP'], $_ENV['OPENSWOOLE_PORT']);

$server->on("start", function () {
Expand Down

0 comments on commit e152fad

Please sign in to comment.