initial
This commit is contained in:
11 files changed
+456
No files matched your search
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val address = System.getenv("WS_ADDRESS")
|
||||
val password = System.getenv("WS_PASSWORD")
|
||||
val fancyBot = FancyBot()
|
||||
val wsClient = ROneBotFactory.createClient("", "", fancyBot)
|
||||
val commandManager = wsClient.commandManager
|
||||
commandManager.register(EchoCommand())
|
||||
commandManager.register(JrrpCommand())
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/8/27
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands
|
||||
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.OBMessage
|
||||
|
||||
class EchoCommand: BaseCommand() {
|
||||
override val commandName = "/echo"
|
||||
|
||||
override fun executeGroup(listener: OBMessage, message: GroupMessage, args: List<String>) {
|
||||
listener.sendGroupMessage(message.groupId, args.joinToString(" "))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/8/27
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.commands
|
||||
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.OBMessage
|
||||
import kotlin.random.Random
|
||||
|
||||
class JrrpCommand: BaseCommand() {
|
||||
override val commandName = "/jrrp"
|
||||
|
||||
override fun executeGroup(listener: OBMessage, message: GroupMessage, args: List<String>) {
|
||||
val score = Random.nextInt(0, 101)
|
||||
listener.sendGroupMessage(message.groupId, score.toString())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user