chore: format code
This commit is contained in:
7 files changed
+67
-49
No files matched your search
@@ -24,6 +24,7 @@ import cn.rtast.fancybot.items.BaisiItem
|
||||
import cn.rtast.fancybot.items.HeisiItem
|
||||
import cn.rtast.fancybot.items.SetuItem
|
||||
import cn.rtast.fancybot.util.file.ConfigManager
|
||||
import cn.rtast.fancybot.util.file.SignManager
|
||||
import cn.rtast.fancybot.util.initDatabase
|
||||
import cn.rtast.fancybot.util.item.ItemManager
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
@@ -66,10 +67,12 @@ class FancyBot : OBMessage {
|
||||
}
|
||||
|
||||
val commands = listOf(
|
||||
EchoCommand(), JrrpCommand(), MusicCommand(),
|
||||
SignCommand(), RedeemCommand(), MyPointCommand(),
|
||||
HitokotoCommand(), FKXQSCommand(), QRCodeCommand(),
|
||||
AntiRevokeCommand(), MCPingCommand(), HelpCommand()
|
||||
EchoCommand(), JrrpCommand(),
|
||||
MusicCommand(), SignCommand(),
|
||||
RedeemCommand(), MyPointCommand(),
|
||||
HitokotoCommand(), FKXQSCommand(),
|
||||
QRCodeCommand(), AntiRevokeCommand(),
|
||||
MCPingCommand(), HelpCommand()
|
||||
)
|
||||
|
||||
val items = listOf(
|
||||
@@ -80,6 +83,7 @@ val items = listOf(
|
||||
|
||||
val configManager = ConfigManager()
|
||||
val itemManager = ItemManager()
|
||||
val signManager = SignManager()
|
||||
|
||||
suspend fun main() {
|
||||
val fancyBot = FancyBot()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package cn.rtast.fancybot.commands
|
||||
|
||||
import cn.rtast.fancybot.entity.MCPingResponse
|
||||
import cn.rtast.fancybot.entity.MCPing
|
||||
import cn.rtast.fancybot.util.fromJson
|
||||
import cn.rtast.motdpinger.MotdPinger
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
@@ -44,7 +44,7 @@ class MCPingCommand : BaseCommand() {
|
||||
}
|
||||
try {
|
||||
val rawResponse = pingInstance.pingServer(host, port)
|
||||
val jsonResponse = rawResponse?.fromJson<MCPingResponse>()!!
|
||||
val jsonResponse = rawResponse?.fromJson<MCPing>()!!
|
||||
val msg = MessageChain.Builder().addAt(message.sender.userId).addNewLine()
|
||||
if (jsonResponse.favicon != null) msg.addImage(jsonResponse.favicon, true)
|
||||
msg.addText("服务器地址: $host:$port")
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/9/4
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands
|
||||
|
||||
import cn.rtast.fancybot.ADMINS
|
||||
import cn.rtast.fancybot.signManager
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.enums.UserRole
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OBMessage
|
||||
|
||||
class MyPointCommand : BaseCommand() {
|
||||
override val commandNames = listOf("/我的点数", "/mp")
|
||||
|
||||
override suspend fun executeGroup(listener: OBMessage, message: GroupMessage, args: List<String>) {
|
||||
// query target's point
|
||||
if (args.isNotEmpty() && (message.sender.role == UserRole.admin || message.sender.userId in ADMINS)) {
|
||||
val targetId = args.first().toLong()
|
||||
val targetData = signManager.getStatus(targetId)
|
||||
val msg = MessageChain.Builder().addAt(message.sender.userId)
|
||||
|
||||
if (targetData == null) {
|
||||
msg.addText("用户不存在, 需要先签到一次才能查询点数呢~")
|
||||
} else {
|
||||
msg.addText("用户: ${targetData.id} 的点数有: ${targetData.points}")
|
||||
}
|
||||
listener.sendGroupMessage(message.groupId, msg.build())
|
||||
return
|
||||
}
|
||||
// query self point
|
||||
val status = signManager.getStatus(message.sender.userId)
|
||||
if (status == null) {
|
||||
val msg = MessageChain.Builder()
|
||||
.addAt(message.sender.userId)
|
||||
.addText("你还没有签到过呢! 先发送‘/签到’再来查询吧~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
return
|
||||
} else {
|
||||
val msg = MessageChain.Builder()
|
||||
.addAt(message.sender.userId)
|
||||
.addText("你当前的点数为: ${status.points}")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package cn.rtast.fancybot.commands
|
||||
|
||||
import cn.rtast.fancybot.itemManager
|
||||
import cn.rtast.fancybot.signManager
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
|
||||
@@ -7,15 +7,12 @@
|
||||
|
||||
package cn.rtast.fancybot.commands
|
||||
|
||||
import cn.rtast.fancybot.ADMINS
|
||||
import cn.rtast.fancybot.util.file.SignManager
|
||||
import cn.rtast.fancybot.signManager
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.enums.UserRole
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.MessageChain
|
||||
import cn.rtast.rob.util.ob.OBMessage
|
||||
|
||||
val signManager = SignManager()
|
||||
|
||||
class SignCommand : BaseCommand() {
|
||||
override val commandNames = listOf("/签到", "/sign")
|
||||
@@ -39,40 +36,3 @@ class SignCommand : BaseCommand() {
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
}
|
||||
}
|
||||
|
||||
class MyPointCommand : BaseCommand() {
|
||||
override val commandNames = listOf("/我的点数", "/mp")
|
||||
|
||||
override suspend fun executeGroup(listener: OBMessage, message: GroupMessage, args: List<String>) {
|
||||
// query target's point
|
||||
if (args.isNotEmpty() && (message.sender.role == UserRole.admin || message.sender.userId in ADMINS)) {
|
||||
val targetId = args.first().toLong()
|
||||
val targetData = signManager.getStatus(targetId)
|
||||
val msg = MessageChain.Builder().addAt(message.sender.userId)
|
||||
|
||||
if (targetData == null) {
|
||||
msg.addText("用户不存在, 需要先签到一次才能查询点数呢~")
|
||||
} else {
|
||||
msg.addText("用户: ${targetData.id} 的点数有: ${targetData.points}")
|
||||
}
|
||||
listener.sendGroupMessage(message.groupId, msg.build())
|
||||
return
|
||||
}
|
||||
// query self point
|
||||
val status = signManager.getStatus(message.sender.userId)
|
||||
if (status == null) {
|
||||
val msg = MessageChain.Builder()
|
||||
.addAt(message.sender.userId)
|
||||
.addText("你还没有签到过呢! 先发送‘/签到’再来查询吧~")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
return
|
||||
} else {
|
||||
val msg = MessageChain.Builder()
|
||||
.addAt(message.sender.userId)
|
||||
.addText("你当前的点数为: ${status.points}")
|
||||
.build()
|
||||
listener.sendGroupMessage(message.groupId, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
package cn.rtast.fancybot.entity
|
||||
|
||||
data class MCPingResponse(
|
||||
data class MCPing(
|
||||
val version: Version,
|
||||
val players: Players,
|
||||
val favicon: String?
|
||||
Reference in New Issue
Block a user