2024-09-18 16:52:28 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2024 RTAkland
|
|
|
|
|
* Author: RTAkland
|
|
|
|
|
* Date: 2024/9/18
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2024-09-20 16:30:33 +08:00
|
|
|
package cn.rtast.fancybot.commands.misc
|
2024-09-18 16:52:28 +08:00
|
|
|
|
2024-09-26 05:20:10 +08:00
|
|
|
import cn.rtast.fancybot.annotations.CommandDescription
|
2024-09-18 16:52:28 +08:00
|
|
|
import cn.rtast.rob.entity.GroupMessage
|
2024-09-19 11:06:40 +08:00
|
|
|
import cn.rtast.rob.entity.PrivateMessage
|
2024-09-18 16:52:28 +08:00
|
|
|
import cn.rtast.rob.util.BaseCommand
|
|
|
|
|
import cn.rtast.rob.util.ob.MessageChain
|
2024-09-19 11:06:40 +08:00
|
|
|
import cn.rtast.rob.util.ob.OneBotListener
|
|
|
|
|
|
|
|
|
|
val users = mutableMapOf<Long, Long>()
|
2024-09-18 16:52:28 +08:00
|
|
|
|
2024-09-26 05:20:10 +08:00
|
|
|
@CommandDescription("自闭去吧你")
|
2024-09-18 16:52:28 +08:00
|
|
|
class ZiBiCommand : BaseCommand() {
|
|
|
|
|
override val commandNames = listOf("/自闭", "自闭")
|
|
|
|
|
|
2024-09-19 11:06:40 +08:00
|
|
|
override suspend fun executeGroup(listener: OneBotListener, message: GroupMessage, args: List<String>) {
|
2024-09-18 16:52:28 +08:00
|
|
|
try {
|
2024-09-19 11:06:40 +08:00
|
|
|
users.remove(message.sender.userId)
|
2024-09-18 16:52:28 +08:00
|
|
|
val duration = if (args.isEmpty()) 1 else args.first().toInt()
|
|
|
|
|
message.sender.ban(duration * 60)
|
|
|
|
|
val msg = MessageChain.Builder()
|
|
|
|
|
.addText("你先自闭${duration}分钟吧~")
|
2024-09-19 11:06:40 +08:00
|
|
|
.addNewLine()
|
|
|
|
|
.addText("私聊发送`我想开了`即可取消禁言~")
|
2024-09-18 16:52:28 +08:00
|
|
|
.build()
|
|
|
|
|
message.reply(msg)
|
|
|
|
|
} catch (_: Exception) {
|
|
|
|
|
val msg = MessageChain.Builder()
|
|
|
|
|
.addText("你输入有误所以我决定让你自闭1天~")
|
|
|
|
|
.build()
|
|
|
|
|
message.reply(msg)
|
|
|
|
|
message.sender.ban(86400)
|
2024-09-26 21:56:16 +08:00
|
|
|
} finally {
|
|
|
|
|
users[message.sender.userId] = message.groupId
|
2024-09-18 16:52:28 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-09-19 11:06:40 +08:00
|
|
|
}
|
|
|
|
|
|
2024-09-26 05:20:10 +08:00
|
|
|
@CommandDescription("我好像突然想开了")
|
2024-09-19 11:06:40 +08:00
|
|
|
class UnsetZiBiCommand : BaseCommand() {
|
|
|
|
|
override val commandNames = listOf("我想开了")
|
|
|
|
|
|
|
|
|
|
override suspend fun executePrivate(listener: OneBotListener, message: PrivateMessage, args: List<String>) {
|
|
|
|
|
if (!users.any { it.key == message.sender.userId }) {
|
|
|
|
|
val msg = MessageChain.Builder()
|
|
|
|
|
.addText("你没有在自闭列表中~")
|
|
|
|
|
.build()
|
|
|
|
|
message.reply(msg)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
listener.setGroupBan(users.getValue(message.sender.userId), message.sender.userId, 0)
|
|
|
|
|
val msg = MessageChain.Builder()
|
|
|
|
|
.addText("祝你天天开心不要自闭~~")
|
|
|
|
|
.build()
|
|
|
|
|
message.reply(msg)
|
|
|
|
|
users.remove(message.sender.userId)
|
|
|
|
|
}
|
2024-09-18 16:52:28 +08:00
|
|
|
}
|