Compare commits
2 Commits
c1ce931677
...
832be45a7a
| Author | SHA1 | Date | |
|---|---|---|---|
|
832be45a7a
|
|||
|
e42d7d75fe
|
@@ -72,9 +72,9 @@ 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, '/list') => $this->processListCommand(),
|
str_starts_with($commandText, '/list') => $this->processListCommand(),
|
||||||
str_starts_with($commandText, '/info') => $this->processInfoCommand(),
|
str_starts_with($commandText, '/info') => $this->processInfoCommand(),
|
||||||
str_starts_with($commandText, '/help') => $this->processHelpCommand(),
|
str_starts_with($commandText, '/help') => $this->processHelpCommand(),
|
||||||
@@ -89,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 = 'Плейлистов нет';
|
||||||
@@ -131,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();
|
||||||
@@ -224,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[] = 'Плейлисты проверяются сервером автоматически\.';
|
||||||
@@ -249,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());
|
||||||
@@ -274,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