[Change] ConsoleMain, ConsoleMessageEvent 支持启动时设置会话群组Id和QQId;

This commit is contained in:
LamGC 2020-06-06 10:52:12 +08:00
parent e570ddbb53
commit c1a21d1065
2 changed files with 7 additions and 3 deletions

View File

@ -12,6 +12,10 @@ public class ConsoleMain {
MessageSenderBuilder.setCurrentMessageSenderFactory(new ConsoleMessageSenderFactory()); MessageSenderBuilder.setCurrentMessageSenderFactory(new ConsoleMessageSenderFactory());
ApplicationBoot.initialBot(); ApplicationBoot.initialBot();
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
System.out.print("会话QQ:");
long qqId = scanner.nextLong();
System.out.print("会话群组号:");
long groupId = scanner.nextLong();
boolean isGroup = false; boolean isGroup = false;
do { do {
String input = scanner.nextLine(); String input = scanner.nextLine();
@ -23,7 +27,7 @@ public class ConsoleMain {
System.out.println("System: 群模式状态已变更: " + isGroup); System.out.println("System: 群模式状态已变更: " + isGroup);
continue; continue;
} }
BotEventHandler.executeMessageEvent(new ConsoleMessageEvent(input, isGroup)); BotEventHandler.executeMessageEvent(new ConsoleMessageEvent(isGroup ? groupId : 0, qqId, input));
} while(true); } while(true);
} }

View File

@ -6,8 +6,8 @@ import java.util.Date;
public class ConsoleMessageEvent extends MessageEvent { public class ConsoleMessageEvent extends MessageEvent {
public ConsoleMessageEvent(String message, boolean isGroup) { public ConsoleMessageEvent(long groupId, long qqId, String message) {
super(isGroup ? 1 : 0, 1, message); super(groupId, qqId, message);
} }
@Override @Override