dd/app/Services/SDK/Master/Telegram.php
2026-01-02 19:10:22 +08:00

66 lines
1.4 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace App\Services\SDK\Master;
use App\Services\TomTool\HttpV2;
final class Telegram
{
public $sBotCode;
public $sChatCode;
public $sBotToken = null;
public $iChatId = null;
public static function make($sBot = "base", $sChat = "base")
{
$oInstans = new self($sBot, $sChat);
$oInstans->sBotCode = $sBot;
$oInstans->sChatCode = $sChat;
return $oInstans;
}
public function bot($sBotCode)
{
$this->sBotCode = $sBotCode;
return $this;
}
public function botToken($sBotToken)
{
$this->sBotToken = $sBotToken;
return $this;
}
public function chatId($iChatId)
{
$this->chatId = $iChatId;
return $this;
}
public function chat($sChatCode)
{
$this->sChatCode = $sChatCode;
return $this;
}
public function send($sMsg = '')
{
$aData = [
"sBotCode" => $this->sBotCode,
"sChatCode" => $this->sChatCode,
"sBotToken" => $this->sBotToken,
"iChatId" => $this->iChatId,
"sMsg" => $this->sMsg,
];
HttpV2::make("https://".$_ENV['url_master_base']."/api/open/tg/send")
->setData($aData)
->async()
->send();
}
}