mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-12 14:00:12 +08:00
ConfigSectionList
This commit is contained in:
parent
125bfd3245
commit
b57fe1bb49
@ -0,0 +1,16 @@
|
||||
package net.mamoe.mirai.console
|
||||
|
||||
import net.mamoe.mirai.console.plugins.Config
|
||||
import net.mamoe.mirai.console.plugins.loadAsConfig
|
||||
import net.mamoe.mirai.console.plugins.withDefaultWriteSave
|
||||
import java.io.File
|
||||
|
||||
object Data {
|
||||
val section = (File(System.getProperty("user.dir") + "/setu.yml")).loadAsConfig()
|
||||
val R18 = section.getList
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
||||
|
||||
}
|
@ -131,13 +131,6 @@ object DefaultCommands {
|
||||
}
|
||||
bot.login()
|
||||
bot.subscribeMessages {
|
||||
contains("test") {
|
||||
if (this is GroupMessage) {
|
||||
quoteReply("Hello $senderName")
|
||||
} else {
|
||||
reply("Hello!")
|
||||
}
|
||||
}
|
||||
this.startsWith("/") {
|
||||
if (bot.checkManager(this.sender.id)) {
|
||||
val sender = ContactCommandSender(this.subject)
|
||||
@ -149,7 +142,6 @@ object DefaultCommands {
|
||||
}
|
||||
sendMessage("$qqNumber login successes")
|
||||
MiraiConsole.frontEnd.pushBot(bot)
|
||||
|
||||
} catch (e: Exception) {
|
||||
sendMessage("$qqNumber login failed -> " + e.message)
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ interface Config {
|
||||
fun getFloatList(key: String): List<Float>
|
||||
fun getDoubleList(key: String): List<Double>
|
||||
fun getLongList(key: String): List<Long>
|
||||
fun getConfigSectionList(key: String): List<ConfigSection>
|
||||
operator fun set(key: String, value: Any)
|
||||
operator fun get(key: String): Any?
|
||||
operator fun contains(key: String): Boolean
|
||||
@ -271,6 +272,16 @@ interface ConfigSection : Config, MutableMap<String, Any> {
|
||||
return ((get(key) ?: error("ConfigSection does not contain $key ")) as List<*>).map { it.toString().toLong() }
|
||||
}
|
||||
|
||||
override fun getConfigSectionList(key: String): List<ConfigSection> {
|
||||
return ((get(key) ?: error("ConfigSection does not contain $key ")) as List<*>).map {
|
||||
if (it is ConfigSection) {
|
||||
it
|
||||
} else {
|
||||
ConfigSectionDelegation(it as MutableMap<String, Any>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun exist(key: String): Boolean {
|
||||
return get(key) != null
|
||||
}
|
||||
|
3
mirai-core/src/jvmTest/kotlin/mirai/test/setu.kt
Normal file
3
mirai-core/src/jvmTest/kotlin/mirai/test/setu.kt
Normal file
@ -0,0 +1,3 @@
|
||||
package mirai.test
|
||||
|
||||
import java.io.File
|
Loading…
Reference in New Issue
Block a user