fix music command and add dockerfile
This commit is contained in:
7 files changed
+104
-25
No files matched your search
@@ -12,29 +12,43 @@ import cn.rtast.fancybot.commands.JrrpCommand
|
||||
import cn.rtast.fancybot.commands.MusicCommand
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
import cn.rtast.rob.util.BaseCommand
|
||||
import cn.rtast.rob.util.ob.OBMessage
|
||||
import com.sun.net.httpserver.HttpServer
|
||||
import org.java_websocket.WebSocket
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
class FancyBot : OBMessage {
|
||||
override fun onGroupMessage(websocket: WebSocket, message: GroupMessage, json: String) {
|
||||
override suspend fun onGroupMessage(websocket: WebSocket, message: GroupMessage, json: String) {
|
||||
println(message.rawMessage)
|
||||
}
|
||||
}
|
||||
|
||||
val commands = listOf<BaseCommand>(
|
||||
val commands = listOf(
|
||||
EchoCommand(),
|
||||
JrrpCommand(),
|
||||
MusicCommand()
|
||||
)
|
||||
|
||||
fun createFakeServer() {
|
||||
val server = HttpServer.create(InetSocketAddress(8000), 0)
|
||||
server.createContext("/") { exchange ->
|
||||
val response = "Hello, Kotlin HTTP Server!"
|
||||
exchange.sendResponseHeaders(200, response.toByteArray().size.toLong())
|
||||
val os = exchange.responseBody
|
||||
os.write(response.toByteArray())
|
||||
os.close()
|
||||
}
|
||||
server.start()
|
||||
println("Server is running on port 8000...")
|
||||
}
|
||||
|
||||
|
||||
fun main() {
|
||||
val address = System.getenv("WS_ADDRESS")
|
||||
val password = System.getenv("WS_PASSWORD")
|
||||
val fancyBot = FancyBot()
|
||||
val wsClient = ROneBotFactory.createClient(address, password, fancyBot)
|
||||
val commandManager = wsClient.commandManager
|
||||
commands.forEach {
|
||||
commandManager.register(it)
|
||||
}
|
||||
commands.forEach { commandManager.register(it) }
|
||||
createFakeServer()
|
||||
}
|
||||
Reference in New Issue
Block a user