Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - #1048: Better namespace #1077

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
[0.44.0-bc-update-content-type]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#update-getupdatecontent
[example-bot]: https://github.com/php-telegram-bot/example-bot
[PSR-3]: https://www.php-fig.org/psr/psr-3
[Tidelift]: https://tidelift.com/subscription/pkg/packagist-longman-telegram-bot?utm_source=packagist-longman-telegram-bot&utm_medium=referral&utm_campaign=changelog
[Tidelift]: https://tidelift.com/subscription/pkg/packagist-php-telegram-bot-core?utm_source=packagist-php-telegram-bot-core&utm_medium=referral&utm_campaign=changelog

[Unreleased]: https://github.com/php-telegram-bot/core/compare/master...develop
[0.62.0]: https://github.com/php-telegram-bot/core/compare/0.61.1...0.62.0
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ A Telegram Bot based on the official [Telegram Bot API]
[![Build Status](https://travis-ci.org/php-telegram-bot/core.svg?branch=master)](https://travis-ci.org/php-telegram-bot/core)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-telegram-bot/core/master.svg?style=flat)](https://scrutinizer-ci.com/g/php-telegram-bot/core/?b=master)
[![Code Quality](https://img.shields.io/scrutinizer/g/php-telegram-bot/core/master.svg?style=flat)](https://scrutinizer-ci.com/g/php-telegram-bot/core/?b=master)
[![Latest Stable Version](https://img.shields.io/packagist/v/longman/telegram-bot.svg)](https://packagist.org/packages/longman/telegram-bot)
[![Latest Stable Version](https://img.shields.io/packagist/v/php-telegram-bot/core.svg)](https://packagist.org/packages/php-telegram-bot/core)
[![Dependencies](https://tidelift.com/badges/github/php-telegram-bot/core?style=flat)][Tidelift]
[![Total Downloads](https://img.shields.io/packagist/dt/longman/telegram-bot.svg)](https://packagist.org/packages/longman/telegram-bot)
[![Downloads Month](https://img.shields.io/packagist/dm/longman/telegram-bot.svg)](https://packagist.org/packages/longman/telegram-bot)
[![Total Downloads](https://img.shields.io/packagist/dt/php-telegram-bot/core.svg)](https://packagist.org/packages/php-telegram-bot/core)
[![Downloads Month](https://img.shields.io/packagist/dm/php-telegram-bot/core.svg)](https://packagist.org/packages/php-telegram-bot/core)
[![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D5.6-8892BF.svg)](https://php.net/)
[![License](https://img.shields.io/packagist/l/longman/telegram-bot.svg)](https://github.com/php-telegram-bot/core/LICENSE)
[![License](https://img.shields.io/packagist/l/php-telegram-bot/core.svg)](https://github.com/php-telegram-bot/core/LICENSE)

## Table of Contents
- [Introduction](#introduction)
Expand Down Expand Up @@ -166,7 +166,7 @@ above, but start it with `@`)
### Require this package with Composer

Install this package through [Composer].
Edit your project's `composer.json` file to require `longman/telegram-bot`.
Edit your project's `composer.json` file to require `php-telegram-bot/core`.

Create *composer.json* file
```json
Expand All @@ -175,7 +175,7 @@ Create *composer.json* file
"type": "project",
"require": {
"php": ">=5.5",
"longman/telegram-bot": "*"
"php-telegram-bot/core": "*"
}
}
```
Expand All @@ -186,7 +186,7 @@ and run `composer update`
run this command in your command line:

```bash
composer require longman/telegram-bot
composer require php-telegram-bot/core
```

### Choose how to retrieve Telegram updates
Expand Down Expand Up @@ -218,14 +218,14 @@ $hook_url = 'https://your-domain/path/to/hook.php';

try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
$telegram = new PhpTelegramBot\Core\Telegram($bot_api_key, $bot_username);

// Set webhook
$result = $telegram->setWebhook($hook_url);
if ($result->isOk()) {
echo $result->getDescription();
}
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
} catch (PhpTelegramBot\Core\Exception\TelegramException $e) {
// log telegram errors
// echo $e->getMessage();
}
Expand All @@ -245,11 +245,11 @@ $bot_username = 'username_bot';

try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
$telegram = new PhpTelegramBot\Core\Telegram($bot_api_key, $bot_username);

// Handle telegram webhook request
$telegram->handle();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
} catch (PhpTelegramBot\Core\Exception\TelegramException $e) {
// Silence is golden!
// log telegram errors
// echo $e->getMessage();
Expand Down Expand Up @@ -290,14 +290,14 @@ $mysql_credentials = [

try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);
$telegram = new PhpTelegramBot\Core\Telegram($bot_api_key, $bot_username);

// Enable MySQL
$telegram->enableMySql($mysql_credentials);

// Handle telegram getUpdates request
$telegram->handleGetUpdates();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
} catch (PhpTelegramBot\Core\Exception\TelegramException $e) {
// log telegram errors
// echo $e->getMessage();
}
Expand Down Expand Up @@ -382,7 +382,7 @@ See the [*ImageCommand.php*][ImageCommand.php] for a full example.
```php
Request::sendChatAction([
'chat_id' => $chat_id,
'action' => Longman\TelegramBot\ChatAction::TYPING,
'action' => PhpTelegramBot\Core\ChatAction::TYPING,
]);
```

Expand Down Expand Up @@ -611,7 +611,7 @@ Thank you for keeping this project alive :pray:
- [![Patreon](https://user-images.githubusercontent.com/9423417/59235980-a5fa6b80-8be3-11e9-8ae7-020bc4ae9baa.png) Patreon.com/phptelegrambot][Patreon]
- [![OpenCollective](https://user-images.githubusercontent.com/9423417/59235978-a561d500-8be3-11e9-89be-82ec54be1546.png) OpenCollective.com/php-telegram-bot][OpenCollective]
- [![Ko-fi](https://user-images.githubusercontent.com/9423417/59235976-a561d500-8be3-11e9-911d-b1908c3e6a33.png) Ko-fi.com/phptelegrambot][Ko-fi]
- [![Tidelift](https://user-images.githubusercontent.com/9423417/59235982-a6930200-8be3-11e9-8ac2-bfb6991d80c5.png) Tidelift.com/longman/telegram-bot][Tidelift]
- [![Tidelift](https://user-images.githubusercontent.com/9423417/59235982-a6930200-8be3-11e9-8ac2-bfb6991d80c5.png) Tidelift.com/php-telegram-bot/core][Tidelift]
- [![Liberapay](https://user-images.githubusercontent.com/9423417/59235977-a561d500-8be3-11e9-9d16-bc3b13d3ceba.png) Liberapay.com/PHP-Telegram-Bot][Liberapay]
- [![PayPal](https://user-images.githubusercontent.com/9423417/59235981-a5fa6b80-8be3-11e9-9761-15eb7a524cb0.png) PayPal.me/noplanman][PayPal-noplanman] (account of @noplanman)
- [![Bitcoin](https://user-images.githubusercontent.com/9423417/59235974-a4c93e80-8be3-11e9-9fde-260c821b6eae.png) 166NcyE7nDxkRPWidWtG1rqrNJoD5oYNiV][Bitcoin]
Expand Down Expand Up @@ -655,7 +655,7 @@ Credit list in [CREDITS](CREDITS)
[Patreon]: https://www.patreon.com/phptelegrambot "Support us on Patreon"
[OpenCollective]: https://opencollective.com/php-telegram-bot "Support us on Open Collective"
[Ko-fi]: https://ko-fi.com/phptelegrambot "Support us on Ko-fi"
[Tidelift]: https://tidelift.com/subscription/pkg/packagist-longman-telegram-bot?utm_source=packagist-longman-telegram-bot&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Learn more about the Tidelift Subscription"
[Tidelift]: https://tidelift.com/subscription/pkg/packagist-php-telegram-bot-core?utm_source=packagist-php-telegram-bot-core&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Learn more about the Tidelift Subscription"
[Liberapay]: https://liberapay.com/PHP-Telegram-Bot "Donate with Liberapay"
[PayPal-noplanman]: https://paypal.me/noplanman "Donate with PayPal"
[Bitcoin]: https://www.blockchain.com/btc/address/166NcyE7nDxkRPWidWtG1rqrNJoD5oYNiV "Donate with Bitcoin"
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "longman/telegram-bot",
"name": "php-telegram-bot/core",
"type": "library",
"description": "PHP Telegram bot",
"keywords": ["telegram", "bot", "api"],
Expand Down Expand Up @@ -39,12 +39,12 @@
},
"autoload": {
"psr-4": {
"Longman\\TelegramBot\\": "src/"
"PhpTelegramBot\\Core\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Longman\\TelegramBot\\Tests\\Unit\\": "tests/unit"
"PhpTelegramBot\\Core\\Tests\\Unit\\": "tests/unit"
}
},
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions doc/01-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The first parameter is the main logger, the second one is used for the raw updat

(in this example we're using [Monolog])
```php
use Longman\TelegramBot\TelegramLog;
use PhpTelegramBot\Core\TelegramLog;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
Expand Down Expand Up @@ -43,14 +43,14 @@ Remember to always backup first!!
### Always log request and response data
If you's like to always log the request and response data to the debug log, also for successful requests, you can set the appropriate variable:
```php
\Longman\TelegramBot\TelegramLog::$always_log_request_and_response = true;
\PhpTelegramBot\Core\TelegramLog::$always_log_request_and_response = true;
```

### Hiding API token from the log
By default, the API token is removed from the log, to prevent any mistaken leakage when posting logs online.
This behaviour can be changed by setting the appropriate variable:
``php
\Longman\TelegramBot\TelegramLog::$remove_bot_token = false;
\PhpTelegramBot\Core\TelegramLog::$remove_bot_token = false;
```

[PSR-3]: https://www.php-fig.org/psr/psr-3
Expand Down
2 changes: 1 addition & 1 deletion src/ChatAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot;
namespace PhpTelegramBot\Core;

class ChatAction
{
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands;
namespace PhpTelegramBot\Core\Commands;

abstract class AdminCommand extends Command
{
Expand Down
16 changes: 8 additions & 8 deletions src/Commands/AdminCommands/ChatsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands\AdminCommands;

use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\Chat;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
namespace PhpTelegramBot\Core\Commands\AdminCommands;

use PhpTelegramBot\Core\Commands\AdminCommand;
use PhpTelegramBot\Core\DB;
use PhpTelegramBot\Core\Entities\Chat;
use PhpTelegramBot\Core\Entities\ServerResponse;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;

class ChatsCommand extends AdminCommand
{
Expand Down
16 changes: 8 additions & 8 deletions src/Commands/AdminCommands/CleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands\AdminCommands;

use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\TelegramLog;
namespace PhpTelegramBot\Core\Commands\AdminCommands;

use PhpTelegramBot\Core\Commands\AdminCommand;
use PhpTelegramBot\Core\DB;
use PhpTelegramBot\Core\Entities\ServerResponse;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;
use PhpTelegramBot\Core\TelegramLog;
use PDOException;

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Commands/AdminCommands/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands\AdminCommands;
namespace PhpTelegramBot\Core\Commands\AdminCommands;

use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
use PhpTelegramBot\Core\Commands\AdminCommand;
use PhpTelegramBot\Core\DB;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;

/**
* Admin "/debug" command
Expand Down
12 changes: 6 additions & 6 deletions src/Commands/AdminCommands/SendtoallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands\AdminCommands;
namespace PhpTelegramBot\Core\Commands\AdminCommands;

use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\Entities\Message;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
use PhpTelegramBot\Core\Commands\AdminCommand;
use PhpTelegramBot\Core\Entities\Message;
use PhpTelegramBot\Core\Entities\ServerResponse;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;

/**
* Admin "/sendtoall" command
Expand Down
20 changes: 10 additions & 10 deletions src/Commands/AdminCommands/SendtochannelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands\AdminCommands;

use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\Conversation;
use Longman\TelegramBot\Entities\Chat;
use Longman\TelegramBot\Entities\Keyboard;
use Longman\TelegramBot\Entities\Message;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
namespace PhpTelegramBot\Core\Commands\AdminCommands;

use PhpTelegramBot\Core\Commands\AdminCommand;
use PhpTelegramBot\Core\Conversation;
use PhpTelegramBot\Core\Entities\Chat;
use PhpTelegramBot\Core\Entities\Keyboard;
use PhpTelegramBot\Core\Entities\Message;
use PhpTelegramBot\Core\Entities\ServerResponse;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;

class SendtochannelCommand extends AdminCommand
{
Expand Down
20 changes: 10 additions & 10 deletions src/Commands/AdminCommands/WhoisCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
* Written by Jack'lul <jacklul@jacklul.com>
*/

namespace Longman\TelegramBot\Commands\AdminCommands;

use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\Chat;
use Longman\TelegramBot\Entities\PhotoSize;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Entities\UserProfilePhotos;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
namespace PhpTelegramBot\Core\Commands\AdminCommands;

use PhpTelegramBot\Core\Commands\AdminCommand;
use PhpTelegramBot\Core\DB;
use PhpTelegramBot\Core\Entities\Chat;
use PhpTelegramBot\Core\Entities\PhotoSize;
use PhpTelegramBot\Core\Entities\ServerResponse;
use PhpTelegramBot\Core\Entities\UserProfilePhotos;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;

/**
* Admin "/whois" command
Expand Down
30 changes: 15 additions & 15 deletions src/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands;

use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\CallbackQuery;
use Longman\TelegramBot\Entities\ChosenInlineResult;
use Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\Message;
use Longman\TelegramBot\Entities\Payments\PreCheckoutQuery;
use Longman\TelegramBot\Entities\Payments\ShippingQuery;
use Longman\TelegramBot\Entities\Poll;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Telegram;
namespace PhpTelegramBot\Core\Commands;

use PhpTelegramBot\Core\DB;
use PhpTelegramBot\Core\Entities\CallbackQuery;
use PhpTelegramBot\Core\Entities\ChosenInlineResult;
use PhpTelegramBot\Core\Entities\InlineQuery;
use PhpTelegramBot\Core\Entities\Message;
use PhpTelegramBot\Core\Entities\Payments\PreCheckoutQuery;
use PhpTelegramBot\Core\Entities\Payments\ShippingQuery;
use PhpTelegramBot\Core\Entities\Poll;
use PhpTelegramBot\Core\Entities\ServerResponse;
use PhpTelegramBot\Core\Entities\Update;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;
use PhpTelegramBot\Core\Telegram;

/**
* Class Command
Expand Down
10 changes: 5 additions & 5 deletions src/Commands/SystemCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Commands;
namespace PhpTelegramBot\Core\Commands;

use Longman\TelegramBot\Conversation;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;
use PhpTelegramBot\Core\Conversation;
use PhpTelegramBot\Core\Entities\ServerResponse;
use PhpTelegramBot\Core\Exception\TelegramException;
use PhpTelegramBot\Core\Request;

abstract class SystemCommand extends Command
{
Expand Down
Loading