mamoe / mirai Goto Github PK
View Code? Open in Web Editor NEW高效率 QQ 机器人支持库
Home Page: https://mirai.mamoe.net
License: GNU Affero General Public License v3.0
高效率 QQ 机器人支持库
Home Page: https://mirai.mamoe.net
License: GNU Affero General Public License v3.0
Mirai 15:38:12 : ByteReadPacket 群消息=19 00 2D 01 00 2A EA 02 27 08 9F 01 10 A2 FF 8C F0 03 18 D0 C4 D7 EF 05 20 01 2A 12 0A 10 0A 0E E5 BB BA E8 AE AE 5B E5 9B BE E7 89 87 5D 30 00 01 00 1D 01 00 0A 40 48 69 6D 31 38 38 6D 6F 65 06 00 0D 00 01 00 00 00 0A 00 3E 03 3F A2 00 00 01 00 04 01 00 01 20 01 00 1D 01 00 0A 40 48 69 6D 31 38 38 6D 6F 65 06 00 0D 00 01 00 00 00 0A 00 3E 03 3F A2 00 00 01 00 1F 01 00 1C 20 E4 BD A0 E8 BF 99 E6 98 AF E4 BB 80 E4 B9 88 E7 A5 9E E7 A7 98 E7 89 88 E6 9C AC 19 00 3A 01 00 37 AA 02 34 50 00 60 00 68 00 88 01 00 9A 01 28 08 09 78 00 C8 01 00 F0 01 00 F8 01 00 90 02 00 C8 02 00 98 03 00 A0 03 00 B0 03 00 C0 03 00 D0 03 00 E8 03 00 90 04 00 0E 00 0E 01 00 04 00 00 00 00 07 00 04 00 00 00 01 12 00 21 05 00 04 00 00 00 01 08 00 04 00 00 00 01 01 00 0C E5 8D 83 E9 87 8C E5 86 B0 E5 B0 81 03 00 01 01
java.lang.IllegalStateException: Count not readTLVMap: duplicated key 0x00000001. map={1=[B@76e16d4d}, duplicating value=[B@39e5e329, remaining=01 00 1D 01 00 0A 40 48 69 6D 31 38 38 6D 6F 65 06 00 0D 00 01 00 00 00 0A 00 3E 03 3F A2 00 00 01 00 1F 01 00 1C 20 E4 BD A0 E8 BF 99 E6 98 AF E4 BB 80 E4 B9 88 E7 A5 9E E7 A7 98 E7 89 88 E6 9C AC 19 00 3A 01 00 37 AA 02 34 50 00 60 00 68 00 88 01 00 9A 01 28 08 09 78 00 C8 01 00 F0 01 00 F8 01 00 90 02 00 C8 02 00 98 03 00 A0 03 00 B0 03 00 C0 03 00 D0 03 00 E8 03 00 90 04 00 0E 00 0E 01 00 04 00 00 00 00 07 00 04 00 00 00 01 12 00 21 05 00 04 00 00 00 01 08 00 04 00 00 00 01 01 00 0C E5 8D 83 E9 87 8C E5 86 B0 E5 B0 81 03 00 01 01
at net.mamoe.mirai.utils.io.InputUtilsKt.readTLVMap(InputUtils.kt:79)
at net.mamoe.mirai.utils.io.InputUtilsKt.readTLVMap$default(InputUtils.kt:59)
at net.mamoe.mirai.network.protocol.tim.packet.event.GroupMessageEventParserAndHandler.parse(MessageEvent.kt:148)
at net.mamoe.mirai.network.protocol.tim.packet.event.EventPacketFactory.decode-MgswzbQ(EventPacketFactory.kt:51)
at net.mamoe.mirai.network.protocol.tim.packet.event.EventPacketFactory$decode$1.invokeSuspend(EventPacketFactory.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.ResumeModeKt.resumeUninterceptedMode(ResumeMode.kt:46)
at kotlinx.coroutines.internal.ScopeCoroutine.afterCompletionInternal(Scopes.kt:32)
at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:310)
at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.kt:276)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:807)
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:787)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Mirai 15:38:22 : ByteReadPacket 群消息=01 00 34 01 00 31 E6 88 91 E6 80 8E E4 B9 88 E6 B2 A1 E8 A7 81 E8 BF 87 E9 82 A3 E4 B8 AA 20 6F 70 65 6E 20 61 73 20 62 69 6E 61 72 79 20 E7 9A 84 E9 80 89 E9 A1 B9 19 00 3A 01 00 37 AA 02 34 50 00 60 00 68 00 88 01 00 9A 01 28 08 09 78 00 C8 01 00 F0 01 00 F8 01 00 90 02 00 C8 02 00 98 03 00 A0 03 00 B0 03 00 C0 03 00 D0 03 00 E8 03 00 90 04 00 0E 00 0E 01 00 04 00 00 00 00 07 00 04 00 00 00 01 12 00 21 05 00 04 00 00 00 01 08 00 04 00 00 00 01 01 00 0C E5 8D 83 E9 87 8C E5 86 B0 E5 B0 81 03 00 01 01
Mirai 15:38:22 : Packet received: GroupMessage(group=655057127, senderName=千里冰封, sender=951394653, permission=MEMBER, message=我怎么没见过那个 open as binary 的选项)
如 no such member, null group.
Setting up some CI integration will help, I think
Mirai 07:29:51 : login response packet size = 454, data=3F 01 09 00 93 00 01 D1 3C D3 0E C4 1F 15 EA 9B 8A DA D2 81 8F 65 05 00 38 6C 06 8A 70 DF AE 42 90 7F 44 51 48 F5 34 11 CD CB 8B 58 9E 07 04 4C 21 F1 26 9C 5C D1 4B 5F 64 D9 66 FB 2B 41 50 0A C5 47 81 72 16 F9 F7 D5 3E F0 0E 10 B0 4A 59 E2 C9 00 20 BA 42 D5 47 33 5F 3D BF 40 9C 7F CB 35 E9 0B E2 C5 1E 32 28 FE E2 D0 9D 62 A5 34 C8 0A 00 4A AB 00 23 02 00 20 B9 AE CC 3E 3D AE 37 78 69 8D 5D 3E A1 01 84 F5 A0 39 04 C2 EC 53 2B CD A5 9D A0 23 67 FA CA 35 00 29 00 30 23 3F 9C 86 60 9C 16 68 E6 9F 3D C2 D4 92 4A 90 D7 7A 2F 5A 37 10 8D 2E E7 92 20 A8 9B C2 92 2C BC A6 77 C3 F1 DA 1C 48 E2 7A DA 24 84 89 19 60 05 08 00 22 01 00 00 03 E8 00 1B 02 00 00 00 01 00 00 15 85 08 36 00 00 00 3F 00 00 00 00 03 79 89 A5 00 00 02 27 04 04 00 28 D1 41 3F 2A 93 08 26 1E F7 62 FF B7 48 2D A8 CA D8 06 DC 9A 9B 0D 91 AD C1 A6 E3 E9 F9 A0 37 73 DE D5 B2 45 6E 3E 97 25 01 00 00 6F 00 01 08 36 00 00 02 27 00 65 24 55 49 4E 24 E6 9C AC E6 AC A1 E7 99 BB E5 BD 95 E9 9C 80 E8 BF 9B E8 A1 8C E8 BA AB E4 BB BD E9 AA 8C E8 AF 81 EF BC 8C E8 AF B7 E7 82 B9 E5 87 BB E7 99 BB E5 BD 95 E7 AA 97 E5 8F A3 E5 8F B3 E4 B8 8B E6 96 B9 E4 BA 8C E7 BB B4 E7 A0 81 E5 9B BE E6 A0 87 E8 BF 9B E8 A1 8C E7 99 BB E5 BD 95 E3 80 82 04 02 00 08 2B 7A 65 5D 6B 24 59 3C 04 03 00 08 27 66 67 7B 21 6B 67 2B 04 06 00 05 01 00 00 00 00 01 15 00 10 FB 87 BF 1F 96 6D 15 29 97 27 22 4D DA 43 2B C7
Bot(453723464) 07:29:51 : Packet received: Failed(result=UNKNOWN)
Exception in thread "main" net.mamoe.mirai.utils.LoginFailedException: Login failed with reason UNKNOWN
at net.mamoe.mirai.timpc.network.TIMPCBotNetworkHandler.login(TIMPCBotNetworkHandler.kt:73)
at net.mamoe.mirai.timpc.network.TIMPCBotNetworkHandler$login$1.invokeSuspend(TIMPCBotNetworkHandler.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
因为我之前使用的是酷Q的机器人,在酷Q内,emoji表情需要转换为CQ码发送:https://docs.cqp.im/manual/cqcode/#emoji%E8%A1%A8%E6%83%85
为 NetworkHandler 添加一个 logger, 并将所有现有网络层日志引用改到这个 logger
Could not resolve com.soywiz.korlibs.klock:klock-metadata:1.7.0.
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Klock 经常找不到. 考虑删掉引用
还是美玲?
ContactList 的 forEach 在某种内联复合情况下会丢失内联类型.
如 UInt 编译后签名为 Int, 因而导致 ==
判断无法成功.
这个问题已经在 Kotlin youtrack 存在多年
考虑使用 Long 替换全部的 UInt.
好友消息收发正常,群消息无法正常收取,相关log如下
Mirai 17:57:41 : Packet sent: GroupPacket(00 02)
java.io.EOFException: Only 5 bytes were discarded of 13 requested
at kotlinx.io.core.InputKt.discardExact(Input.kt:158)
at kotlinx.io.core.InputKt.discardExact(Input.kt:168)
at net.mamoe.mirai.network.protocol.tim.packet.action.GroupPacket.decode-MgswzbQ(GroupPacket.kt:186)
at net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler$BotSocketAdapter$processReceive$2.invokeSuspend(TIMBotNetworkHandler.kt:174)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:830)
Mirai 17:57:42 : ByteReadPacket 群消息=01 00 09 01 00 06 66 61 69 6C 65 64 19 00 45 01 00 42 AA 02 3F 08 06 50 02 60 00 68 00 88 01 00 9A 01 31 08 0A 78 00 C8 01 00 F0 01 00 F8 01 00 90 02 00 C8 02 00 98 03 00 A0 03 02 B0 03 00 C0 03 00 D0 03 00 E8 03 02 8A 04 04 08 02 08 01 90 04 80 C8 10 0E 00 0E 01 00 04 00 00 08 E4 07 00 04 00 00 00 01 12 00 1E 02 00 09 E9 85 B1 E9 87 8E E6 98 9F 03 00 01 02 05 00 04 00 00 00 03 08 00 04 00 00 00 04
测试demo发现接受移动端发送的消息和PC端发送的消息是不一样的
PC端发送的消息能够正常解析
移动端发送的消息接收到的内容为
message=你好AA 02 19 08 00 88 01 00 9A 01 11 78 00 C8 01 00 F0 01 00 F8 01 00 90 02 00 C8 02 00
会造成解析错误
mirai-core-jvm-0.15.0.jar
被错误地引入为 mirai-core-0.15.0.jar
需修改 mirai-core
为 JVM target
现在只有 CorotuineScope.subscribe
监听全部的事件.
当使用 bot.subscribe<>
时造成会歧义: 也能监听到不属于这个 bot 的事件.
Mirai 21:45:37 : Packet received: UnknownEventPacket(id=00 8D, identity=(135169108->2172256417))
= 00 00 00 20 00 05 00 02 00 06 00 06 00 04 00 01 26 02 00 09 00 06 03 E9 20 02 EC A0 00 0A 00 04 01 00 00 00 00 65 01 02 00 00 00 00 00 00 00 00 00 00 30 C6 1E 7B 57 47 0C 1B AF 64 30 0C 4C 2A 26 FB 1C E0 5C 65 70 62 18 CC 3D CD A1 2D C7 09 6E A0 2F CE BD D6 6E B0 7D C1 39 D8 D4 49 B7 8A E9 FF 60 00 26 00 1C 02 00 00 00 5D EF A1 81 00 01 51 80 81 7A 00 A1 08 0E 84 54 00 00 00 1F 00 00 00 00 36 11 EE 25 36 11 EE 25 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 17 08 0E 84 54 81 7A 00 A1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 77 77 5D EF A1 81 00 00 5D EF A1 81 00 00 00 00 00 4D 53 47 00 00 00 00 00 5D EF A1 81 10 C7 6E 71 00 00 00 00 0A 00 86 02 00 06 E5 AE 8B E4 BD 93 00 00 01 00 07 01 00 04 6D 65 6F 77 0E 00 0E 01 00 04 00 00 00 00 0A 00 04 00 00 00 00 19 00 1C 01 00 19 AA 02 16 08 00 88 01 00 9A 01 0E 78 00 C8 01 00 F0 01 00 F8 01 00 90 02 00
mirai/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
Lines 187 to 190 in 8948eb2
You can use _qqs[id] ?: qqsLock.withLock { _qqs.getOrPut(id) { QQ(bot, id, coroutineContext) } }
能否提供详细文档,或者协议层能否单独打包成jar,想移植到Android客户端。
有时候(<10%)可以看到
这样比较符合使用习惯,消息内容的string可以通过message获取
版本 0.10.6
suspend fun Bot.messageDSL() {
subscribeGroupMessages {
contains("test") {
reply("test from " + sender.group)
}
}
}
错误
java.io.EOFException: Not enough data in packet (2) to read 4 byte(s)
at kotlinx.io.core.ByteReadPacketBase.notEnoughBytesAvailable(Packet.kt:675)
at kotlinx.io.core.ByteReadPacketBase.access$notEnoughBytesAvailable(Packet.kt:15)
at kotlinx.io.core.ByteReadPacketBase.readIntSlow(Packet.kt:989)
at kotlinx.io.core.ByteReadPacketBase.readInt(Packet.kt:201)
at net.mamoe.mirai.timpc.network.packet.action.GroupPacket.decode-awkMUvk(GroupPacket.kt:702)
at net.mamoe.mirai.timpc.network.TIMPCBotNetworkHandler$BotSocketAdapter$processReceive$2.invokeSuspend(TIMPCBotNetworkHandler.kt:151)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:126)
at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:92)
at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:491)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:270)
at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:68)
at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.IllegalStateException: Cannot obtain group info for id <<GROUP_NUMBER>>
at net.mamoe.mirai.timpc.TIMPCBotBase.getGroup(TIMPCBot.kt:312)
at net.mamoe.mirai.timpc.TIMPCBotBase$getGroup$4.invokeSuspend(TIMPCBot.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.ResumeModeKt.resumeUninterceptedWithExceptionMode(ResumeMode.kt:56)
at kotlinx.coroutines.TimeoutCoroutine.afterCompletionInternal(Timeout.kt:98)
at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:310)
at kotlinx.coroutines.JobSupport.tryFinalizeFinishingState(JobSupport.kt:236)
at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:849)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:811)
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:787)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:334)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
对于 JVM 平台, Mirai 提供额外的足以应对大多数情况的扩展函数:
ExternalImageJvm
若有必要, 这些函数将会创建临时文件以避免使用内存缓存图片
The link ExternalImageJvm
is 404 for me
mirai/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotHelper.kt
Lines 93 to 100 in 8948eb2
This looks inlineable to me.
版本:0.8.2
主动发送图片时出现异常
sender.uploadImage(File("pic.jpg"));
sender.sendImage(URL(url));
均出现异常java.io.EOFException: One more byte required but reached end of input
版本: 0.8.2
对于QQ号码位10位数的消息无法获取。或出现
java.util.NoSuchElementException: No such member whose id is xxxx in group xxxx
异常,
或出现未知的messageType=0xC 后文=xxxxxxxxx
日志,且没有后续操作
对于QQ号码为9位数的消息解析正常,怀疑部分地方没有做无符号数兼容
Mirai 15:44:55 : ByteReadPacket GroupFileUploadPacket=00 00 00 11 00 0A 00 04 01 00 00 00 00 0C 00 05 00 01 00 01 01 27 0B 60 E7 01 00 00 00 C0 5D F5 E4 71 00 00 00 3A 01 38 B5 21 5D 01 86 00 14 3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31 2E 30 22 20 65 6E 63 6F 64 69 6E 67 3D 22 75 74 66 2D 38 22 3F 3E 3C 64 3E 3C 6E 20 74 3D 22 68 22 20 75 3D 22 39 35 31 33 39 34 36 35 33 22 20 69 3D 22 36 22 20 73 3D 22 31 2E 75 72 6C 2E 63 6E 2F 71 75 6E 2F 66 65 65 64 73 2F 69 6D 67 2F 73 65 72 76 65 72 2F 67 31 36 2E 70 6E 67 22 2F 3E 3C 6E 20 74 3D 22 74 22 20 73 3D 22 E5 88 86 E4 BA AB E6 96 87 E4 BB B6 20 31 35 3A 34 34 3A 34 39 22 2F 3E 3C 6E 20 74 3D 22 72 22 2F 3E 3C 6E 20 74 3D 22 74 22 20 73 3D 22 26 71 75 6F 74 3B 71 71 62 6F 74 2E 7A 69 70 26 71 75 6F 74 3B 22 2F 3E 3C 6E 20 74 3D 22 62 22 2F 3E 3C 6E 20 74 3D 22 74 22 20 6C 3D 22 68 74 74 70 3A 2F 2F 70 74 6C 6F 67 69 6E 32 2E 71 71 2E 63 6F 6D 2F 71 75 6E 5F 64 65 74 61 69 6C 3F 74 79 70 65 3D 6D 69 6E 69 70 6F 72 74 61 6C 22 20 73 3D 22 E4 B8 8B E8 BD BD 22 20 70 3D 22 65 6D 6E 36 4B 4F 39 57 30 43 36 6F 43 7A 56 4C 4C 52 44 4C 62 35 76 76 33 2A 6B 55 46 67 39 48 34 4A 36 6C 65 4D 68 69 5A 4E 52 36 67 37 7A 61 73 42 39 43 52 45 73 4D 59 36 67 72 49 6B 34 47 7E 65 37 36 30 30 62 32 37 30 30 30 30 30 30 30 30 37 31 65 34 66 35 35 64 65 62 39 66 30 61 30 30 2D 30 22 2F 3E 3C 2F 64 3E
疑似安全验证,相关日志如下
Mirai 23:12:50 : Packet sent: CaptchaPacket(00 BA)
Mirai 23:12:50 : Packet received: CaptchaResponse.Correct
Mirai 23:12:50 : Packet sent: SubmitPasswordPacket(08 36)
Mirai 23:12:50 : login response packet size = 454, data=3F 01 09 00 93 00 01 13 12 A8 7E FE F8 0A 34 D3 71 8A 5C AA 4D BA 83 00 38 5F E7 63 9E 06 CB 79 5C 73 F3 81 C9 C7 D0 9F C6 EE 6F A7 F7 30 77 45 DA 90 31 F8 91 6A 08 54 96 2A F3 86 EB E4 94 35 AE 28 68 80 79 AF AF 0B A7 A4 21 D1 2F A8 38 29 D3 00 20 23 E6 6F C0 8B B5 A2 50 D8 14 5C 5C A7 C7 FC 19 90 8E 33 ED FF 5D EC 4F 46 AD 44 17 07 A4 72 22 00 23 02 00 20 A3 1F 33 A6 87 6F B3 DF 12 4F A6 23 5E 96 35 45 93 74 5A 76 2A 7D B0 69 62 A5 02 37 EE A9 0A F9 00 29 00 30 66 C6 0B 15 85 D7 04 AA C3 A7 AD B7 88 C9 1F AE 97 EA 24 0F ED DC 9B 92 A0 94 3E DC EC 5F BF 4E 98 C4 06 4C A1 AE B5 17 98 9D C2 2D 7F 4F 49 0B 05 08 00 22 01 00 00 03 E8 00 1B 02 00 00 00 01 00 00 15 85 08 36 00 00 00 3F 00 00 00 00 B7 48 8D 04 00 00 02 27 04 04 00 28 F8 87 A3 E9 64 38 7E 4B CB 7A F9 76 FB EA 72 5C 7A 1B 77 BC 5E 91 D0 AA 35 22 67 2A 01 75 1B B6 93 30 15 12 61 9E CC 89 01 00 00 6F 00 01 08 36 00 00 02 27 00 65 24 55 49 4E 24 E6 9C AC E6 AC A1 E7 99 BB E5 BD 95 E9 9C 80 E8 BF 9B E8 A1 8C E8 BA AB E4 BB BD E9 AA 8C E8 AF 81 EF BC 8C E8 AF B7 E7 82 B9 E5 87 BB E7 99 BB E5 BD 95 E7 AA 97 E5 8F A3 E5 8F B3 E4 B8 8B E6 96 B9 E4 BA 8C E7 BB B4 E7 A0 81 E5 9B BE E6 A0 87 E8 BF 9B E8 A1 8C E7 99 BB E5 BD 95 E3 80 82 04 02 00 08 66 2B 69 36 42 7B 7D 68 04 03 00 08 69 3B 34 2D 6A 5A 77 3A 04 06 00 05 01 00 00 00 00 01 15 00 10 C8 BC 7D E7 49 61 66 BD 8A 7C DD 89 93 36 65 DB
Mirai 23:12:50 : Packet received: Failed(result=UNKNOWN)
Exception in thread "main" java.lang.IllegalStateException: Login failed: UNKNOWN
OS:macOS 10.14.6
JDK版本:13.0.2
gradle版本:6.1.1
代码基于README中给出的示例代码
package net.im45.nologin;
import net.mamoe.mirai.japt.BlockingBot;
import net.mamoe.mirai.japt.BlockingContacts;
import net.mamoe.mirai.japt.BlockingQQ;
import net.mamoe.mirai.japt.Events;
import net.mamoe.mirai.message.GroupMessage;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Test {
public static void main(String[] args) throws InterruptedException {
final String filename = "credential.txt";
long id;
String password;
try (BufferedReader prd = new BufferedReader(new FileReader(filename))) {
id = Long.parseLong(prd.readLine());
password = prd.readLine();
} catch (IOException exc) {
System.out.println("Cannot open file: " + filename);
exc.printStackTrace();
return;
}
BlockingBot bot = BlockingBot.newInstance(id, password);
bot.login();
bot.getFriendList().forEach(friend -> System.out.println(friend.getNick()));
Events.subscribeAlways(GroupMessage.class, (GroupMessage message) -> {
final BlockingQQ sender = BlockingContacts.createBlocking(message.getSender());
// sender.sendMessage("Hello");
});
Thread.sleep(999999999);
}
}
报错:
> Task :Test.main() FAILED
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
net/mamoe/mirai/event/internal/EventListenerManager.get$mirai_core(Lkotlin/reflect/KClass;)Lnet/mamoe/mirai/event/internal/EventListeners; @205: putfield
Reason:
Type 'net/mamoe/mirai/event/internal/EventListenerManagerLockRefVolatile' (current frame, stack[1]) is not assignable to integer
Current Frame:
bci: @205
flags: { }
locals: { 'net/mamoe/mirai/event/internal/EventListenerManager', 'kotlin/reflect/KClass', 'net/mamoe/mirai/event/internal/EventListenerManager$Registry', integer, 'net/mamoe/mirai/utils/Node' }
stack: { integer, 'net/mamoe/mirai/event/internal/EventListenerManagerLockRefVolatile' }
Bytecode:
0000000: 2b12 17b8 001d b200 1f4d 033e 2cb6 0025
0000010: c000 273a 0400 1904 2cb6 002b a600 06a7
0000020: 0085 1904 3a05 0336 0619 053a 0703 3608
0000030: 1907 3a09 0336 0a19 09c1 002d 9a00 1e19
0000040: 073a 0903 360a 1909 c100 2f9a 000f 1907
0000050: b800 359a 0007 04a7 0004 039a 0006 a700
0000060: 3c19 05b6 0039 3a07 1907 c600 3019 07c0
0000070: 0007 3a0b 0336 0c19 0bb6 003d 2bb8 0041
0000080: 9900 1719 0bb6 0045 59c7 000d bb00 4759
0000090: 1249 b700 4dbf b0a7 0003 1904 b600 513a
00000a0: 04a7 ff74 b200 53b2 0055 0304 b600 5b99
00000b0: 0034 bb00 0759 2bbb 005d 59b7 0060 b700
00000c0: 634d b200 1f2c b600 6703 b200 55b5 006d
00000d0: 2cb6 0045 59c7 000d bb00 4759 1249 b700
00000e0: 4dbf b0a7 ff1d
Stackmap Table:
same_frame(@0)
append_frame(@21,Object[#33],Integer,Object[#39])
same_frame(@34)
full_frame(@90,{Object[#2],Object[#131],Object[#33],Integer,Object[#39],Object[#39],Integer,Object[#39],Integer,Object[#39],Integer},{})
same_locals_1_stack_item_frame(@91,Integer)
same_frame(@97)
full_frame(@150,{Object[#2],Object[#131],Object[#33],Integer,Object[#39],Object[#39],Integer,Object[#4],Integer,Object[#39],Integer,Object[#7],Integer},{Object[#93]})
same_frame(@151)
chop_frame(@154,2)
full_frame(@164,{Object[#2],Object[#131],Object[#33],Integer,Object[#39]},{})
full_frame(@226,{Object[#2],Object[#131],Object[#7],Integer,Object[#39]},{Object[#93]})
full_frame(@227,{Object[#2],Object[#131],Object[#33],Integer,Object[#39]},{})
at net.mamoe.mirai.event.internal.InternalEventListenersKt.listeners(InternalEventListeners.kt:78)
at net.mamoe.mirai.event.internal.InternalEventListenersKt.subscribeInternal(InternalEventListeners.kt:29)
at net.mamoe.mirai.BotImpl.<init>(BotImpl.kt:198)
at net.mamoe.mirai.qqandroid.QQAndroidBotBase.<init>(QQAndroidBot.kt:46)
at net.mamoe.mirai.qqandroid.QQAndroidBot.<init>(QQAndroidBot.kt:27)
at net.mamoe.mirai.qqandroid.QQAndroid.Bot(QQAndroid.kt:28)
at net.mamoe.mirai.BotFactoryJvmKt.Bot(BotFactoryJvm.kt:63)
at net.mamoe.mirai.BotFactoryJvmKt.Bot$default(BotFactoryJvm.kt:62)
at net.mamoe.mirai.BotFactoryJvmKt.Bot(BotFactoryJvm.kt)
at net.mamoe.mirai.japt.BlockingBot.newInstance(BlockingBot.java:40)
at net.im45.nologin.Test.main(Test.java:28)
Execution failed for task ':Test.main()'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
build.gradle
:
plugins {
id 'java'
}
group 'net.im45.nologin'
version '0.1-SNAPSHOT'
sourceCompatibility = 13
targetCompatibility = 13
repositories {
jcenter()
mavenCentral()
}
dependencies {
implementation "net.mamoe:mirai-core-qqandroid-jvm:0.15.1"
implementation "net.mamoe:mirai-japt:1.0.0"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
类似如下的log反复出现
Mirai 10:57:01 : Packet received: CaptchaResponse.Transmission
Mirai 10:57:01 : Packet sent: CaptchaPacket(00 BA)
Mirai 10:57:01 : ByteReadPacket 验证码包=00 05 01 00 00 01 23 00 40 55 2D 27 48 58 0C 84 90 38 A5 FA EC 1D 30 30 97 E9 4D 74 4C 2C 4B 96 EC 7B 3D 27 33 B7 89 5A 96 77 AB 5A 64 92 55 46 82 5B 55 89 B6 3A 70 10 61 AB AF 0F BD 18 F0 E1 26 95 DE 09 60 15 47 F4 5F 01 9B 15 63 E3 86 C9 2E DD 5C 7F C9 3E A6 D2 F3 5E 53 3A 53 3D 8E 7A EE 6F E1 FE A8 87 1C 5B 3B 62 4A 9E EE 9D 3B 9B 61 72 86 10 70 EF C1 21 B9 D8 B4 C1 3F 2C B7 4C C5 AE 65 4B EB A7 7D 7D F3 3A 73 AF 40 F7 84 7E DF 3D 3C DA FF 81 0D DB AD CB 91 EE 12 C3 A5 B8 7D E1 69 CC 8C FA B7 7D C7 63 E3 F2 12 D2 6B 9B EF BE 2A FA 96 3A 65 AD 6B E6 E8 E8 DC B2 83 A4 D8 72 60 23 0E 6E AB DB 74 0F 41 1F 00 F6 73 2D D2 E5 3B FA B1 E5 86 A9 10 E8 7C 76 18 EC 47 BE 2C 23 D6 2F 46 A4 CB BD D3 3B DF B4 6F 9E E9 C5 E3 5E F6 3B F5 1E 97 85 C0 F5 B7 61 DB 0A 23 39 EB 73 1E E9 69 65 7D B1 13 E7 1A 47 BF 1A 90 7E 84 46 DA 49 4D 18 F3 35 F7 AF 6B 3A C7 A1 7E 5C E8 09 0B E9 1B AA 7B 46 4F A9 AE 3F CB C2 2E F4 90 C5 5D 57 CE 1D BD FA DD D1 74 D9 6B D2 DB 06 EE D9 65 D5 27 A0 A4 F5 D5 99 F4 0D 20 DD 37 CA 61 01 B3 2D 00 E0 C0 6C 33 5B D6 F5 03 D5 5F 8C D0 A7 72 EA EB 78 62 E1 AD 9E 1F 67 D9 6A 85 06 4C 4C E8 F4 50 BA F5 F6 47 83 9F B1 F0 B1 CA FE C6 FB 6B A4 AE DF BB 43 F7 52 E9 E5 8B 72 B5 68 7A 67 C4 BF B6 89 75 FD F1 66 E9 0A C5 BF 1C FA F5 52 9E ED 8F DE 80 71 AD 80 3E 5F 55 9F EF A7 0F 79 3C FF DD 40 9F 9D D8 8F 1E ED DF C9 EA 4F F9 EB AF 7F 18 7A B8 46 FA 6F 37 FF EB E9 C7 68 F9 1F A6 9E C6 0F 1A 08 1A 2E 00 00 00 00 49 45 4E 44 AE 42 60 82 03 00 00 28 25 50 07 A6 73 7E 1A 5D 99 BE 14 FD 47 40 41 43 0D 89 5F E3 F5 3A B2 DB 0C E9 EF 3E C5 E4 C5 AE DC EA 8D E3 7C 18 DE C0 00 10 3B 82 0D 41 EA 8B 2F 6B F8 D3 05 4D 4F B8 FB BD
25 50 07 A6 73 7E 1A 5D 99 BE 14 FD 47 40 41 43 0D 89 5F E3 F5 3A B2 DB 0C E9 EF 3E C5 E4 C5 AE DC EA 8D E3 7C 18 DE C0
Mirai 10:57:01 : Packet received: CaptchaResponse.Transmission
Mirai 10:57:01 : 需要验证码登录, 验证码为 4 字母
Mirai 10:57:01 : 若看不清字符图片, 请查看 /tmp/tmp18115206322555123127.png
Mirai 10:57:01 : ####### ##
################
################
#### ##### ### #### ###
### ############################# ######
### ## ############################ ### ########
## ## ######### ########################## #### ###
## ## ### #### ## ### ########################## ###
## ####### ### ## # ##### ########## #### ###
## #### ## ## # #### ########### ### ###
## ## ### ## ######### ## ####### ## ### ###
## ######## ### ######### ## ######### ### ###
## ######### ### ######### ## ####### ### ##########
## ### ###### ## ######### # ######## ### ############
## ## #### ## ## ####### ## ### ### ### ##### ######
## ## # ## ## #### ## ## ##### ## ######
# ## # ## ## # ## ## ######## ##########
# ## ###### # ## ########## #### ###### ####
## ### ######### # ### ######### ##### ####### ###
### ################ # ################ ### ## ### ##
### ######## ## ## # ######### ### ### ## ## ##
########### # ## ### ### ## ## ##
############### ############# ### ###### ##
######################### ### ###### ##
##### ######### ### ##### ##
### ##
### ### ###
### ####### ####
#################
#### #########
Mirai 10:57:01 : 若要更换验证码, 请直接回车
引入 abstract class CancellableEvent() : Event
来解决可取消的情况
https://gitter.im/#createcommunity
Gitter, 你的选择。
PC端根据 display 来识别 at, 安卓端根据 buffer 识别
或者希望能帮忙协助开发
bot引用别人的内容,Tim PC看不见引用的内容,能看见bot发出的消息内容
Tim PC引用bot的引用回复,Tim PC显示的是 一个引用,但看不见bot发出的消息内容,手机端显示为At
Mirai 10:00:16 : 若看不清字符图片, 请查看 /var/folders/np/n_2jb2c12yb696bx4lc34wlc0000gn/T/tmp8533570238447634917.png
Mirai 10:00:16 : ########## #############
## ############ #################
## ###### ## # ##### ###
# ######### ## ## ## ##
## ## ###### ## ## ## ##
## # ### ## ## ##
## # ## ## ### ##
## # ## ##### ####
#### ##### ## ##########
############### ##################
############## ##################
######### #### ######### #######
######## ######### ############ ######### #######
######### ### #### ########### #### ######### #######
######### ### ############ ##### ## ######## #######
######### ## ##### #### ###### # #################
######## ### # ## ### ## ## # #################
######## ## ## ## ### ## ## ## ###############
######## ## # ## ## ## # ## ##########
# # ## ### ###### ####
# # ## ### ###########
####### # #####################
####### ## ######################
####### ############### #########
####### ############### ########
####### ################# #########
####### ####### ######### #########
####### ####### ########## #########
###### ####### ##################
####### ######## #################
###### ####### ###############
############# #######
############
##########
######
Mirai 10:00:16 : 若要更换验证码, 请直接回车
<<=<==========---> 80% EXECUTING [29s]
Mirai 10:00:22 : Packet sent: CaptchaPacket(00 BA)
<==========---> 80% EXECUTING [5h 50m 15s]
用的就是 readme 中的代码
val bot = Bot(qqId, password).alsoLogin()
bot.subscribeMessages {
"你好" reply "你好!"
"profile" reply { sender.queryProfile() }
contains("图片"){ File(imagePath).send() }
}
bot.subscribeAlways<MemberPermissionChangedEvent> {
if (it.kind == BECOME_OPERATOR)
reply("${it.member.id} 成为了管理员")
}
无论是输入正确或者错误的验证码,在包发出去后就无法进行下一步了。
环境:
Kotlin version 1.3.50-release-112 (JRE 11.0.2+9)
macOS 10.14.6
Mirai version: 0.8.0
相关 log:
Mirai 02:47:04 : ByteReadPacket 群消息=01 00 09 01 00 06 E3 80 82 E3 80 82 19 00 39 01 00 36 AA 02 33 08 06 50 02 60 00 68 00 9A 01 28 08 0A 20 DB 50 C8 01 00 F0 01 00 F8 01 00 90 02 00 98 03 00 A0 03 02 B0 03 00 C0 03 00 D0 03 00 E8 03 00 90 04 80 C0 10 0E 00 0E 01 00 04 00 00 08 E4 07 00 04 00 00 00 04 12 00 28 05 00 04 00 00 00 01 08 00 04 00 00 00 01 02 00 0C E6 88 91 E5 A5 BD E8 8F 9C E5 95 8A 03 00 01 04 04 00 04 00 00 00 10
Mirai 02:47:04 : Packet sent: GroupPacket.QueryGroupInfo
Mirai 02:47:04 : Packet received: GroupPacket.InfoResponse.GroupNotFound
java.lang.IllegalStateException: Cannot obtain group info for id 221056495
at net.mamoe.mirai.Bot$ContactSystem.getGroup-aCOW_bc(Bot.kt:204)
at net.mamoe.mirai.Bot$ContactSystem$getGroup$2.invokeSuspend(Bot.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.ResumeModeKt.resumeUninterceptedMode(ResumeMode.kt:45)
at kotlinx.coroutines.TimeoutCoroutine.afterCompletionInternal(Timeout.kt:100)
at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:310)
at kotlinx.coroutines.JobSupport.tryFinalizeFinishingState(JobSupport.kt:236)
at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:849)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:811)
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:787)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: net.mamoe.mirai.utils.GroupNotFoundException
at net.mamoe.mirai.Bot$ContactSystem.getGroup-aCOW_bc(Bot.kt:200)
... 15 more
mirai/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
Lines 37 to 38 in 8948eb2
I understand why you need these. A better solution will be to overload the invoke
operator for the companion object of Bot
, which will give you identical invocation syntax and Kotlin will be happy with that (no function name warning anymore 😉)
Packet 22:17:04 : 传递给 PacketFactory 的数据 = 00 00 01 01 10 02 2C 3C 4C 56 0A 4D 65 73 73 61 67 65 53 76 63 66 0A 50 75 73 68 4E 6F 74 69 66 79 7D 00 01 00 D6 08 00 01 06 0E 72 65 71 5F 50 75 73 68 4E 6F 74 69 66 79 18 00 01 06 20 50 75 73 68 4E 6F 74 69 66 79 50 61 63 6B 2E 52 65 71 75 65 73 74 50 75 73 68 4E 6F 74 69 66 79 1D 00 01 00 99 0A 03 00 00 00 00 CA CC 69 8B 10 01 26 0A 4D 65 73 73 61 67 65 53 76 63 36 0A 50 75 73 68 4E 6F 74 69 66 79 4D 00 0C 51 00 A6 60 01 70 01 8C 9A 0C 1C 2C 3C 46 00 5C 6D 00 0C 7C 8D 00 0C 9D 00 0C AC B0 01 C9 0C DA 06 00 16 00 26 00 36 00 0B EC FD 0F 00 0C F6 10 00 F6 11 00 F9 12 0C 0B A6 00 BD 00 00 15 08 01 12 0D 39 2E 31 34 38 2E 31 37 35 2E 31 36 37 18 DF 86 03 CC DC ED 00 0C FA 0F 0C 1C 2C 3C 4C 0B FA 10 0C 1C 2C 3C 4C 0B FA 11 06 00 16 00 26 00 0B 0B 8C 98 0C A8 0C
能不能添加一个支持使用http协议操作的api
localhost:port/send?qq=qqid&group=groupid&message=text
之类的
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.