feat: add repeater
This commit is contained in:
1 file changed
+12
@@ -61,6 +61,8 @@ class FancyBot : OneBotListener {
|
||||
|
||||
private val logger = Logger.getLogger<FancyBot>()
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
private var lastText = ""
|
||||
private var repeatCount = 0
|
||||
|
||||
override suspend fun onWebsocketOpenEvent(action: OneBotAction) {
|
||||
action.sendPrivateMessage(configManager.noticeUser, "FancyBot启动完成~")
|
||||
@@ -75,6 +77,16 @@ class FancyBot : OneBotListener {
|
||||
logger.info("$sender($senderId: $groupId >>> $messageId): $msg")
|
||||
logger.trace("$sender($senderId: $groupId >>> $messageId: $json")
|
||||
|
||||
if (message.text == lastText) {
|
||||
repeatCount++
|
||||
if (repeatCount >= 1) {
|
||||
message.action.sendGroupMessage(message.groupId, message.message)
|
||||
}
|
||||
} else {
|
||||
repeatCount = 0
|
||||
}
|
||||
lastText = message.text
|
||||
|
||||
if (message.message.any { it.type == ArrayMessageType.face && it.data.id.toString() == "419" }) {
|
||||
message.reply("你发牛魔的火车呢, 我直接就是打断")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user