Explorar el Código

fix wrong bot bug in SayCmd

00ll00 hace 5 años
padre
commit
2747e2af75
Se han modificado 1 ficheros con 9 adiciones y 3 borrados
  1. 9 3
      src/main/kotlin/bot_luo_core/cli/commands/SayCmd.kt

+ 9 - 3
src/main/kotlin/bot_luo_core/cli/commands/SayCmd.kt

@@ -31,9 +31,15 @@ class SayCmd(context: CmdContext) : Cmd(context) {
     ): CmdReceipt { with(context) {
 
         if (!group.virtual) {
-            group.bot = if (user.virtual) BotLuo.getContactableBots(group).randomOrNull()
-            else BotLuo.getBotOrNull(user.id)
-            group.sendMessage(msg)
+            if (user.virtual)
+                context.sendMessageWithLog(msg)
+            else {
+                val contact = BotLuo.getContactableBots(group).find { it.id == user.id }?.getGroup(group.id)
+                if (contact != null) {
+                    group.contact = contact
+                    context.sendMessageWithLog(msg)
+                }
+            }
         }
 
         VirtualMessageEvent(