-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 临时的崩溃修复 * 问题修复和代码格式化 现在发送消息不会导致服务器暂停 调整一些对象的作用域
- Loading branch information
Showing
4 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
fabric/src/main/java/cn/evole/mods/mcbot/util/onebot/MessageThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cn.evole.mods.mcbot.util.onebot; | ||
|
||
import cn.evole.mods.mcbot.Const; | ||
import cn.evole.mods.mcbot.McBot; | ||
import com.google.gson.JsonArray; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
/** | ||
* @Project: McBot-fabric | ||
* @Author: xia-mc | ||
* @CreateTime: 2024/2/12 16:11 | ||
* @Description: 笑点解析: | ||
*/ | ||
public class MessageThread { | ||
private final ExecutorService executor; | ||
public MessageThread() { | ||
executor = Executors.newCachedThreadPool(); | ||
} | ||
|
||
public void submit(long groupId, String msg, boolean autoEscape) { | ||
Const.LOGGER.debug(String.format("转发游戏消息: %s", msg)); | ||
executor.submit(() -> McBot.onebot.getBot().sendGroupMsg(groupId, msg, autoEscape)); | ||
} | ||
|
||
public void submit(long groupId, JsonArray msg, boolean autoEscape) { | ||
Const.LOGGER.debug(String.format("转发游戏消息: %s", msg)); | ||
executor.submit(() -> McBot.onebot.getBot().sendGroupMsg(groupId, msg, autoEscape)); | ||
} | ||
|
||
public void submit(String guildID, String channelID, String message) { | ||
Const.LOGGER.debug(String.format("转发游戏消息: %s", message)); | ||
executor.submit(() -> McBot.onebot.getBot().sendGuildMsg(guildID, channelID, message)); | ||
} | ||
|
||
public void submit(String guildID, String channelID, JsonArray message) { | ||
Const.LOGGER.debug(String.format("转发游戏消息: %s", message)); | ||
executor.submit(() -> McBot.onebot.getBot().sendGuildMsg(guildID, channelID, message)); | ||
} | ||
|
||
public void stop() { | ||
executor.shutdownNow(); | ||
} | ||
} |