mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-29 22:27:33 +00:00
[Fix] CQPluginMain 通过延迟加载来修复ApplicationBoot初始化失败的问题;
This commit is contained in:
parent
05e933838e
commit
f80b6e72e0
@ -14,11 +14,15 @@ import net.lz1998.cq.robot.CoolQ;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Component
|
||||
public class CQPluginMain extends CQPlugin implements EventHandler {
|
||||
|
||||
private final static AtomicBoolean initialState = new AtomicBoolean();
|
||||
|
||||
public CQPluginMain() {
|
||||
ApplicationBoot.initialBot();
|
||||
|
||||
LoggerFactory.getLogger(CQPluginMain.class)
|
||||
.info("BotEventHandler.COMMAND_PREFIX = {}", BotEventHandler.COMMAND_PREFIX);
|
||||
}
|
||||
@ -46,6 +50,12 @@ public class CQPluginMain extends CQPlugin implements EventHandler {
|
||||
*/
|
||||
private static int processMessage(CoolQ cq, CQMessageEvent event) {
|
||||
SpringCQMessageSenderFactory.setCoolQ(cq);
|
||||
synchronized (initialState) {
|
||||
if(!initialState.get()) {
|
||||
ApplicationBoot.initialBot();
|
||||
initialState.set(true);
|
||||
}
|
||||
}
|
||||
if(BotEventHandler.mismatch(event.getMessage())) {
|
||||
return MESSAGE_IGNORE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user