no message

This commit is contained in:
hellcat 2025-07-15 16:55:23 +08:00
parent 36dd451ed2
commit e7f51134d9
12 changed files with 470 additions and 82 deletions

View File

@ -35,11 +35,11 @@ final class HookController
$sText = $aUpdate["message"]["text"];
if (isset($aUpdate["is_dove"])) {
$sSendType = "dove";
} else {
$sSendType = false;
}
// if (isset($aUpdate["is_dove"])) {
// $sSendType = "dove";
// } else {
// $sSendType = false;
// }
// var_dump($sSendType);
// exit;
// test
@ -79,10 +79,10 @@ final class HookController
// 返回可以是数组
if (is_array($r)) {
foreach ($r as $row) {
$oTGHttp->sendToTG($row, $sSendType);
$oTGHttp->sendToTG($row, $aUpdate);
}
} else {
$oTGHttp->sendToTG($r, $sSendType);
$oTGHttp->sendToTG($r, $aUpdate);
}
Http::response(200);
@ -95,7 +95,7 @@ final class HookController
} catch (\Throwable $e) {
$sMessage = "错误(文件: " . $e->getFile() . ",行: " . $e->getLine() . ": " . $e->getMessage();
$oTGHttp->sendToTG($sMessage, $sSendType);
$oTGHttp->sendToTG($sMessage, $aUpdate);
Http::response(200, 'error');
}

View File

@ -6,7 +6,9 @@ use Illuminate\Http\Request;
use App\Models\Article;
use App\Models\Option;
use App\Services\TG\Http as TGHttp;
use App\Services\TomTool\Http as Http;
use App\Services\Github\Github as ServiceGithub;
use App\Services\Github\Blade as ServiceBlade;
class CronController
{
@ -21,6 +23,8 @@ class CronController
private $aArticle;
private $isTest = 0;
public function index()
{
try {
@ -29,20 +33,24 @@ class CronController
$i = date("i");
$s = date("s");
$iRand = rand(1, 1440);
$aUpdate = [];
// $isTest = 0;
//test
$aGet = $_GET;
if (isset($aGet['is_test']) && $aGet['is_test'] == 1) {
$isTest = 1;
$this->isTest = 1;
$aUpdate["shell"] = "cmd";
if ($aGet["time_type"] == 'i') {
$i = (string) $aGet['v'];
} else if ($aGet["time_type"] == 'h') {
$h = (string) $aGet['v'];
} else if ($aGet["time_type"] == "rand") {
$iRand = $aGet["v"];
} else if ($aGet["time_type"] == "id") {
$iTestId = $aGet["v"];
}
} else {
$isTest = 0;
}
// 暂停
@ -52,6 +60,17 @@ class CronController
exit("暂停");
}
// id测试
if (isset($iTestId)) {
$aArticle = Article::where("id", $iTestId)->get()->toArray();
if (!empty($aArticle)) {
$this->run($aArticle);
} else {
exit("这个id没找到");
}
exit;
}
// i_in10规则
$iIin10 = $i[1];
$aArticle = Article::where("i_in10", $iIin10)->where("status", 1)->get()->toArray();
@ -93,7 +112,7 @@ class CronController
$sMessage = "错误(文件: " . $e->getFile() . ",行: " . $e->getLine() . ": " . $e->getMessage();
$oTGHttp = new TGHttp();
$oTGHttp->sendToTG($sMessage);
$oTGHttp->sendToTG($sMessage, $aUpdate);
}
@ -109,8 +128,26 @@ class CronController
$this->sProjectPath = env("BASE_DIR")."github/".$this->sUserName."-".$this->sProjectName;
$this->sProjectUrl = "git@".$this->sMailName.".com:".$this->sUserName."/".$this->sProjectName.".git";
$this->aArticle = $row;
$aArticleRow = $row;
$sModType = $row["mod_type"] ?? "v1";
$sMod = $row["mod"];
$sReadMe = ServiceGithub::GetReadMe($row);
// 获取文章的方式
if ($sModType == "v1") {
$sReadMe = ServiceGithub::GetReadMe($row);
// 新版
} else {
$oHttp = new Http();
$oHttp->sMethod = "post";
$sMasterUrl = "https://".env("www_master")."/api/github/get";
// $oHttp->bIsJson = true;
$oHttp->aData = $row;
$sReadMe = $oHttp->send($sMasterUrl);
}
// 没有文件夹,创建一个
if (!is_dir($this->sProjectPath)) {
@ -134,9 +171,15 @@ class CronController
}
file_put_contents($this->sProjectPath."/version.text", time());
// 提交
$this->gitPush();
if ($this->isTest == 1) {
$content = file_get_contents($this->sProjectPath."/README.md");
echo $content;
exit;
} else {
$this->gitPush();
}
}
}
@ -176,7 +219,7 @@ class CronController
private function formatstr($str)
{
$str = substr($str, 1, -1);
// $str = substr($str, 1, -1);
return $str;
}

View File

@ -17,44 +17,6 @@ class TestsController
public function hook($sHostName = 'ssssss')
{
// // 定义要添加的配置
// $host = $sHostName;
// $hostname = "github.com";
// $user = "git";
// $identityFile = env("path_ssh")."/id_rsa_".$sHostName;
//
// // 构建配置字符串
// $config = "\nHost ".$host.".com\n";
// $config .= "\tHostName $hostname\n";
// $config .= "\tUser $user\n";
// $config .= "\tIdentityFile $identityFile\n";
//
// // 指定 SSH 配置文件路径
// $sshConfigFile = env("path_ssh")."/config";
//
// // 检查文件是否存在,如果不存在则创建
// if (!file_exists($sshConfigFile)) {
// touch($sshConfigFile);
// }
//
// // 追加配置到文件
// file_put_contents($sshConfigFile, $config, FILE_APPEND | LOCK_EX);
//
// // 设置文件权限
// chmod($sshConfigFile, 0600);
//
// echo "SSH config updated successfully.";
// exit;
// $t = [];
// $a = $t['zz']["cc"] += 10;
// $a = $t['zz']["cc"] += 10;
// tomd($a);
// exit;
@$k = $_GET["k"];
@$s = $_GET["s"];
@ -62,17 +24,14 @@ class TestsController
// exit("?");
// }
$s = '/'.$s;
//test
// $s = "\/AticleSet__1115zz__sale_rate 1118.118";
// $s = "\/git#LastTime 1";
$s= "/test#cron__i 07";
$s = "/dog#list";
$s = "/dog#github 1002";
$s = "/test#cron__rand 1";
$oHttp = new Http();
$oHttp->sMethod = "post";
$oHttp->sToUrl = env("APP_URL")."/api/tg/hook";

21
app/Models/Blade.php Executable file
View File

@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Blade extends Model
{
protected $table = 'blade';
public static function _listKey()
{
$aSelf = self::all()->toArray();
foreach ($aSelf as &$aSelfRow) {
unset($aSelfRow["content"]);
}
return $aSelf;
}
}

View File

@ -0,0 +1,146 @@
<?php
namespace App\Services\Github;
use App\Services\TomTool\Http;
use App\Models\Blade as ModelBlade;
function xx($x)
{
return $x;
};
class Blade extends Github{
private function echo($zz){
return $zz;
}
private function eval($sEval)
{
return eval("return ".$sEval);
}
private function date($date)
{
return date($date);
}
private function goodToStr($sGood)
{
$aGood = json_decode($sGood, true);
$sGoodStr = "";
$i = 0;
foreach ($aGood as $row) {
if ($i !== 0) {
$sGoodStr .= "
";
}
$sGoodStr .= $row;
$i++;
}
return $sGoodStr;
}
public function get($aArticle)
{
//// dog自带系列
$dog_mod = $aArticle["mod"];
$dog_mod_type = $aArticle["mod_type"];
$dog_sale_code = $aArticle["sale_code"];
$dog_sale_rate = $aArticle["sale_rate"];
$dog_ship_code = $aArticle["ship_code"];
$dog_fn_www = $aArticle["fn_www"];
//// 组合生成系列
$ex_feed_v2ray_url = "https://".$aArticle["fn_www"]."/feed/v2ray-".date("Ymd").".txt";
$ex_feed_clash_url = "https://".$aArticle["fn_www"]."/clash/v2ray-".date("Ymd").".yaml";
//// ship系列
$oHttp = new Http();
$oHttp->sMethod = "get";
$oHttp->bIsJson = true;
$sDateNow = date("Y-m-d");
$sMasterUrl = "https://".env("www_master")."/api/ship/get/".$aArticle["ship_code"]."/github/".$aArticle["user_name"]."-".$aArticle["project_name"];
$sShip = $oHttp->send($sMasterUrl);
$aShip = json_decode($sShip, true);
$ship_name = $aShip["name"];
$ship_www = $aShip["www"];
$ship_good = $this->goodToStr($aShip["good"]);
$ship_have_huodong = $aShip["have_huodong"];
$ship_huodong_str = $aShip["huodong"]["str"] ?? false;
//// ship系列end
//// rand 系列
//// good pool系列
// 随机good预留
$oHttp = new Http();
$oHttp->sMethod = "get";
$sMasterUrl = "https://".env("www_master")."/api/good/rand/".$dog_ship_code;
$oHttp->bIsJson = true;
$sGood = $oHttp->send($sMasterUrl);
$aGood = json_decode($sGood, true);
$rand_good = $this->goodToStr($aGood["good"]);
tomd($rand_good, 1);
// $ship_www =
// $aArticle["ex_ship"] = $aShip;
// $aArticle["ex_ship_name"] = $aShip["name"];
// $aArticle["ex_ship_www"] = $aShip["www"];
//
//
//
//
//
//
//
// $aArticle["ex_feed_v2ray_url"] = "https://".$aArticle["fn_www"]."/feed/v2ray-".date("Ymd").".txt";
// $aArticle["ex_feed_clash_url"] = "https://".$aArticle["fn_www"]."/clash/v2ray-".date("Ymd").".yaml";
//
// $aArticle["ex_ship"] = $aShip;
// $aArticle["ex_ship_name"] = $aShip["name"];
// $aArticle["ex_ship_www"] = $aShip["www"];
// tomd($aArticle);
// $oBlade = ModelBlade::all();
// tomd($oBlade, 1);
// echo eval("");
// echo 123;
// exit;
$zz = "???";
$s = "zabc{$this->date('Y-m-d')}defg";
return $s;
// $r = $this->GetShip($aArticle);
tomd($r, 1);
echo "balzzzzde";
exit;
}
}

View File

@ -13,22 +13,43 @@ class Github {
$sClass = "App\\Services\\Github\\Mod\\".$sClassDir."\\".$sClass;
$sFunc = "Get";
if (method_exists($sClass, $sFunc)) {
// tomd($sClass, 1);
$oInstans = new $sClass();
// $oInstans->aHuodong = self::GetHuodong($aArticle);
$oInstans->aShip = self::GetShip($aArticle);
$aShip = self::GetShip($aArticle);
$oInstans->aShip = $aShip; // 之前脑残了,这个思路傻逼,直接补充$aArticle就行了
$aArticle = self::ArticleEx($aArticle, $aShip); // 难看就难看吧,兼容一下
$sReadMe = $oInstans->$sFunc($aArticle);
return $sReadMe;
} else {
// 模版里可以返回false但不能没有模版
throw new \Exception("没找到这个模版:".$sClass."\\".$sFunc);
// return false;
}
}
// 扩展都往里这里来
public static function ArticleEx($aArticle, $aShip)
{
$aArticle["ex_feed_v2ray_url"] = "https://".$aArticle["fn_www"]."/feed/v2ray-".date("Ymd").".txt";
$aArticle["ex_feed_clash_url"] = "https://".$aArticle["fn_www"]."/clash/v2ray-".date("Ymd").".yaml";
$aArticle["ex_ship"] = $aShip;
$aArticle["ex_ship_name"] = $aShip["name"];
$aArticle["ex_ship_www"] = $aShip["www"];
return $aArticle;
}
public static function GetShip($aArticle)
{
$oHttp = new Http();
@ -40,6 +61,22 @@ class Github {
$sShip = $oHttp->send($sMasterUrl);
$aShip = json_decode($sShip, true);
$aGood = json_decode($aShip["good"], true);
// tomd($aShip, 1);
$sGoodStr = "";
$i = 0;
foreach ($aGood as $row) {
if ($i !== 0) {
$sGoodStr .= "
";
}
$sGoodStr .= $row;
$i++;
}
$aShip["good_str"] = $sGoodStr;
$aShip["youhui_str"] = "购买套餐时输入【".$aArticle['sale_code']."】优惠码,可享".$aArticle['sale_rate']."折优惠折后低至8元/月。";
if (isset($aShip["huodong"]["str"]) && !empty($aShip["huodong"]["str"])) {
@ -48,12 +85,14 @@ class Github {
".$aShip["huodong"]["str"];
}
// tomd(empty($aShip["huodong"]["str"]), 1);
// tomd($aShip, 1);
return $aShip;
}
// public static GetFeedV2ray($aArticle)
// {
//
// }
// public static function GetHuodong($aArticle)
// {

View File

@ -10,15 +10,9 @@ class C extends Base {
public function Get($aArticle)
{
// if (!$this->todayUpd()) {
// return false;
// }
$aFreenodeCountry = $this->getFreenodeCountryFromMaster();
// tomd($aFreenodeCountry, 1);
$sContent = "
# 公益免费v2ray/clash节点订阅每小时更新最后更新时间".date('Y-m-d H:i:s')."

View File

@ -0,0 +1,71 @@
<?php
namespace App\Services\Github\Mod\FreeNode;
use App\Services\Github\Mod\Base;
//use App\Services\TomTool\Http;
class D extends Base {
// public $aShip; // 必须,注入
public function Get($aArticle)
{
// if (!$this->todayUpd()) {
// return false;
// }
// tomd($aArticle, 1);
$sContent = "# 免费v2ray/clash节点订阅 每日自动更新
翻墙、免费翻墙、免费科学上网、免费节点、免费梯子、免费ss/v2ray/trojan节点、蓝灯、谷歌商店、翻墙梯子
免费节点来自:".$aArticle["fn_www"]."
## 客户端下载
| 名称 | 操作系统 | 地址 |
|------|----------|------|
| SingBox | Mac/Linux/Android/Ios | [https://sing-box.sagernet.org/clients/](https://sing-box.sagernet.org/clients/) |
| FlClash | Mac/Linux/Windows/Android | [https://github.com/chen08209/FlClash](https://github.com/chen08209/FlClash) |
| Clash Verge | Mac/Linux/Windows | [https://github.com/clash-verge-rev/clash-verge-rev](https://github.com/clash-verge-rev/clash-verge-rev) |
| Clash Meta Android | Android | [https://github.com/MetaCubeX/ClashMetaForAndroid](https://github.com/MetaCubeX/ClashMetaForAndroid) |
| ClashX Meta | Mac | [https://github.com/MetaCubeX/ClashX.Meta](https://github.com/MetaCubeX/ClashX.Meta) |
| V2RayN | Windows | [https://github.com/2dust/v2rayN](https://github.com/2dust/v2rayN) |
| V2RayNG | Android | [https://github.com/2dust/v2rayNG](https://github.com/2dust/v2rayNG) |
| V2RayU | Mac | [https://github.com/yanue/V2rayU](https://github.com/yanue/V2rayU) |
## 订阅链接:
### Clash订阅链接
- ".$aArticle["ex_feed_clash_url"]."
### V2ray订阅链接
- ".$aArticle["ex_feed_v2ray_url"]."
## 更多clash节点订阅
### 性价比机场推荐:[".$aArticle["ex_ship_name"]."](https://".$aArticle["ex_ship_www"].")
".$aArticle["ex_ship"]["good_str"]."
".$aArticle["ex_ship"]["youhui_str"]."
点击进入[".$aArticle["ex_ship_www"]."机场官网](https://".$aArticle["ex_ship_www"].")
#### 更新于:".date("Y-m-d H:i:s");
// $t = ["test1","test2"];
// $t = json_encode($t);
//
// tomd($t, 1);
tomd($sContent, 1);
return $sContent;
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace App\Services\TG\Hook\Mod;
use App\Models\Blade as ModelBlade;
class Blade extends Base {
private function filter($oBlade)
{
foreach ($oBlade as &$oBladeRow) {
unset($oBladeRow->content);
unset($oBladeRow->id);
}
return $oBlade;
}
public function List()
{
$oBlade = ModelBlade::all();
$oBlade = $this->filter($oBlade);
return $this->toJson($oBlade);
}
public function Find($aParam)
{
$sField = $aParam["aOption"][1] ?? "id";
$sValue = $aParam["aArg"][1] ?? false;
if ($sValue == "?") {
return "/blade#find__{field?} {value}";
}
$oBlade = ModelBlade::where($sField, $sValue)->first();
return $oBlade->content;
}
public function Like($aParam)
{
$sField = $aParam["aOption"][1] ?? false;
$sValue = $aParam["aArg"][1] ?? false;
if ($sValue == "?") {
return "/blade#like__{field} {value}";
}
if (!$sField) {
return "需要field";
}
if (!$sValue) {
return "需要value";
}
$oBlade = ModelBlade::where($sField, "like", "%".$sValue."%")->get();
$oBlade = $this->filter($oBlade);
return $this->toJson($oBlade);
}
public function Del($aParam)
{
$sCode = $aParam["aArg"][]
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Services\TG\Hook\Mod;
//use App\Models\Article as ModelArticle;
class Db extends Base {
public function sql($aParam)
{
if ($aParam["aArg"][1] == "?") {
return "/db#sql {value}";
}
$aValue = $aParam["aArg"];
$sValue = implode(" ", $aValue);
$r = \DB::statement($sValue);
return $r;
}
public function me()
{
$str = "
添加字段ALTER Table `ship` ADD `good_test` TEXT DEFAULT NULL AFTER `api_huodong`
删除字段ALTER TABLE `ship` DROP COLUMN `good_test`
修改字段ALTER TABLE `ship` MODIFY `good_test` VARCHAR(255) DEFAULT NULL
";
return $str;
}
}

View File

@ -9,12 +9,19 @@ class Test extends Base {
{
$sTimeType = $aParam["aOption"][1];
$sValue = $aParam["aArg"][1];
$sIsText = $aParam["aOption"][2] ?? "yes";
if ($sIsText == "yes") {
$is_test = true;
} else if ($sIsText == "no") {
$is_test = false;
}
$this->oHttp->sMethod = "get";
$this->oHttp->sToUrl = env("APP_URL")."/cron";
$this->oHttp->bIsJson = true;
$this->oHttp->aData = [
"is_test" => true,
"is_test" => $is_test,
"time_type" => $sTimeType,
"v" => $sValue
];

View File

@ -13,29 +13,33 @@ class Http {
$this->sApiChatId = env('telegram_chatid');
}
public function sendToTG($sMsg, $mType = false)
public function sendToTG($sMsg, $aUpdate = [])
{
// var_dump($mType);
// exit;
if ($mType == "dove") {
if (isset($aUpdate["shell"]) && $aUpdate["shell"] == "cmd") {
echo $sMsg;
if (env("is_loc") == true) {
echo "<pre>";
}
} else if (isset($aUpdate["is_dove"]) && $aUpdate["is_dove"] == true) {
echo $sMsg;
} else {
if (env("is_loc") == true) {
echo "<pre>";
echo($sMsg);
echo $sMsg;
} else {
$url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
file_get_contents($url);
}
// if (env("is_loc") == true) {
// echo "<pre>";
// echo $sMsg;
// } else {
// $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
// file_get_contents($url);
// }
}