mirror of
https://github.com/v2board/v2board.git
synced 2025-01-11 00:29:09 +08:00
bot add getLatestUrl
This commit is contained in:
parent
d3d18d2390
commit
b6f2a034ec
@ -3,7 +3,9 @@
|
|||||||
namespace App\Http\Controllers\Client;
|
namespace App\Http\Controllers\Client;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Services\ServerService;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
|
use App\Utils\Clash;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
@ -20,44 +22,20 @@ class AppController extends Controller
|
|||||||
$user = $request->user;
|
$user = $request->user;
|
||||||
$userService = new UserService();
|
$userService = new UserService();
|
||||||
if ($userService->isAvailable($user)) {
|
if ($userService->isAvailable($user)) {
|
||||||
$servers = Server::where('show', 1)
|
$serverService = new ServerService();
|
||||||
->orderBy('sort', 'ASC')
|
$servers = $serverService->getAllServers($user);
|
||||||
->get();
|
|
||||||
foreach ($servers as $item) {
|
|
||||||
$groupId = json_decode($item['group_id']);
|
|
||||||
if (in_array($user->group_id, $groupId)) {
|
|
||||||
array_push($server, $item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$config = Yaml::parseFile(base_path() . '/resources/rules/app.clash.yaml');
|
$config = Yaml::parseFile(base_path() . '/resources/rules/app.clash.yaml');
|
||||||
$proxy = [];
|
$proxy = [];
|
||||||
$proxies = [];
|
$proxies = [];
|
||||||
foreach ($server as $item) {
|
|
||||||
$array = [];
|
foreach ($servers['vmess'] as $item) {
|
||||||
$array['name'] = $item->name;
|
array_push($proxy, Clash::buildVmess($user->uuid, $item));
|
||||||
$array['type'] = 'vmess';
|
array_push($proxies, $item->name);
|
||||||
$array['server'] = $item->host;
|
}
|
||||||
$array['port'] = $item->port;
|
|
||||||
$array['uuid'] = $user->uuid;
|
foreach ($servers['trojan'] as $item) {
|
||||||
$array['alterId'] = $user->v2ray_alter_id;
|
array_push($proxy, Clash::buildTrojan($user->uuid, $item));
|
||||||
$array['cipher'] = 'auto';
|
|
||||||
if ($item->tls) {
|
|
||||||
$tlsSettings = json_decode($item->tlsSettings);
|
|
||||||
$array['tls'] = true;
|
|
||||||
if (isset($tlsSettings->allowInsecure)) $array['skip-cert-verify'] = ($tlsSettings->allowInsecure ? true : false );
|
|
||||||
}
|
|
||||||
if ($item->network == 'ws') {
|
|
||||||
$array['network'] = $item->network;
|
|
||||||
if ($item->networkSettings) {
|
|
||||||
$wsSettings = json_decode($item->networkSettings);
|
|
||||||
if (isset($wsSettings->path)) $array['ws-path'] = $wsSettings->path;
|
|
||||||
if (isset($wsSettings->headers->Host)) $array['ws-headers'] = [
|
|
||||||
'Host' => $wsSettings->headers->Host
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
array_push($proxy, $array);
|
|
||||||
array_push($proxies, $item->name);
|
array_push($proxies, $item->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ class TelegramController extends Controller
|
|||||||
break;
|
break;
|
||||||
case '/traffic': $this->traffic();
|
case '/traffic': $this->traffic();
|
||||||
break;
|
break;
|
||||||
|
case '/getLatestUrl': $this->getLatestUrl();
|
||||||
|
break;
|
||||||
default: $this->help();
|
default: $this->help();
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -84,7 +86,8 @@ class TelegramController extends Controller
|
|||||||
$telegramService = new TelegramService();
|
$telegramService = new TelegramService();
|
||||||
$commands = [
|
$commands = [
|
||||||
'/bind 订阅地址 - 绑定你的' . config('v2board.app_name', 'V2Board') . '账号',
|
'/bind 订阅地址 - 绑定你的' . config('v2board.app_name', 'V2Board') . '账号',
|
||||||
'/traffic - 查询流量信息'
|
'/traffic - 查询流量信息',
|
||||||
|
'/getLatestUrl - 获取最新的' . config('v2board.app_name', 'V2Board') . '网址'
|
||||||
];
|
];
|
||||||
$text = implode(PHP_EOL, $commands);
|
$text = implode(PHP_EOL, $commands);
|
||||||
$telegramService->sendMessage($msg->chat_id, "你可以使用以下命令进行操作:\n\n$text", 'markdown');
|
$telegramService->sendMessage($msg->chat_id, "你可以使用以下命令进行操作:\n\n$text", 'markdown');
|
||||||
@ -108,4 +111,17 @@ class TelegramController extends Controller
|
|||||||
$text = "🚥流量查询\n———————————————\n计划流量:`{$transferEnable}`\n已用上行:`{$up}`\n已用下行:`{$down}`\n剩余流量:`{$remaining}`";
|
$text = "🚥流量查询\n———————————————\n计划流量:`{$transferEnable}`\n已用上行:`{$up}`\n已用下行:`{$down}`\n剩余流量:`{$remaining}`";
|
||||||
$telegramService->sendMessage($msg->chat_id, $text, 'markdown');
|
$telegramService->sendMessage($msg->chat_id, $text, 'markdown');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getLatestUrl()
|
||||||
|
{
|
||||||
|
$msg = $this->msg;
|
||||||
|
$user = User::where('telegram_id', $msg->chat_id)->first();
|
||||||
|
$telegramService = new TelegramService();
|
||||||
|
$text = sprintf(
|
||||||
|
"%s的最新网址是:%s",
|
||||||
|
config('v2board.app_name', 'V2Board'),
|
||||||
|
config('v2board.app_url')
|
||||||
|
);
|
||||||
|
$telegramService->sendMessage($msg->chat_id, $text, 'markdown');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user