Ver Fonte

logout command (#417)

* logout command

* modify

* fix `sender`

* improve log

Co-authored-by: Him188 <[email protected]>

* del `scopeWith`

Co-authored-by: Him188 <[email protected]>
Eritque arcus há 4 anos atrás
pai
commit
96dced9132
1 ficheiros alterados com 18 adições e 1 exclusões
  1. 18 1
      backend/mirai-console/src/command/BuiltInCommands.kt

+ 18 - 1
backend/mirai-console/src/command/BuiltInCommands.kt

@@ -171,6 +171,23 @@ public object BuiltInCommands {
         }
     }
 
+    public object LogoutCommand : SimpleCommand(
+        ConsoleCommandOwner, "logout", "登出",
+        description = "登出一个账号",
+    ), BuiltInCommandInternal {
+
+        @Handler
+        public suspend fun CommandSender.handle(
+            @Name("qq") id: Long
+        ){
+            if (Bot.getInstanceOrNull(id)?.close() == null) {
+                sendMessage("$id 未登录")
+            } else {
+                sendMessage("$id 已登出")
+            }
+        }
+    }
+
     public object LoginCommand : SimpleCommand(
         ConsoleCommandOwner, "login", "登录",
         description = "登录一个账号",
@@ -618,4 +635,4 @@ public object BuiltInCommands {
             lines.maxOf { it[r].length }
         }
     }
-}
+}