diff --git a/app/Plugins/Telegram/Commands/UnBind.php b/app/Plugins/Telegram/Commands/UnBind.php index ebd9325..67fd022 100644 --- a/app/Plugins/Telegram/Commands/UnBind.php +++ b/app/Plugins/Telegram/Commands/UnBind.php @@ -12,11 +12,17 @@ class UnBind extends 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) { - $telegramService->sendMessage($message->chat_id, '没有查询到您的用户信息,请先绑定账号', 'markdown'); - return; + if (!isset($message->args[0])) { + $user = User::where('telegram_id', $message->chat_id)->first(); + } else { + $chat = User::where('telegram_id', $message->chat_id)->first(); + if (!$chat) return; + if (!($chat->is_admin || $chat->is_staff)) return; + if (strpos($message->args[0], '@') !== true) { + $user = User::where('email', $message->args[0])->first(); + } else { + $user = User::where('telegram_id', $message->args[0])->first(); + } } $user->telegram_id = NULL; if (!$user->save()) {