no message

This commit is contained in:
hellcat committed 2025-05-05 17:54:15 +08:00
1 parent 5f9f707c8e
commit 2b2d20fde7
62 files changed
+617 -212

No files matched your search

+4 -11
View File
@@ -4,26 +4,19 @@ declare(strict_types=1);
namespace App\Http\Controllers\Api\TG;
use App\Models\Article;
//use App\Models\Article;
use App\Services\TomTool\Http;
use App\Services\TG\Http as TGHttp;
final class HookController
{
public function __construct()
{
// $this->middleware('csrf')->except(['cmd']);
// 或者 $this->middleware('csrf')->only(['specificMethod']);
}
public function cmd()
{
try {
$oTGHttp = new TGHttp();
$oTGHttp->sApiToken = env('telegram_token');
$oTGHttp->sApiChatId = env('telegram_chatid');
@@ -31,7 +24,7 @@ final class HookController
$aUpdate = json_decode($sUpdate, true);
@file_put_contents('/www/_tg/bot_log.txt', json_encode($aUpdate, JSON_PRETTY_PRINT));
// @file_put_contents('/www/_tg/bot_log.txt', json_encode($aUpdate, JSON_PRETTY_PRINT));
$aData['chatId'] = $aUpdate["message"]["chat"]["id"];
$aData['fromId'] = $aUpdate["message"]["from"]["id"];
@@ -132,6 +132,7 @@ class ListController extends Controller
'sMenu' => $sMenu,
'sType' => $sType,
'sTypeSub' => $sTypeSub,
// 'sSiteCode' => env('site_code'),
]);
}
}
+11 -1
View File
@@ -303,7 +303,12 @@ class ExecController extends Controller
'美国、新加坡、日本、俄罗斯',
'香港、台湾、美国、日本、新加坡、德国',
'美国、新加坡、加拿大、香港、欧洲、韩国、日本',
'美国、日本、新加坡、台湾'
'美国、日本、新加坡、台湾',
'日本、香港、台湾、越南、土耳其、阿根廷、俄罗斯',
'日本、台湾、新加坡,韩国、俄罗斯、法国、美国、德国',
'新加坡、日本、台湾、美国、韩国、德国、香港',
'香港、台湾、日本、韩国、越南、阿根廷、俄罗斯、加拿大、美国',
'上'
];
$iNodeRegionRandKey = array_rand($aNodeRegionPool);
$sNodeZone = $aNodeRegionPool[$iNodeRegionRandKey];
@@ -398,6 +403,9 @@ class ExecController extends Controller
// 直接生成文章
public function freenodeDataAll ()
{
ArticleList::where('type', 'node')->delete(); // 先删除节点文章
$sTimeSet = -env('freenode_keep_day');
for ($i=$sTimeSet; $i<=0; $i++) {
@@ -409,6 +417,7 @@ class ExecController extends Controller
$sDateCodePrev = date("Ymd", $sTimePrev);
//// 文章入库 start
// 图片
$iPrevImgId = ArticleList::where("code", $sDateCodePrev)->first()?->img_id;
if ($iPrevImgId >= env('article_img_count')) {
@@ -486,6 +495,7 @@ class ExecController extends Controller
dd($sDateCodeStart);
}
// 指定文章静态化
public function freenodeHtmlSingle($code)
{
+72 -33
View File
@@ -7,47 +7,86 @@ use App\Models\ArticleList;
use App\Services\Time;
use voku\helper\AntiXSS;
use App\Models\Tags;
use App\Services\TomTool\Http;
class SakaiController extends Controller
{
public function tool() {
// $directory = 'feed'; // 替换为你的文件夹路径
// $files = glob($directory . '/clash-*'); // 查找以sss开头的文件
//
// foreach ($files as $file) {
// $pathInfo = pathinfo($file); // 获取文件信息
// $newFileName = $pathInfo['dirname'] . '/' . $pathInfo['filename'] . '.yaml'; // 新文件名
// rename($file, $newFileName); // 重命名文件
// }
//
// echo "文件后缀已更改为 .ccc";
//
// exit;
// $k = request('k');
//
// if ($k != env('k')) {
// exit;
// }
$kv = [
'节点每日更新 @cron' => '/exec/freenode/up',
'静态生成 - 客户端文章' => '/exec/html/client',
'模版 - 免费节点文章' => '/fn/single/20241231',
'模版 - 客户端文章' => '/client/singe/1001',
'静态生成 - 热门标签 @cron' => '/exec/html/toptags',
'节点文章 - 批量抓' => '/exec/freenode/craw',
'节点文章 - 自动删除 @cron' => '/exec/freenode/del',
'点赞 - 初始数据' => '/exec/like/init',
'点赞 - 自动增加 @cron' => '/exec/like/auto',
'节点文章 - 生成数据' => '/exec/freenode/data/all',
'所有文章 - 静态化' => '/exec/freenode/html/all',
"/exec/cron" => "cron n合1",
"@cron /exec/freenode/up" => "免费节点文章每日更新",
"@cron /exec/freenode/del" => "免费节点文章自动删除(超过1年)",
"@cron /exec/html/toptags" => "静态生成 - 热门标签",
"@cron /exec/like/auto" => "自动点赞",
"/exec/html/client" => "静态生成 - 客户端文章",
"/exec/html/article" => "静态生成 - 所有文章",
"/exec/html/single/{code}" => "静态生成 - 指定文章",
"/exec/data/freenode/all" => "数据生成 - 所有免费节点文章(一年)(凭空生成无压力)",
"/exec/like/init" => "点赞重新赋值 - 所有文章(无压力刷着玩)",
"/exec/freenode/craw/{day}" => "免费节点文章批量抓(循环调用up)",
];
return view('test/tool', [
'ky' => $kv
]);
$str = "\n";
foreach ($kv as $k => $v) {
$str .= $k." >>> ".$v."\n\n";
}
$str .= "\n";
echo $str;
exit;
}
public function test1()
{
@$k = $_GET["k"];
@$s = $_GET["s"];
if ($k !== "wocaonide") {
exit("?");
}
$s = '/'.$s;
//test
// $s = "\/AticleSet__1115zz__sale_rate 1118.118";
// $s = "\/git#LastTime 1";
$s= "/cmd#list";
$oHttp = new Http();
$oHttp->sMethod = "post";
$oHttp->sToUrl = env("APP_URL")."/api/tg/hook";
$oHttp->bIsJson = true;
$oHttp->aData = [
'update_id' => 123456789,
'message' => [
'message_id' => 1,
'from' => [
'id' => 7740568271,
'is_bot' => false,
'first_name' => 'John',
'last_name' => 'Doe',
'username' => 'johndoe',
'language_code' => 'en'
],
'chat' => [
'id' => -4668400285,
'first_name' => 'John',
'last_name' => 'Doe',
'username' => 'johndoe',
'type' => 'private'
],
'date' => 1610000000,
"text" => $s,
]
];
$r = $oHttp->send();
var_dump($r);
exit;
}
}
-112
View File
@@ -1,112 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api\TG;
use App\Models\Article;
use App\Services\TomTool\Http;
use App\Services\TG\Http as TGHttp;
final class HookController
{
public function __construct()
{
// $this->middleware('csrf')->except(['cmd']);
// 或者 $this->middleware('csrf')->only(['specificMethod']);
}
public function cmd()
{
try {
$oTGHttp = new TGHttp();
$oTGHttp->sApiToken = env('telegram_token');
$oTGHttp->sApiChatId = env('telegram_chatid');
$sUpdate = file_get_contents("php://input");
$aUpdate = json_decode($sUpdate, true);
@file_put_contents('/www/_tg/bot_log.txt', json_encode($aUpdate, JSON_PRETTY_PRINT));
$aData['chatId'] = $aUpdate["message"]["chat"]["id"];
$aData['fromId'] = $aUpdate["message"]["from"]["id"];
if (!isset($aUpdate["message"]["text"])) {
throw new \Exception("?");
}
$sText = $aUpdate["message"]["text"];
// test
// $sText = "\\//Article#List ni__aaa__bbb 111 222";
// $sText = "///\\\SaleCode#SetRate__zzxx 2";
// $sText = "///\\\SaleCode#List";
// $sText = "///\\\SaleCode#Find zzxx";
// $sText = "/Article#Like__sale_code zzx";
// $sText = "////Article#Add jxxjjjj";
// $sText = "//\\\//Article#Del 9";
// $sText = "/Article#Set__1__user_name xxx";
@$aArg = explode(" ", $sText);
@$aOption = explode("__", $aArg[0]);
$sCmd = $this->cleanCmd($aOption[0]);
list($sClass, $sFunc) = explode("#", $sCmd);
$sClass = ucfirst($sClass);
$sFunc = ucfirst($sFunc);
unset($aOption[0]);
unset($aArg[0]);
$aParams['aOption'] = $aOption;
$aParams['aArg'] = $aArg;
$sClassPath = "App\\Services\\TG\\Hook\\Mod\\".$sClass;
if (method_exists($sClassPath, $sFunc)) {
$oInstans = new $sClassPath();
$r = $oInstans->$sFunc($aParams);
// 可以不返回,里面直接send
if (isset($r)) {
if (empty($r)) { $r = 'hook的mod返回空'; }
// 返回可以是数组
if (is_array($r)) {
foreach ($r as $row) {
$oTGHttp->sendToTG($row);
}
} else {
$oTGHttp->sendToTG($r);
}
Http::response(200, 'ok');
}
} else {
throw new \Exception("没有这个方法:".$sClass.'#'.$sFunc);
}
} catch (\Throwable $e) {
$sMessage = "错误(line:".$e->getLine()."): " . $e->getMessage();
$oTGHttp->sendToTG($sMessage);
Http::response(200, 'error');
}
}
private function cleanCmd($input) {
$input = str_replace('\\', '', $input);
$input = str_replace('/', '', $input);
return $input;
}
}