mirror of
https://github.com/v2board/v2board.git
synced 2024-11-15 00:09:13 +08:00
29 lines
1.2 KiB
PHP
29 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Plugins\Telegram\Commands;
|
|
|
|
use App\Models\User;
|
|
use App\Plugins\Telegram\Telegram;
|
|
use App\Utils\Helper;
|
|
|
|
class Traffic extends Telegram {
|
|
public $command = '/traffic';
|
|
public $description = '查询流量信息';
|
|
|
|
public function handle($message, $match = []) {
|
|
$telegramService = $this->telegramService;
|
|
if (!$message->is_private) return;
|
|
$user = User::where('telegram_id', $message->chat_id)->first();
|
|
if (!$user) {
|
|
$telegramService->sendMessage($message->chat_id, '没有查询到您的用户信息,请先绑定账号', 'markdown');
|
|
return;
|
|
}
|
|
$transferEnable = Helper::trafficConvert($user->transfer_enable);
|
|
$up = Helper::trafficConvert($user->u);
|
|
$down = Helper::trafficConvert($user->d);
|
|
$remaining = Helper::trafficConvert($user->transfer_enable - ($user->u + $user->d));
|
|
$text = "🚥流量查询\n———————————————\n计划流量:`{$transferEnable}`\n已用上行:`{$up}`\n已用下行:`{$down}`\n剩余流量:`{$remaining}`";
|
|
$telegramService->sendMessage($message->chat_id, $text, 'markdown');
|
|
}
|
|
}
|