This commit is contained in:
hellcat 2025-03-24 21:38:09 +08:00
parent 11b2bdb036
commit ea9717c009

View File

@ -53,7 +53,48 @@ final class HookController
}
$sText = $aUpdate["message"]["text"];
// 先检查step
if ($oTgStep->fromIdHit($aData['fromId'])) {
$sText = ltrim($sText, '/');
$aTgStepFirst = $oTgStep->find($aData["fromId"]);
if ($aTgStepFirst["cmd"] == "reply") {
if ($aTgStepFirst['step'] == 1) {
$oHttp = new Http();
$oHttp->sMethod = "put";
$oHttp->sToUrl = $_ENV['baseUrl']."/api/tg/ticket/".$aTgStepFirst['cache']['ticketId'];
$oHttp->bIsJson = true;
$aData['comment'] = $sText;
$aData['admin_name'] = $aUpdate["message"]["from"]["first_name"];
$oHttp->aData = $aData;
$r = @json_decode($oHttp->send(), true);
// 不论失败成功都清除step
$oTgStep->clearByFromId($aUpdate["message"]["from"]["id"]);
if ($r["ret"] == 1) {
$sMessage = "成功";
} else {
$sMessage = "失败";
Http::response(500, json_encode($aData));
}
$this->sendMessage($sMessage);
Http::response(200, 'ok');
}
}
}
// 命令
if ($sText === "/test") {
$serverTime = date("Y-m-d H:i:s");
@ -90,43 +131,6 @@ final class HookController
}
if ($oTgStep->fromIdHit($aData['fromId'])) {
$aTgStepFirst = $oTgStep->find($aData["fromId"]);
if ($aTgStepFirst["cmd"] == "reply") {
if ($aTgStepFirst['step'] == 1) {
$oHttp = new Http();
$oHttp->sMethod = "put";
$oHttp->sToUrl = $_ENV['baseUrl']."/api/tg/ticket/".$aTgStepFirst['cache']['ticketId'];
$oHttp->bIsJson = true;
$aData['comment'] = $sText;
$aData['admin_name'] = $aUpdate["message"]["from"]["first_name"];
$oHttp->aData = $aData;
$r = @json_decode($oHttp->send(), true);
// 不论失败成功都清除step
$oTgStep->clearByFromId($aUpdate["message"]["from"]["id"]);
if ($r["ret"] == 1) {
$sMessage = "成功";
} else {
$sMessage = "失败";
Http::response(500, json_encode($aData));
}
$this->sendMessage($sMessage);
Http::response(200, 'ok');
}
}
}
Http::response(200, '无');
}