60 lines
1.6 KiB
PHP
Executable File
60 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\OpenApi;
|
|
|
|
use Illuminate\Http\Request;
|
|
//use App\Services\TomTool\TelegramV2;
|
|
use App\Services\TomTool\Flow;
|
|
use App\Services\TomTool\Telegram\Master as TeleMaster;
|
|
//use App\Services\TomTool\Telegram\Slave as TeleSlave;
|
|
use Telegram\Bot\Api;
|
|
use Telegram\Bot\Exceptions\TelegramSDKException;
|
|
|
|
/**
|
|
|
|
接收slave的tg发送请求
|
|
|
|
*/
|
|
|
|
final class Telegram
|
|
{
|
|
public function post()
|
|
{
|
|
$oFlow = Flow::make("master::tgpost");
|
|
|
|
$sArg = file_get_contents('php://input');
|
|
$aArg = json_decode($sArg, true);
|
|
|
|
$sBotCode = $aArg["sBotCode"] ?? '';
|
|
$sChatCode = $aArg["sChatCode"] ?? '';
|
|
$sBotToken = $aArg["sBotToken"] ?? '';
|
|
$iChatId = (int) ($aArg["iChatId"] ?? 0);
|
|
$enableMasterQueue = $aArg["enableMasterQueue"] ?? false; // 用不着了
|
|
$sMsg = $aArg["sMsg"] ?? '';
|
|
$sPhotoUrl = $aArg["sPhotoUrl"] ?? '';
|
|
$iPhotoWidth = $aArg["iPhotoWidth"] ?? 0;
|
|
$iPhotoHeight = $aArg["iPhotoHeight"] ?? 0;
|
|
$sFileUrl = $aArg["sFileUrl"] ?? '';
|
|
$sFileName = $aArg["sFileName"] ?? '';
|
|
$sType = $aArg["sType"] ?? '';
|
|
|
|
$r = TeleMaster::start()
|
|
->setBotCode($sBotCode)
|
|
->setChatCode($sChatCode)
|
|
->setBotToken($sBotToken)
|
|
->setChatId($iChatId)
|
|
->setPhotoUrl($sPhotoUrl, $iPhotoWidth, $iPhotoHeight)
|
|
->setFileUrl($sFileUrl, $sFileName)
|
|
->setType($sType)
|
|
->send($sMsg);
|
|
|
|
echo json_encode($r->getResult());
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
}
|