mirror of
https://github.com/v2board/v2board.git
synced 2025-03-13 06:04:42 +08:00
update telegram
This commit is contained in:
parent
422b18ca66
commit
29d7228861
@ -21,13 +21,17 @@ class ConfigController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTelegramWebhook()
|
public function setTelegramWebhook(Request $request)
|
||||||
{
|
{
|
||||||
$telegramService = new TelegramService();
|
$telegramService = new TelegramService($request->input('telegram_bot_token'));
|
||||||
if (!$telegramService->getMe()) {
|
if (!$telegramService->getMe()) {
|
||||||
abort(500, '机器人Token有误');
|
abort(500, '机器人Token有误');
|
||||||
}
|
}
|
||||||
if (!$telegramService->setWebhook(config('v2board.app_url') . '/api/v1/guest/telegram/webhook?access_token=' . md5(config('v2board.telegram_bot_token')))) {
|
if (!$telegramService->setWebhook(
|
||||||
|
config('v2board.app_url')
|
||||||
|
. '/api/v1/guest/telegram/webhook?access_token='
|
||||||
|
. md5(config('v2board.telegram_bot_token', $request->input('telegram_bot_token')))
|
||||||
|
)) {
|
||||||
abort(500, 'Webhook设置失败');
|
abort(500, 'Webhook设置失败');
|
||||||
}
|
}
|
||||||
return response([
|
return response([
|
||||||
|
@ -6,9 +6,9 @@ use \Curl\Curl;
|
|||||||
class TelegramService {
|
class TelegramService {
|
||||||
protected $api;
|
protected $api;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(string $token = '')
|
||||||
{
|
{
|
||||||
$this->api = 'https://api.telegram.org/bot' . config('v2board.telegram_bot_token') . '/';
|
$this->api = 'https://api.telegram.org/bot' . config('v2board.telegram_bot_token', $token) . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendMessage(int $chatId, string $text, string $parseMode = '')
|
public function sendMessage(int $chatId, string $text, string $parseMode = '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user