From 585c32975be28128ad824498085ffb4efff12841 Mon Sep 17 00:00:00 2001 From: GianC-Dev Date: Fri, 7 Aug 2020 13:44:49 +0300 Subject: [PATCH] Update | Beta 1.0 --- .env | 2 +- .idea/Ourted.iml | 2 +- .idea/workspace.xml | 194 ++- Example.php | 54 + README.md | 101 +- example/Ourted.php | 128 +- example/composer.json | 5 - example/composer.lock | 1453 ----------------- example/scratch.php | 132 -- example/test.php | 54 + example/vendor/ourted/ourted/.idea/Ourted.iml | 12 - src/Bot.php | 107 +- src/Command/Dispatch.php | 7 +- src/Interfaces/Command.php | 2 +- src/Interfaces/EventListener.php | 132 +- src/State.php | 42 +- src/Utils/Functions.php | 2 +- 17 files changed, 647 insertions(+), 1782 deletions(-) create mode 100644 Example.php delete mode 100644 example/composer.json delete mode 100644 example/composer.lock delete mode 100644 example/scratch.php create mode 100644 example/test.php delete mode 100644 example/vendor/ourted/ourted/.idea/Ourted.iml diff --git a/.env b/.env index c13d8bc..f3f9b4c 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -BOT_TOKEN=NzQwNjQyNDAyODg4NDUwMTQw.Xyr-_Q.GuDhf7g7Ue_P9Lal0X8L9_kt4QE \ No newline at end of file +BOT_TOKEN=NzQwNjQyNDAyODg4NDUwMTQw.Xyr-_Q.qmCZP9S1rMAoqVE7eTuZSI-uQgA \ No newline at end of file diff --git a/.idea/Ourted.iml b/.idea/Ourted.iml index 591ae8e..d6d5c2f 100644 --- a/.idea/Ourted.iml +++ b/.idea/Ourted.iml @@ -2,7 +2,7 @@ - + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9c4dfa5..006cfa4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,20 +6,44 @@ + + + + + + + + + - + + + + + + + - - - - - - + + + + - + + + + + + + + + + + @@ -98,7 +122,7 @@ - + @@ -167,8 +191,24 @@ - + + + + + 1596747044571 + + + 1596747153619 + + @@ -177,13 +217,67 @@ + + + + + + + @@ -195,71 +289,97 @@ - + + + + + - - + + - + + + + + - + - - - + + - - - + + + - - - + + + - - + + + + + + + - + + + + + + - - - + + + - - - + + - + + + + + + + + + + - + + \ No newline at end of file diff --git a/Example.php b/Example.php new file mode 100644 index 0000000..c3ec093 --- /dev/null +++ b/Example.php @@ -0,0 +1,54 @@ +load(); + $this->token = $_ENV['BOT_TOKEN']; + parent::__construct($this->token); + $this->setBot(); + } + + public function setBot() + { + // Ready Event Listener + $this->addListener( + "EventListener" + ); + echo "Hello World\n"; + $this->run(); + } +} + +class EventListener extends \Ourted\Interfaces\EventListener +{ + + public function onMessageCreate($json, $bot) + { + /* + Content: $json->content + Author Username: $json->author->username + Author Discriminator: $json->author->discriminator + Author ID: $json->author->id + */ + + if(isset($json->author->bot)){ + return; + } + $this->func->sendMessage("Message Sended! By: <@{$json->author->id}>, Content: {$json->content}", $json->channel_id); + } + + +} + +new Ourted(); diff --git a/README.md b/README.md index 8d7a5c1..64095ce 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,106 @@ ## Ourted: A Discord bot in PHP -The `Ourted` library provides a long-running bot process written in PHP. +The `Ourted` library provides a running bot process written in PHP. ### Installation ``` -git clone git@github.com:GianC-Dev/Ourret.git -composer install +composer require ourted/ourted ``` -Copy the `.env.dist` file to `.env` and configure it with your bot's token. +Edit ``.env`` and configure bot token -### Usage +### Examples +Without Event Listener +```php +load(); + $this->token = $_ENV['BOT_TOKEN']; + parent::__construct($this->token); + $this->setBot(); + } + + public function setBot() + { + echo "Hello World\n"; + $this->run(); + } +} + +new Ourted(); +?> +``` -When the Discord API sends a new event on the websocket, your bot will receive the message with a `t` value in the JSON. This is the "dispatch type". Handlers for these can be added to the `bin/dbot.php` script like this for a `GUILD_CREATE`: +With Event Listener ```php addDispatch('GUILD_CREATE', function($json) { - echo 'guild create!!!!'."\n"; +require_once __DIR__ . '\\..\\vendor\\autoload.php'; + +use Dotenv\Dotenv; +use Ourted\Bot; + +class Ourted extends Bot +{ + + public $token; + + public function __construct() + { + $dotenv = Dotenv::createImmutable(__DIR__ . '/../'); + $dotenv->load(); + $this->token = $_ENV['BOT_TOKEN']; + parent::__construct($this->token); + $this->setBot(); + } + + public function setBot() + { + // Ready Event Listener + $this->addListener( + "EventListener" + ); + echo "Hello World\n"; + $this->run(); + } +} + +class EventListener extends \Ourted\Interfaces\EventListener +{ + + public function onMessageCreate($json, $bot) + { + /* + Content: $json->content + Author Username: $json->author->username + Author Discriminator: $json->author->discriminator + Author ID: $json->author->id + */ + + if(isset($json->author->bot)){ + return; + } + $this->func->sendMessage("Message Sended! By: <@{$json->author->id}>, Content: {$json->content}", $json->channel_id); + } + - return 'test'; -}); +} -$bot->init(); +new Ourted(); ?> ``` diff --git a/example/Ourted.php b/example/Ourted.php index 797cbf0..7a9c3c6 100644 --- a/example/Ourted.php +++ b/example/Ourted.php @@ -1,134 +1,170 @@ token = "NzQwNjQyNDAyODg4NDUwMTQw.Xyr-_Q.SbxDdHfUB4_F1cQgBK5-Z6hHbpg"; - parent::init($this->token); + $dotenv = Dotenv::createImmutable(__DIR__ . '/../'); + $dotenv->load(); + $this->token = $_ENV['BOT_TOKEN']; + parent::__construct($this->token); $this->setBot(); } public function setBot() { - $func = parent::getFunctions(); - $settings = parent::getSettings(); - + $func = $this->functions; + $settings = $this->settings; // Ready Event Listener - new EventListener($this->getBot()); - - - - + $this->addListener( + "EventListener" + ); // Send Message $func->sendMessage("Test", "701838704095920198"); - - // Change Bot Username $settings->change_bot_username("test_bot"); - - /* Embed Start */ $embed_array = array(); $embed_string = ""; - foreach (json_decode($func->get_guilds_properties()) as $key => $server){ + foreach (json_decode($func->get_guilds_properties()) as $key => $server) { $embed_array[] = array("name" => "Server of {$key}.", "value" => $server->name); $embed_string .= " Server of {$key}: {$server->name} "; } - $func->sendMessage("Family: ".$embed_string, "701838704095920198"); + + + // Without Embed + $func->sendMessage("Family: " . $embed_string, "701838704095920198"); // With Single Array $embed = new Embed("Family", parent::getBot(), "701838704095920198", "Family"); - $embed->add_field( $embed_array); + $embed->add_field($embed_array); $embed->send_embed(); // With Multiple Array $embed = new Embed("Family", parent::getBot(), "701838704095920198", "Family"); - $embed->add_field(array("name" => "ege", "value" => "FF"), array("name" => "eggge", "value" => "FgggF")); + $embed->add_field(array("name" => "Field 1", "value" => "Field 1 Value"), array("name" => "Field 2", "value" => "Field 2 Value")); $embed->send_embed(); - - - /* Embed End */ + // Change Error Reporting $settings->change_error_reporting(0); $settings->change_error_reporting(false); - parent::run(); } } + class EventListener extends \Ourted\Interfaces\EventListener { - public function __construct($bot) +# Guild + public function onGuildJoin($json, $bot) { - parent::__construct($bot); + } - public function onGuildCreate($json) + public function onGuildUpdate($json, $bot) { - // TODO: Implement onGuildCreate() method. + } - public function onGuildMemberUpdate($json) + public function onGuildDelete($json, $bot) { - // TODO: Implement onGuildMemberUpdate() method. + } + + # Member + public function onGuildMemberAdd($json, $bot) + { } - public function onGuildUpdate($json) + public function onGuildMemberUpdate($json, $bot) { - // TODO: Implement onGuildUpdate() method. + } - public function onGuildDelete($json) + public function onGuildMemberDelete($json, $bot) { - // TODO: Implement onGuildDelete() method. + } - public function onGuildRoleCreate($json) + # Channel + public function onChannelCreate($json, $bot) { - // TODO: Implement onGuildRoleCreate() method. + } - public function onGuildRoleUpdate($json) + public function onChannelUpdate($json, $bot) { - // TODO: Implement onGuildRoleUpdate() method. + } - public function onMessageCreate($json) + public function onChannelDelete($json, $bot) { - /* Command Start */ - if($json->d->content == "??ping"){ - $this->func->sendMessage("Pong!", "701838704095920198"); - } + } + + public function onChannelPinsUpdate($json, $bot) + { + + } + + + + + + + # Role + public function onGuildRoleCreate($json, $bot) + { + + } + + public function onGuildRoleUpdate($json, $bot) + { - /* Command End */ } -} + public function onGuildRoleDelete($json, $bot) + { + + } + + # Message + public function onMessageCreate($json, $bot) + { + + } + + # Bot + public function onReady($json, $bot) + { + + } + + +} -new bot_(); \ No newline at end of file +new Ourted(); \ No newline at end of file diff --git a/example/composer.json b/example/composer.json deleted file mode 100644 index 0636654..0000000 --- a/example/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "ourted/ourted": "1.3" - } -} \ No newline at end of file diff --git a/example/composer.lock b/example/composer.lock deleted file mode 100644 index 0e44b81..0000000 --- a/example/composer.lock +++ /dev/null @@ -1,1453 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "b3892f285438b8e46089dfd40d5ae133", - "packages": [ - { - "name": "evenement/evenement", - "version": "v3.0.1", - "source": { - "type": "git", - "url": "https://github.com/igorw/evenement.git", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Evenement": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "Événement is a very simple event dispatching library for PHP", - "keywords": [ - "event-dispatcher", - "event-emitter" - ], - "support": { - "issues": "https://github.com/igorw/evenement/issues", - "source": "https://github.com/igorw/evenement/tree/master" - }, - "time": "2017-07-23T21:35:13+00:00" - }, - { - "name": "graham-campbell/result-type", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/7e279d2cd5d7fbb156ce46daada972355cea27bb", - "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb", - "shasum": "" - }, - "require": { - "php": "^7.0|^8.0", - "phpoption/phpoption": "^1.7.3" - }, - "require-dev": { - "phpunit/phpunit": "^6.5|^7.5|^8.5|^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "GrahamCampbell\\ResultType\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "graham@alt-three.com" - } - ], - "description": "An Implementation Of The Result Type", - "keywords": [ - "Graham Campbell", - "GrahamCampbell", - "Result Type", - "Result-Type", - "result" - ], - "support": { - "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", - "type": "tidelift" - } - ], - "time": "2020-04-13T13:17:36+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", - "reference": "239400de7a173fe9901b9ac7c06497751f00727a", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" - }, - "suggest": { - "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.6.1" - }, - "time": "2019-07-01T23:21:34+00:00" - }, - { - "name": "ourted/ourted", - "version": "1.3", - "source": { - "type": "git", - "url": "https://github.com/GianC-Dev/Ourted.git", - "reference": "d2b01511a4b53e58f1ec92c9da73d6b03b63f617" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/GianC-Dev/Ourted/zipball/d2b01511a4b53e58f1ec92c9da73d6b03b63f617", - "reference": "d2b01511a4b53e58f1ec92c9da73d6b03b63f617", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "php": "7.*", - "ratchet/pawl": "*", - "react/event-loop": "*", - "react/react": "*", - "vlucas/phpdotenv": "*" - }, - "type": "library", - "autoload": { - "psr-4": { - "Ourted\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-3.0-or-later" - ], - "authors": [ - { - "name": "GianC-Dev", - "email": "gianegekck@gmail.com" - } - ], - "description": "The Ourted library provides a discord bot process written in PHP.", - "support": { - "issues": "https://github.com/GianC-Dev/Ourted/issues", - "source": "https://github.com/GianC-Dev/Ourted/tree/1.3" - }, - "time": "2020-08-06T20:34:40+00:00" - }, - { - "name": "phpoption/phpoption", - "version": "1.7.5", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/994ecccd8f3283ecf5ac33254543eb0ac946d525", - "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525", - "shasum": "" - }, - "require": { - "php": "^5.5.9 || ^7.0 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.7-dev" - } - }, - "autoload": { - "psr-4": { - "PhpOption\\": "src/PhpOption/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "support": { - "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.7.5" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], - "time": "2020-07-20T17:29:33+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/master" - }, - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "ratchet/pawl", - "version": "v0.3.5", - "source": { - "type": "git", - "url": "https://github.com/ratchetphp/Pawl.git", - "reference": "89ec703c76dc893484a2a0ed44b48a37d445abd5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ratchetphp/Pawl/zipball/89ec703c76dc893484a2a0ed44b48a37d445abd5", - "reference": "89ec703c76dc893484a2a0ed44b48a37d445abd5", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0", - "php": ">=5.4", - "ratchet/rfc6455": "^0.3", - "react/socket": "^1.0 || ^0.8 || ^0.7" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "suggest": { - "reactivex/rxphp": "~2.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Ratchet\\Client\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Asynchronous WebSocket client", - "keywords": [ - "Ratchet", - "async", - "client", - "websocket", - "websocket client" - ], - "support": { - "issues": "https://github.com/ratchetphp/Pawl/issues", - "source": "https://github.com/ratchetphp/Pawl/tree/master" - }, - "time": "2020-07-17T15:32:47+00:00" - }, - { - "name": "ratchet/rfc6455", - "version": "v0.3", - "source": { - "type": "git", - "url": "https://github.com/ratchetphp/RFC6455.git", - "reference": "c8651c7938651c2d55f5d8c2422ac5e57a183341" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ratchetphp/RFC6455/zipball/c8651c7938651c2d55f5d8c2422ac5e57a183341", - "reference": "c8651c7938651c2d55f5d8c2422ac5e57a183341", - "shasum": "" - }, - "require": { - "guzzlehttp/psr7": "^1.0", - "php": ">=5.4.2" - }, - "require-dev": { - "phpunit/phpunit": "5.7.*", - "react/socket": "^1.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Ratchet\\RFC6455\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "role": "Developer" - }, - { - "name": "Matt Bonneau", - "role": "Developer" - } - ], - "description": "RFC6455 WebSocket protocol handler", - "homepage": "http://socketo.me", - "keywords": [ - "WebSockets", - "rfc6455", - "websocket" - ], - "support": { - "chat": "https://gitter.im/reactphp/reactphp", - "issues": "https://github.com/ratchetphp/RFC6455/issues", - "source": "https://github.com/ratchetphp/RFC6455/tree/v0.3" - }, - "time": "2020-05-15T18:31:24+00:00" - }, - { - "name": "react/cache", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/cache.git", - "reference": "aa10d63a1b40a36a486bdf527f28bac607ee6466" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/cache/zipball/aa10d63a1b40a36a486bdf527f28bac607ee6466", - "reference": "aa10d63a1b40a36a486bdf527f28bac607ee6466", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "react/promise": "~2.0|~1.1" - }, - "require-dev": { - "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Async, Promise-based cache interface for ReactPHP", - "keywords": [ - "cache", - "caching", - "promise", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/cache/issues", - "source": "https://github.com/reactphp/cache/tree/v1.0.0" - }, - "time": "2019-07-11T13:45:28+00:00" - }, - { - "name": "react/dns", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/dns.git", - "reference": "89d83794e959ef3e0f1ab792f070b0157de1abf2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/dns/zipball/89d83794e959ef3e0f1ab792f070b0157de1abf2", - "reference": "89d83794e959ef3e0f1ab792f070b0157de1abf2", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "react/cache": "^1.0 || ^0.6 || ^0.5", - "react/event-loop": "^1.0 || ^0.5", - "react/promise": "^3.0 || ^2.7 || ^1.2.1", - "react/promise-timer": "^1.2" - }, - "require-dev": { - "clue/block-react": "^1.2", - "phpunit/phpunit": "^9.0 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Dns\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Async DNS resolver for ReactPHP", - "keywords": [ - "async", - "dns", - "dns-resolver", - "reactphp" - ], - "support": { - "issues": "https://github.com/reactphp/dns/issues", - "source": "https://github.com/reactphp/dns/tree/v1.3.0" - }, - "time": "2020-07-10T12:12:50+00:00" - }, - { - "name": "react/event-loop", - "version": "v1.1.1", - "source": { - "type": "git", - "url": "https://github.com/reactphp/event-loop.git", - "reference": "6d24de090cd59cfc830263cfba965be77b563c13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/6d24de090cd59cfc830263cfba965be77b563c13", - "reference": "6d24de090cd59cfc830263cfba965be77b563c13", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35" - }, - "suggest": { - "ext-event": "~1.0 for ExtEventLoop", - "ext-pcntl": "For signal handling support when using the StreamSelectLoop", - "ext-uv": "* for ExtUvLoop" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\EventLoop\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", - "keywords": [ - "asynchronous", - "event-loop" - ], - "support": { - "issues": "https://github.com/reactphp/event-loop/issues", - "source": "https://github.com/reactphp/event-loop/tree/v1.1.1" - }, - "time": "2020-01-01T18:39:52+00:00" - }, - { - "name": "react/http", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/http.git", - "reference": "865694453c95122f8972b9ed7961efb3c517fc5e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/http/zipball/865694453c95122f8972b9ed7961efb3c517fc5e", - "reference": "865694453c95122f8972b9ed7961efb3c517fc5e", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.0", - "psr/http-message": "^1.0", - "react/event-loop": "^1.0 || ^0.5", - "react/promise": "^2.3 || ^1.2.1", - "react/promise-stream": "^1.1", - "react/socket": "^1.1", - "react/stream": "^1.0 || ^0.7.5", - "ringcentral/psr7": "^1.2" - }, - "require-dev": { - "clue/block-react": "^1.1", - "clue/http-proxy-react": "^1.3", - "clue/reactphp-ssh-proxy": "^1.0", - "clue/socks-react": "^1.0", - "phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Http\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering", - "homepage": "https://clue.engineering/" - }, - { - "name": "Cees-Jan Kiewiet", - "email": "reactphp@ceesjankiewiet.nl", - "homepage": "https://wyrihaximus.net/" - }, - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com", - "homepage": "https://sorgalla.com/" - }, - { - "name": "Chris Boden", - "email": "cboden@gmail.com", - "homepage": "https://cboden.dev/" - } - ], - "description": "Event-driven, streaming HTTP client and server implementation for ReactPHP", - "keywords": [ - "async", - "client", - "event-driven", - "http", - "http client", - "http server", - "https", - "psr-7", - "reactphp", - "server", - "streaming" - ], - "support": { - "issues": "https://github.com/reactphp/http/issues", - "source": "https://github.com/reactphp/http/tree/v1.0.0" - }, - "time": "2020-07-11T13:29:43+00:00" - }, - { - "name": "react/promise", - "version": "v2.8.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/f3cff96a19736714524ca0dd1d4130de73dbbbc4", - "reference": "f3cff96a19736714524ca0dd1d4130de73dbbbc4", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^7.0 || ^6.5 || ^5.7 || ^4.8.36" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "keywords": [ - "promise", - "promises" - ], - "support": { - "issues": "https://github.com/reactphp/promise/issues", - "source": "https://github.com/reactphp/promise/tree/v2.8.0" - }, - "time": "2020-05-12T15:16:56+00:00" - }, - { - "name": "react/promise-stream", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise-stream.git", - "reference": "6384d8b76cf7dcc44b0bf3343fb2b2928412d1fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise-stream/zipball/6384d8b76cf7dcc44b0bf3343fb2b2928412d1fe", - "reference": "6384d8b76cf7dcc44b0bf3343fb2b2928412d1fe", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "react/promise": "^2.1 || ^1.2", - "react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.6" - }, - "require-dev": { - "clue/block-react": "^1.0", - "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35", - "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3", - "react/promise-timer": "^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Promise\\Stream\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@lueck.tv" - } - ], - "description": "The missing link between Promise-land and Stream-land for ReactPHP", - "homepage": "https://github.com/reactphp/promise-stream", - "keywords": [ - "Buffer", - "async", - "promise", - "reactphp", - "stream", - "unwrap" - ], - "support": { - "issues": "https://github.com/reactphp/promise-stream/issues", - "source": "https://github.com/reactphp/promise-stream/tree/v1.2.0" - }, - "time": "2019-07-03T12:29:10+00:00" - }, - { - "name": "react/promise-timer", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise-timer.git", - "reference": "daee9baf6ef30c43ea4c86399f828bb5f558f6e6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/daee9baf6ef30c43ea4c86399f828bb5f558f6e6", - "reference": "daee9baf6ef30c43ea4c86399f828bb5f558f6e6", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5", - "react/promise": "^3.0 || ^2.7.0 || ^1.2.1" - }, - "require-dev": { - "phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Promise\\Timer\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@lueck.tv" - } - ], - "description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.", - "homepage": "https://github.com/reactphp/promise-timer", - "keywords": [ - "async", - "event-loop", - "promise", - "reactphp", - "timeout", - "timer" - ], - "support": { - "issues": "https://github.com/reactphp/promise-timer/issues", - "source": "https://github.com/reactphp/promise-timer/tree/v1.6.0" - }, - "time": "2020-07-10T12:18:06+00:00" - }, - { - "name": "react/react", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/reactphp.git", - "reference": "527e5cc6c88c85858b39f1a58e32f3173f5233c0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/reactphp/zipball/527e5cc6c88c85858b39f1a58e32f3173f5233c0", - "reference": "527e5cc6c88c85858b39f1a58e32f3173f5233c0", - "shasum": "" - }, - "require": { - "php": ">=5.3.8", - "react/cache": "^1.0", - "react/dns": "^1.3", - "react/event-loop": "^1.0", - "react/http": "^1.0", - "react/promise": "^2.1 || ^1.2", - "react/promise-stream": "^1.1.1", - "react/promise-timer": "^1.6", - "react/socket": "^1.4", - "react/stream": "^1.0" - }, - "require-dev": { - "clue/block-react": "^1.1", - "clue/stream-filter": "^1.3", - "phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "ReactPHP: Event-driven, non-blocking I/O with PHP.", - "homepage": "https://reactphp.org/", - "keywords": [ - "asynchronous", - "reactor", - "reactphp" - ], - "support": { - "chat": "https://gitter.im/reactphp/reactphp", - "issues": "https://github.com/reactphp/reactphp/issues", - "source": "https://github.com/reactphp/reactphp/tree/v1.1.0" - }, - "time": "2020-07-11T16:33:07+00:00" - }, - { - "name": "react/socket", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/socket.git", - "reference": "842dcd71df86671ee9491734035b3d2cf4a80ece" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/socket/zipball/842dcd71df86671ee9491734035b3d2cf4a80ece", - "reference": "842dcd71df86671ee9491734035b3d2cf4a80ece", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.0", - "react/dns": "^1.1", - "react/event-loop": "^1.0 || ^0.5", - "react/promise": "^2.6.0 || ^1.2.1", - "react/promise-timer": "^1.4.0", - "react/stream": "^1.1" - }, - "require-dev": { - "clue/block-react": "^1.2", - "phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35", - "react/promise-stream": "^1.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Socket\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", - "keywords": [ - "Connection", - "Socket", - "async", - "reactphp", - "stream" - ], - "support": { - "issues": "https://github.com/reactphp/socket/issues", - "source": "https://github.com/reactphp/socket/tree/v1.5.0" - }, - "time": "2020-07-01T12:50:00+00:00" - }, - { - "name": "react/stream", - "version": "v1.1.1", - "source": { - "type": "git", - "url": "https://github.com/reactphp/stream.git", - "reference": "7c02b510ee3f582c810aeccd3a197b9c2f52ff1a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/7c02b510ee3f582c810aeccd3a197b9c2f52ff1a", - "reference": "7c02b510ee3f582c810aeccd3a197b9c2f52ff1a", - "shasum": "" - }, - "require": { - "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "php": ">=5.3.8", - "react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5" - }, - "require-dev": { - "clue/stream-filter": "~1.2", - "phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Stream\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", - "keywords": [ - "event-driven", - "io", - "non-blocking", - "pipe", - "reactphp", - "readable", - "stream", - "writable" - ], - "support": { - "issues": "https://github.com/reactphp/stream/issues", - "source": "https://github.com/reactphp/stream/tree/v1.1.1" - }, - "time": "2020-05-04T10:17:57+00:00" - }, - { - "name": "ringcentral/psr7", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/ringcentral/psr7.git", - "reference": "360faaec4b563958b673fb52bbe94e37f14bc686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ringcentral/psr7/zipball/360faaec4b563958b673fb52bbe94e37f14bc686", - "reference": "360faaec4b563958b673fb52bbe94e37f14bc686", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "RingCentral\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "PSR-7 message implementation", - "keywords": [ - "http", - "message", - "stream", - "uri" - ], - "support": { - "source": "https://github.com/ringcentral/psr7/tree/master" - }, - "time": "2018-05-29T20:21:04+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.18.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", - "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.18-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.18.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-07-14T12:35:20+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.18.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", - "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.18-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.18.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-07-14T12:35:20+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.18.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981", - "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981", - "shasum": "" - }, - "require": { - "php": ">=7.0.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.18-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/master" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-07-14T12:35:20+00:00" - }, - { - "name": "vlucas/phpdotenv", - "version": "v5.1.0", - "source": { - "type": "git", - "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "448c76d7a9e30c341ff5bc367a923af74ae18467" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/448c76d7a9e30c341ff5bc367a923af74ae18467", - "reference": "448c76d7a9e30c341ff5bc367a923af74ae18467", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "graham-campbell/result-type": "^1.0.1", - "php": "^7.1.3 || ^8.0", - "phpoption/phpoption": "^1.7.4", - "symfony/polyfill-ctype": "^1.17", - "symfony/polyfill-mbstring": "^1.17", - "symfony/polyfill-php80": "^1.17" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "ext-filter": "*", - "phpunit/phpunit": "^7.5.20 || ^8.5.2 || ^9.0" - }, - "suggest": { - "ext-filter": "Required to use the boolean validator." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Dotenv\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "homepage": "https://gjcampbell.co.uk/" - }, - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://vancelucas.com/" - } - ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", - "keywords": [ - "dotenv", - "env", - "environment" - ], - "support": { - "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/master" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], - "time": "2020-07-14T19:26:25+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.0.0" -} diff --git a/example/scratch.php b/example/scratch.php deleted file mode 100644 index c201106..0000000 --- a/example/scratch.php +++ /dev/null @@ -1,132 +0,0 @@ -token = "NzQwNjQyNDAyODg4NDUwMTQw.Xyr-_Q.Zkc2FWA5xUB3EtQqprwytSIzQss"; - parent::init($this->token); - $this->setBot(); - } - - public function setBot() - { - - $func = parent::getFunctions(); - $settings = parent::getSettings(); - - - // Ready Event Listener - new EventListener($this->getBot()); - - - - // Send Message - $func->sendMessage("Test", "701838704095920198"); - - - - - // Change Bot Username - $settings->change_bot_username("test_bot"); - - - - - /* Embed Start */ - $embed_array = array(); - $embed_string = ""; - foreach (json_decode($func->get_guilds_properties()) as $key => $server){ - $embed_array[] = array("name" => "Server of {$key}.", "value" => $server->name); - $embed_string .= " Server of {$key}: {$server->name} "; - } - $func->sendMessage("Family: ".$embed_string, "701838704095920198"); - - - // With Single Array - $embed = new Embed("Family", parent::getBot(), "701838704095920198", "Family"); - $embed->add_field( $embed_array); - $embed->send_embed(); - - - // With Multiple Array - $embed = new Embed("Family", parent::getBot(), "701838704095920198", "Family"); - $embed->add_field(array("name" => "ege", "value" => "FF"), array("name" => "eggge", "value" => "FgggF")); - $embed->send_embed(); - - - - - /* Embed End */ - - // Change Error Reporting - $settings->change_error_reporting(0); - $settings->change_error_reporting(false); - - - - parent::run(); - - } -} -class EventListener extends \Ourted\Interfaces\EventListener -{ - - public function __construct($bot) - { - parent::__construct($bot); - } - - public function onGuildCreate($json) - { - // TODO: Implement onGuildCreate() method. - } - - public function onGuildMemberUpdate($json) - { - // TODO: Implement onGuildMemberUpdate() method. - - - } - - public function onGuildUpdate($json) - { - // TODO: Implement onGuildUpdate() method. - } - - public function onGuildDelete($json) - { - // TODO: Implement onGuildDelete() method. - } - - public function onGuildRoleCreate($json) - { - // TODO: Implement onGuildRoleCreate() method. - } - - public function onGuildRoleUpdate($json) - { - // TODO: Implement onGuildRoleUpdate() method. - } - - public function onMessageCreate($json) - { - /* Command Start */ - - if($json->d->content == "??ping"){ - $this->func->sendMessage("Pong!", "701838704095920198"); - } - - /* Command End */ - } -} - - - -new bot_(); \ No newline at end of file diff --git a/example/test.php b/example/test.php new file mode 100644 index 0000000..6826bf9 --- /dev/null +++ b/example/test.php @@ -0,0 +1,54 @@ +load(); + $this->token = $_ENV['BOT_TOKEN']; + parent::__construct($this->token); + $this->setBot(); + } + + public function setBot() + { + // Ready Event Listener + $this->addListener( + "EventListener" + ); + echo "Hello World\n"; + $this->run(); + } +} + +class EventListener extends \Ourted\Interfaces\EventListener +{ + + public function onMessageCreate($json, $bot) + { + /* + Content: $json->content + Author Username: $json->author->username + Author Discriminator: $json->author->discriminator + + */ + + if(isset($json->author->bot)){ + return; + } + $this->func->sendMessage("Message Sended! By: <@{$json->author->id}>, Content: {$json->content}", $json->channel_id); + } + + +} + +new Ourted(); diff --git a/example/vendor/ourted/ourted/.idea/Ourted.iml b/example/vendor/ourted/ourted/.idea/Ourted.iml deleted file mode 100644 index 90a7d0e..0000000 --- a/example/vendor/ourted/ourted/.idea/Ourted.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Bot.php b/src/Bot.php index ac539df..04416f8 100644 --- a/src/Bot.php +++ b/src/Bot.php @@ -1,7 +1,6 @@ dispatch[$type] = $callback; + $this->dispatch[$type][$type] = $callback; } - /** - * Init the bot and set up the loop/actions for the WebSocket + * Set Bot * * @param string $botToken Current bot token * @param string $wssUrl WSS URL [optional] */ - public function init($botToken, $wssUrl = null) + + public function __construct($botToken, $wssUrl = null) { if ($wssUrl !== null) { $this->wssUrl = $wssUrl; } $this->token = $botToken; - + $this->functions = new Functions($this); + $this->settings = new Settings($this); $this->loop = Factory::create(); + $this->init(); + } + + /** + * Add a new dispatch handler + * + * @param string $listener + */ + public function addListener($listener) + { + $this->listeners[] = $listener; + new $listener($this->getBot()); + } + + + /** + * Init the bot and set up the loop/actions for the WebSocket + */ + public function init() + { $reactConnector = new \React\Socket\Connector($this->loop); $connector = new Connector($this->loop, $reactConnector); $connector($this->wssUrl)->then(function (WebSocket $conn) { + $this->connection = $conn; + $state = new State($conn, $this->loop, $this->token); + $state->addDispatch($this->dispatch); + $conn->on('message', function (MessageInterface $msg) use ($conn, $state) { + $json = json_decode($msg); + $state->action($json, $this->loop); + }); - $state = new State($conn, $this->token, $this->loop); - $state->addDispatch($this->dispatch); - - $conn->on('message', function (MessageInterface $msg) use ($conn, $state) { - $json = json_decode($msg); - $state->action($json, $this->loop); - }); - - $conn->on('close', function ($code = null, $reason = null) { - echo "Connection closed ({$code} - {$reason})\n"; - die(); - }); - }, function (Exception $e) { - echo "Could not connect: {$e->getMessage()}\n"; - $this->stop(); + $conn->on('close', function ($code = null, $reason = null) { + echo "Connection closed ({$code} - {$reason})\n"; + die(); }); + }, function (Exception $e) { + echo "Could not connect: {$e->getMessage()}\n"; + $this->stop(); + }); return null; } - public function getFunctions(){ - return new Functions($this); - } - - public function getSettings(){ - return new Settings($this); - } - public function run() { $this->loop->run(); } - public function stop(){ + public function stop() + { $this->loop->stop(); } - /** * Get Connection * @@ -114,14 +148,7 @@ public function stop(){ */ public function getConnection() { - $loop = Factory::create(); - $reactConnector = new \React\Socket\Connector($loop); - $connector = new Connector($loop, $reactConnector); - - $connector($this->wssUrl)->then(function (WebSocket $conn) { - return $conn; - }); - return null; + return $this->connection; } public function getToken() diff --git a/src/Command/Dispatch.php b/src/Command/Dispatch.php index 990f785..c3643d1 100644 --- a/src/Command/Dispatch.php +++ b/src/Command/Dispatch.php @@ -13,16 +13,11 @@ public function execute($json) $type = $json->t; \Ourted\State::log('Dispatch type: '.$type); - - // Once we get our first dispatch, be sure we're sending a heartbeat $this->getLoop()->addPeriodicTimer($bot->getInterval(), function() use ($bot){ - // \Ourted\State::log('Execute: HELLO'); $command = new \Ourted\Command\Heartbeat($bot, $loop); $command->execute(null); }); - // Dispatch the event - $result = $bot->dispatch($type, $json); - //var_export($result) ?? null; + $bot->dispatch($type, $json); } } diff --git a/src/Interfaces/Command.php b/src/Interfaces/Command.php index ce07cbd..e11be95 100644 --- a/src/Interfaces/Command.php +++ b/src/Interfaces/Command.php @@ -24,7 +24,7 @@ abstract class Command * Init the instance and set the bot and loop instance * * @param Bot $bot Bot instance - * @param EventLoop\ $loop EventLoop instance + * @param EventLoop\ExtEventLoop $loop EventLoop instance */ public function __construct(&$bot, &$loop) { diff --git a/src/Interfaces/EventListener.php b/src/Interfaces/EventListener.php index d4a7c57..58ab0f5 100644 --- a/src/Interfaces/EventListener.php +++ b/src/Interfaces/EventListener.php @@ -5,7 +5,7 @@ use Ourted\Bot; use Ourted\Utils\Functions; -abstract class EventListener +class EventListener { /** * Bot @@ -37,40 +37,140 @@ public function __construct($bot) { $this->bot = $bot; $this->token = $bot->getToken(); - $this->func = $bot->getFunctions(); + $this->func = $bot->functions; $bot->addDispatch('GUILD_CREATE', function ($json) { - $this->onGuildCreate($json); + $this->onGuildJoin($json->d, $this->bot); + }); + $bot->addDispatch('GUILD_MEMBER_ADD', function ($json) { + $this->onGuildMemberAdd($json->d, $this->bot); }); $bot->addDispatch('GUILD_MEMBER_UPDATE', function ($json) { - $this->onGuildMemberUpdate($json); + $this->onGuildMemberUpdate($json->d, $this->bot); + }); + $bot->addDispatch('GUILD_MEMBER_DELETE', function ($json) { + $this->onGuildMemberDelete($json->d, $this->bot); }); $bot->addDispatch('GUILD_UPDATE', function ($json) { - $this->onGuildUpdate($json); + $this->onGuildDelete($json->d, $this->bot); }); $bot->addDispatch('GUILD_DELETE', function ($json) { - $this->onGuildUpdate($json); + $this->onGuildUpdate($json->d, $this->bot); }); $bot->addDispatch('GUILD_ROLE_CREATE', function ($json) { - $this->onGuildRoleCreate($json); + $this->onGuildRoleCreate($json->d, $this->bot); }); $bot->addDispatch('GUILD_ROLE_UPDATE', function ($json) { - $this->onGuildRoleUpdate($json); + $this->onGuildRoleUpdate($json->d, $this->bot); + }); + $bot->addDispatch('GUILD_ROLE_DELETE', function ($json) { + $this->onGuildRoleDelete($json->d, $this->bot); }); $bot->addDispatch('MESSAGE_CREATE', function ($json) { - $this->onMessageCreate($json); + $this->onMessageCreate($json->d, $this->bot); + }); + $bot->addDispatch('CHANNEL_CREATE', function ($json) { + $this->onChannelCreate($json->d, $this->bot); + }); + $bot->addDispatch('CHANNEL_UPDATE', function ($json) { + $this->onChannelUpdate($json->d, $this->bot); + }); + $bot->addDispatch('CHANNEL_DELETE', function ($json) { + $this->onChannelDelete($json->d, $this->bot); + }); + $bot->addDispatch('CHANNEL_PINS_UPDATE', function ($json) { + $this->onChannelPinsUpdate($json->d, $this->bot); + }); + + $bot->addDispatch('READY', function ($json) { + $this->onReady($json->d, $this->bot); }); } - public abstract function onGuildCreate($json); - public abstract function onGuildMemberUpdate($json); - public abstract function onGuildUpdate($json); - public abstract function onGuildDelete($json); - public abstract function onGuildRoleCreate($json); - public abstract function onGuildRoleUpdate($json); - public abstract function onMessageCreate($json); + # Guild + public function onGuildJoin($json, $bot) + { + + } + + public function onGuildUpdate($json, $bot) + { + + } + + public function onGuildDelete($json, $bot) + { + + } + + # Member + public function onGuildMemberAdd($json, $bot) + { + + } + + public function onGuildMemberUpdate($json, $bot) + { + + } + + public function onGuildMemberDelete($json, $bot) + { + + } + + # Channel + public function onChannelCreate($json, $bot) + { + + } + + public function onChannelUpdate($json, $bot) + { + + } + + public function onChannelDelete($json, $bot) + { + + } + + public function onChannelPinsUpdate($json, $bot) + { + + } + + # Role + public function onGuildRoleCreate($json, $bot) + { + + } + + public function onGuildRoleUpdate($json, $bot) + { + + } + + public function onGuildRoleDelete($json, $bot) + { + + } + + # Message + public function onMessageCreate($json, $bot) + { + + } + + # Bot + public function onReady($json, $bot) + { + + } + + } diff --git a/src/State.php b/src/State.php index a2c463a..066405d 100644 --- a/src/State.php +++ b/src/State.php @@ -2,7 +2,10 @@ namespace Ourted; +use Closure; +use Ourted\Command\Identify; use Ratchet\Client\WebSocket; +use React\EventLoop\ExtEventLoop; class State { @@ -20,10 +23,16 @@ class State /** * Loop instance - * @var \React\EventLoop + * @var ExtEventLoop */ protected $loop; + /** + * Loop instance + * @var Bot + */ + protected $bot; + /** * Default heartbeat interval * @var integer @@ -66,10 +75,10 @@ class State * Init the State handler and set the connection, token and loop properties * * @param WebSocket $conn Connection instance - * @param string $token Bot token (from API) - * @param \React\EventLoop $loop Loop instance + * @param ExtEventLoop $loop Loop instance + * @param mixed $token Current Bot Token */ - public function __construct($conn, $token, $loop) + public function __construct($conn, $loop, $token) { $this->connection = $conn; $this->token = $token; @@ -109,7 +118,7 @@ public function getToken() /** * Get the current event loop * - * @return \React\EventLoop instance + * @return ExtEventLoop instance */ public function getLoop() { @@ -160,7 +169,8 @@ public function authorize() { $loop = $this->getLoop(); - $command = new \Ourted\Command\Identify($this, $loop); + /** @noinspection PhpParamsInspection */ + $command = new Identify($this, $loop); $command->execute(null); $this->status = self::STATUS_AUTHED; @@ -191,20 +201,22 @@ public function addDispatch(array $dispatch) * * @param string $type Type of action * @param object $json JSON object - * @return mixed Result from call of dispatch handler + * @return null */ public function dispatch($type, $json) { - if (!array_key_exists($type, $this->dispatch)) { + $dis = $this->dispatch[$type]; + if(empty($dis)){ return null; } - $dis = $this->dispatch[$type]; - - if ($dis instanceof \Closure) { - return $dis($json); - } elseif (is_callable($dis)) { - $obj = $dis[0]; - return $obj->$dis[1]($json); + foreach ($dis as $key => $item) { + if ($item instanceof Closure) { + return $item($json); + } elseif (is_callable($dis)) { + $obj = $item[0]; + return $obj->$item[1]($json); + } } + return null; } } diff --git a/src/Utils/Functions.php b/src/Utils/Functions.php index 3f6c9e4..7e059f4 100644 --- a/src/Utils/Functions.php +++ b/src/Utils/Functions.php @@ -89,7 +89,7 @@ protected function init_curl_with_header_print_r($url, $headers, $tur = "POST") * Sending Message to Selected Channel * * @var string|int $msg Message - * @var int $channel_id Channel ID + * @var string|int $channel_id Channel ID */ public function sendMessage($msg, $channel_id)