diff --git a/CHANGELOG.md b/CHANGELOG.md index f749a8b..a267576 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ### Fixed ### Security +## [1.0.0] - 2017-05-08 +### Changed +- [:exclamation:][1.0.0-bc-move] Move to `php-telegram-bot/telegram-bot-manager` on packagist. +- [:exclamation:][1.0.0-bc-move] Move to `TelegramBot\TelegramBotManager` namespace. + ## [0.44.0] - 2017-05-05 ### Added - Ability to define custom valid IPs to access webhook. @@ -77,4 +82,5 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ### Added - First minor version that contains the basic functionality. +[1.0.0-bc-move]: https://github.com/php-telegram-bot/telegram-bot-manager/wiki/Breaking-backwards-compatibility#namespace-and-package-name-changed "Namespace and package name changed" [0.44.0-bc-parameter-structure]: https://github.com/php-telegram-bot/telegram-bot-manager/wiki/Breaking-backwards-compatibility#parameter-structure-changed "Parameter structure changed" diff --git a/README.md b/README.md index 284f583..9ffa797 100644 --- a/README.md +++ b/README.md @@ -20,16 +20,16 @@ Installation and usage is pretty straight forward: Either run this command in your command line: ```bash -composer require noplanman/telegram-bot-manager:^0.44 +composer require php-telegram-bot/telegram-bot-manager:^1.0 ``` **or** -For existing Composer projects, edit your project's `composer.json` file to require `noplanman/telegram-bot-manager`: +For existing Composer projects, edit your project's `composer.json` file to require `php-telegram-bot/telegram-bot-manager`: ```yaml "require": { - "noplanman/telegram-bot-manager": "^0.44" + "php-telegram-bot/telegram-bot-manager": "^1.0" } ``` and then run `composer update` @@ -42,7 +42,7 @@ It is possible however, to override the core version that this library requires: ```yaml "require": { - "noplanman/telegram-bot-manager": "^0.44", + "php-telegram-bot/telegram-bot-manager": "^1.0", "longman/telegram-bot": "dev-develop as 0.44" } ``` @@ -133,7 +133,7 @@ Let's start off with a simple example that uses the webhook method: ```php [ + 'mysql' => [ 'host' => '127.0.0.1', 'user' => 'root', 'password' => 'root', @@ -337,7 +337,7 @@ It probably makes sense for you to create a new dummy bot for this. [github-tgbot-core]: https://github.com/php-telegram-bot/core "PHP Telegram Bot on GitHub" [github-tgbot-core-instructions]: https://github.com/php-telegram-bot/core#instructions "PHP Telegram Bot instructions on GitHub" [github-tgbot-manager]: https://github.com/php-telegram-bot/telegram-bot-manager "PHP Telegram Bot Manager on GitHub" -[packagist-tgbot-manager]: https://packagist.org/packages/noplanman/telegram-bot-manager "PHP Telegram Bot Manager on Packagist" +[packagist-tgbot-manager]: https://packagist.org/packages/php-telegram-bot/telegram-bot-manager "PHP Telegram Bot Manager on Packagist" [license]: https://github.com/php-telegram-bot/telegram-bot-manager/blob/master/LICENSE "PHP Telegram Bot Manager license" [code-quality-badge]: https://img.shields.io/scrutinizer/g/php-telegram-bot/telegram-bot-manager.svg @@ -347,9 +347,9 @@ It probably makes sense for you to create a new dummy bot for this. [build-status-badge]: https://img.shields.io/travis/php-telegram-bot/telegram-bot-manager.svg [build-status]: https://travis-ci.org/php-telegram-bot/telegram-bot-manager "Build status on Travis-CI" -[latest-version-badge]: https://img.shields.io/packagist/v/noplanman/telegram-bot-manager.svg -[total-downloads-badge]: https://img.shields.io/packagist/dt/noplanman/telegram-bot-manager.svg -[license-badge]: https://img.shields.io/packagist/l/noplanman/telegram-bot-manager.svg +[latest-version-badge]: https://img.shields.io/packagist/v/php-telegram-bot/telegram-bot-manager.svg +[total-downloads-badge]: https://img.shields.io/packagist/dt/php-telegram-bot/telegram-bot-manager.svg +[license-badge]: https://img.shields.io/packagist/l/php-telegram-bot/telegram-bot-manager.svg [random-characters]: https://www.random.org/strings/?num=7&len=12&digits=on&upperalpha=on&loweralpha=on&unique=on&format=plain&rnd=new "Generate random characters" [travis-repository-settings]: https://docs.travis-ci.com/user/environment-variables#Defining-Variables-in-Repository-Settings "Repository Settings on Travis-CI" diff --git a/composer.json b/composer.json index bef47ba..08c916a 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,13 @@ { - "name": "noplanman/telegram-bot-manager", + "name": "php-telegram-bot/telegram-bot-manager", "type": "library", "description": "PHP Telegram Bot Manager", "keywords": ["telegram", "bot", "manager"], "license": "MIT", - "homepage": "https://github.com/noplanman/php-telegram-bot-manager", + "homepage": "https://github.com/php-telegram-bot/telegram-bot-manager", "support": { - "issues": "https://github.com/noplanman/php-telegram-bot-manager/issues", - "source": "https://github.com/noplanman/php-telegram-bot-manager" + "issues": "https://github.com/php-telegram-bot/telegram-bot-manager/issues", + "source": "https://github.com/php-telegram-bot/telegram-bot-manager" }, "authors": [ { @@ -31,16 +31,16 @@ "require-dev": { "jakub-onderka/php-parallel-lint": "^0.9.2", "phpunit/phpunit": "^6.1", - "squizlabs/php_codesniffer": "^2.8" + "squizlabs/php_codesniffer": "^2.9" }, "autoload": { "psr-4": { - "NPM\\TelegramBotManager\\": "src" + "TelegramBot\\TelegramBotManager\\": "src" } }, "autoload-dev": { "psr-4": { - "NPM\\TelegramBotManager\\Tests\\": "tests/TelegramBotManager/Tests" + "TelegramBot\\TelegramBotManager\\Tests\\": "tests" } }, "scripts": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c0e6b0c..a373b36 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,33 @@ - + - tests/ + tests/ - + src/ - - + + diff --git a/src/Action.php b/src/Action.php index bf80d36..9d0df40 100644 --- a/src/Action.php +++ b/src/Action.php @@ -8,9 +8,9 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager; +namespace TelegramBot\TelegramBotManager; -use NPM\TelegramBotManager\Exception\InvalidActionException; +use TelegramBot\TelegramBotManager\Exception\InvalidActionException; class Action { @@ -35,7 +35,7 @@ class Action * * @param string $action * - * @throws \NPM\TelegramBotManager\Exception\InvalidActionException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidActionException */ public function __construct($action = 'handle') { diff --git a/src/BotManager.php b/src/BotManager.php index 0de67e4..821eaed 100644 --- a/src/BotManager.php +++ b/src/BotManager.php @@ -8,15 +8,15 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager; +namespace TelegramBot\TelegramBotManager; use Allty\Utils\IpTools; use Longman\TelegramBot\Entities; use Longman\TelegramBot\Request; use Longman\TelegramBot\Telegram; use Longman\TelegramBot\TelegramLog; -use NPM\TelegramBotManager\Exception\InvalidAccessException; -use NPM\TelegramBotManager\Exception\InvalidWebhookException; +use TelegramBot\TelegramBotManager\Exception\InvalidAccessException; +use TelegramBot\TelegramBotManager\Exception\InvalidWebhookException; class BotManager { @@ -36,12 +36,12 @@ class BotManager private $telegram; /** - * @var \NPM\TelegramBotManager\Params Object that manages the parameters. + * @var \TelegramBot\TelegramBotManager\Params Object that manages the parameters. */ private $params; /** - * @var \NPM\TelegramBotManager\Action Object that contains the current action. + * @var \TelegramBot\TelegramBotManager\Action Object that contains the current action. */ private $action; @@ -50,8 +50,8 @@ class BotManager * * @param array $params * - * @throws \NPM\TelegramBotManager\Exception\InvalidParamsException - * @throws \NPM\TelegramBotManager\Exception\InvalidActionException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidParamsException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidActionException * @throws \Longman\TelegramBot\Exception\TelegramException */ public function __construct(array $params) @@ -92,7 +92,7 @@ public function getTelegram(): Telegram /** * Get the Params object. * - * @return \NPM\TelegramBotManager\Params + * @return \TelegramBot\TelegramBotManager\Params */ public function getParams(): Params { @@ -102,7 +102,7 @@ public function getParams(): Params /** * Get the Action object. * - * @return \NPM\TelegramBotManager\Action + * @return \TelegramBot\TelegramBotManager\Action */ public function getAction(): Action { @@ -112,10 +112,10 @@ public function getAction(): Action /** * Run this thing in all its glory! * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException - * @throws \NPM\TelegramBotManager\Exception\InvalidAccessException - * @throws \NPM\TelegramBotManager\Exception\InvalidWebhookException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidAccessException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidWebhookException * @throws \Exception */ public function run(): self @@ -145,7 +145,7 @@ public function run(): self * * @param array $log_paths * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Exception */ public function initLogging(array $log_paths): self @@ -164,8 +164,8 @@ public function initLogging(array $log_paths): self * * @param bool $force Force validation, even on CLI. * - * @return \NPM\TelegramBotManager\BotManager - * @throws \NPM\TelegramBotManager\Exception\InvalidAccessException + * @return \TelegramBot\TelegramBotManager\BotManager + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidAccessException */ public function validateSecret(bool $force = false): self { @@ -184,9 +184,9 @@ public function validateSecret(bool $force = false): self /** * Make sure the webhook is valid and perform the requested webhook operation. * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException - * @throws \NPM\TelegramBotManager\Exception\InvalidWebhookException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidWebhookException */ public function validateAndSetWebhook(): self { @@ -224,7 +224,7 @@ public function validateAndSetWebhook(): self * * @param string $output * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager */ private function handleOutput(string $output): self { @@ -240,7 +240,7 @@ private function handleOutput(string $output): self /** * Set any extra bot features that have been assigned on construction. * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException */ public function setBotExtras(): self @@ -254,7 +254,7 @@ public function setBotExtras(): self /** * Set extra bot parameters for Telegram object. * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException */ protected function setBotExtrasTelegram(): self @@ -293,7 +293,7 @@ protected function setBotExtrasTelegram(): self /** * Set extra bot parameters for Request class. * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException */ protected function setBotExtrasRequest(): self @@ -322,8 +322,8 @@ protected function setBotExtrasRequest(): self /** * Handle the request, which calls either the Webhook or getUpdates method respectively. * - * @return \NPM\TelegramBotManager\BotManager - * @throws \NPM\TelegramBotManager\Exception\InvalidAccessException + * @return \TelegramBot\TelegramBotManager\BotManager + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidAccessException * @throws \Longman\TelegramBot\Exception\TelegramException */ public function handleRequest(): self @@ -344,7 +344,7 @@ public function handleRequest(): self /** * Handle cron. * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException */ public function handleCron(): self @@ -403,7 +403,7 @@ public function getLoopInterval(): int * @param int $loop_time_in_seconds * @param int $loop_interval_in_seconds * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException */ public function handleGetUpdatesLoop(int $loop_time_in_seconds, int $loop_interval_in_seconds = 2): self @@ -426,7 +426,7 @@ public function handleGetUpdatesLoop(int $loop_time_in_seconds, int $loop_interv /** * Handle the updates using the getUpdates method. * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException */ public function handleGetUpdates(): self @@ -473,9 +473,9 @@ public function handleGetUpdates(): self /** * Handle the updates using the Webhook method. * - * @return \NPM\TelegramBotManager\BotManager + * @return \TelegramBot\TelegramBotManager\BotManager * @throws \Longman\TelegramBot\Exception\TelegramException - * @throws \NPM\TelegramBotManager\Exception\InvalidAccessException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidAccessException */ public function handleWebhook(): self { diff --git a/src/Exception/BotManagerException.php b/src/Exception/BotManagerException.php index 64b4307..e5fd638 100644 --- a/src/Exception/BotManagerException.php +++ b/src/Exception/BotManagerException.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Exception; +namespace TelegramBot\TelegramBotManager\Exception; class BotManagerException extends \Exception { diff --git a/src/Exception/InvalidAccessException.php b/src/Exception/InvalidAccessException.php index 7afdf71..cfcd5d3 100644 --- a/src/Exception/InvalidAccessException.php +++ b/src/Exception/InvalidAccessException.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Exception; +namespace TelegramBot\TelegramBotManager\Exception; class InvalidAccessException extends BotManagerException { diff --git a/src/Exception/InvalidActionException.php b/src/Exception/InvalidActionException.php index 4cfd109..745c2ea 100644 --- a/src/Exception/InvalidActionException.php +++ b/src/Exception/InvalidActionException.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Exception; +namespace TelegramBot\TelegramBotManager\Exception; class InvalidActionException extends BotManagerException { diff --git a/src/Exception/InvalidParamsException.php b/src/Exception/InvalidParamsException.php index 51f0a5a..8bdea4a 100644 --- a/src/Exception/InvalidParamsException.php +++ b/src/Exception/InvalidParamsException.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Exception; +namespace TelegramBot\TelegramBotManager\Exception; class InvalidParamsException extends BotManagerException { diff --git a/src/Exception/InvalidWebhookException.php b/src/Exception/InvalidWebhookException.php index 3aca471..cddb2cc 100644 --- a/src/Exception/InvalidWebhookException.php +++ b/src/Exception/InvalidWebhookException.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Exception; +namespace TelegramBot\TelegramBotManager\Exception; class InvalidWebhookException extends BotManagerException { diff --git a/src/Params.php b/src/Params.php index 79dbe41..ca84c4f 100644 --- a/src/Params.php +++ b/src/Params.php @@ -8,9 +8,9 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager; +namespace TelegramBot\TelegramBotManager; -use NPM\TelegramBotManager\Exception\InvalidParamsException; +use TelegramBot\TelegramBotManager\Exception\InvalidParamsException; class Params { @@ -99,7 +99,7 @@ class Params * * @param array $params All params to set the bot up with. * - * @throws \NPM\TelegramBotManager\Exception\InvalidParamsException + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidParamsException */ public function __construct(array $params) { @@ -112,8 +112,8 @@ public function __construct(array $params) * * @param $params * - * @return \NPM\TelegramBotManager\Params - * @throws \NPM\TelegramBotManager\Exception\InvalidParamsException + * @return \TelegramBot\TelegramBotManager\Params + * @throws \TelegramBot\TelegramBotManager\Exception\InvalidParamsException */ private function validateAndSetBotParams($params): self { @@ -149,7 +149,7 @@ private function validateAndSetBotParams($params): self * https://url/entry.php?s=&a=&l= * $ php entry.php s= a= l= * - * @return \NPM\TelegramBotManager\Params + * @return \TelegramBot\TelegramBotManager\Params */ private function validateAndSetScriptParams(): self { diff --git a/tests/TelegramBotManager/Tests/ActionTest.php b/tests/ActionTest.php similarity index 90% rename from tests/TelegramBotManager/Tests/ActionTest.php rename to tests/ActionTest.php index 09e12c3..4fcf13e 100644 --- a/tests/TelegramBotManager/Tests/ActionTest.php +++ b/tests/ActionTest.php @@ -8,9 +8,9 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Tests; +namespace TelegramBot\TelegramBotManager\Tests; -use NPM\TelegramBotManager\Action; +use TelegramBot\TelegramBotManager\Action; class ActionTest extends \PHPUnit\Framework\TestCase { @@ -24,7 +24,7 @@ public function testConstruct() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidActionException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidActionException * @expectedExceptionMessageRegExp /^Invalid action: non-existent$/ */ public function testConstructFail() diff --git a/tests/TelegramBotManager/Tests/BotManagerTest.php b/tests/BotManagerTest.php similarity index 96% rename from tests/TelegramBotManager/Tests/BotManagerTest.php rename to tests/BotManagerTest.php index ae23c97..04ad038 100644 --- a/tests/TelegramBotManager/Tests/BotManagerTest.php +++ b/tests/BotManagerTest.php @@ -8,19 +8,19 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Tests; +namespace TelegramBot\TelegramBotManager\Tests; use Longman\TelegramBot\Request; use Longman\TelegramBot\Telegram; use Longman\TelegramBot\TelegramLog; -use NPM\TelegramBotManager\BotManager; +use TelegramBot\TelegramBotManager\BotManager; /** * Class BotManagerTest.php * * Leave all member variables public to allow easy modification. * - * @package NPM\TelegramBotManager + * @package TelegramBot\TelegramBotManager */ class BotManagerTest extends \PHPUnit\Framework\TestCase { @@ -73,7 +73,7 @@ public function testInTest() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidParamsException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidParamsException * @expectedExceptionMessage Some vital info is missing: api_key */ public function testNoVitalsFail() @@ -82,7 +82,7 @@ public function testNoVitalsFail() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidParamsException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidParamsException * @expectedExceptionMessage Some vital info is missing: secret */ public function testIncompleteVitalsFail() @@ -128,7 +128,7 @@ public function testInitLogging() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidAccessException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidAccessException * @expectedExceptionMessage Invalid access */ public function testValidateSecretFail() @@ -263,7 +263,7 @@ public function testDeleteWebhookViaRunLiveBot() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidWebhookException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidWebhookException * @expectedExceptionMessage Invalid webhook */ public function testValidateAndSetWebhookFailSetWithoutWebhook() @@ -275,7 +275,7 @@ public function testValidateAndSetWebhookFailSetWithoutWebhook() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidWebhookException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidWebhookException * @expectedExceptionMessage Invalid webhook */ public function testValidateAndSetWebhookFailResetWithoutWebhook() diff --git a/tests/TelegramBotManager/Tests/ParamsTest.php b/tests/ParamsTest.php similarity index 95% rename from tests/TelegramBotManager/Tests/ParamsTest.php rename to tests/ParamsTest.php index c6e6ad4..3f65fdb 100644 --- a/tests/TelegramBotManager/Tests/ParamsTest.php +++ b/tests/ParamsTest.php @@ -8,9 +8,9 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Tests; +namespace TelegramBot\TelegramBotManager\Tests; -use NPM\TelegramBotManager\Params; +use TelegramBot\TelegramBotManager\Params; class ParamsTest extends \PHPUnit\Framework\TestCase { @@ -91,7 +91,7 @@ public function testConstruct() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidParamsException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidParamsException * @expectedExceptionMessage Some vital info is missing: api_key */ public function testConstructWithoutApiKey() @@ -100,7 +100,7 @@ public function testConstructWithoutApiKey() } /** - * @expectedException \NPM\TelegramBotManager\Exception\InvalidParamsException + * @expectedException \TelegramBot\TelegramBotManager\Exception\InvalidParamsException * @expectedExceptionMessage Some vital info is missing: secret */ public function testConstructWithWebhookWithoutSecret() diff --git a/tests/TelegramBotManager/Tests/TestHelpers.php b/tests/TestHelpers.php similarity index 97% rename from tests/TelegramBotManager/Tests/TestHelpers.php rename to tests/TestHelpers.php index c9fda5b..86d333d 100644 --- a/tests/TelegramBotManager/Tests/TestHelpers.php +++ b/tests/TestHelpers.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace NPM\TelegramBotManager\Tests; +namespace TelegramBot\TelegramBotManager\Tests; class TestHelpers { diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index f653380..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// Set error reporting to the max level. -error_reporting(-1); - -// Set UTC timezone. -date_default_timezone_set('UTC'); - -// Include the Composer autoloader. -require_once __DIR__ . '/../vendor/autoload.php';