From 44bf6e5cdfed89c96b9710ac7259beef42f55294 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Mon, 12 Jan 2026 18:30:52 +0800 Subject: [PATCH] no message --- app/Services/Article/CacheTg.php | 38 +++++++++++++++++++++++++++++++ app/Services/Tg/Hook/Mod/Cron.php | 15 ++++++++++++ 2 files changed, 53 insertions(+) diff --git a/app/Services/Article/CacheTg.php b/app/Services/Article/CacheTg.php index 156f20ee..c641f5ed 100755 --- a/app/Services/Article/CacheTg.php +++ b/app/Services/Article/CacheTg.php @@ -199,6 +199,24 @@ final class CacheTg if (isset($aContent["message"]["caption"])) { $sStr = $aContent["message"]["caption"]; + + $aEntities = $aContent["message"]["caption_entities"] ?? []; + + foreach ($aEntities as $aEntitiesRow) { + $iEntitiesOffset = $aEntitiesRow["offset"] ?? 0; + $iEntitiesLen = $aEntitiesRow["length"] ?? 0; + $sEntitiesType = $aEntitiesRow["type"] ?? ""; + + if ($sGroupCode == "ffq_tg_a") { // 按说都改替换,缝补就这样 + if ($sEntitiesType == "text_link") { + $sEntitiesUrl = $aEntitiesRow["url"] ?? ""; + $sLinkText = $this->tg_replace($sStr, "", $iEntitiesOffset, $iEntitiesLen, true); + $sLinkHtml = "".$sLinkText.""; + + $sStr = $this->tg_replace($sStr, $sLinkHtml, $iEntitiesOffset, $iEntitiesLen, false); + } + } + } $aDataTmp = []; $aDataTmp["type"] = "str"; @@ -339,6 +357,7 @@ final class CacheTg ], ]; + //// 本地不爬,上线取消注释 preg_match('/论坛[::]\s*(https?:\/\/[^\s]*?\.html)/u', $sStrBaoliu, $matches); if (isset($matches[1])) { $sUrl = $matches[1]; @@ -447,4 +466,23 @@ final class CacheTg return $oResult->sData($sHtml)->done(); } + function tg_replace($text, $repl, $offset, $length, $onlyReturn = false) { + // 1. 统一转为 UTF-16LE 字节流,对齐 TG 的索引逻辑 + $u16 = mb_convert_encoding($text, 'UTF-16LE', 'UTF-8'); + + // 2. 锁定靶区(TG offset * 2 字节) + if ($onlyReturn) { + // 模式 A:侦察目标 + $target = substr($u16, $offset * 2, $length * 2); + return mb_convert_encoding($target, 'UTF-8', 'UTF-16LE'); + } + + // 模式 B:定点清除 + $pre = substr($u16, 0, $offset * 2); + $suf = substr($u16, ($offset + $length) * 2); + + $replU16 = mb_convert_encoding($repl, 'UTF-16LE', 'UTF-8'); + return mb_convert_encoding($pre . $replU16 . $suf, 'UTF-8', 'UTF-16LE'); + } + } diff --git a/app/Services/Tg/Hook/Mod/Cron.php b/app/Services/Tg/Hook/Mod/Cron.php index ac2657f3..2e547218 100755 --- a/app/Services/Tg/Hook/Mod/Cron.php +++ b/app/Services/Tg/Hook/Mod/Cron.php @@ -5,9 +5,24 @@ namespace App\Services\Tg\Hook\Mod; use App\Services\TomTool\Http; use App\Services\Cron as ServicesCron; use App\Services\Cron\HttpQueue as CronHttpQueue; +use App\Models\ArticleCacheTime as ModelArticleCacheTime; class Cron extends Base { + public function testArticleSchema() + { + $oCacheTime = ModelArticleCacheTime::first(); + $oCacheTime->time = strtotime('-10 days'); + $oCacheTime->save(); + + $oServicesCron = new ServicesCron(); + $oServicesCron->setTestH('01'); + $oServicesCron->setTestI('03'); + $oServicesCron->setTestS('00'); + + return $oServicesCron->run(); + } + public function httpQueuePop() { $r = CronHttpQueue::pop();