You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ss-panel-v3-mod_Uim2/app/Utils/Telegram/Commands/HelpCommand.php

88 lines
2.3 KiB
PHP

<?php
namespace App\Utils\Telegram\Commands;
use App\Models\User;
use App\Services\Config;
use App\Utils\Telegram\{Process, Reply};
use Telegram\Bot\Actions;
use Telegram\Bot\Commands\Command;
/**
* Class HelpCommand.
*/
class HelpCommand extends Command
{
/**
* @var string Command Name
*/
protected $name = 'help';
/**
* @var string Command Description
*/
protected $description = '菜单';
/**
* {@inheritdoc}
*/
public function handle($arguments)
{
$Update = $this->getUpdate();
$Message = $Update->getMessage();
// 消息会话 ID
$ChatID = $Message->getChat()->getId();
if ($ChatID > 0) {
// 私人会话
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 触发用户
$SendUser = [
'id' => $Message->getFrom()->getId(),
'name' => $Message->getFrom()->getFirstName() . ' ' . $Message->getFrom()->getLastName(),
'username' => $Message->getFrom()->getUsername(),
];
$user = Process::getUser($SendUser['id']);
$reply = Reply::getInlinekeyboard($user, 'index');
// 回送信息
$this->replyWithMessage(
[
'text' => $reply['text'],
'parse_mode' => 'Markdown',
'disable_web_page_preview' => false,
'reply_to_message_id' => null,
'reply_markup' => json_encode(
[
'inline_keyboard' => $reply['keyboard']
]
),
]
);
} else {
// 群组
if (Config::get('new_telegram_group_quiet') === true || strpos($Message->getText(), '/' . $this->name) !== 0) {
// 群组中不回应
return;
}
// 发送 '输入中' 会话状态
$this->replyWithChatAction(['action' => Actions::TYPING]);
// 回送信息
$this->replyWithMessage(
[
'text' => '喵?',
]
);
}
}
}