no message
This commit is contained in:
parent
04a741b609
commit
44bf6e5cdf
@ -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 = "<a class='text_link' href='".$sEntitiesUrl."'>".$sLinkText."</a>";
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user