mirror of
https://github.com/v2board/v2board.git
synced 2025-06-13 13:17:52 +08:00
update: telegram bot modularization
This commit is contained in:
28
app/Plugins/Telegram/Commands/UnBind.php
Normal file
28
app/Plugins/Telegram/Commands/UnBind.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Plugins\Telegram\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Plugins\Telegram\Telegram;
|
||||
|
||||
class UnBind extends Telegram {
|
||||
public $command = '/unbind';
|
||||
public $description = '将Telegram账号从网站解绑';
|
||||
|
||||
public function handle($message, $match = []) {
|
||||
if (!$message->is_private) return;
|
||||
$user = User::where('telegram_id', $message->chat_id)->first();
|
||||
$telegramService = $this->telegramService;
|
||||
if (!$user) {
|
||||
$help = new Help();
|
||||
$help->handle($message);
|
||||
$telegramService->sendMessage($message->chat_id, '没有查询到您的用户信息,请先绑定账号', 'markdown');
|
||||
return;
|
||||
}
|
||||
$user->telegram_id = NULL;
|
||||
if (!$user->save()) {
|
||||
abort(500, '解绑失败');
|
||||
}
|
||||
$telegramService->sendMessage($message->chat_id, '解绑成功', 'markdown');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user