mirror of
https://github.com/mamoe/mirai.git
synced 2026-09-06 07:04:56 +08:00
Update core dependency to 0.32.0
This commit is contained in:
44
build.gradle
44
build.gradle
@@ -1,44 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'https://mirrors.huaweicloud.com/repository/maven' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
|
||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:1.4-M1"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M1"
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' // don't use any other.
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
def keyProps = new Properties()
|
||||
def keyFile = file("local.properties")
|
||||
if (keyFile.exists()) keyFile.withInputStream { keyProps.load(it) }
|
||||
if (!keyProps.getProperty("sdk.dir", "").isEmpty()) {
|
||||
project.ext.set("isAndroidSDKAvailable", true)
|
||||
} else {
|
||||
project.ext.set("isAndroidSDKAvailable", false)
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
group = "net.mamoe"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "https://mirrors.huaweicloud.com/repository/maven" }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
|
||||
maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
|
||||
}
|
||||
}
|
||||
26
build.gradle.kts
Normal file
26
build.gradle.kts
Normal file
@@ -0,0 +1,26 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
maven(url = "https://mirrors.huaweicloud.com/repository/maven")
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("com.github.jengelman.gradle.plugins:shadow:5.2.0")
|
||||
classpath("org.jetbrains.kotlin:kotlin-serialization:${Versions.Kotlin.stdlib}")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin.stdlib}")
|
||||
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4") // don"t use any other.
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
group = "net.mamoe"
|
||||
|
||||
repositories {
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
|
||||
maven(url = "https://mirrors.huaweicloud.com/repository/maven")
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
@@ -11,33 +11,18 @@ import org.gradle.kotlin.dsl.DependencyHandlerScope
|
||||
|
||||
object Versions {
|
||||
object Mirai {
|
||||
const val core = "0.31.0"
|
||||
const val console = "0.4.1"
|
||||
const val core = "0.32.0"
|
||||
const val console = "0.4.2"
|
||||
const val consoleGraphical = "0.0.5"
|
||||
const val consoleWrapper = "0.2.0"
|
||||
}
|
||||
|
||||
object Kotlin {
|
||||
const val stdlib = "1.4-M1"
|
||||
const val coroutines = "1.3.5-1.4-M1"
|
||||
const val atomicFU = "0.14.2-1.4-M1"
|
||||
const val serialization = "0.20.0-1.4-M1"
|
||||
const val ktor = "1.3.2-1.4-M1"
|
||||
|
||||
const val io = "0.1.16"
|
||||
const val coroutinesIo = "0.1.16"
|
||||
const val dokka = "0.10.1"
|
||||
const val stdlib = "1.3.71"
|
||||
const val coroutines = "1.3.5"
|
||||
const val serialization = "0.20.0"
|
||||
const val ktor = "1.3.2"
|
||||
}
|
||||
|
||||
object Android {
|
||||
const val androidGradlePlugin = "3.5.3"
|
||||
}
|
||||
|
||||
object Publishing {
|
||||
const val bintray = "1.8.4-jetbrains-3"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
|
||||
@@ -49,21 +49,6 @@ bintray {
|
||||
}
|
||||
}
|
||||
|
||||
val kotlinVersion: String by rootProject.ext
|
||||
val atomicFuVersion: String by rootProject.ext
|
||||
val coroutinesVersion: String by rootProject.ext
|
||||
val kotlinXIoVersion: String by rootProject.ext
|
||||
val coroutinesIoVersion: String by rootProject.ext
|
||||
|
||||
val klockVersion: String by rootProject.ext
|
||||
val ktorVersion: String by rootProject.ext
|
||||
|
||||
val serializationVersion: String by rootProject.ext
|
||||
|
||||
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
|
||||
|
||||
fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
|
||||
|
||||
dependencies {
|
||||
compileOnly("net.mamoe:mirai-core-jvm:${Versions.Mirai.core}")
|
||||
implementation(project(":mirai-console"))
|
||||
|
||||
@@ -85,7 +85,7 @@ class MiraiGraphicalUIController : Controller(), MiraiConsoleUI {
|
||||
}
|
||||
|
||||
override fun pushBot(bot: Bot) = Platform.runLater {
|
||||
cache[bot.uin]?.bot = bot
|
||||
cache[bot.id]?.bot = bot
|
||||
}
|
||||
|
||||
override fun pushVersion(consoleVersion: String, consoleBuild: String, coreVersion: String) {
|
||||
|
||||
@@ -15,7 +15,7 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>() {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
api("net.mamoe:mirai-core-qqandroid-jvm:${Versions.Mirai.core}")
|
||||
compileOnly("net.mamoe:mirai-core-qqandroid:${Versions.Mirai.core}")
|
||||
api(project(":mirai-console"))
|
||||
api(group = "com.googlecode.lanterna", name = "lanterna", version = "3.0.2")
|
||||
}
|
||||
@@ -97,8 +97,8 @@ object MiraiConsoleTerminalUI : MiraiConsoleUI {
|
||||
}
|
||||
|
||||
override fun pushBot(bot: Bot) {
|
||||
botAdminCount[bot.uin] = 0
|
||||
screens.add(bot.uin)
|
||||
botAdminCount[bot.id] = 0
|
||||
screens.add(bot.id)
|
||||
drawFrame(this.getScreenName(currentScreenId))
|
||||
if (terminal is SwingTerminalFrame) {
|
||||
terminal.flush()
|
||||
|
||||
@@ -119,13 +119,4 @@ internal object ConsoleUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun downloadConsole(version: String) {
|
||||
|
||||
/*
|
||||
tryNTimesOrQuit(3, "Failed to download Console, please seek for help") {
|
||||
Http.downloadMavenArchive("net/mamoe", getProjectName(), version)
|
||||
.saveToContent("${getProjectName()}-$version.jar")
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ private class MiraiDownloaderImpl(
|
||||
val input= con.inputStream
|
||||
totalSize.addAndGet(con.contentLength)
|
||||
val outputStream = FileOutputStream(file)
|
||||
var len = -1
|
||||
var len: Int
|
||||
val buff = ByteArray(1024)
|
||||
while (input.read(buff).also { len = it } != -1) {
|
||||
totalDownload.addAndGet(buff.size)
|
||||
|
||||
@@ -32,7 +32,6 @@ dependencies {
|
||||
|
||||
testApi("net.mamoe:mirai-core-qqandroid-jvm:${Versions.Mirai.core}")
|
||||
testApi(kotlin("stdlib"))
|
||||
testApi("org.jsoup:jsoup:1.12.1")
|
||||
}
|
||||
|
||||
version = Versions.Mirai.console
|
||||
|
||||
@@ -9,16 +9,13 @@
|
||||
|
||||
package net.mamoe.mirai.console
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.io.charsets.Charset
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.command.CommandSender
|
||||
import net.mamoe.mirai.console.command.ConsoleCommandSender
|
||||
import net.mamoe.mirai.console.command.DefaultCommands
|
||||
import net.mamoe.mirai.console.plugins.PluginManager
|
||||
import net.mamoe.mirai.console.utils.MiraiConsoleUI
|
||||
import net.mamoe.mirai.utils.SimpleLogger.LogPriority
|
||||
import net.mamoe.mirai.utils.io.encodeToString
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.PrintStream
|
||||
|
||||
@@ -29,6 +26,7 @@ object MiraiConsole {
|
||||
*/
|
||||
const val build = "Pkmon"
|
||||
lateinit var version: String
|
||||
internal set
|
||||
|
||||
/**
|
||||
* 获取从Console登陆上的Bot, Bots
|
||||
@@ -36,7 +34,7 @@ object MiraiConsole {
|
||||
val bots get() = Bot.instances
|
||||
|
||||
fun getBotOrNull(uin: Long): Bot? {
|
||||
return bots.asSequence().mapNotNull { it.get() }.firstOrNull { it.uin == uin }
|
||||
return bots.asSequence().mapNotNull { it.get() }.firstOrNull { it.id == uin }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,64 +96,12 @@ object MiraiConsole {
|
||||
*/
|
||||
fun stop() {
|
||||
PluginManager.disablePlugins()
|
||||
CommandManager.cancel()
|
||||
CommandManager.cancel()
|
||||
try {
|
||||
bots.forEach {
|
||||
it.get()?.close()
|
||||
}
|
||||
} catch (ignored: Exception) { }
|
||||
}
|
||||
|
||||
@Suppress("RedundantSuspendModifier") // binary compatibility
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release",
|
||||
ReplaceWith(
|
||||
"CommandManager",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
object CommandProcessor {
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runConsoleCommand(command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
), level = DeprecationLevel.ERROR
|
||||
)
|
||||
suspend fun runConsoleCommand(command: String) {
|
||||
CommandManager.runCommand(ConsoleCommandSender, command)
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(sender, command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
), level = DeprecationLevel.ERROR
|
||||
)
|
||||
suspend fun runCommand(sender: CommandSender, command: String) {
|
||||
CommandManager.runCommand(sender, command)
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager",
|
||||
"net.mamoe.mirai.console.command.ConsoleCommandSender"
|
||||
), level = DeprecationLevel.ERROR
|
||||
)
|
||||
fun runConsoleCommandBlocking(command: String) =
|
||||
runBlocking { CommandManager.runCommand(ConsoleCommandSender, command) }
|
||||
|
||||
|
||||
@Suppress("unused")
|
||||
@Deprecated(
|
||||
"Please use CommandManager directly, this will be removed in later release", ReplaceWith(
|
||||
"CommandManager.runCommand(sender, command)",
|
||||
"net.mamoe.mirai.console.command.CommandManager"
|
||||
), level = DeprecationLevel.ERROR
|
||||
)
|
||||
fun runCommandBlocking(sender: CommandSender, command: String) = runBlocking {
|
||||
CommandManager.runCommand(sender, command)
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,4 +154,9 @@ internal val Throwable.stacktraceString: String
|
||||
get() =
|
||||
ByteArrayOutputStream().apply {
|
||||
printStackTrace(PrintStream(this))
|
||||
}.use { it.toByteArray().encodeToString() }
|
||||
}.use { it.toByteArray().encodeToString() }
|
||||
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun ByteArray.encodeToString(charset: Charset = Charsets.UTF_8): String =
|
||||
kotlinx.io.core.String(this, charset = charset)
|
||||
|
||||
@@ -2,34 +2,34 @@ package net.mamoe.mirai.console.center
|
||||
|
||||
interface PluginCenter {
|
||||
|
||||
companion object{
|
||||
val Default:PluginCenter = CuiPluginCenter
|
||||
companion object {
|
||||
val Default: PluginCenter = CuiPluginCenter
|
||||
}
|
||||
|
||||
data class PluginInsight(
|
||||
val name:String,
|
||||
val version:String,
|
||||
val coreVersion:String,
|
||||
val consoleVersion:String,
|
||||
val author:String,
|
||||
val name: String,
|
||||
val version: String,
|
||||
val coreVersion: String,
|
||||
val consoleVersion: String,
|
||||
val author: String,
|
||||
val description: String,
|
||||
val tags:List<String>,
|
||||
val commands:List<String>,
|
||||
val tags: List<String>,
|
||||
val commands: List<String>
|
||||
)
|
||||
|
||||
data class PluginInfo(
|
||||
val name:String,
|
||||
val version:String,
|
||||
val coreVersion:String,
|
||||
val consoleVersion:String,
|
||||
val tags:List<String>,
|
||||
val author:String,
|
||||
val contact:String,
|
||||
val name: String,
|
||||
val version: String,
|
||||
val coreVersion: String,
|
||||
val consoleVersion: String,
|
||||
val tags: List<String>,
|
||||
val author: String,
|
||||
val contact: String,
|
||||
val description: String,
|
||||
val usage:String,
|
||||
val vcs:String,
|
||||
val commands:String,
|
||||
val changeLog:List<String>
|
||||
val usage: String,
|
||||
val vcs: String,
|
||||
val commands: String,
|
||||
val changeLog: List<String>
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -37,12 +37,12 @@ interface PluginCenter {
|
||||
* 能获取到多少由实际的PluginCenter决定
|
||||
* 返回 插件名->Insight
|
||||
*/
|
||||
suspend fun fetchPlugin(page: Int) :Map<String,PluginInsight>
|
||||
suspend fun fetchPlugin(page: Int): Map<String, PluginInsight>
|
||||
|
||||
/**
|
||||
* 尝试获取到某个插件by全名, case sensitive
|
||||
* null则没有
|
||||
*/
|
||||
suspend fun findPlugin(name:String):PluginInfo?
|
||||
suspend fun findPlugin(name: String): PluginInfo?
|
||||
}
|
||||
|
||||
|
||||
@@ -50,22 +50,10 @@ interface Command {
|
||||
*/
|
||||
inline fun Command.register(commandOwner: CommandOwner) = CommandManager.register(commandOwner,this)
|
||||
|
||||
|
||||
/**
|
||||
* 构造并注册一个指令
|
||||
*/
|
||||
@Deprecated("this will be removed in next few release")
|
||||
object AnonymousCommandOwner:CommandOwner
|
||||
@Deprecated("this will become internal in next few release, please use PluginBase.registerCommand() for plugin")
|
||||
inline fun registerCommand(builder: CommandBuilder.() -> Unit): Command {
|
||||
return CommandBuilder().apply(builder).register(AnonymousCommandOwner)
|
||||
}
|
||||
|
||||
internal inline fun registerConsoleCommands(builder: CommandBuilder.() -> Unit):Command{
|
||||
return CommandBuilder().apply(builder).register(ConsoleCommandOwner)
|
||||
}
|
||||
|
||||
|
||||
inline fun PluginBase.registerCommand(builder: CommandBuilder.() -> Unit):Command{
|
||||
return CommandBuilder().apply(builder).register(this.asCommandOwner())
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import net.mamoe.mirai.console.utils.removeManager
|
||||
import net.mamoe.mirai.contact.sendMessage
|
||||
import net.mamoe.mirai.event.subscribeMessages
|
||||
import net.mamoe.mirai.getFriendOrNull
|
||||
import net.mamoe.mirai.utils.FileBasedDeviceInfo
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
import java.util.*
|
||||
|
||||
@@ -117,7 +116,7 @@ object DefaultCommands {
|
||||
try {
|
||||
MiraiConsole.frontEnd.prePushBot(qqNumber)
|
||||
val bot = Bot(qqNumber, qqPassword) {
|
||||
+FileBasedDeviceInfo
|
||||
fileBasedDeviceInfo()
|
||||
this.loginSolver = MiraiConsole.frontEnd.createLoginSolver()
|
||||
this.botLoggerSupplier = {
|
||||
SimpleLogger("BOT $qqNumber]") { _, message, e ->
|
||||
@@ -168,10 +167,10 @@ object DefaultCommands {
|
||||
val bot = args[0]
|
||||
var find = false
|
||||
MiraiConsole.bots.forEach {
|
||||
if (it.get()?.uin.toString().contains(bot)) {
|
||||
if (it.get()?.id.toString().contains(bot)) {
|
||||
find = true
|
||||
appendMessage(
|
||||
"" + it.get()?.uin + ": 在线中; 好友数量:" + it.get()?.friends?.size + "; 群组数量:" + it.get()
|
||||
"" + it.get()?.id + ": 在线中; 好友数量:" + it.get()?.friends?.size + "; 群组数量:" + it.get()
|
||||
?.groups?.size
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import com.moandjiezana.toml.Toml
|
||||
import com.moandjiezana.toml.TomlWriter
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.UnstableDefault
|
||||
import net.mamoe.mirai.console.encodeToString
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.io.encodeToString
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
@@ -486,7 +486,7 @@ abstract class FileConfigImpl internal constructor(
|
||||
|
||||
}
|
||||
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
class JsonConfig internal constructor(
|
||||
content: String
|
||||
) : FileConfigImpl(content) {
|
||||
@@ -513,7 +513,7 @@ class JsonConfig internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
class YamlConfig internal constructor(content: String) : FileConfigImpl(content) {
|
||||
constructor(file: File) : this(file.readText()) {
|
||||
this.file = file
|
||||
@@ -536,7 +536,7 @@ class YamlConfig internal constructor(content: String) : FileConfigImpl(content)
|
||||
|
||||
}
|
||||
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
@OptIn(MiraiInternalAPI::class)
|
||||
class TomlConfig internal constructor(content: String) : FileConfigImpl(content) {
|
||||
constructor(file: File) : this(file.readText()) {
|
||||
this.file = file
|
||||
|
||||
@@ -16,8 +16,8 @@ import net.mamoe.mirai.console.MiraiConsole
|
||||
import net.mamoe.mirai.console.command.Command
|
||||
import net.mamoe.mirai.console.command.CommandManager
|
||||
import net.mamoe.mirai.console.command.CommandSender
|
||||
import net.mamoe.mirai.console.encodeToString
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
import net.mamoe.mirai.utils.io.encodeToString
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.lang.reflect.Constructor
|
||||
|
||||
@@ -24,23 +24,23 @@ internal object BotManagers {
|
||||
}
|
||||
|
||||
fun Bot.addManager(long: Long) {
|
||||
BOT_MANAGERS.putIfAbsent(this.uin.toString(), mutableListOf<Long>())
|
||||
BOT_MANAGERS[this.uin.toString()] =
|
||||
(BOT_MANAGERS.getLongList(this.uin.toString()) as MutableList<Long>).apply { add(long) }
|
||||
BOT_MANAGERS.putIfAbsent(this.id.toString(), mutableListOf<Long>())
|
||||
BOT_MANAGERS[this.id.toString()] =
|
||||
(BOT_MANAGERS.getLongList(this.id.toString()) as MutableList<Long>).apply { add(long) }
|
||||
BotManagers.config.save()
|
||||
}
|
||||
|
||||
fun Bot.removeManager(long: Long) {
|
||||
BOT_MANAGERS.putIfAbsent(this.uin.toString(), mutableListOf<Long>())
|
||||
BOT_MANAGERS[this.uin.toString()] =
|
||||
(BOT_MANAGERS.getLongList(this.uin.toString()) as MutableList<Long>).apply { add(long) }
|
||||
BOT_MANAGERS.putIfAbsent(this.id.toString(), mutableListOf<Long>())
|
||||
BOT_MANAGERS[this.id.toString()] =
|
||||
(BOT_MANAGERS.getLongList(this.id.toString()) as MutableList<Long>).apply { add(long) }
|
||||
BotManagers.config.save()
|
||||
}
|
||||
|
||||
val Bot.managers: List<Long>
|
||||
get() {
|
||||
BOT_MANAGERS.putIfAbsent(this.uin.toString(), mutableListOf<Long>())
|
||||
return BOT_MANAGERS.getLongList(this.uin.toString())
|
||||
BOT_MANAGERS.putIfAbsent(this.id.toString(), mutableListOf<Long>())
|
||||
return BOT_MANAGERS.getLongList(this.id.toString())
|
||||
}
|
||||
|
||||
fun Bot.checkManager(long: Long): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user