Skip to content

Commit e45b1bb

Browse files
committed
Version 0.10.0, PHP 8 tweaks
1 parent 2a80ae3 commit e45b1bb

14 files changed

+276
-225
lines changed

Diff for: CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
55

66
## [Unreleased]
77
### Added
8-
- Rules notice to use Pastebin instead of posting code directly.
98
### Changed
109
### Deprecated
1110
### Removed
1211
### Fixed
1312
### Security
1413

14+
## [0.10.0] - 2021-06-14
15+
### Added
16+
- Rules notice to use Pastebin instead of posting code directly.
17+
### Changed
18+
- Bumped to manager 1.7.0 and core 0.73.
19+
- Various code tweaks, make use of PHP 8.
20+
### Security
21+
- Bumped dependencies.
22+
1523
## [0.9.0] - 2021-03-14
1624
### Changed
1725
- Moved to PHP 8.

Diff for: commands/CallbackqueryCommand.php

+6-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CallbackqueryCommand extends SystemCommand
3838
/**
3939
* @var string
4040
*/
41-
protected $version = '0.1.0';
41+
protected $version = '0.2.0';
4242

4343
/**
4444
* Command execute method
@@ -50,14 +50,10 @@ public function execute(): ServerResponse
5050
$callback_query = $this->getCallbackQuery();
5151
parse_str($callback_query->getData(), $callback_data);
5252

53-
if ('donate' === $callback_data['command']) {
54-
return DonateCommand::handleCallbackQuery($callback_query, $callback_data);
55-
}
56-
57-
if ('rules' === $callback_data['command']) {
58-
return RulesCommand::handleCallbackQuery($callback_query, $callback_data);
59-
}
60-
61-
return $callback_query->answer();
53+
return match ($callback_data['command'] ?? null) {
54+
'donate' => DonateCommand::handleCallbackQuery($callback_query, $callback_data),
55+
'rules' => RulesCommand::handleCallbackQuery($callback_query, $callback_data),
56+
default => $callback_query->answer(),
57+
};
6258
}
6359
}

Diff for: commands/DonateCommand.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use function TelegramBot\SupportBot\cache;
2828

2929
/**
30+
* User "/donate" command
31+
*
3032
* Donate using Telegram Payments.
3133
*/
3234
class DonateCommand extends UserCommand
@@ -51,7 +53,7 @@ class DonateCommand extends UserCommand
5153
/**
5254
* @var string
5355
*/
54-
protected $version = '0.1.0';
56+
protected $version = '0.1.1';
5557

5658
/**
5759
* @var bool
@@ -192,7 +194,7 @@ public static function createPaymentInvoice(int $chat_id, int $amount, string $c
192194
* @return array|ServerResponse
193195
* @throws TelegramException
194196
*/
195-
protected function validateCurrencyFetching()
197+
protected function validateCurrencyFetching(): array|ServerResponse
196198
{
197199
if ($currencies = $this->fetchCurrenciesFromTelegram()) {
198200
return $currencies;
@@ -216,7 +218,7 @@ protected function validateCurrencyFetching()
216218
* @return array|ServerResponse
217219
* @throws TelegramException
218220
*/
219-
protected function validateCurrency(string $currency_code)
221+
protected function validateCurrency(string $currency_code): array|ServerResponse
220222
{
221223
$currencies = $this->fetchCurrenciesFromTelegram();
222224

@@ -244,7 +246,7 @@ protected function validateCurrency(string $currency_code)
244246
* @return int|ServerResponse
245247
* @throws TelegramException
246248
*/
247-
protected function validateAmount(string $amount, array $currency)
249+
protected function validateAmount(string $amount, array $currency): int|ServerResponse
248250
{
249251
$int_amount = (int) ceil((float) $amount);
250252

Diff for: commands/NewchatmembersCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use TelegramBot\SupportBot\Helpers;
2828

2929
/**
30-
* New chat members command
30+
* Send a welcome message to new chat members.
3131
*/
3232
class NewchatmembersCommand extends SystemCommand
3333
{

Diff for: commands/PreCheckoutQueryCommand.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<?php
22

3-
namespace Longman\TelegramBot\Commands\UserCommands;
3+
namespace Longman\TelegramBot\Commands\SystemCommands;
44

55
use Longman\TelegramBot\Commands\SystemCommand;
66
use Longman\TelegramBot\Entities\ServerResponse;
77

8+
/**
9+
* No pre-checkout checks required at this point, just approve.
10+
*/
811
class PreCheckoutQueryCommand extends SystemCommand
912
{
1013
/**

Diff for: commands/RulesCommand.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
/**
2727
* User "/rules" command
28+
*
29+
* Display the rules of the support group.
30+
* Provide an inline button for the user to agree to the rules.
2831
*/
2932
class RulesCommand extends UserCommand
3033
{
@@ -41,7 +44,7 @@ class RulesCommand extends UserCommand
4144
/**
4245
* @var string
4346
*/
44-
protected $version = '0.1.0';
47+
protected $version = '0.2.0';
4548

4649
/**
4750
* @var string
@@ -109,19 +112,19 @@ public static function handleCallbackQuery(CallbackQuery $callback_query, array
109112
public function execute(): ServerResponse
110113
{
111114
$text = "
112-
Rules: `English only | No Spamming or Nonsense Posting | No Bots`
115+
Rules: `English only | No Spam | No Bots | No long Code`
113116
114117
**:uk: English only**
115118
Please keep your conversations in English inside this chatroom, otherwise your message will be deleted.
116119
117120
**:do_not_litter: No Spamming or Nonsense Posting**
118-
Don't spam or send Messages with useless Content. When repeated you may be kicked or banned.
121+
Don't spam or send Messages with useless Content. When repeated, you may be kicked or banned.
119122
120123
**:robot: No Bots**
121124
Please do not add a Bot inside this Chat without asking the Admins first. Feel free to mention the Bot in a Message
122125
123-
**:paper: Use Pastebin to post Source Code**
124-
If you want to share your Code for troubleshooting, please upload it to [Pastebin](https://pastebin.com) and post the link. Don't send longer code parts directly in the Chat.
126+
**:memo: Use Pastebin to post Source Code**
127+
If you want to share your Code for troubleshooting, please upload it to [Pastebin](https://pastebin.com) and post the link. Don't send long code parts directly in the Chat.
125128
126129
Also keep in mind that the [PHP Telegram Bot Support Chat](https://t.me/PHP_Telegram_Bot_Support) applies only for the [PHP Telegram Bot library](https://github.com/php-telegram-bot/core).
127130
";

Diff for: commands/StartCommand.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Longman\TelegramBot\Commands\SystemCommands;
14+
namespace Longman\TelegramBot\Commands\UserCommands;
1515

16-
use Longman\TelegramBot\Commands\SystemCommand;
16+
use Longman\TelegramBot\Commands\UserCommand;
1717
use Longman\TelegramBot\Entities\ServerResponse;
1818
use Longman\TelegramBot\Exception\TelegramException;
1919

2020
/**
2121
* System "/start" command
2222
*/
23-
class StartCommand extends SystemCommand
23+
class StartCommand extends UserCommand
2424
{
2525
/**
2626
* @var string
@@ -35,7 +35,7 @@ class StartCommand extends SystemCommand
3535
/**
3636
* @var string
3737
*/
38-
protected $version = '0.1.0';
38+
protected $version = '0.2.0';
3939

4040
/**
4141
* @var string
@@ -53,14 +53,13 @@ class StartCommand extends SystemCommand
5353
*/
5454
public function execute(): ServerResponse
5555
{
56-
if ('activate' === $this->getMessage()->getText(true)) {
57-
return $this->getTelegram()->executeCommand('activate');
58-
}
56+
$text = $this->getMessage()->getText(true);
5957

60-
if ('rules' === $this->getMessage()->getText(true)) {
61-
return $this->getTelegram()->executeCommand('rules');
58+
// Fall back to /help command.
59+
if (!in_array($text, ['activate', 'rules'])) {
60+
$text = 'help';
6261
}
6362

64-
return $this->getTelegram()->executeCommand('help');
63+
return $this->getTelegram()->executeCommand($text);
6564
}
6665
}

Diff for: composer.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020
"php": "^8.0",
2121
"ext-json": "*",
2222
"ext-pdo": "*",
23-
"php-telegram-bot/telegram-bot-manager": "^1.6",
24-
"longman/telegram-bot": "0.71.0 as 0.70",
23+
"php-telegram-bot/telegram-bot-manager": "^1.7",
24+
"longman/telegram-bot": "0.73.0 as 0.73",
2525
"noplanman/service-webhook-handler": "^0.2",
2626
"vlucas/phpdotenv": "^5.3",
2727
"elvanto/litemoji": "^4.0",
2828
"monolog/monolog": "^2.2",
2929
"matthiasmullie/scrapbook": "^1.4",
30-
"knplabs/github-api": "^3.1",
31-
"guzzlehttp/guzzle": "^7.2",
30+
"knplabs/github-api": "^3.3",
31+
"guzzlehttp/guzzle": "^7.3",
3232
"http-interop/http-factory-guzzle": "^1.0"
3333
},
3434
"require-dev": {
3535
"roave/security-advisories": "dev-master",
36-
"squizlabs/php_codesniffer": "^3.5",
37-
"php-parallel-lint/php-parallel-lint": "^1.2",
38-
"symfony/var-dumper": "^5.2"
36+
"squizlabs/php_codesniffer": "^3.6",
37+
"php-parallel-lint/php-parallel-lint": "^1.3",
38+
"symfony/var-dumper": "^5.3"
3939
},
4040
"autoload": {
4141
"psr-4": {

0 commit comments

Comments
 (0)