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