MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    面向新人的 mirai 开发/使用文档

    开发交流
    7
    21
    3167
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MrXiaoM
      MrXiaoM 童心未泯 last edited by MrXiaoM

      @Deprecated

      新文档已部署到 https://wiki.mrxiaom.top/mirai
      以下信息均已过期。

      旧文档备份 https://mirai.mamoe.net/topic/802

      MrXiaoM/mirai-docs: 面向初学者的mirai非官方帮助文档
      接近保姆级的文档目前正在施工中,敬请期待(

      访问地址:https://mirai-docs.doomteam.fun

      1 Reply Last reply Reply Quote 4
      • RainChan
        RainChan 摸鱼 last edited by

        很不错的项目,如果部署GitHub page可能能照顾到更多GitHub访问困难的人。

        其实也能复制一份到论坛,发到技术交流板块就可以

        MrXiaoM 1 Reply Last reply Reply Quote 0
        • MrXiaoM
          MrXiaoM 童心未泯 @RainChan last edited by

          @rainchan 已部署到 GitBook

          1 Reply Last reply Reply Quote 0
          • HollisMeynell
            HollisMeynell last edited by

            请问java怎么发送文件呢,官方文档就给了个ExternalResource.create然后就没了下文...

            MrXiaoM 1 Reply Last reply Reply Quote 0
            • MrXiaoM
              MrXiaoM 童心未泯 @HollisMeynell last edited by

              @hollismeynell

              ExternalResource res = ExternalResource.create(xxx);
              group.getFilesRoot().upload(res);
              res.close();
              
              HollisMeynell 3 Replies Last reply Reply Quote 0
              • HollisMeynell
                HollisMeynell @MrXiaoM last edited by

                @mrxiaom 非常感谢

                1 Reply Last reply Reply Quote 0
                • HollisMeynell
                  HollisMeynell @MrXiaoM last edited by

                  @mrxiaom 请问怎样向个人发送文件

                  MrXiaoM 1 Reply Last reply Reply Quote 0
                  • MrXiaoM
                    MrXiaoM 童心未泯 @HollisMeynell last edited by

                    @hollismeynell 暂无接口

                    HollisMeynell 1 Reply Last reply Reply Quote 0
                    • HollisMeynell
                      HollisMeynell @MrXiaoM last edited by

                      @mrxiaom 好的,非常感谢

                      1 Reply Last reply Reply Quote 0
                      • HollisMeynell
                        HollisMeynell @MrXiaoM last edited by

                        @mrxiaom
                        当我尝试上传文件的时候,框架发生了错误,相关代码:

                        Files.writeString(Path.of("/root/f.json"), allFriend.toString());
                                    var file = ExternalResource.create(new File("/root/f.json"));
                                    if (from instanceof Group){
                                        ((Group) from).getFilesRoot().upload(file); //报错代码位置
                                        file.close();
                                    }
                        

                        查看服务器后台,确认文件正确写入,程序有读取权限,文件正常,机器人在群里是管理员,群文件空间正常,我手动上传文件正常,下面是报错信息

                        java.lang.IllegalStateException: Failed to upload file.
                        	at net.mamoe.mirai.internal.utils.RemoteFileImpl.upload(RemoteFileImpl.kt:529) ~[mirai-core-jvm-2.7.1.jar!/:2.7.1]
                        	at net.mamoe.mirai.internal.utils.RemoteFileImpl.upload(RemoteFileImpl.kt:537) ~[mirai-core-jvm-2.7.1.jar!/:2.7.1]
                        	at net.mamoe.mirai.utils.RemoteFile$upload$3.invoke(RemoteFile.kt) ~[mirai-core-api-jvm-2.7.1.jar!/:2.7.1]
                        	at net.mamoe.mirai.utils.RemoteFile$upload$3.invoke(RemoteFile.kt) ~[mirai-core-api-jvm-2.7.1.jar!/:2.7.1]
                        	at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:205) ~[kotlin-stdlib-1.5.21.jar!/:1.5.21-release-314 (1.5.21)]
                        	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.5.21.jar!/:1.5.21-release-314 (1.5.21)]
                        	at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115) ~[kotlin-stdlib-1.5.21.jar!/:1.5.21-release-314 (1.5.21)]
                        	at net.mamoe.kjbb.internal.RunBlockingKt.$runSuspend$(RunBlocking.kt:18) ~[kotlin-jvm-blocking-bridge-jvm-1.10.3.jar!/:na]
                        	at net.mamoe.mirai.utils.RemoteFile.upload(RemoteFile.kt) ~[mirai-core-api-jvm-2.7.1.jar!/:2.7.1]
                        	at com.now.nowbot.service.MessageService.FriendService.HandleMessage(FriendService.java:110) ~[classes!/:linux]
                        	at com.now.nowbot.service.MessageService.FriendService$$FastClassBySpringCGLIB$$adb4d8a8.invoke(<generated>) ~[classes!/:linux]
                        	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:49) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692) ~[spring-aop-5.3.9.jar!/:5.3.9]
                        	at com.now.nowbot.service.MessageService.FriendService$$EnhancerBySpringCGLIB$$70ada296.HandleMessage(<generated>) ~[classes!/:linux]
                        	at com.now.nowbot.listener.MessageListener.msg(MessageListener.java:98) ~[classes!/:linux]
                        	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
                        	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
                        	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
                        	at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
                        	at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt.registerEventHandler$callMethod$invokeWithErrorReport(JvmMethodListenersInternal.kt:140) ~[mirai-core-api-jvm-2.7.1.jar!/:2.7.1]
                        	at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt.access$registerEventHandler$callMethod$invokeWithErrorReport(JvmMethodListenersInternal.kt:1) ~[mirai-core-api-jvm-2.7.1.jar!/:2.7.1]
                        	at net.mamoe.mirai.internal.event.JvmMethodListenersInternalKt$registerEventHandler$callMethod$2.invokeSuspend(JvmMethodListenersInternal.kt:154) ~[mirai-core-api-jvm-2.7.1.jar!/:2.7.1]
                        	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.5.21.jar!/:1.5.21-release-314 (1.5.21)]
                        	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.5.1.jar!/:na]
                        	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) ~[kotlinx-coroutines-core-jvm-1.5.1.jar!/:na]
                        	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) ~[kotlinx-coroutines-core-jvm-1.5.1.jar!/:na]
                        	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) ~[kotlinx-coroutines-core-jvm-1.5.1.jar!/:na]
                        	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) ~[kotlinx-coroutines-core-jvm-1.5.1.jar!/:na]
                        
                        

                        请问如何解决

                        MrXiaoM 1 Reply Last reply Reply Quote 0
                        • MrXiaoM
                          MrXiaoM 童心未泯 @HollisMeynell last edited by

                          @hollismeynell 不知道,如果升级到 2.8.0 还不行的话,建议提出issue或者到漏洞反馈区发帖

                          HollisMeynell 1 Reply Last reply Reply Quote 0
                          • HollisMeynell
                            HollisMeynell @MrXiaoM last edited by

                            @mrxiaom 好的,我更新一下试试,谢谢回答

                            1 Reply Last reply Reply Quote 0
                            • MrXiaoM
                              MrXiaoM 童心未泯 last edited by

                              提醒一下,文档已经更新了,但可能存在一些错漏,如果有什么疑问或者改进建议请提出,我会尽我能力去解决

                              HollisMeynell 1 Reply Last reply Reply Quote 0
                              • I
                                imldy last edited by

                                感谢楼主的文档,不过在 监听事件 这一节的

                                channel.registerListenerHost(xwx);
                                

                                不知道xwx是什么

                                Orisland MrXiaoM 2 Replies Last reply Reply Quote 0
                                • Orisland
                                  Orisland 摸鱼 @imldy last edited by Orisland

                                  @imldy
                                  看看这里,你可以用这个。

                                  GlobalEventChannel.INSTANCE.registerListenerHost(new Handler());
                                  //new Handler()为上面链接里的Handler
                                  

                                  参考这个帖子。
                                  估计是他忘记写了xwx了。
                                  SimpleListenerHostTestJava

                                  I 1 Reply Last reply Reply Quote 0
                                  • I
                                    imldy @Orisland last edited by imldy

                                    @orisland 谢谢,我试试

                                    更新,已成功。
                                    这里填的是SimpleListenerHost的子类的实例,子类写一些方法并使用@EventHandler注解,参数填不同的Event,例如FriendMessageEvent等。

                                    1 Reply Last reply Reply Quote 0
                                    • MrXiaoM
                                      MrXiaoM 童心未泯 @imldy last edited by

                                      @imldy 其实这个地方的 xwx 是乱写的(
                                      在这段的前面我告诉在文档阅读者,之后消息通道都会用 channel 代替了,然后下面这里给出了替换的示例,那个地方没加粗,好像在粗读的时候很难看到,以后改

                                      1 Reply Last reply Reply Quote 1
                                      • HollisMeynell
                                        HollisMeynell @MrXiaoM last edited by

                                        @mrxiaom 非常感谢,大佬辛苦了

                                        1 Reply Last reply Reply Quote 0
                                        • HollisMeynell
                                          HollisMeynell last edited by

                                          请问关于2.8.0版本的AbsoluteFileFolder文件操作java如何使用,以及私聊文件的事件或者文件发送/接受事件如何监听,似乎MessageEvent无法监听私聊文件发送

                                          1 Reply Last reply Reply Quote 0
                                          • CloudChaan
                                            CloudChaan last edited by

                                            呜呜
                                            为什么没有早点看到大佬的指南
                                            官方的指南太阴间了连个hello world都没有

                                            1 Reply Last reply Reply Quote 1
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact