dd/app/Services/Tg/Hook/Mod/Hook_old.php
2026-01-02 19:10:22 +08:00

84 lines
2.0 KiB
PHP
Executable File
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\Hook as ModelHook;
use App\Models\SiteList as ModelSiteList;
class Hook extends Base {
public function set($aParam, $aData)
{
$sKey = $aParam['aArg'][1];
$iFromId = $aData["message"]["from"]["id"];
// 先清除,等于是覆盖,单进程
$r = ModelHook::where("tg_user_id", $iFromId)->delete();
// 添加
$oHook = new ModelHook();
$oHook->tg_user_id = $iFromId;
$oHook->key = $sKey;
$oHook->steap = 1;
$r = $oHook->save();
if ($r) {
$aKey = explode(":", $sKey, 2);
// site类hook处理
if ($aKey[0] === "site") {
$sCode = $aKey[1];
$oSiteSingle = ModelSiteList::where("code", $sCode)->first();
if ($oSiteSingle) {
$r = "site::".$oSiteSingle->code."@".$oSiteSingle->www." | 就绪!";
} else {
$r = "没有这个site";
}
}
}
return $r;
}
public function go($aParam, $aData)
{
// $aApiUrl =
}
public function now($aParam, $aData)
{
$iFromId = $aData["message"]["from"]["id"];
$oHookNow = ModelHook::where("tg_user_id", $iFromId)->first();
if ($oHookNow) {
$aHookNow = $oHookNow->toArray();
unset($aHookNow['id']);
unset($aHookNow['tg_user_id']);
$r = $this->toJson($aHookNow);
} else {
$r = "没有!";
}
return $r;
}
public function break($aParam, $aData)
{
$iFromId = $aData["message"]["from"]["id"];
$r = ModelHook::where("tg_user_id", $iFromId)->delete();
return $r;
}
}