simple-robot / simpler-robot

Simple Robot,一个bot风格的Kotlin多平台事件调度框架,异步高效、Java友好!/ A Bot-style Kotlin Multiplatform event scheduling framework, asynchronous and high-performance, java-friendly! 🐱😼😻😸
https://simbot.forte.love
GNU Lesser General Public License v3.0
520 stars 43 forks source link

关于device.json的导入 #424

Closed wunameya closed 2 years ago

wunameya commented 2 years ago

版本号

v2.4.0

附加版本

No response

问题描述

登录bot时因报环境安全问题,尝试多种方法无果 尝试使用MiraiAndroid登录 登录成功后将device.json导出,并在yml文件中使用deviceInfoFile指向device.json文件 报错 [2022-08-12T18:22:46.011]-[ERROR] | love.f.s.c.m.c.MiraiBotVerifier : Verifier bot(182048****) failed. Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at love.forte.common.ioc.MethodDependPass.invoke(DependPass.kt:76) at love.forte.common.ioc.DependCenter.init(DependCenter.kt:108) at love.forte.simbot.core.SimbotApp.initDependCenter(SimbotApp.kt:434) at love.forte.simbot.core.SimbotApp.run$core(SimbotApp.kt:279) at love.forte.simbot.core.SimbotApp$Run.run(SimbotApp.kt:509) at love.forte.simbot.core.SimbotApp$Run.run$default(SimbotApp.kt:472) at love.forte.simbot.core.SimbotApp$Run.run(SimbotApp.kt) at love.forte.simbot.core.SimbotApp.run(SimbotApp.kt) at TwoCY.Run.main(Run.java:14) Caused by: java.lang.VerifyError: kotlinx/serialization/json/internal/StreamingJsonDecoder at kotlinx.serialization.json.Json.decodeFromString(Json.kt:99) at net.mamoe.mirai.utils.BotConfiguration$loadDeviceInfoJson$1.invoke(BotConfiguration.kt:328) at net.mamoe.mirai.utils.BotConfiguration$loadDeviceInfoJson$1.invoke(BotConfiguration.kt:327) at net.mamoe.mirai.internal.network.components.SsoProcessorContextKt.createDeviceInfo(SsoProcessorContext.kt:47) at net.mamoe.mirai.internal.network.components.SsoProcessorContextImpl.(SsoProcessorContext.kt:42) at net.mamoe.mirai.internal.QQAndroidBot.createBotLevelComponents(QQAndroidBot.kt:195) at net.mamoe.mirai.internal.QQAndroidBot$defaultBotLevelComponents$2.invoke(QQAndroidBot.kt:163) at net.mamoe.mirai.internal.QQAndroidBot$defaultBotLevelComponents$2.invoke(QQAndroidBot.kt:162) at net.mamoe.mirai.utils.LateinitMutableProperty.getValue(LateinitMutableProperty.kt:38) at net.mamoe.mirai.internal.QQAndroidBot.getDefaultBotLevelComponents(QQAndroidBot.kt:162) at net.mamoe.mirai.internal.QQAndroidBot.createNetworkLevelComponents(QQAndroidBot.kt:249) at net.mamoe.mirai.internal.QQAndroidBot$createNetworkHandler$1.invoke(QQAndroidBot.kt:261) at net.mamoe.mirai.internal.QQAndroidBot$createNetworkHandler$1.invoke(QQAndroidBot.kt:254) at net.mamoe.mirai.internal.network.handler.selector.AbstractKeepAliveNetworkHandlerSelectorKt$KeepAliveNetworkHandlerSelector$1.createInstance(AbstractKeepAliveNetworkHandlerSelector.kt:229) at net.mamoe.mirai.internal.network.handler.selector.AbstractKeepAliveNetworkHandlerSelector.refreshInstance(AbstractKeepAliveNetworkHandlerSelector.kt:200) at net.mamoe.mirai.internal.network.handler.selector.AbstractKeepAliveNetworkHandlerSelector.getCurrentInstanceOrCreate(AbstractKeepAliveNetworkHandlerSelector.kt:58) at net.mamoe.mirai.internal.network.handler.selector.SelectorNetworkHandler.getContext(SelectorNetworkHandler.kt:47) at net.mamoe.mirai.internal.QQAndroidBot.getComponents(QQAndroidBot.kt:160) at net.mamoe.mirai.internal.QQAndroidBot$close$1.invokeSuspend(QQAndroidBot.kt:76) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85) at kotlinx.coroutines.BuildersKtBuildersKt.runBlocking(Builders.kt:59) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) at kotlinx.coroutines.BuildersKtBuildersKt.runBlocking$default(Builders.kt:38) at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) at net.mamoe.mirai.internal.QQAndroidBot.close(QQAndroidBot.kt:74) at net.mamoe.mirai.Bot.closeAndJoin$suspendImpl(Bot.kt:235) at net.mamoe.mirai.Bot.closeAndJoin(Bot.kt) at love.forte.simbot.component.mirai.configuration.MiraiBotVerifier$verity$2$1.invokeSuspend(MiraiBotVerifier.kt:114) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284) at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85) at kotlinx.coroutines.BuildersKtBuildersKt.runBlocking(Builders.kt:59) at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) at kotlinx.coroutines.BuildersKtBuildersKt.runBlocking$default(Builders.kt:38) at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) at love.forte.simbot.component.mirai.configuration.MiraiBotVerifier.verity(MiraiBotVerifier.kt:114) at love.forte.simbot.component.mirai.configuration.MiraiBotManager.registerBot(MiraiBotManager.kt:103) at love.forte.simbot.core.configuration.CoreBotRegistrar.registerBots(CoreBotRegistrar.kt:65) ... 13 more

不知道是我账号环境问题还是我方法的问题

复现方式

best hope to you

相关日志

No response

其他补充

No response

ForteScarlet commented 2 years ago

请提供项目结构、配置文件、依赖配置(例如pom.xml)等信息

wunameya commented 2 years ago

尝试导出simbot登录产生的simbot-devInfo.json,发现与MiraiAndroid产生的device.json并不相同 device.json位于resources中 device.json

{
        "deviceInfo": {
                "type": "object",
                "object": {
                        "display": [76, 73, 82, 65, 73, 45, 83, 73, 77, 66, 79, 84, 46, 50, 48, 48, 49, 50, 50, 46, 48, 48, 49],
                        "product": [108, 105, 114, 97, 105, 45, 115, 105, 109, 98, 111, 116],
                        "device": [108, 105, 114, 97, 105, 45, 115, 105, 109, 98, 111, 116],
                        "board": [108, 105, 114, 97, 105, 45, 115, 105, 109, 98, 111, 116],
                        "brand": [101, 111, 114, 116, 101],
                        "model": [108, 105, 114, 97, 105, 45, 115, 105, 109, 98, 111, 116],
                        "bootloader": [117, 110, 107, 110, 111, 119, 110],
                        "fingerprint": [109, 97, 109, 111, 101, 47, 109, 105, 114, 97, 105, 47, 109, 105, 114, 97, 105, 58, 49, 48, 47, 77, 73, 82, 65, 73, 46, 50, 48, 48, 49, 50, 50, 46, 48, 48, 49, 47, 54, 53, 56, 51, 55, 54, 48, 58, 117, 115, 101, 114, 47, 114, 101, 108, 101, 97, 115, 101, 45, 107, 101, 121, 115],
                        "bootId": [-44, 29, -116, -39, -113, 0, -78, 4, -23, -128, 9, -104, -20, -8, 66, 126],
                        "procVersion": [76, 105, 110, 117, 120, 32, 118, 101, 114, 115, 105, 111, 110, 32, 51, 46, 48, 46, 51, 49, 45, 50, 71, 54, 57, 72, 122, 115, 105, 32, 40, 97, 110, 100, 114, 111, 105, 100, 45, 98, 117, 105, 108, 100, 64, 120, 120, 120, 46, 120, 120, 120, 46, 120, 120, 120, 46, 120, 120, 120, 46, 99, 111, 109, 41],
                        "baseBand": [],
                        "version": {
                                "incremental": [53, 56, 57, 49, 57, 51, 56],
                                "release": [49, 48],
                                "codename": [82, 69, 76],
                                "sdk": 29
                        },
                        "simInfo": [84, 45, 77, 111, 98, 105, 108, 101],
                        "osType": [97, 110, 100, 114, 111, 105, 100],
                        "macAddress": [48, 50, 58, 48, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48],
                        "wifiBSSID": [48, 50, 58, 48, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48],
                        "wifiSSID": [60, 117, 110, 107, 110, 111, 119, 110, 32, 115, 115, 105, 100, 62],
                        "imsiMd5": [-44, 29, -116, -39, -113, 0, -78, 4, -23, -128, 9, -104, -20, -8, 66, 126],
                        "imei": "899752952597699",
                        "apn": [119, 105, 102, 105]
                }
        }
}

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>bot1</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <simbot.version>2.4.0</simbot.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!--
                通过parent进行版本控制。当然,也可以直接放到 parent 标签中。
                            - simbot-parent中管理的版本有:
              - catCode
              - simbot 相关依赖
              - forte-common 相关依赖
              - hutool 相关依赖
              - kotlin 相关依赖
              - fastJson
              - slf4j-api
             -->
            <dependency>
                <groupId>love.forte.simple-robot</groupId>
                <artifactId>parent</artifactId>
                <version>${simbot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.75</version>
        </dependency>
        <!-- 使用mirai组件开发QQ机器人。 -->
        <dependency>
            <groupId>love.forte.simple-robot</groupId>
            <artifactId>component-mirai</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.12</version>
        </dependency>
        <!-- 定时任务模块-quartz实现 -->
        <dependency>
            <groupId>love.forte.simple-robot.time-task</groupId>
            <artifactId>time-task-quartz</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- 编译插件 plugin. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <!-- 打包插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.4.RELEASE</version>
                <configuration>
                    <mainClass>bot.Run</mainClass>
                    <executable>true</executable>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

bot.yml

simbot:
  core:
    bots: code:password
  component:
    mirai:
      deviceInfo-file: device.json
ForteScarlet commented 2 years ago

device.json

你所提供的 device.json 内容既不属于 simbot2 ,也不属于 MiraiAndroid 所产生的结果。这是 simbot3 所提供的配置格式,且无法在 simbot2 中使用。

wunameya commented 2 years ago

非常抱歉,报错时参考了simbot3的文档,并复制进行尝试 MiraiAndroid的device.json { "deviceInfoVersion": 2, "data": { "display": "MIRAI.209724.001", "product": "mirai", "device": "mirai", "board": "mirai", "brand": "mamoe", "model": "mirai", "bootloader": "unknown", "fingerprint": "mamoe/mirai/mirai:10/MIRAI.200122.001/3284623:user/release-keys", "bootId": "C9D0FA4B-0CB8-1A36-1E0C-41A68B3DA1E5", "procVersion": "Linux version 3.0.31-2tyfoBZ9 (android-build@xxx.xxx.xxx.xxx.com)", "baseBand": "", "version": { "incremental": "5891938", "release": "10", "codename": "REL" }, "simInfo": "T-Mobile", "osType": "android", "macAddress": "02:00:00:00:00:00", "wifiBSSID": "02:00:00:00:00:00", "wifiSSID": "<unknown ssid>", "imsiMd5": "f9c7e59d06f22b0b63eb35f37a4a49e0", "imei": "581560551458119", "apn": "wifi" } } 非常抱歉,麻烦您了,我在官方qq客户端上登录了两天,现如今已经登录上了 非常感谢您的帮助