fix: telegram机器人setwebhook接口url设置为站点网址,防止一些反向代理配置导致绑定机器人失败的问题

This commit is contained in:
xboard 2023-12-07 23:12:05 +08:00
parent fe5e448dfb
commit b0a504a44c

View File

@ -51,7 +51,12 @@ class ConfigController extends Controller
public function setTelegramWebhook(Request $request)
{
$hookUrl = url('/api/v1/guest/telegram/webhook?access_token=' . md5(admin_setting('telegram_bot_token', $request->input('telegram_bot_token'))));
// 判断站点网址
$app_url = admin_setting('app_url');
if(blank($app_url)) return $this->fail([422, '请先设置站点网址']);
$hookUrl = $app_url .'/api/v1/guest/telegram/webhook?' . http_build_query([
'access_token' => md5(admin_setting('telegram_bot_token', $request->input('telegram_bot_token')))
]);
$telegramService = new TelegramService($request->input('telegram_bot_token'));
$telegramService->getMe();
$telegramService->setWebhook($hookUrl);