Compare commits

...

2 Commits

View File

@@ -72,9 +72,9 @@ class Bot
*/
public function process(): bool
{
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
$commandText = $this->getBotCommandText();
return match (true) {
str_starts_with($commandText, '/start') => $this->processHelpCommand(),
str_starts_with($commandText, '/list') => $this->processListCommand(),
str_starts_with($commandText, '/info') => $this->processInfoCommand(),
str_starts_with($commandText, '/help') => $this->processHelpCommand(),
@@ -89,9 +89,13 @@ class Bot
*
* @return bool
* @throws InvalidArgumentException
* @throws \TelegramBot\Api\Exception
* @throws Exception
*/
protected function processListCommand(): bool
{
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
$playlists = ini()->getPlaylists();
if (empty($playlists)) {
$replyText = 'Плейлистов нет';
@@ -131,9 +135,12 @@ class Bot
*
* @return bool
* @throws InvalidArgumentException
* @throws \TelegramBot\Api\Exception
*/
protected function processInfoCommand(): bool
{
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
$message = $this->update->getMessage();
$text = $message->getText();
$command = $this->getBotCommand();
@@ -224,9 +231,12 @@ class Bot
* Обрабатывает команду /help
*
* @return bool
* @throws \TelegramBot\Api\Exception
*/
protected function processHelpCommand(): bool
{
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
$replyText[] = 'Бот предоставляет короткую сводку о плейлистах, которые видны на сайте ' .
$this->escape(base_url()) . '\.';
$replyText[] = 'Плейлисты проверяются сервером автоматически\.';
@@ -249,9 +259,12 @@ class Bot
* Обрабатывает команду /links
*
* @return bool
* @throws \TelegramBot\Api\Exception
*/
protected function processLinksCommand(): bool
{
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
$replyText[] = '*Ресурсы и страницы*';
$replyText[] = '';
$replyText[] = '🌏 Сайт: ' . $this->escape(base_url());
@@ -274,6 +287,8 @@ class Bot
*/
protected function processStatsCommand(): bool
{
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
$allChannels = [];
foreach (ini()->getPlaylists() as $pls) {
$allChannels = array_merge($allChannels, $pls['channels'] ?? []);