dd/app/Services/TG/Hook/Mod/Article.php
2025-10-21 14:51:14 +08:00

87 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Services\TG\Hook\Mod;
use App\Models\Article as ModelArticle;
use App\Models\ArticleCache as ModelArticleCache;
use App\Services\TG\Hook\Dog;
class Article extends Base {
private $oDog;
public function __construct($aUpdate)
{
$this->oDog = new Dog(new ModelArticle());
// $this->oDog->_setPrimaryKey("id"); // 可选默认id
$this->oDog->_setDogName("article"); // 必须me用正常就是类名只不过后期没准改名所以就这里写死要在最前面
$this->oDog->_setStrField(["content"]); // 可选,指定长文本字段
}
public function __call($sName, $aArg)
{
return $this->oDog->$sName($aArg[0]);
}
public function cache($aParam)
{
$sContent = implode(' ', $aParam["aArg"]);
$oModelArticleCache = new ModelArticleCache();
$oModelArticleCache->content = $sContent;
$oModelArticleCache->created_at = time();
$r = $oModelArticleCache->save();
}
public function saveFFQ($aParam)
{
$aParam["aArg"][1] = "ffq_tg";
return $this->save($aParam);
}
public function save($aParam)
{
$sFrom = $aParam["aArg"][1] ?? false;
if (!$sFrom) {
return "需要from";
}
if ($aParam["aArg"][1] == '?') {
return "/article#save [from]";
}
$oModelArticleCache = ModelArticleCache::orderBy('id', 'asc')->get();
if ($sFrom == "ffq" || $sFrom == "ffq_tg") {
$sArticle = '';
foreach ($oModelArticleCache as $oModelArticleCacheRow) {
$sArticle .= $oModelArticleCacheRow->content;
}
$oModelArticle = new ModelArticle();
$oModelArticle->from_type = "ffq_tg";
$oModelArticle->to_type = "vp_md";
$oModelArticle->title = "test";
$oModelArticle->content = $sArticle;
$oModelArticle->code = "ffq_tg:".uniqid();
$r = $oModelArticle->save();
}
return $r;
}
}
//{{ $site.title }}