2024-08-27 18:44:32 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2024 RTAkland
|
|
|
|
|
* Author: RTAkland
|
|
|
|
|
* Date: 2024/8/26
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package cn.rtast.fancybot
|
|
|
|
|
|
|
|
|
|
import cn.rtast.fancybot.commands.EchoCommand
|
|
|
|
|
import cn.rtast.fancybot.commands.JrrpCommand
|
2024-08-27 19:15:47 +08:00
|
|
|
import cn.rtast.fancybot.commands.MusicCommand
|
2024-08-27 18:44:32 +08:00
|
|
|
import cn.rtast.rob.ROneBotFactory
|
|
|
|
|
import cn.rtast.rob.entity.GroupMessage
|
2024-08-27 19:15:47 +08:00
|
|
|
import cn.rtast.rob.util.BaseCommand
|
2024-08-27 18:44:32 +08:00
|
|
|
import cn.rtast.rob.util.ob.OBMessage
|
|
|
|
|
import org.java_websocket.WebSocket
|
|
|
|
|
|
|
|
|
|
class FancyBot : OBMessage {
|
|
|
|
|
override fun onGroupMessage(websocket: WebSocket, message: GroupMessage, json: String) {
|
|
|
|
|
println(message.rawMessage)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 19:15:47 +08:00
|
|
|
val commands = listOf<BaseCommand>(
|
|
|
|
|
EchoCommand(),
|
|
|
|
|
JrrpCommand(),
|
|
|
|
|
MusicCommand()
|
|
|
|
|
)
|
|
|
|
|
|
2024-08-27 18:44:32 +08:00
|
|
|
fun main() {
|
|
|
|
|
val address = System.getenv("WS_ADDRESS")
|
|
|
|
|
val password = System.getenv("WS_PASSWORD")
|
|
|
|
|
val fancyBot = FancyBot()
|
2024-08-27 19:15:47 +08:00
|
|
|
val wsClient = ROneBotFactory.createClient(address, password, fancyBot)
|
2024-08-27 18:44:32 +08:00
|
|
|
val commandManager = wsClient.commandManager
|
2024-08-27 19:15:47 +08:00
|
|
|
commands.forEach {
|
|
|
|
|
commandManager.register(it)
|
|
|
|
|
}
|
2024-08-27 18:44:32 +08:00
|
|
|
}
|