Skip to content

Commit

Permalink
Version 0.7.0, PHP 7.4, PTB 0.64.0
Browse files Browse the repository at this point in the history
  • Loading branch information
noplanman committed Oct 4, 2020
1 parent 383cc03 commit b69792c
Show file tree
Hide file tree
Showing 12 changed files with 1,180 additions and 196 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Expand Up @@ -5,13 +5,20 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c

## [Unreleased]
### Added
- Rules must be agreed to before allowing a user to post in the group.
### Changed
### Deprecated
### Removed
### Fixed
### Security

## [0.7.0] - 2020-10-04
### Added
- Rules must be agreed to before allowing a user to post in the group. (#43)
### Changed
- Bumped dependencies, use explicit version 0.64.0 of core.
### Security
- Minimum PHP 7.4.

## [0.6.0] - 2020-07-06
### Added
- New `/donate` command, to allow users to donate via Telegram Payments. (#40)
Expand Down Expand Up @@ -59,6 +66,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
- Extended `.env.example` file.

[Unreleased]: https://github.com/php-telegram-bot/support-bot/compare/master...develop
[0.7.0]: https://github.com/php-telegram-bot/support-bot/compare/0.6.0...0.7.0
[0.6.0]: https://github.com/php-telegram-bot/support-bot/compare/0.5.0...0.6.0
[0.5.0]: https://github.com/php-telegram-bot/support-bot/compare/0.4.0...0.5.0
[0.4.0]: https://github.com/php-telegram-bot/support-bot/compare/0.3.0...0.4.0
Expand Down
2 changes: 1 addition & 1 deletion commands/DonateCommand.php
Expand Up @@ -244,7 +244,7 @@ protected function validateCurrency(string $currency_code)
* @return int|ServerResponse
* @throws TelegramException
*/
protected function validateAmount(string $amount, $currency)
protected function validateAmount(string $amount, array $currency)
{
$int_amount = (int) ceil((float) $amount);

Expand Down
2 changes: 0 additions & 2 deletions commands/HelpCommand.php
Expand Up @@ -129,13 +129,11 @@ protected function getUserAdminCommands(): array
ksort($commands);

$user_commands = array_filter($commands, static function ($command) {
/** @var Command $command */
return $command->isUserCommand();
});
ksort($user_commands);

$admin_commands = array_filter($commands, static function ($command) {
/** @var Command $command */
return $command->isAdminCommand();
});
ksort($admin_commands);
Expand Down
18 changes: 9 additions & 9 deletions commands/NewchatmembersCommand.php
Expand Up @@ -49,22 +49,22 @@ class NewchatmembersCommand extends SystemCommand
/**
* @var Message
*/
private $message;
private Message $message;

/**
* @var int
*/
private $chat_id;
private int $chat_id;

/**
* @var int
*/
private $user_id;
private int $user_id;

/**
* @var string
*/
private $group_name = 'PHP Telegram Support Bot';
private string $group_name = 'PHP Telegram Support Bot';

/**
* @inheritdoc
Expand Down Expand Up @@ -128,6 +128,7 @@ private function refreshWelcomeMessage(array $new_users): ServerResponse
return Request::emptyResponse();
}

/** @var Message $welcome_message */
$welcome_message = $welcome_message_sent->getResult();

$new_message_id = $welcome_message->getMessageId();
Expand Down Expand Up @@ -206,11 +207,11 @@ private function kickDisallowedBots(array $bots): void
/**
* Write users join date to DB.
*
* @param array $new_users
* @param User[] $new_users
*
* @return bool
*/
private function updateUsersJoinedDate($new_users): bool
private function updateUsersJoinedDate(array $new_users): bool
{
$new_users_ids = array_map(static function (User $user) {
return $user->getId();
Expand All @@ -227,15 +228,14 @@ private function updateUsersJoinedDate($new_users): bool
/**
* Restrict permissions in support group for passed users.
*
* @param array $new_users
* @param User[] $new_users
*
* @return array
*/
private function restrictNewUsers($new_users): array
private function restrictNewUsers(array $new_users): array
{
$responses = [];

/** @var User[] $new_users */
foreach ($new_users as $new_user) {
$user_id = $new_user->getId();
$responses[$user_id] = Request::restrictChatMember([
Expand Down
5 changes: 3 additions & 2 deletions commands/RulesCommand.php
Expand Up @@ -21,6 +21,7 @@
use Longman\TelegramBot\Entities\InlineKeyboard;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Request;
use PDO;

/**
* User "/rules" command
Expand Down Expand Up @@ -74,7 +75,7 @@ public static function handleCallbackQuery(CallbackQuery $callback_query, array
]);
}

$give_permissions = Request::restrictChatMember([
Request::restrictChatMember([
'chat_id' => getenv('TG_SUPPORT_GROUP_ID'),
'user_id' => $clicked_user_id,
'permissions' => new ChatPermissions([
Expand Down Expand Up @@ -153,7 +154,7 @@ protected static function hasUserAgreedToRules(int $user_id): bool
AND `activated_at` IS NOT NULL
');
$statement->execute([$user_id]);
$agreed = $statement->fetchAll(\PDO::FETCH_COLUMN, 0);
$agreed = $statement->fetchAll(PDO::FETCH_COLUMN, 0);

return !empty($agreed);
}
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Expand Up @@ -2,7 +2,7 @@
"name": "telegram-bot/support-bot",
"type": "project",
"description": "Friendly and helpful bot for t.me/PHP_Telegram_Support_Bot",
"keywords": ["telegram", "bot", "manager"],
"keywords": ["telegram", "bot", "manager", "support"],
"license": "MIT",
"homepage": "https://github.com/php-telegram-bot/support-bot",
"support": {
Expand All @@ -17,23 +17,24 @@
}
],
"require": {
"php": ">= 7.3",
"php": ">= 7.4",
"ext-json": "*",
"ext-pdo": "*",
"php-telegram-bot/telegram-bot-manager": "^1.5",
"longman/telegram-bot": "dev-master as 0.59",
"longman/telegram-bot": "0.64.0 as 0.59",
"noplanman/service-webhook-handler": "^0.2",
"vlucas/phpdotenv": "^3.6",
"php-http/guzzle6-adapter": "^1.1",
"knplabs/github-api": "^2.12",
"knplabs/github-api": "^2.15",
"elvanto/litemoji": "^1.4",
"monolog/monolog": "^2.0",
"monolog/monolog": "^2.1",
"matthiasmullie/scrapbook": "^1.4"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "^3.5",
"jakub-onderka/php-parallel-lint": "^1.0",
"symfony/var-dumper": "^5.0"
"php-parallel-lint/php-parallel-lint": "^1.2",
"symfony/var-dumper": "^5.1"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit b69792c

Please sign in to comment.