77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace App\Services\Tg\Hook\Mod;
|
||
|
||
use App\Models\Ann as ModelAnn;
|
||
use App\Services\Tg\Hook\Dog;
|
||
use App\Services\IM\TelegramV2;
|
||
|
||
class Ann extends Base {
|
||
|
||
private $oDog;
|
||
|
||
public function __construct($aUpdate)
|
||
{
|
||
|
||
$this->oDog = new Dog(new ModelAnn());
|
||
$this->oDog->_setDogName("ann"); // 必须,me用,正常就是类名,只不过后期没准改名,所以就这里写死
|
||
// $this->oDog->_setPrimaryKey("code"); // 可选,默认id
|
||
$this->oDog->_setStrField(["content"]); // 可选,指定长文本字段
|
||
$this->oDog->_setInFormat(["date"]);
|
||
}
|
||
|
||
public function __call($sName, $aArg)
|
||
{
|
||
|
||
return $this->oDog->$sName($aArg[0]);
|
||
|
||
}
|
||
|
||
public function post($aParam)
|
||
{
|
||
$iId = $aParam["aArg"][1] ?? false;
|
||
$sConfirm = $aParam["aOption"][1] ?? "n";
|
||
|
||
if (!$iId) {
|
||
return "需要id";
|
||
}
|
||
|
||
if ($aParam["aArg"][1] == "?") {
|
||
return "/ann#post__[:n,y] id | n发私有群测试";
|
||
}
|
||
|
||
$oAnn = ModelAnn::where("id", $iId)->first();
|
||
|
||
if (!$oAnn) {
|
||
return "没有这个数据";
|
||
}
|
||
|
||
$oTelegramV2 = new TelegramV2("fuuuuCloud_bot");
|
||
$oTelegramV2->setMsgType("html");
|
||
|
||
if ($sConfirm == "n") {
|
||
|
||
$oTelegramV2->setTo("base");
|
||
|
||
$oTelegramV2->send($oAnn->content, "str");
|
||
|
||
} else if ($sConfirm == "y") {
|
||
|
||
$oTelegramV2->setTo("tongzhiqun");
|
||
|
||
$r = $oTelegramV2->send($oAnn->content, "str");
|
||
|
||
if ($r) {
|
||
$oAnn->post = 1;
|
||
$oAnn->save();
|
||
return "ok,状态以更新";
|
||
}
|
||
|
||
}
|
||
|
||
return "ok";
|
||
|
||
}
|
||
|
||
}
|