chore: bump dep version
This commit is contained in:
12 files changed
+58
-35
No files matched your search
@@ -12,35 +12,17 @@ import cn.rtast.fancybot.commands.JrrpCommand
|
||||
import cn.rtast.fancybot.commands.MusicCommand
|
||||
import cn.rtast.fancybot.commands.MyPointCommand
|
||||
import cn.rtast.fancybot.commands.SignCommand
|
||||
import cn.rtast.fancybot.entity.enums.WSType
|
||||
import cn.rtast.fancybot.util.file.ConfigManager
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
import cn.rtast.rob.entity.GroupMessage
|
||||
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 suspend fun onGroupMessage(websocket: WebSocket, message: GroupMessage, json: String) {
|
||||
println(message.rawMessage)
|
||||
}
|
||||
|
||||
override suspend fun onWebsocketError(webSocket: WebSocket, ex: Exception) {
|
||||
println(ex.message)
|
||||
}
|
||||
}
|
||||
|
||||
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...")
|
||||
}
|
||||
|
||||
val commands = listOf(
|
||||
@@ -54,11 +36,16 @@ val commands = listOf(
|
||||
val configManager = ConfigManager()
|
||||
|
||||
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
|
||||
val workType = configManager.wsType
|
||||
val accessToken = configManager.accessToken
|
||||
val rob = if (workType == WSType.Client) {
|
||||
val address = configManager.wsAddress
|
||||
ROneBotFactory.createClient(address, accessToken, fancyBot)
|
||||
} else {
|
||||
val port = configManager.wsPort
|
||||
ROneBotFactory.createServer(port, accessToken, fancyBot)
|
||||
}
|
||||
val commandManager = rob.commandManager
|
||||
commands.forEach { commandManager.register(it) }
|
||||
createFakeServer()
|
||||
}
|
||||
Reference in New Issue
Block a user