mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +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()) {
|
||||
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设置失败');
|
||||
}
|
||||
return response([
|
||||
|
@ -6,9 +6,9 @@ use \Curl\Curl;
|
||||
class TelegramService {
|
||||
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 = '')
|
||||
|
Loading…
Reference in New Issue
Block a user