验证码方面,现在是每次都用mirai-login-solver-selenium这个方法,看到提示里面说在原先那个坏了之后可以用mirai-login-solver-sakura,但是去看了一眼发现是mirai console的插件,想问问这玩意在mirai core中能用么,咋整呢
PS. 仓库ISSUE里面有人问过这个问题,但是那个回复我没看懂
mirai core版本2.15.0-M1
验证码方面,现在是每次都用mirai-login-solver-selenium这个方法,看到提示里面说在原先那个坏了之后可以用mirai-login-solver-sakura,但是去看了一眼发现是mirai console的插件,想问问这玩意在mirai core中能用么,咋整呢
PS. 仓库ISSUE里面有人问过这个问题,但是那个回复我没看懂
mirai core版本2.15.0-M1
@Nambers
确实,试了下把本身的排除掉,OK了
implementation(group: 'net.mamoe', name: 'mirai-core', version: rootProject.ext.miraiVersion) {
exclude(group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-core-jvm')
exclude(group: 'org.jetbrains.kotlinx', module: 'kotlinx-coroutines-jdk8')
}
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-jvm', version: '1.6.4'
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-jdk8', version: '1.6.4'
@Aye10032 补充一下报错
2022-10-22 02:07:27 [main] [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter]-[DEBUG] Application failed to start due to an exception
java.lang.NoSuchMethodError: 'kotlinx.coroutines.CoroutineDispatcher kotlinx.coroutines.CoroutineDispatcher.limitedParallelism(int)'
at net.mamoe.mirai.internal.deps.io.ktor.client.utils.CoroutineDispatcherUtilsKt.clientDispatcher(CoroutineDispatcherUtils.kt:22)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.okhttp.OkHttpEngine$dispatcher$2.invoke(OkHttpEngine.kt:32)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.okhttp.OkHttpEngine$dispatcher$2.invoke(OkHttpEngine.kt:31)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.okhttp.OkHttpEngine.getDispatcher(OkHttpEngine.kt:31)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.HttpClientEngineBase$coroutineContext$2.invoke(HttpClientEngineBase.kt:22)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.HttpClientEngineBase$coroutineContext$2.invoke(HttpClientEngineBase.kt:21)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.HttpClientEngineBase.getCoroutineContext(HttpClientEngineBase.kt:21)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.okhttp.OkHttpEngine.<init>(OkHttpEngine.kt:51)
at net.mamoe.mirai.internal.deps.io.ktor.client.engine.okhttp.OkHttp.create(OkHttp.kt:31)
at net.mamoe.mirai.internal.deps.io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:41)
at net.mamoe.mirai.internal.MiraiImplKt.createDefaultHttpClient(MiraiImpl.kt:29)
at net.mamoe.mirai.internal.MiraiImpl.<init>(MiraiImpl.kt:97)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:780)
at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:722)
at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:272)
at net.mamoe.mirai.utils.ServicesKt.loadService(Services.kt:18)
at net.mamoe.mirai.Mirai.findMiraiInstance(IMirai.kt:357)
at net.mamoe.mirai._MiraiInstance.get(IMirai.kt:348)
at net.mamoe.mirai.Mirai.getInstance(IMirai.kt:39)
at net.mamoe.mirai.internal.message.MessageSerializersImpl.getSerializersModule(MessageSerializersImpl.kt:65)
at net.mamoe.mirai.internal.message.MessageSerializersImpl.registerSerializers(MessageSerializersImpl.kt:76)
at net.mamoe.mirai.message.MessageSerializers$INSTANCE.registerSerializers(MessageSerializers.kt)
at net.mamoe.mirai.internal.message.protocol.MessageProtocolFacade.<clinit>(MessageProtocolFacade.kt:165)
at net.mamoe.mirai.internal.MiraiImplKt._MiraiImpl_static_init(MiraiImpl.kt:25)
at net.mamoe.mirai.internal.MiraiImpl.<clinit>(MiraiImpl.kt:87)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:780)
at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:722)
at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:272)
at net.mamoe.mirai.utils.ServicesKt.loadService(Services.kt:18)
at net.mamoe.mirai.Mirai.findMiraiInstance(IMirai.kt:357)
at net.mamoe.mirai._MiraiInstance.get(IMirai.kt:348)
at net.mamoe.mirai.Mirai.getInstance(IMirai.kt:39)
at net.mamoe.mirai.BotFactory$INSTANCE.newBot(BotFactory.kt:116)
at com.dazo66.config.BotConfig.getBot(BotConfig.java:41)
at com.dazo66.config.BotConfig$$EnhancerBySpringCGLIB$$d11bcb62.CGLIB$getBot$0(<generated>)
at com.dazo66.config.BotConfig$$EnhancerBySpringCGLIB$$d11bcb62$$FastClassBySpringCGLIB$$90009b06.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at com.dazo66.config.BotConfig$$EnhancerBySpringCGLIB$$d11bcb62.getBot(<generated>)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at com.dazo66.Main.main(Main.java:20)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
之前一直在用2.10.0的版本,今天要用新功能升级到了2.13.0-RC2,gradle build的时候报错
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
net.mamoe.mirai.internal.deps.io.ktor.client.utils.CoroutineDispatcherUtilsKt.clientDispatcher(CoroutineDispatcherUtils.kt:22)
The following method did not exist:
'kotlinx.coroutines.CoroutineDispatcher kotlinx.coroutines.CoroutineDispatcher.limitedParallelism(int)'
The calling method's class, net.mamoe.mirai.internal.deps.io.ktor.client.utils.CoroutineDispatcherUtilsKt, was loaded from the following location:
jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/mirai-core-jvm-2.13.0-RC2.jar!/net/mamoe/mirai/internal/deps/io/ktor/client/utils/CoroutineDispatcherUtilsKt.class
The called method's class, kotlinx.coroutines.CoroutineDispatcher, is available from the following locations:
jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/kotlinx-coroutines-core-jvm-1.5.2.jar!/kotlinx/coroutines/CoroutineDispatcher.class
The called method's class hierarchy was loaded from the following locations:
kotlinx.coroutines.CoroutineDispatcher: jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/kotlinx-coroutines-core-jvm-1.5.2.jar!/
kotlin.coroutines.AbstractCoroutineContextElement: jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/kotlin-stdlib-1.7.10.jar!/
Action:
Correct the classpath of your application so that it contains compatible versions of the classes net.mamoe.mirai.internal.deps.io.ktor.client.utils.CoroutineDispatcherUtilsKt and kotlinx.coroutines.CoroutineDispatcher
感觉应该是版本依赖的问题,试了半天不知道从何下手
附上build.gradle:
import java.text.SimpleDateFormat
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
classpath "gradle.plugin.ua.eshepelyuk:ManifestClasspath:1.0.0"
}
}
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.21'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'org.springframework.boot' version '2.6.6'
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '11'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
ext {
springVersion = '2.6.6'
miraiVersion = '2.13.0-RC2'
ktVersion = '1.6.21'
}
apply plugin: "ua.eshepelyuk.ManifestClasspath"
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.serialization'
group 'com.aye10032'
version '2.1.0'
repositories {
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
implementation group: 'junit', name: 'junit', version: '4.12'
implementation group: 'net.mamoe', name: 'mirai-core', version: rootProject.ext.miraiVersion
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: rootProject.ext.springVersion
// https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter
implementation group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '2.2.2'
// https://mvnrepository.com/artifact/org.jdom/jdom
implementation group: 'org.jdom', name: 'jdom', version: '2.0.2'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.8.1'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.13'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
implementation group: 'com.rometools', name: 'rome', version: '1.18.0'
//JavaCV相关
implementation group:'org.bytedeco', name: 'javacv-platform', version: '1.5.7'
implementation group: 'com.github.Aye10032', name: 'rtroapiutil', version: 'v1.2'
implementation(fileTree(dir: 'libs', includes: ['*.jar']))
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-quartz
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-quartz', version: rootProject.ext.springVersion
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.29'
implementation group: 'org.reflections', name: 'reflections', version: '0.10.2'
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
testCompileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
test {
useJUnitPlatform()
}
// 点这个箭头进行打包
/*jar {
configurations.compile.canBeResolved = true
configurations.implementation.canBeResolved = true
configurations.api.canBeResolved = true
//把以前的重命名归档起来
destinationDir = file("$rootDir/build")
File oldJarFile = file(destinationDir.toString() + "/" + rootProject.name + "-" + version + ".jar")
SimpleDateFormat ft = new SimpleDateFormat("MM-dd-hh-mm-ss")
File newJarFile = file(destinationDir.toString() + "/" + rootProject.name + "-" + version + "-" + ft.format(new Date()) + ".jar")
if (oldJarFile.exists()) {
oldJarFile.renameTo(newJarFile)
}
if (newJarFile.exists()) {
ant.move file: newJarFile,
todir: "${buildDir}/toArchive"
}
manifest {
//mainifest下的classpath头
def classpathPrefix = 'libs'
Set<File> files = configurations.runtimeClasspath.files
def builder = new StringBuilder()
for (def f : files) {
builder.append(classpathPrefix).append("/").append(f.getName()).append(" ")
}
attributes('Main-Class': 'com.dazo66.Main')//入口点
attributes('Class-Path': builder.toString())
}
// 将 build.gradle 打入到 jar 中, 方便查看依赖包版本
from("./") {
include 'build.gradle'
}
// 会自动把依赖复制到编译目录下的libs文件夹里面
// 如果有添加新的依赖记得复制到运行环境下的libs
copy() {
def classpathPrefix = configurations
from configurations.compile.collect { it }
into "$buildDir/libs"
}
}*/
简而言之就是从MessageEvent中通过event.getMessage()方法获得到MessageChain,之后再通过chain.get(OnlineAudio.Key)获得到OnlineAudio的对象,但是通过(audio).getUrlForDownload()拿下载URL的时候如果是群语音就会报错,拿不到
我这边直接通过messagechain获取到onlineAudio对象,然后得到下载链接,我自己对BOT私聊发送语音的时候是可以的,但是到群里测试就报错说无法获得下载链接
附上部分代码和日志:
这边的SimpleMsg是自己封装的,其中获取messagechain相关的代码:
用这个方法私聊的语音就能下下来,换群聊就不行了
mirai-core版本2.10.0