no message
This commit is contained in:
parent
16a45ee4c8
commit
55ea14bbcf
@ -24,7 +24,7 @@ final class HookController
|
||||
$aUpdate = json_decode($sUpdate, true);
|
||||
$sText = $aUpdate["message"]["text"] ?? "没有text";
|
||||
if (!str_starts_with($sText, '/')) {
|
||||
$this->sCustomText = "/article#cacheAdd__{$sGroupCode}"." ".$sUpdate;
|
||||
$this->sCustomText = "/cacheTg#add__{$sGroupCode}"." ".$sUpdate;
|
||||
}
|
||||
|
||||
$this->cmd();
|
||||
@ -90,7 +90,6 @@ final class HookController
|
||||
$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'] = (string) $aUpdate["message"]["chat"]["id"];
|
||||
@ -170,6 +169,7 @@ final class HookController
|
||||
TelegramSlave::fail()->enableSlaveQueue(false)->setMsgA($aDataTg)->send();
|
||||
|
||||
$aDataCmd = $aDataTg;
|
||||
$aDataCmd["_update"] = $aUpdate;
|
||||
$sDataCmd = json_encode($aDataCmd, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
$sDataCmd = str_replace("\\n", "<br>", $sDataCmd);
|
||||
echo $sDataCmd;
|
||||
|
||||
@ -7,18 +7,19 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class ArticleSchema extends Model
|
||||
{
|
||||
protected $table = 'article_schema';
|
||||
// public $timestamps = false;
|
||||
|
||||
// public static function _listKey()
|
||||
// {
|
||||
// $aSelf = self::all()->toArray();
|
||||
//
|
||||
// foreach ($aSelf as &$aSelfRow) {
|
||||
// unset($aSelfRow["content"]);
|
||||
// }
|
||||
//
|
||||
// return $aSelf;
|
||||
// }
|
||||
|
||||
public function _opt(array $aKv)
|
||||
{
|
||||
$aOpt = json_decode($this->opt, true) ?? [];
|
||||
|
||||
foreach ($aKv as $k => $v) {
|
||||
$aOpt[$k] = $v;
|
||||
}
|
||||
|
||||
$this->opt = $aOpt;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -4,21 +4,14 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticleCache extends Model
|
||||
class CacheTg extends Model
|
||||
{
|
||||
protected $table = 'article_cache';
|
||||
protected $table = 'cache_tg';
|
||||
public $timestamps = false;
|
||||
|
||||
// public static function _listKey()
|
||||
// {
|
||||
// $aSelf = self::all()->toArray();
|
||||
//
|
||||
// foreach ($aSelf as &$aSelfRow) {
|
||||
// unset($aSelfRow["content"]);
|
||||
// }
|
||||
//
|
||||
// return $aSelf;
|
||||
// }
|
||||
|
||||
protected $fillable = [
|
||||
'status',
|
||||
'code',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@ -4,21 +4,10 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticleCacheTime extends Model
|
||||
class CacheTgTime extends Model
|
||||
{
|
||||
protected $table = 'article_cache_time';
|
||||
protected $table = 'cache_tg_time';
|
||||
public $timestamps = false;
|
||||
|
||||
// public static function _listKey()
|
||||
// {
|
||||
// $aSelf = self::all()->toArray();
|
||||
//
|
||||
// foreach ($aSelf as &$aSelfRow) {
|
||||
// unset($aSelfRow["content"]);
|
||||
// }
|
||||
//
|
||||
// return $aSelf;
|
||||
// }
|
||||
|
||||
protected $fillable = ['group_code', 'time'];
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ namespace App\Services\Article;
|
||||
use App\Models\SiteMap as ModelSiteMap;
|
||||
use App\Models\ArticleSchema as ModelArticleSchema;
|
||||
use App\Models\ArticleSiteMapGroup as ModelArticleSiteMapGroup;
|
||||
use App\Services\SlaveMap as ServiceSlaveMap;
|
||||
//use App\Services\SlaveMap as ServiceSlaveMap;
|
||||
use App\Services\TomTool\Flow;
|
||||
|
||||
/**
|
||||
@ -36,7 +36,7 @@ use App\Services\TomTool\Flow;
|
||||
clear()
|
||||
|
||||
helper:
|
||||
::helper_buildCmd($sCmdKey, $sCmd = '', $sValue = '')
|
||||
::helper_buildCmd($sCmdKey, $sCmd = '', $aOpt = '')
|
||||
::helper_buildCmdKey($sSiteGroupCode, $sSiteCode)
|
||||
::helper_cmdKeyByArticleGroup($sArticleGoupCode, $xDefultCmd = '', $xDefultValue = '')
|
||||
|
||||
@ -119,7 +119,7 @@ final class Cmd
|
||||
return $oFlow->done();
|
||||
}
|
||||
|
||||
public function save(string $sCmd = '', string $sValue = ''): Flow
|
||||
public function save(string $sCmd = '', $aOpt = []): Flow
|
||||
{
|
||||
$oFlow = Flow::start("save");
|
||||
|
||||
@ -131,7 +131,7 @@ final class Cmd
|
||||
if ($this->sSiteCode) {
|
||||
|
||||
$sCmdKey = self::helper_buildCmdKey($this->sSiteGroupCode, $this->sSiteCode);
|
||||
$aCmd = self::helper_buildCmd($sCmdKey, $sCmd, $sValue, $sSiteCode);
|
||||
$aCmd = self::helper_buildCmd($sCmdKey, $sCmd, $aOpt, $sSiteCode);
|
||||
$aCmdList[$sCmdKey] = $aCmd;
|
||||
|
||||
} else if ($this->sSiteGroupCode) {
|
||||
@ -140,12 +140,12 @@ final class Cmd
|
||||
|
||||
foreach ($aSiteList as $sSiteCode) {
|
||||
$sCmdKey = self::helper_buildCmdKey($this->sSiteGroupCode, $sSiteCode);
|
||||
$aCmd = self::helper_buildCmd($sCmdKey, $sCmd, $sValue, $sSiteCode);
|
||||
$aCmd = self::helper_buildCmd($sCmdKey, $sCmd, $aOpt, $sSiteCode);
|
||||
$aCmdList[$sCmdKey] = $aCmd;
|
||||
}
|
||||
|
||||
} else {
|
||||
$aCmdListNew = self::helper_cmdKeyByArticleGroup($this->oArticle->group_code, $sCmd, $sValue);
|
||||
$aCmdListNew = self::helper_cmdKeyByArticleGroup($this->oArticle->group_code, $sCmd, $aOpt);
|
||||
foreach ($aCmdListNew as $sCmdKey => $aCmdListNewRow) {
|
||||
$aCmdList[$sCmdKey] = $aCmdListNewRow;
|
||||
}
|
||||
@ -166,7 +166,7 @@ final class Cmd
|
||||
private function _syncAuto()
|
||||
{
|
||||
$this->useArticle();
|
||||
$aCmd = json_decode($this->oArticle->cmd, true);
|
||||
$aCmd = json_decode($this->oArticle->cmd, true) ?? [];
|
||||
|
||||
if (count($aCmd) > 0) {
|
||||
$this->oArticle->enable_sync = 1;
|
||||
@ -193,12 +193,12 @@ final class Cmd
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function helper_buildCmd($sCmdKey, $sCmd = '', $sValue = '', $sSiteCode = '')
|
||||
public static function helper_buildCmd($sCmdKey, $sCmd = '', $aOpt = [], $sSiteCode = '')
|
||||
{
|
||||
$arr = [
|
||||
"site_code"=> $sSiteCode,
|
||||
"cmd" => $sCmd,
|
||||
"value" => $sValue,
|
||||
"opt" => $aOpt,
|
||||
"date" => date("Y-m-d H:i:s"),
|
||||
];
|
||||
|
||||
|
||||
@ -11,6 +11,10 @@ use App\Services\TomTool\Telegram\Slave as TeleSlave;
|
||||
use App\Services\TomTool\Flow;
|
||||
//use App\Services\Article\Cmd as ServiceArticleCmd;
|
||||
//use App\Models\Option as ModelOption;
|
||||
//use Intervention\Image\Facades\Image;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
final class Schema
|
||||
{
|
||||
@ -42,12 +46,13 @@ final class Schema
|
||||
$oInstance = new self();
|
||||
$oInstance->sArticleCode = $sArticleCode;
|
||||
$oInstance->sSiteCode = $sSiteCode;
|
||||
$oInstance->oArticle = $oArticleSchema;
|
||||
$oInstance->sSiteGroupCode = $oSiteMap->group_code;
|
||||
$oInstance->sSiteName = $oSiteMap->name;
|
||||
$oInstance->sSiteUrl = $oSiteMap->url;
|
||||
// $oInstance->sArticleConfig = $sArticleConfig;
|
||||
|
||||
$oInstance->oArticle = $oArticleSchema;
|
||||
|
||||
return $oInstance;
|
||||
}
|
||||
|
||||
@ -66,43 +71,156 @@ final class Schema
|
||||
|
||||
|
||||
// 废弃,改直接推了
|
||||
public function api_buildArticle()
|
||||
// public function api_buildArticle()
|
||||
// {
|
||||
// $oFlow = Flow::start("api_buildArticle");
|
||||
//
|
||||
// $sArg = file_get_contents('php://input');
|
||||
// $aArg = json_decode($sArg, true);
|
||||
//
|
||||
// $sArticleCode = $aArg[""] ?? '';
|
||||
// $sSiteCode = $aArg["sSiteCode"] ?? ''; // ffcp
|
||||
// $sSiteName = $aArg["sSiteName"] ?? ''; // ttcp
|
||||
// $sSiteUrl = $aArg["sSiteUrl"] ?? ''; // ttcp.com
|
||||
// $isTest = $aArg["isTest"] ?? false;
|
||||
//
|
||||
// $sSiteGroupCode = ModelSiteMap::where("code", $sSiteCode)->first()?->group_code;
|
||||
// $oArticleSchema = ModelArticleSchema::where("code", $sArticleCode)->first();
|
||||
//
|
||||
// $aArg = [
|
||||
// "sArticleCode" => $sArticleCode,
|
||||
// "sSiteGroupCode"=> $sSiteGroupCode,
|
||||
// "sSiteCode" => $sSiteCode,
|
||||
// "sSiteName" => $sSiteName,
|
||||
// "sSiteUrl" => $sSiteUrl,
|
||||
// "isTest" => $isTest,
|
||||
// "aSchema" => json_decode($oArticleSchema->schema, true),
|
||||
// ];
|
||||
//
|
||||
// $sMethod = "build_article__".$sSiteGroupCode;
|
||||
// if (method_exists($this, $sMethod)) {
|
||||
// $oArticleFlow = $this->$sMethod($aArg);
|
||||
// } else {
|
||||
// $aResult = $oFlow->fail("没有".$sMethod."的对应处理")->getResult();
|
||||
// echo json_encode($aReturn);
|
||||
// exit;
|
||||
// }
|
||||
//
|
||||
// echo json_encode($oArticleFlow->getResult());
|
||||
// exit;
|
||||
// }
|
||||
|
||||
private function build_article__resource()
|
||||
{
|
||||
$oFlow = Flow::start("api_buildArticle");
|
||||
$oFlow = Flow::start("build_article__resource");
|
||||
|
||||
$sArg = file_get_contents('php://input');
|
||||
$aArg = json_decode($sArg, true);
|
||||
$aSchema = json_decode($this->oArticle->schema, true) ?? [];
|
||||
$aSchemaData = $aSchema["data"] ?? [];
|
||||
$sSchemaType = $aSchema["type"] ?? '';
|
||||
|
||||
$sArticleCode = $aArg[""] ?? '';
|
||||
$sSiteCode = $aArg["sSiteCode"] ?? ''; // ffcp
|
||||
$sSiteName = $aArg["sSiteName"] ?? ''; // ttcp
|
||||
$sSiteUrl = $aArg["sSiteUrl"] ?? ''; // ttcp.com
|
||||
$isTest = $aArg["isTest"] ?? false;
|
||||
$aDataSend = []; // 它是各站各异的,不保存
|
||||
$aSchemaPro = []; // 他是上者的通用版本,保存一份
|
||||
|
||||
$sSiteGroupCode = ModelSiteMap::where("code", $sSiteCode)->first()?->group_code;
|
||||
$oArticleSchema = ModelArticleSchema::where("code", $sArticleCode)->first();
|
||||
$iRowId = 0;
|
||||
foreach ($aSchemaData as $aSchemaDataRow) {
|
||||
$iRowId++;
|
||||
|
||||
$aSchemaProRow = [];
|
||||
$aSchemaProRow["type"] = $aSchemaDataRow["type"] ?? '';
|
||||
$aSchemaProRow["data"] = []; // 默认空,等于判断之外的给空
|
||||
|
||||
if ($sSchemaType == "cache_tg") {
|
||||
if ($this->oArticle->group_code == "tg_xiuren_a") {
|
||||
if ($aSchemaProRow["type"] == "photo") {
|
||||
|
||||
// $sRowUuid = $sUuid = Str::uuid()->toString();
|
||||
|
||||
$iPhotoFullSizeKey = $aSchemaDataRow["photo_fullSizeKey"];
|
||||
$aPhotoFullSize = $aSchemaDataRow["photo"][$iPhotoFullSizeKey];
|
||||
|
||||
// --- 裁剪参数配置区(指挥部) ---
|
||||
$iWatermarkTop = 50; // 顶部裁掉的水印高度
|
||||
$iWatermarkBottom = 38; // 底部裁掉的水印高度 (合计88)
|
||||
$iThumbClipHeight = 500; // 裁剪取样的原始高度
|
||||
$iTargetHeight = 400; // 缩略图最终输出高度
|
||||
|
||||
// 各部位起始偏移(基于裁完水印后的底部向上计算)
|
||||
$iOffsetLeg = 0; // 腿:贴底
|
||||
$iOffsetBody = 500; // 身:从底往上500位置开始
|
||||
$iOffsetHead = 600; // 头:从底往上600位置开始
|
||||
|
||||
// --- 1. 初始化阵地 ---
|
||||
$oImageManager = new ImageManager(new Driver());
|
||||
$oImgMain = $oImageManager->read($aPhotoFullSize["file_path"]);
|
||||
$sExtension = pathinfo($aPhotoFullSize["file_path"], PATHINFO_EXTENSION);
|
||||
$sUploadPath = 'upload/';
|
||||
$sUploadDir = config('system.dir_base') . "public/" . $sUploadPath;
|
||||
$aSavedPath = []; // 弹药库:存放所有生成的路径
|
||||
|
||||
// --- 2. 预处理:裁掉水印 ---
|
||||
$iMainHeight = $oImgMain->height() - ($iWatermarkTop + $iWatermarkBottom);
|
||||
// 保险:防止原图高度不足以支撑裁切
|
||||
$iMainHeight = max(1, $iMainHeight);
|
||||
$oImgMain->crop($oImgMain->width(), $iMainHeight, 0, $iWatermarkTop);
|
||||
|
||||
// 保存全尺寸去水印图
|
||||
$sTmp = $this->oArticle->code . '-'.$iRowId.'-full.' . $sExtension;
|
||||
$sFullSavePath = $sUploadDir . $sTmp;
|
||||
$sFullSavePathUrl = $sUploadPath . $sTmp;
|
||||
$oImgMain->save($sFullSavePath);
|
||||
$aSavedPath['full'] = $sFullSavePathUrl;
|
||||
|
||||
// --- 3. 局部裁剪与归档:[后缀 => 距离底部的偏移] ---
|
||||
$aClips = [
|
||||
'thumb_a' => $iOffsetHead,
|
||||
'thumb_b' => $iOffsetBody,
|
||||
'thumb_c' => $iOffsetLeg,
|
||||
];
|
||||
|
||||
// 遍历截取图片
|
||||
foreach ($aClips as $sSuffix => $iBottomOffset) {
|
||||
// 必须克隆,保护主阵地不被连环裁剪搞残
|
||||
$oTmp = clone $oImgMain;
|
||||
$iCurrentH = $oTmp->height();
|
||||
|
||||
// 计算 Y 轴起点:总高 - 底部偏移 - 准备截取的高度
|
||||
$iY = max(0, $iCurrentH - $iBottomOffset - $iThumbClipHeight);
|
||||
|
||||
// 计算实际可截取高度:防止上方空间不足
|
||||
$iH = ($iCurrentH > $iBottomOffset) ? min($iThumbClipHeight, $iCurrentH - $iBottomOffset) : 1;
|
||||
|
||||
// 拼装存储路径
|
||||
$sTmp = $this->oArticle->code.'-'.$iRowId.'-'.$sSuffix.'.'.$sExtension;
|
||||
$sCurrentPath = $sUploadDir . $sTmp;
|
||||
$sCurrentPathUrl = $sUploadPath . $sTmp;
|
||||
|
||||
// 执行:裁切 -> 等比例缩放 -> 保存
|
||||
$oTmp->crop($oTmp->width(), $iH, 0, $iY)
|
||||
->scale(height: $iTargetHeight)
|
||||
->save($sCurrentPath);
|
||||
|
||||
// 路径入库
|
||||
$aSavedPath[$sSuffix] = $sCurrentPathUrl;
|
||||
|
||||
unset($oTmp); // 及时释放资源,老兵的职业操守
|
||||
}
|
||||
|
||||
$aSchemaProRow["data"] = $aSavedPath;
|
||||
|
||||
$aSchemaPro[] = $aSchemaProRow; // 关键
|
||||
$aDataSend[] = $aSchemaProRow; // 公约
|
||||
} // is photo
|
||||
} // xiuren end
|
||||
} // cache_tg end
|
||||
|
||||
} // schema foreach end
|
||||
|
||||
$aArg = [
|
||||
"sArticleCode" => $sArticleCode,
|
||||
"sSiteGroupCode"=> $sSiteGroupCode,
|
||||
"sSiteCode" => $sSiteCode,
|
||||
"sSiteName" => $sSiteName,
|
||||
"sSiteUrl" => $sSiteUrl,
|
||||
"isTest" => $isTest,
|
||||
"aSchema" => json_decode($oArticleSchema->schema, true),
|
||||
];
|
||||
|
||||
$sMethod = "build_article__".$sSiteGroupCode;
|
||||
if (method_exists($this, $sMethod)) {
|
||||
$oArticleFlow = $this->$sMethod($aArg);
|
||||
} else {
|
||||
$aResult = $oFlow->fail("没有".$sMethod."的对应处理")->getResult();
|
||||
echo json_encode($aReturn);
|
||||
exit;
|
||||
}
|
||||
$this->oArticle->schema_pro = $aSchemaPro;
|
||||
$this->oArticle->save();
|
||||
|
||||
echo json_encode($oArticleFlow->getResult());
|
||||
exit;
|
||||
return $oFlow->setDataA($aDataSend)->done();
|
||||
|
||||
}
|
||||
|
||||
private function build_article__jccp_a()
|
||||
|
||||
@ -4,65 +4,198 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\BoxCountry as ModelCountry;
|
||||
use App\Models\CacheTg as ModelCacheTg;
|
||||
use App\Models\CacheTgTime as ModelCacheTgTime;
|
||||
use App\Models\ArticleSchema as ModelArticleSchema;
|
||||
use App\Services\TomTool\Flow;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
//use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Models\TelegramKey as ModelTelegramKey;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Services\Article\Cmd as ServiceArticleCmd;
|
||||
|
||||
final class Country
|
||||
final class CacheTg
|
||||
{
|
||||
|
||||
// case等于不同的集成方案
|
||||
public function rand($sCase = "a")
|
||||
public function add($sContent, $sGroupCode)
|
||||
{
|
||||
$oFlow = Flow::start("CacheTg::add");
|
||||
|
||||
if ($sCase == "a") {
|
||||
$iCountryLimit = rand(5, 8); // 平均6
|
||||
$iNodeLimit = rand(10, 35); // 平局20多
|
||||
$iSpeedLimit = rand(5, 30);
|
||||
$oModelCacheTg = new ModelCacheTg();
|
||||
$oModelCacheTg->content = $sContent;
|
||||
$oModelCacheTg->group_code = $sGroupCode;
|
||||
$r = $oModelCacheTg->save();
|
||||
|
||||
if (!$r) {
|
||||
return $oFlow->fail("add失败?");
|
||||
}
|
||||
|
||||
//test
|
||||
// $iCountryLimit = 3;
|
||||
$r = ModelCacheTgTime::updateOrCreate(
|
||||
['group_code' => $sGroupCode], // 查找条件:有没有这个组?
|
||||
['time' => time()] // 更新或创建的数据:就改这个时间!
|
||||
);
|
||||
|
||||
$iNodeCount = $iNodeLimit;
|
||||
$iSpeed = $iSpeedLimit;
|
||||
|
||||
$aCountry = ModelCountry::all()->toArray();
|
||||
|
||||
shuffle($aCountry);
|
||||
|
||||
$i = 1;
|
||||
$aRandCountry = [];
|
||||
foreach ($aCountry as $aCountryRow) {
|
||||
|
||||
if (in_array($aCountryRow["name"], $aRandCountry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$aRandCountry[] = $aCountryRow["name"];
|
||||
|
||||
if ($i >= $iCountryLimit) {
|
||||
break;
|
||||
} else {
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$r->exists) {
|
||||
return $oFlow->fail("cache写入成功但time更新失败?");
|
||||
}
|
||||
|
||||
$aData["country"] = $aRandCountry;
|
||||
$aData["nodeCount"] = $iNodeCount;
|
||||
$aData["speed"] = $iSpeed;
|
||||
// $aData["str"] = "本次更新共".$iNodeLimit."个可用节点,";
|
||||
|
||||
return $aData;
|
||||
//
|
||||
// echo json_encode($aData);
|
||||
// exit;
|
||||
return $oFlow->done();
|
||||
}
|
||||
|
||||
public function strGithub($randData)
|
||||
public static function cron_saveToSchema()
|
||||
{
|
||||
$str = date('Y年m月d日').",本次更新共".$randData["nodeCount"]."个可用节点,最高速度".$randData["speed"]."M/S。覆盖".implode("、", $randData["country"])."等多个区域。";
|
||||
$sCronMsg = '';
|
||||
|
||||
return $str;
|
||||
$sCronMsg .= "\n\nCacheTg::saveToSchema() - 开始";
|
||||
|
||||
$bHaveTime = ModelCacheTgTime::where("time", ">", 0)->exists();
|
||||
|
||||
if (!$bHaveTime) {
|
||||
$sCronMsg .= "\n - 没有活跃time正常跳出";
|
||||
return $sCronMsg;
|
||||
}
|
||||
|
||||
$iTimeNow = time();
|
||||
|
||||
$oModelCacheTgTime = ModelCacheTgTime::where("time", ">", 0)->first();
|
||||
|
||||
$iTimeDiff = $iTimeNow - $oModelCacheTgTime->time;
|
||||
|
||||
if ($iTimeDiff < $oModelCacheTgTime->delay) {
|
||||
$sCronMsg .= "\n - time活跃但未到delay时间";
|
||||
return $sCronMsg;
|
||||
}
|
||||
|
||||
$oFlow = (new self())->saveToSchema($oModelCacheTgTime->group_code);
|
||||
|
||||
if ($oFlow->isFail()) {
|
||||
$sCronMsg .= "\n - ".$oFlow->toJson();
|
||||
return $sCronMsg;
|
||||
}
|
||||
|
||||
$oModelCacheTgTime->time = 0;
|
||||
$oModelCacheTgTime->save();
|
||||
|
||||
$sCronMsg .= "\n - ok";
|
||||
|
||||
return $sCronMsg;
|
||||
}
|
||||
|
||||
public function saveToSchema($sGroupCode)
|
||||
{
|
||||
$oFlow = Flow::start();
|
||||
|
||||
$aSchema = [];
|
||||
$aSchema["type"] = "cache_tg";
|
||||
// $aSchema["group"] = $sGroupCode;
|
||||
$aSchema["data"] = [];
|
||||
|
||||
$oModelCacheTg = ModelCacheTg::where("status", 1)->where("group_code", $sGroupCode)->get();
|
||||
|
||||
if ($oModelCacheTg->isEmpty()) {
|
||||
return $oFlow->done();
|
||||
}
|
||||
|
||||
$sUlid = (string) Str::ulid();
|
||||
|
||||
$sCode = $sGroupCode."-".$sUlid;
|
||||
|
||||
$sBotToken = ModelTelegramKey::botTokenByCode($sGroupCode);
|
||||
|
||||
// $sDocumentRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||
|
||||
//// test
|
||||
// $sBotToken = ModelTelegramKey::botTokenByCode("test");
|
||||
//// test end
|
||||
|
||||
foreach ($oModelCacheTg as $oModelCacheTgRow) {
|
||||
$sCacheContent = $oModelCacheTgRow->content;
|
||||
$aCacheContent = json_decode($sCacheContent, true);
|
||||
|
||||
if (isset($aCacheContent["message"]["photo"])) {
|
||||
|
||||
$aSchemaRow = [];
|
||||
$aSchemaRow["type"] = "photo";
|
||||
$aSchemaRow["photo_fullSizeKey"] = 0;
|
||||
$aSchemaRow["photo"] = [];
|
||||
// $aSchemaRow["title"] = "xxx"; 意思一下,这么扩展
|
||||
|
||||
$aTgPhoto = $aCacheContent["message"]["photo"];
|
||||
|
||||
$iFullSize = 0;
|
||||
foreach ($aTgPhoto as $k => $aTgPhotoRow) {
|
||||
|
||||
$aPhotoRow = $aTgPhotoRow;
|
||||
|
||||
$sFileId = $aTgPhotoRow["file_id"];
|
||||
|
||||
if ($aTgPhotoRow["file_size"] > $iFullSize) {
|
||||
$iFullSize = $aTgPhotoRow["file_size"];
|
||||
$aSchemaRow["photo_fullSizeKey"] = $k;
|
||||
}
|
||||
|
||||
$oResponse = Http::get("https://api.telegram.org/bot{$sBotToken}/getFile", [
|
||||
'file_id' => $sFileId
|
||||
]);
|
||||
|
||||
if (!$oResponse->successful()) {
|
||||
throw new \Exception("获取路径失败:" . $oResponse->body());
|
||||
}
|
||||
|
||||
$sFileName = $oResponse->json('result.file_path');
|
||||
|
||||
$sDownloadUrl = "https://api.telegram.org/file/bot{$sBotToken}/{$sFileName}";
|
||||
|
||||
$sFileContents = Http::get($sDownloadUrl)->body();
|
||||
|
||||
$sFileContents = Http::get($sDownloadUrl)
|
||||
->throw()
|
||||
->body();
|
||||
|
||||
$sFileNameBase = basename($sFileName);
|
||||
$sFileSaveName = $sCode."-".$sFileNameBase;
|
||||
|
||||
$sLocalPath = public_path()."/upload/" . $sFileSaveName;
|
||||
|
||||
$b = File::put($sLocalPath, $sFileContents);
|
||||
|
||||
if (!$b) {
|
||||
throw new \Exception("文件保存失败:" . $sLocalPath);
|
||||
}
|
||||
|
||||
$aPhotoRow["file_path"] = $sLocalPath;
|
||||
unset($aPhotoRow["file_id"]);
|
||||
unset($aPhotoRow["file_unique_id"]);
|
||||
|
||||
$aSchemaRow["photo"][] = $aPhotoRow;
|
||||
|
||||
}
|
||||
|
||||
$aSchema["data"][] = $aSchemaRow;
|
||||
|
||||
} else {
|
||||
// 不在预设里的,先不管
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$oModelArticleSchema = new ModelArticleSchema();
|
||||
$oModelArticleSchema->code = $sCode;
|
||||
$oModelArticleSchema->schema = json_encode($aSchema);
|
||||
$oModelArticleSchema->group_code = $sGroupCode;
|
||||
$oModelArticleSchema->save();
|
||||
|
||||
$oModelArticleSchema->_opt([
|
||||
"thumb_use" => ['b','c']
|
||||
]);
|
||||
|
||||
ServiceArticleCmd::startWithO($oModelArticleSchema)->syncOpen()->save("new");
|
||||
|
||||
$oModelCacheTg->each->update(['status' => 0, 'code' => $sCode]);
|
||||
// $oModelCacheTg->each->update(['status' => 1, 'code' => $sCode]); // ! test
|
||||
|
||||
return $oFlow->done();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ use App\Services\Cron\FreenodeSync as CronFreenodeSync;
|
||||
use App\Services\Cron\ArticleSchema as CronArticleSchema;
|
||||
use App\Services\Cron\FnTgPublish as CronFnTgPublish;
|
||||
use App\Services\TomTool\Telegram\Slave as TeleSlave;
|
||||
use App\Services\CacheTg as ServiceCacheTg;
|
||||
|
||||
final class Cron
|
||||
{
|
||||
@ -68,6 +69,7 @@ final class Cron
|
||||
}
|
||||
|
||||
if ($i % 3 === 0) {
|
||||
echo ServiceCacheTg::cron_saveToSchema();
|
||||
CronArticleSchema::cacheTgSave();
|
||||
CronArticleSchema::pushToSlave();
|
||||
CronHttpQueue::pop();
|
||||
|
||||
@ -30,14 +30,9 @@ final class ArticleSchema
|
||||
echo " - 没有需要同步的文章\n";
|
||||
}
|
||||
|
||||
// foreach ($oArticleSchemaList->toArray() as $R) {
|
||||
// unset($R["schema"]);
|
||||
// tomd($R);
|
||||
// }
|
||||
|
||||
foreach ($oArticleSchemaList as $oArticleSchema) {
|
||||
|
||||
$aCmdList = json_decode($oArticleSchema->cmd, true);
|
||||
$aCmdList = json_decode($oArticleSchema->cmd ?? [], true) ?? [];
|
||||
|
||||
foreach ($aCmdList as $sCmdKey => $aCmd) {
|
||||
|
||||
@ -64,19 +59,24 @@ final class ArticleSchema
|
||||
|
||||
$sSiteArticleApiUrl = "https://".$sSiteUrlBase.$sSiteArticleApiPath;
|
||||
|
||||
// 直接附加raw就该
|
||||
// $aCmd["_raw"] = $oArticleSchema->toArray();
|
||||
|
||||
// 附加常规
|
||||
$aCmd["key"] = $sCmdKey;
|
||||
$aCmd["article_code"] = $oArticleSchema->code;
|
||||
$aCmd["group_code"] = $oArticleSchema->group_code;
|
||||
$aCmd["article_opt"] = json_decode($oArticleSchema->opt);
|
||||
|
||||
|
||||
// 附加config
|
||||
$sArticleConfig = ModelArticleConfig::where("article_group_code", $oArticleSchema->group_code)->where("site_group_code", $sSiteGroupCode)->first()?->config;
|
||||
$sArticleConfig = ModelArticleConfig::where("article_group_code", $oArticleSchema->group_code)->where("site_group_code", $sSiteGroupCode)->first()?->config ?? '';
|
||||
$aArticleConfig = json_decode($sArticleConfig, true);
|
||||
$aCmd["config"] = $aArticleConfig;
|
||||
|
||||
// 按需要附加其他
|
||||
if ($aCmd["cmd"] == "new") {
|
||||
$oArticleFlow = ServiceArticleSchema::start($oArticleSchema->code, $sSiteCode)->build();
|
||||
$oArticleFlow = ServiceArticleSchema::start($oArticleSchema->code, $sSiteCode)->build(); // 关键
|
||||
if ($oArticleFlow->isFail()) {
|
||||
$sMsg = "文章build失败";
|
||||
TeleSlave::warn()->send([
|
||||
@ -86,17 +86,21 @@ final class ArticleSchema
|
||||
echo $sMsg;
|
||||
continue;
|
||||
}
|
||||
$aCmd["article"] = $oArticleFlow->getDataA();
|
||||
$aCmd["article"] = $oArticleFlow->getDataA(); // 关键
|
||||
}
|
||||
|
||||
// 发送
|
||||
$sHttpResult = HttpV2::make($sSiteArticleApiUrl)->enableJsonSend()->setDataA($aCmd)->send();
|
||||
$sHttpResult = HttpV2::make($sSiteArticleApiUrl)->withToken()->enableAsync(false)->enableJsonSend()->setDataA($aCmd)->send();
|
||||
$aHttpResult = json_decode($sHttpResult, true);
|
||||
|
||||
if (config("app.is_loc") == true) {
|
||||
// echo $sHttpResult;exit; //// test
|
||||
}
|
||||
|
||||
$bHttpIsDone = $aHttpResult["isDone"] ?? false;
|
||||
|
||||
if (!$bHttpIsDone) {
|
||||
$sMsg = "slave那边同步失败?";
|
||||
$sMsg = "slave那边同步失败?-> {$sHttpResult}";
|
||||
TeleSlave::warn()->send([
|
||||
"msg" => $sMsg,
|
||||
"url" => $sSiteArticleApiUrl,
|
||||
@ -119,7 +123,12 @@ final class ArticleSchema
|
||||
continue;
|
||||
}
|
||||
|
||||
TeleSlave::notify()->send($aHttpResult["aData"]["aNewPath"]);
|
||||
echo var_dump($aHttpResult);
|
||||
|
||||
//// 丑陋缝补一下
|
||||
if (data_get($oArticleSchema, 'group_code') === "ffq_tg_a") {
|
||||
TeleSlave::notify()->send($aHttpResult["aData"]["aNewPath"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -131,8 +140,8 @@ final class ArticleSchema
|
||||
public static function cacheTgSave()
|
||||
{
|
||||
|
||||
echo "\ncacheTgSave::开始\n";
|
||||
$iCacheTimeDelay = 300; // 延迟5分钟
|
||||
echo "\n\ncacheTgSave::开始\n";
|
||||
$iCacheTimeDelay = 60; // 延迟5分钟
|
||||
|
||||
$oCacheTime = ModelArticleCacheTime::first();
|
||||
$iCacheTime = $oCacheTime->time;
|
||||
|
||||
@ -11,7 +11,7 @@ use App\Services\Article\Cmd as ServiceArticleCmd;
|
||||
use App\Services\TomTool\Flow;
|
||||
use App\Services\TomTool\ThrowableHandler;
|
||||
|
||||
class Arsc extends Base {
|
||||
class Arma extends Base {
|
||||
|
||||
public function __construct($aUpdate)
|
||||
{
|
||||
@ -26,7 +26,7 @@ class Arsc extends Base {
|
||||
return $this->oDog->$sName($aArg[0]);
|
||||
}
|
||||
|
||||
public function tu($aParam)
|
||||
public function thumUse($aParam)
|
||||
{
|
||||
$iId = $aParam["aOption"][1] ?? 0;
|
||||
$sThumbUse = $aParam["aArg"][1] ?? "";
|
||||
@ -59,6 +59,8 @@ class Arsc extends Base {
|
||||
$oArticleSchema->opt = $aOpt;
|
||||
$oArticleSchema->save();
|
||||
|
||||
$r = ServiceArticleCmd::startWithO($oArticleSchema)->syncOpen()->save("opt");
|
||||
|
||||
$aResult = [
|
||||
"id" => $oArticleSchema->id,
|
||||
"code" => $oArticleSchema->code,
|
||||
|
||||
@ -2,176 +2,52 @@
|
||||
|
||||
namespace App\Services\Tg\Hook\Mod;
|
||||
|
||||
use App\Models\ArticleSchema as ModelArticleSchema;
|
||||
use App\Models\ArticleCache as ModelArticleCache;
|
||||
use App\Models\ArticleCacheTime as ModelArticleCacheTime;
|
||||
//use App\Models\ArticleSchema as ModelArticleSchema;
|
||||
use App\Models\CacheTg as ModelCacheTg;
|
||||
//use App\Models\ArticleCacheTime as ModelArticleCacheTime;
|
||||
use App\Services\Tg\Hook\Dog;
|
||||
use App\Services\Article\CacheTg as ServiceArticleCacheTg;
|
||||
use App\Services\Article\Schema as ServiceArticleSchema;
|
||||
use App\Services\Article\Cmd as ServiceArticleCmd;
|
||||
use App\Services\TomTool\Flow;
|
||||
//use App\Services\HttpQueue;
|
||||
use App\Services\TomTool\TelegramVdb;
|
||||
use App\Services\TomTool\ThrowableHandler;
|
||||
use Illuminate\Database\QueryException;
|
||||
use RuntimeException;
|
||||
use App\Services\TomTool\HttpV2;
|
||||
use App\Services\Cron\ArticleSchema as CronArticleSchema;
|
||||
//use App\Services\Article\CacheTg as ServiceArticleCacheTg;
|
||||
//use App\Services\Article\Schema as ServiceArticleSchema;
|
||||
//use App\Services\Article\Cmd as ServiceArticleCmd;
|
||||
//use App\Services\TomTool\Flow;
|
||||
////use App\Services\HttpQueue;
|
||||
//use App\Services\TomTool\TelegramVdb;
|
||||
//use App\Services\TomTool\ThrowableHandler;
|
||||
//use Illuminate\Database\QueryException;
|
||||
//use RuntimeException;
|
||||
//use App\Services\TomTool\HttpV2;
|
||||
//use App\Services\Cron\ArticleSchema as CronArticleSchema;
|
||||
use App\Services\CacheTg as ServiceCacheTg;
|
||||
|
||||
class Article extends Base {
|
||||
class CacheTg extends Base {
|
||||
|
||||
private $oDog;
|
||||
private $aUpdate;
|
||||
|
||||
public function __construct($aUpdate)
|
||||
{
|
||||
$this->oDog = new Dog(new ModelArticleSchema());
|
||||
$this->oDog->_setDogName("articleSchema");
|
||||
$this->oDog = new Dog(new ModelCacheTg());
|
||||
$this->oDog->_setDogName("cacheTg");
|
||||
$this->oDog->_setStrField(["content"]);
|
||||
$this->aUpdate = $aUpdate;
|
||||
}
|
||||
|
||||
public function __call($sName, $aArg)
|
||||
{
|
||||
return $this->oDog->$sName($aArg[0]);
|
||||
}
|
||||
|
||||
public function test_cron_saveAuto()
|
||||
{
|
||||
$r = ServiceArticleSchema::make()->cron_saveAuto();
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function build_test_ttcp($aParam)
|
||||
{
|
||||
$oArticleCodeFirst = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
|
||||
|
||||
$aArg["sArticleCode"] = $oArticleCodeFirst->code;
|
||||
$aArg["sFromCode"] = 'ttcp';
|
||||
$aArg["sFromName"] = '天天测评';
|
||||
$aArg["sFromUrl"] = 'ttcp.loc';
|
||||
$aArg["sFromGroup"] = 'vue_md_ceping';
|
||||
|
||||
$aParam["aArg"][1] = json_encode($aArg);
|
||||
$r = $this->build_test($aParam);
|
||||
}
|
||||
|
||||
public function build_test($aParam)
|
||||
{
|
||||
$aJson = $aParam["aArg"];
|
||||
$sJson = implode(" ", $aJson);
|
||||
$aJson = json_decode($sJson, true);
|
||||
|
||||
$sShell = $this->aUpdate["shell"] ?? '';
|
||||
|
||||
$aJson["isTest"] = true;
|
||||
|
||||
$url = $_ENV["APP_URL"]."/api/article/build";
|
||||
|
||||
$r = HttpV2::make($url)->enableJsonSend()->setData($aJson)->send();
|
||||
|
||||
$a = json_decode($r, true);
|
||||
|
||||
if ($sShell !== "cmd") {
|
||||
$oTelegramVdb = TelegramVdb::make("master");
|
||||
foreach ($a["aData"] as $aa) {
|
||||
$oTelegramVdb->send($aa);
|
||||
}
|
||||
}
|
||||
|
||||
echo "标题:".$a["aData"]["title"] ?? "?";
|
||||
echo "<br>";
|
||||
echo $a["aData"]["content"] ?? "?";
|
||||
exit;
|
||||
}
|
||||
|
||||
public function build_test_case($aParam)
|
||||
{
|
||||
$aArg["sArticleCode"] = 'ffq_tg::20251028113221';
|
||||
$aArg["sFromCode"] = 'ttcp';
|
||||
$aArg["sFromName"] = '天天测评';
|
||||
$aArg["sFromUrl"] = 'ttcp.loc';
|
||||
$aArg["sFromGroup"] = 'vue_md_ceping';
|
||||
|
||||
return $this->toJson($aArg);
|
||||
}
|
||||
|
||||
public function cmdReset($aParam)
|
||||
{
|
||||
$xId = $aParam["aArg"][1] ?? "first";
|
||||
|
||||
if ($xId == "?") {
|
||||
return "#cmdRe [xId:first]";
|
||||
}
|
||||
|
||||
if ($xId == "first") {
|
||||
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
|
||||
} else {
|
||||
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->where("id", $xId)->first();
|
||||
}
|
||||
|
||||
$oModelArticleSchema->enable_sync = true;
|
||||
$oModelArticleSchema->save();
|
||||
|
||||
$bool = ServiceArticleCmd::start($oModelArticleSchema->code)->reset();
|
||||
|
||||
return $bool;
|
||||
}
|
||||
|
||||
public function cmdGet($aParam)
|
||||
{
|
||||
$xId = $aParam["aArg"][1] ?? "first";
|
||||
|
||||
if ($xId == "?") {
|
||||
return "#cmdGet [xId:first]";
|
||||
}
|
||||
|
||||
if ($xId == "first") {
|
||||
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
|
||||
} else {
|
||||
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->where("id", $xId)->first();
|
||||
}
|
||||
|
||||
return json_decode($oModelArticleSchema->cmd, true);
|
||||
}
|
||||
|
||||
public function schemaGet($aParam)
|
||||
{
|
||||
$xId = $aParam["aArg"][1] ?? "first";
|
||||
|
||||
if ($xId == "?") {
|
||||
return "#schemaGet [xId:first]";
|
||||
}
|
||||
|
||||
if ($xId == "first") {
|
||||
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();
|
||||
} else {
|
||||
$oModelArticleSchema = ModelArticleSchema::where("status", 1)->where("id", $xId)->first();
|
||||
}
|
||||
|
||||
$aSchema = json_decode($oModelArticleSchema->schema, true);
|
||||
|
||||
$sMsg = json_encode($aSchema, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
|
||||
return $sMsg;
|
||||
}
|
||||
|
||||
public function cacheAdd($aParam)
|
||||
public function add($aParam)
|
||||
{
|
||||
$sFromGroupCode = $aParam["aOption"][1] ?? "ffq_tg_a";
|
||||
$sContent = implode(' ', $aParam["aArg"]);
|
||||
|
||||
$r = ServiceArticleCacheTg::start()->add($sFromGroupCode, $sContent);
|
||||
|
||||
return $r;
|
||||
$oServicesCacheTg = new ServiceCacheTg();
|
||||
|
||||
$oFlow = $oServicesCacheTg->add($sContent, $sFromGroupCode);
|
||||
|
||||
$sMsg = '';
|
||||
|
||||
if ($oFlow->isDone()) {
|
||||
$sMsg = $sFromGroupCode."添加一条缓存";
|
||||
}
|
||||
|
||||
return $sMsg;
|
||||
}
|
||||
|
||||
// public function save($aParam)
|
||||
// {
|
||||
// $r = ServiceArticleSchema::make()->save();
|
||||
//
|
||||
// return $r;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@ class Test extends Base {
|
||||
return $this->oDog->$sName($aArg[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function t1()
|
||||
{
|
||||
TeleSlave::log()->enableSlaveQueue(false)->setFileUrl("https://master.tomshell.my/freenode/template/clash.txt")->setMsgS("fff")->send();
|
||||
@ -40,8 +42,9 @@ class Test extends Base {
|
||||
$sUrl = $aParam["aOption"][1] ?? '';
|
||||
$aDataJson = $aParam["aArg"] ?? [];
|
||||
$sDataJson = implode(" ", $aDataJson);
|
||||
$aDataJson = json_decode($sDataJson, true);
|
||||
|
||||
$r = HttpV2::make($sUrl)->enableJsonAs()->setDataX($sDataJson)->send();
|
||||
$r = HttpV2::make($sUrl)->enableJsonAs(true)->withToken()->setDataA($aDataJson)->send();
|
||||
|
||||
return $r;
|
||||
}
|
||||
@ -51,8 +54,9 @@ class Test extends Base {
|
||||
$sUrl = $aParam["aOption"][1] ?? '';
|
||||
$aDataJson = $aParam["aArg"] ?? [];
|
||||
$sDataJson = implode(" ", $aDataJson);
|
||||
|
||||
$r = HttpV2::make($sUrl)->setDataX($sDataJson)->send();
|
||||
$aDataJson = json_decode($sDataJson, true);
|
||||
|
||||
$r = HttpV2::make($sUrl)->enableJsonAs(false)->withToken()->setDataA($aDataJson)->send();
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
@ -359,6 +359,16 @@ class Flow
|
||||
{
|
||||
return $this->aResult;
|
||||
}
|
||||
|
||||
// action
|
||||
public function toJson($bFormat = true)
|
||||
{
|
||||
if ($bFormat === true) {
|
||||
return json_encode($this->aResult, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this->aResult);
|
||||
}
|
||||
}
|
||||
|
||||
// helper
|
||||
public function isDone()
|
||||
|
||||
@ -53,10 +53,8 @@ class HttpV2
|
||||
protected bool $sendJson = false;
|
||||
protected bool $returnJson = false;
|
||||
protected bool $async = false;
|
||||
// private bool $isChain = false;
|
||||
// private array $aResult = [
|
||||
// "isDone" = false
|
||||
// ];
|
||||
// 匈牙利命名法,仅新增一个 token 变量
|
||||
protected string $sToken = '';
|
||||
|
||||
public static function make(string $url, string $method = 'post'): self
|
||||
{
|
||||
@ -66,35 +64,21 @@ class HttpV2
|
||||
return $instance;
|
||||
}
|
||||
|
||||
// public static function start(string $sUrl, string $sMethod = 'post'): self
|
||||
// {
|
||||
// $oInstance = new self();
|
||||
// $oInstance->url = $sUrl;
|
||||
// $oInstance->method = $sMethod;
|
||||
// $oInstance->isChain = true;
|
||||
// return $oInstance;
|
||||
// }
|
||||
//
|
||||
// public function isDone()
|
||||
// {
|
||||
// return $this->aResult["isDone"] ?? false;
|
||||
// }
|
||||
//
|
||||
// public function isFail()
|
||||
// {
|
||||
// return !$this->isDone();
|
||||
// }
|
||||
|
||||
// public function getResult()
|
||||
// {
|
||||
// return $this->aResult;
|
||||
// }
|
||||
|
||||
public function optMethod(string $method): self
|
||||
{
|
||||
$this->method = strtolower($method);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增:支持携带 Token
|
||||
* 如果不传值,默认从环境变量 token_base 获取
|
||||
*/
|
||||
public function withToken(?string $sToken = null): self
|
||||
{
|
||||
$this->sToken = $sToken ?? (string)env('token_base', false);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDataX($xData)
|
||||
{
|
||||
@ -116,43 +100,10 @@ class HttpV2
|
||||
|
||||
public function setData($xData)
|
||||
{
|
||||
// if (is_array($xData)) {
|
||||
// json_encode($xData)
|
||||
// }
|
||||
$this->data = $xData;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// public function aData($aData = [])
|
||||
// {
|
||||
// $this->data($aData);
|
||||
// return $this;
|
||||
// }
|
||||
//
|
||||
// public function sData($sData = '')
|
||||
// {
|
||||
// $this->data($sData);
|
||||
// return $this;
|
||||
// }
|
||||
//
|
||||
// public function jData($jData = '')
|
||||
// {
|
||||
// $this->data($jData);
|
||||
// return $this;
|
||||
// }
|
||||
//
|
||||
// public function xData($xData = '')
|
||||
// {
|
||||
// $this->data($xData);
|
||||
// return $this;
|
||||
// }
|
||||
//
|
||||
// public function data($data = ''): self
|
||||
// {
|
||||
// $this->data = $data;
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
public function enableJsonSend(bool $flag = true): self
|
||||
{
|
||||
$this->sendJson = $flag;
|
||||
@ -185,7 +136,12 @@ class HttpV2
|
||||
$ch = curl_init();
|
||||
$headers = [];
|
||||
|
||||
// 构建 URL 和请求体
|
||||
// --- 核心嵌入:如果 sToken 有值且不是 false,塞进 Header ---
|
||||
if ($this->sToken && $this->sToken !== 'false') {
|
||||
$headers[] = 'Authorization: Bearer ' . $this->sToken;
|
||||
}
|
||||
|
||||
// 构建 URL 和请求体 (完全保留原样)
|
||||
if ($this->method === 'get') {
|
||||
$url = $this->url . '?' . http_build_query($this->data);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
@ -215,11 +171,11 @@ class HttpV2
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
|
||||
// SSL 设置
|
||||
// SSL 设置 (完全保留原样)
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
// 异步发送
|
||||
// 异步发送 (完全保留原样)
|
||||
if ($this->async) {
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 200);
|
||||
@ -230,7 +186,7 @@ class HttpV2
|
||||
return 'sent';
|
||||
}
|
||||
|
||||
// 阻塞执行
|
||||
// 阻塞执行 (完全保留原样)
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
|
||||
@ -243,19 +199,5 @@ class HttpV2
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
// $this->aResult = $oFlow->sData($response)->done();
|
||||
//
|
||||
// if ($this->isChain) {
|
||||
// return $this;
|
||||
// }
|
||||
//
|
||||
// return $this->aResult;
|
||||
}
|
||||
|
||||
// public static function response(int $code, string $message = ''): void
|
||||
// {
|
||||
// http_response_code($code);
|
||||
// echo $message;
|
||||
// exit;
|
||||
// }
|
||||
}
|
||||
|
||||
@ -2,16 +2,9 @@
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
'token_base' => env('token_base', false),
|
||||
|
||||
'is_loc' => (bool) env('is_loc', false),
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
return [
|
||||
|
||||
'dir_base' => env('dir_base'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|
||||
9
fn逻辑.md
9
fn逻辑.md
@ -17,3 +17,12 @@
|
||||
3.CronFreenodeMerge :: 读freenode_pool,存到public/freenode/merge/base/xxx文件。
|
||||
动机:
|
||||
各site定制化,生成最终fn文件
|
||||
|
||||
辅助:
|
||||
CronFreenodeFile :: 辅助处理文件相关
|
||||
CronFreenodeLog :: 辅助处理日志相关,暂时可能没用上
|
||||
CronFreenodeWatch :: 写了一半没用上,不知道干嘛了
|
||||
CronFreenodeSync :: 处理同步cron
|
||||
|
||||
测试:
|
||||
master :: /cron#test__h 6,就可以了,目前整套逻辑都在h6里
|
||||
|
||||
7
vendor/composer/autoload_classmap.php
vendored
7
vendor/composer/autoload_classmap.php
vendored
@ -30,6 +30,8 @@ return array(
|
||||
'App\\Models\\BookOption' => $baseDir . '/app/Models/BookOption.php',
|
||||
'App\\Models\\BookPage' => $baseDir . '/app/Models/BookPage.php',
|
||||
'App\\Models\\BoxGithubTag' => $baseDir . '/app/Models/BoxGithubTag.php',
|
||||
'App\\Models\\CacheTg' => $baseDir . '/app/Models/CacheTg.php',
|
||||
'App\\Models\\CacheTgTime' => $baseDir . '/app/Models/CacheTgTime.php',
|
||||
'App\\Models\\CrawlFreenode' => $baseDir . '/app/Models/CrawlFreenode.php',
|
||||
'App\\Models\\DogOption' => $baseDir . '/app/Models/DogOption.php',
|
||||
'App\\Models\\DoveSite' => $baseDir . '/app/Models/DoveSite.php',
|
||||
@ -50,6 +52,7 @@ return array(
|
||||
'App\\Services\\Article\\CacheTg' => $baseDir . '/app/Services/Article/CacheTg.php',
|
||||
'App\\Services\\Article\\Cmd' => $baseDir . '/app/Services/Article/Cmd.php',
|
||||
'App\\Services\\Article\\Schema' => $baseDir . '/app/Services/Article/Schema.php',
|
||||
'App\\Services\\CacheTg' => $baseDir . '/app/Services/CacheTg.php',
|
||||
'App\\Services\\Cron' => $baseDir . '/app/Services/Cron.php',
|
||||
'App\\Services\\Cron\\ArticleSchema' => $baseDir . '/app/Services/Cron/ArticleSchema.php',
|
||||
'App\\Services\\Cron\\FnTgPublish' => $baseDir . '/app/Services/Cron/FnTgPublish.php',
|
||||
@ -59,6 +62,7 @@ return array(
|
||||
'App\\Services\\Cron\\FreenodeMerge' => $baseDir . '/app/Services/Cron/FreenodeMerge.php',
|
||||
'App\\Services\\Cron\\FreenodePool' => $baseDir . '/app/Services/Cron/FreenodePool.php',
|
||||
'App\\Services\\Cron\\FreenodeSync' => $baseDir . '/app/Services/Cron/FreenodeSync.php',
|
||||
'App\\Services\\Cron\\FreenodeWatch' => $baseDir . '/app/Services/Cron/FreenodeWatch.php',
|
||||
'App\\Services\\Cron\\HttpQueue' => $baseDir . '/app/Services/Cron/HttpQueue.php',
|
||||
'App\\Services\\HttpQueue' => $baseDir . '/app/Services/HttpQueue.php',
|
||||
'App\\Services\\OpenApi\\Telegram' => $baseDir . '/app/Services/OpenApi/Telegram.php',
|
||||
@ -74,11 +78,13 @@ return array(
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Blade' => $baseDir . '/app/Services/Tg/Hook/Mod/Blade.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Book' => $baseDir . '/app/Services/Tg/Hook/Mod/Book.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Box' => $baseDir . '/app/Services/Tg/Hook/Mod/Box.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\CacheTg' => $baseDir . '/app/Services/Tg/Hook/Mod/CacheTg.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Cron' => $baseDir . '/app/Services/Tg/Hook/Mod/Cron.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Db' => $baseDir . '/app/Services/Tg/Hook/Mod/Db.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Dev' => $baseDir . '/app/Services/Tg/Hook/Mod/Dev.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Dove' => $baseDir . '/app/Services/Tg/Hook/Mod/Dove.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\DoveSite' => $baseDir . '/app/Services/Tg/Hook/Mod/DoveSite.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Freenode' => $baseDir . '/app/Services/Tg/Hook/Mod/Freenode.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\FreenodeFrom' => $baseDir . '/app/Services/Tg/Hook/Mod/FreenodeFrom.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\FreenodePool' => $baseDir . '/app/Services/Tg/Hook/Mod/FreenodePool.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\GemboxDns' => $baseDir . '/app/Services/Tg/Hook/Mod/GemboxDns.php',
|
||||
@ -100,6 +106,7 @@ return array(
|
||||
'App\\Services\\TomTool\\Flow' => $baseDir . '/app/Services/TomTool/Flow.php',
|
||||
'App\\Services\\TomTool\\Http' => $baseDir . '/app/Services/TomTool/Http.php',
|
||||
'App\\Services\\TomTool\\HttpV2' => $baseDir . '/app/Services/TomTool/HttpV2.php',
|
||||
'App\\Services\\TomTool\\Map' => $baseDir . '/app/Services/TomTool/Map.php',
|
||||
'App\\Services\\TomTool\\Telegram\\Master' => $baseDir . '/app/Services/TomTool/Telegram/Master.php',
|
||||
'App\\Services\\TomTool\\Telegram\\Sdk' => $baseDir . '/app/Services/TomTool/Telegram/Sdk.php',
|
||||
'App\\Services\\TomTool\\Telegram\\Slave' => $baseDir . '/app/Services/TomTool/Telegram/Slave.php',
|
||||
|
||||
7
vendor/composer/autoload_static.php
vendored
7
vendor/composer/autoload_static.php
vendored
@ -573,6 +573,8 @@ class ComposerStaticInit626b9e7ddd47fb7eff9aaa53cce0c9ad
|
||||
'App\\Models\\BookOption' => __DIR__ . '/../..' . '/app/Models/BookOption.php',
|
||||
'App\\Models\\BookPage' => __DIR__ . '/../..' . '/app/Models/BookPage.php',
|
||||
'App\\Models\\BoxGithubTag' => __DIR__ . '/../..' . '/app/Models/BoxGithubTag.php',
|
||||
'App\\Models\\CacheTg' => __DIR__ . '/../..' . '/app/Models/CacheTg.php',
|
||||
'App\\Models\\CacheTgTime' => __DIR__ . '/../..' . '/app/Models/CacheTgTime.php',
|
||||
'App\\Models\\CrawlFreenode' => __DIR__ . '/../..' . '/app/Models/CrawlFreenode.php',
|
||||
'App\\Models\\DogOption' => __DIR__ . '/../..' . '/app/Models/DogOption.php',
|
||||
'App\\Models\\DoveSite' => __DIR__ . '/../..' . '/app/Models/DoveSite.php',
|
||||
@ -593,6 +595,7 @@ class ComposerStaticInit626b9e7ddd47fb7eff9aaa53cce0c9ad
|
||||
'App\\Services\\Article\\CacheTg' => __DIR__ . '/../..' . '/app/Services/Article/CacheTg.php',
|
||||
'App\\Services\\Article\\Cmd' => __DIR__ . '/../..' . '/app/Services/Article/Cmd.php',
|
||||
'App\\Services\\Article\\Schema' => __DIR__ . '/../..' . '/app/Services/Article/Schema.php',
|
||||
'App\\Services\\CacheTg' => __DIR__ . '/../..' . '/app/Services/CacheTg.php',
|
||||
'App\\Services\\Cron' => __DIR__ . '/../..' . '/app/Services/Cron.php',
|
||||
'App\\Services\\Cron\\ArticleSchema' => __DIR__ . '/../..' . '/app/Services/Cron/ArticleSchema.php',
|
||||
'App\\Services\\Cron\\FnTgPublish' => __DIR__ . '/../..' . '/app/Services/Cron/FnTgPublish.php',
|
||||
@ -602,6 +605,7 @@ class ComposerStaticInit626b9e7ddd47fb7eff9aaa53cce0c9ad
|
||||
'App\\Services\\Cron\\FreenodeMerge' => __DIR__ . '/../..' . '/app/Services/Cron/FreenodeMerge.php',
|
||||
'App\\Services\\Cron\\FreenodePool' => __DIR__ . '/../..' . '/app/Services/Cron/FreenodePool.php',
|
||||
'App\\Services\\Cron\\FreenodeSync' => __DIR__ . '/../..' . '/app/Services/Cron/FreenodeSync.php',
|
||||
'App\\Services\\Cron\\FreenodeWatch' => __DIR__ . '/../..' . '/app/Services/Cron/FreenodeWatch.php',
|
||||
'App\\Services\\Cron\\HttpQueue' => __DIR__ . '/../..' . '/app/Services/Cron/HttpQueue.php',
|
||||
'App\\Services\\HttpQueue' => __DIR__ . '/../..' . '/app/Services/HttpQueue.php',
|
||||
'App\\Services\\OpenApi\\Telegram' => __DIR__ . '/../..' . '/app/Services/OpenApi/Telegram.php',
|
||||
@ -617,11 +621,13 @@ class ComposerStaticInit626b9e7ddd47fb7eff9aaa53cce0c9ad
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Blade' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Blade.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Book' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Book.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Box' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Box.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\CacheTg' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/CacheTg.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Cron' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Cron.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Db' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Db.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Dev' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Dev.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Dove' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Dove.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\DoveSite' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/DoveSite.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\Freenode' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/Freenode.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\FreenodeFrom' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/FreenodeFrom.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\FreenodePool' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/FreenodePool.php',
|
||||
'App\\Services\\Tg\\Hook\\Mod\\GemboxDns' => __DIR__ . '/../..' . '/app/Services/Tg/Hook/Mod/GemboxDns.php',
|
||||
@ -643,6 +649,7 @@ class ComposerStaticInit626b9e7ddd47fb7eff9aaa53cce0c9ad
|
||||
'App\\Services\\TomTool\\Flow' => __DIR__ . '/../..' . '/app/Services/TomTool/Flow.php',
|
||||
'App\\Services\\TomTool\\Http' => __DIR__ . '/../..' . '/app/Services/TomTool/Http.php',
|
||||
'App\\Services\\TomTool\\HttpV2' => __DIR__ . '/../..' . '/app/Services/TomTool/HttpV2.php',
|
||||
'App\\Services\\TomTool\\Map' => __DIR__ . '/../..' . '/app/Services/TomTool/Map.php',
|
||||
'App\\Services\\TomTool\\Telegram\\Master' => __DIR__ . '/../..' . '/app/Services/TomTool/Telegram/Master.php',
|
||||
'App\\Services\\TomTool\\Telegram\\Sdk' => __DIR__ . '/../..' . '/app/Services/TomTool/Telegram/Sdk.php',
|
||||
'App\\Services\\TomTool\\Telegram\\Slave' => __DIR__ . '/../..' . '/app/Services/TomTool/Telegram/Slave.php',
|
||||
|
||||
4
vendor/composer/installed.php
vendored
4
vendor/composer/installed.php
vendored
@ -3,7 +3,7 @@
|
||||
'name' => 'laravel/laravel',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'e87d0e91e4344582a24e8ed70cec7979575b73a4',
|
||||
'reference' => 'dec2fd03ea275b260e589a7fe963ba805a320458',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -415,7 +415,7 @@
|
||||
'laravel/laravel' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => 'e87d0e91e4344582a24e8ed70cec7979575b73a4',
|
||||
'reference' => 'dec2fd03ea275b260e589a7fe963ba805a320458',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user