Giter Club home page Giter Club logo

onebot-kotlin's Introduction

OneBot Mirai - CQHTTP Mirai

OneBot v10 Gradle CI Downloads Release Downloads @latest

OneBot标准 mirai 插件版 (原cqhttp-mirai)

开始使用

  1. 请首先运行mirai-console相关客户端生成plugins文件夹
  2. onebot-mirai生成的jar包文件放入plugins文件夹中
  3. 运行mirai-console, 将在config/OneBot文件夹中自动生成样本配置文件settings.yml
  4. 编辑config/OneBot/settings.yml配置文件, 按照以下配置给出的注释修改保存
  5. 再次启动mirai-console相关客户端

OneBot Kotlin - CQHTTP Mirai Embedded

OneBot标准 Kotlin实现 (原cqhttp-mirai-embedded)

注意事项

  • 此版本内置mirai-coremirai-console
  • 请将此版本Jar包放至与mirai-console-loader, miraiOK同级目录
  • 此版本启动方式java -jar onebot-kotlin-**.jar
  • 请不要将此版本与主分支单插件版同时使用, 即不要在plugins文件夹下放置onebot-mirai的Jar包

开始使用

  1. 运行Jar包: java -jar onebot-kotlin-**.jar
  2. 编辑config/OneBot/settings.yml配置文件, 将以下配置给出的注释修改保存
  3. 重新运行

接收的参数

  • --account 123456789 要自动登录的账号
  • --password ******* 要自动登录账号的密码
  • --args -- --xx传入参数至mirai-console, 如--args -- --help--help传入获取mirai-console提供的帮助信息

读取的环境变量

  • ONEBOT_ACCOUNT--account参数, 但优先级低, 会被参数覆盖
  • ONEBOT_PASSWORD--password参数, 但优先级低, 会被参数覆盖

更新日志: CHANGELOG

配置相关

# 下载图片/语音时使用的Proxy, 配置后, 发送图片/语音时指定`proxy=1`以通过Proxy下载, 如[CQ:image,proxy=1,url=http://***]
# 支持HTTP及Sock两种Proxy, 设置举例 proxy: "http=http://127.0.0.1:8888", proxy : "sock=127.0.0.1:1088"
proxy: ''
# Mirai支持多帐号登录, 故需要对每个帐号进行单独设置
bots:
  # 要进行配置的QQ号
  1234567890: 
    # 是否缓存所有收到的图片, 默认为否 (仅包含图片信息, 不包含图片本身,  < 0.5KB)
    cacheImage: false
    # 是否缓存所有收到的语音, 默认为否 (将下载完整语音进行保存)
    cacheRecord: false
    # 心跳包相关配置
    heartbeat: 
      # 是否发送心跳包, 默认为否
      enable: false
      # 心跳包发送间隔, 默认为 15000毫秒
      interval: 15000
    # HTTP 相关配置
    http: 
      # 可选,是否启用HTTP API服务器, 默认为不启用, 此项开始与否跟postUrl无关
      enable: true
      # 可选,HTTP API服务器监听地址, 默认为0.0.0.0
      host: 0.0.0.0
      # 可选,HTTP API服务器监听端口, 5700
      port: 5700
      # 可选,访问口令, 默认为空, 即不设置Token
      accessToken: ''
      # 可选,事件及数据上报URL, 默认为空, 即不上报
      postUrl: ''
      # 可选,上报消息格式,string 为字符串格式,array 为数组格式, 默认为string
      postMessageFormat: string
      # 可选,上报数据签名密钥, 默认为空
      secret: ''
      # 上报超时时间, 单位毫秒, 须大于0才会生效
      timeout: 0
    # 可选,反向客户端服务
    ws_reverse: 
      # 可选,是否启用反向客户端,默认不启用
      - enable: true
        # 上报消息格式,string 为字符串格式,array 为数组格式
        postMessageFormat: string
        # 反向Websocket主机
        reverseHost: 127.0.0.1
        # 反向Websocket端口
        reversePort: 8080
        # 访问口令, 默认为空, 即不设置Token
        accessToken: ''
        # 反向Websocket路径
        reversePath: /ws
        # 可选, 反向Websocket Api路径, 默认为reversePath
        reverseApiPath: /api
        # 可选, 反向Websocket Event路径, 默认为reversePath
        reverseEventPath: /event
        # 是否使用Universal客户端 默认为true
        useUniversal: true
        # 可选, 是否通过HTTPS连接, 默认为false
        useTLS: false
        # 反向 WebSocket 客户端断线重连间隔,单位毫秒
        reconnectInterval: 3000
      - enable: true # 这里是第二个连接, 相当于CQHTTP分身版
        postMessageFormat: string
        reverseHost: 127.0.0.1
        reversePort: 9222
        reversePath: /ws
        useUniversal: false
        reconnectInterval: 3000
    # 正向Websocket服务器
    ws: 
      # 可选,是否启用正向Websocket服务器,默认不启用
      enable: true
      # 可选,上报消息格式,string 为字符串格式,array 为数组格式, 默认为string
      postMessageFormat: string
      # 监听主机
      wsHost: 0.0.0.0
      # 监听端口
      wsPort: 6700
      # 可选,访问口令, 默认为空, 即不设置Token
      accessToken: ''
  0987654321: # 这里是第二个QQ Bot的配置
    ws_reverse: 
      - enable: true
        postMessageFormat: string
        reverseHost:
        reversePort:
        reversePath: /ws
        reconnectInterval: 3000

实现

  • 反向Websocket客户端
  • HTTP上报服务
  • Websocket服务端
  • HTTP API
已实现CQ码
  • [CQ:at]
  • [CQ:image]
  • [CQ:record]
  • [CQ:face]
  • [CQ:emoji]
  • [CQ:share]
  • [CQ:contact]
  • [CQ:music]
  • [CQ:shake]
  • [CQ:poke]
  • [CQ:xml]
  • [CQ:json]
已支持的OneBot API

特别注意, 很多信息Mirai不支持获取, 如群成员的年龄、性别等, 为保证兼容性, 这些项已用Unknown, 0之类的信息填充占位

API 功能 备注
/send_private_msg 发送私聊消息
/send_group_msg 发送群消息
/send_msg 发送消息 (不包含讨论组消息)
/delete_msg 撤回信息
/set_group_kick 群组T人
/set_group_ban 群组单人禁言
/set_group_whole_ban 群组全员禁言
/set_group_card 设置群名片(群备注)
/set_group_leave 退出群组 (不支持解散群组)
/set_group_special_title 设置群组专属头衔 (不支持设置有效期)
/set_friend_add_request 处理加好友请求 (不支持设置备注)
/set_group_add_request 处理加群请求/邀请
/get_login_info 获取登录号信息
/get_friend_list 获取好友列表
/get_group_honor_info 获取群荣誉信息
/get_image 获取图片
/get_group_list 获取群列表
/get_group_info 获取群信息
/get_group_member_info 获取群成员信息
/get_group_member_list 获取群成员列表
/can_send_image 检查是否可以发送图片 (恒为true)
/can_send_record 检查是否可以发送语音
/get_status 获取插件运行状态 (不完全支持, 仅返回onlinegood两项)
/get_version_info 获取 酷Q 及 CQHTTP插件的版本信息
/set_group_name 设置群名
尚未支持的OneBot API
API 功能 备注
/get_record 获取语音
/send_discuss_msg 发送讨论组消息 已无讨论组
/set_discuss_leave 退出讨论组 已无讨论组
/get_stranger_info 获取陌生人信息
/set_group_anonymous_ban 群组匿名用户禁言
/set_group_admin 群组设置管理员
/send_like 发送好友赞 Mirai不会支持
/get_cookies 获取 Cookies Mirai不会支持
/get_csrf_token 获取 CSRF Token Mirai不会支持
/get_credentials 获取 QQ 相关接口凭证 Mirai不会支持
/set_restart_plugin 重启 CQHTTP
/clean_data_dir 清理数据目录
/clean_plugin_log 清理日志

开源协议

AGPL-3.0 © yyuueexxiinngg

直接或间接引用到的其他开源项目

onebot-kotlin's People

Contributors

metric-void avatar mnixry avatar sandtechnology avatar starhearthunt avatar yaohuomhuom avatar yyuueexxiinngg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onebot-kotlin's Issues

.handle_quick_operation 解析回复消息出错 - 原posturl无法发送"type":"share"内容

[DEBUG] [CQHTTPMirai] 收到上报响应 {"at_sender":false,"reply":[{"type":"share","data":{"url":"https://ff14.huijiwiki.com/wiki/ItemSearch?name=%E7%A5%9E%E9%BE%99","title":"\u795e\u9f99\u7684\u641c\u7d22\u7ed3\u679c","content":"\u5171\u6709 48 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7269\u54c1\u3002","image":"https://huiji-thumb.huijistatic.com/ff14/uploads/thumb/f/f2/Afaf712f5217a53fb07ed791cada1f9d4eb21e77.png/80px-Afaf712f5217a53fb07ed791cada1f9d4eb21e77.png"}}]}

实际未回复消息。

反向ws断线后,似乎只能重启mirai来恢复连接

希望增加

  1. 多次连接尝试,目前似乎只有一次
  2. 手动重连指令
  3. 可以给机器人本身发送提示,来显示断开连接重新连接失败

重连的日志

�[0m 16:00:11 �[38;5;196m[WARNING]�[39;49m [CQHTTPMirai] Websocket连接已断开, 将在3秒后重试连接�[39;49m
�[0m 16:00:15 �[38;5;196m[WARNING]�[39;49m [CQHTTPMirai] Websocket连接出错, 未知错误, 放弃重试连接, 请检查配置正确后重启mirai  Server error(ws://xn--v9x.net:80/ws: 502 Bad Gateway.io.ktor.client.features.ServerResponseException�[39;49m

可否支持多Bot账号连接同一个正向WS地址?

在当前的0.2.1(embedded)版本中,使用CQHTTPMirai支持的多账户配置,配合mirai的多账户登录功能,可以成功使多个账号连接同一个反向WS插件,但对于正向WS则不行,第二个登录的账号会在登录成功后报错"Address already in use",无法与第一个账号登录时连接上的正向WS插件通信。考虑到多个账号的连接都是由同一个CQHTTPMirai插件进行处理的,请问是否有可能使多个账号同时连接同一个正向WS地址?

HTTP API无法上报消息

Exception in thread "DefaultDispatcher-worker-6" java.lang.IllegalStateException: Reader has not consumed the whole input: JsonReader(source='Oh hi there! How are you?', currentPosition=5, tokenClass=0, tokenPosition=3, offset=3)
        at kotlinx.serialization.json.Json.parse(Json.kt:132)
        at kotlinx.serialization.json.Json$Default.parse(Json.kt:210)
        at kotlinx.serialization.json.Json$Default.parseJson(Json.kt:231)
        at tech.mihoyo.mirai.web.http.ReportService.report(ReportService.kt:135)
        at tech.mihoyo.mirai.web.http.ReportService$report$1.invokeSuspend(ReportService.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:238)
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:194)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(PipelineContext.kt:67)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:144)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:238)
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:194)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(PipelineContext.kt:67)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:144)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:238)
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:194)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(PipelineContext.kt:67)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:144)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(PipelineContext.kt:238)
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:194)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(PipelineContext.kt:67)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(PipelineContext.kt:144)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

但是确实上报服务端收到了请求[PicqBotX] [DEBUG(java.lang.Thread.run:748)] Http Failed: INCORRECT_CHARSET: Not UTF-8

提示不是UTF-8

群管理员权限返回administrator何时release

你好,为了和cqhttp表现一致,群管理的role返回的应该是admin,实际使用过程中发现返回administrator。然后发现该问题修复其实已经早就修复,但是是在0.1.4release之后修复的,最新release的0.1.4的jar包还是旧的。请问何时release?

发送长度大于876字节的消息时报错

nonebot使用反向ws连接cqhttp,发送长度大于876字节(876个ascii字符或292个汉字)的消息时抛出如下异常
Z7`TYTRSX8O3_ZYV_@WR_X0.png
消息长度:

len(string.encode('utf-8'))

另:如果一条消息中既有图片又有文字,则单个图片占用248字节(即只剩下627字节可用于文本)(未测试一条消息中包含多个图片的情况)

支持mirai-core 1.2.0?

[21:02:30.8037] I MiraiOK 20200629.160938 running at windows-amd64
[21:02:30.8037] I 此程序以Affero GPL3.0协议发布,使用时请遵守协议
[21:02:30.8037] I 代码库: github.com/LXY1226/MiraiOK gitee.com/LXY1226/MiraiOK
[21:02:31.0810] I JRE: java version "1.8.0_231"
[21:02:31.0810] I JRE: Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
[21:02:31.0810] I JRE: Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
[21:02:31.0820] I 删除.lastupdate来在下次强制检查更新
[21:02:31.0820] I 启动Mirai...
Using proxy: null
You are running Mirai-Console-Wrapper under D:\CQP\Mirai
All additional libraries are located at D:\CQP\Mirai\libraries
Starting Mirai Console Pure, reset by clear /content/
Starting version check...
Fetching Newest Core Version ..
Stay on current version.
Fetching Newest Console Version of Pure
Stay on current version.
Version check complete, starting Mirai
shadow-Protocol:D:\CQP\Mirai\content\mirai-core-qqandroid-1.2.0.jar
Console        :D:\CQP\Mirai\content\mirai-console-0.5.2.jar
Root           :D:\CQP\Mirai/
 21:02:31 [INFO] [Mirai 0.5.2 Pkmon] Mirai-console now running under D:\CQP\Mirai
 21:02:31 [INFO] [Mirai 0.5.2 Pkmon] Get news in github: https://github.com/mamoe/mirai
 21:02:31 [INFO] [Mirai 0.5.2 Pkmon] Mirai为开源项目,请自觉遵守开源项目协议
 21:02:31 [INFO] [Mirai 0.5.2 Pkmon] Powered by Mamoe Technologies and contributors
 21:02:32 [INFO] [Plugin Manager] 开始加载D:\CQP\Mirai/plugins/下的插件
 21:02:32 [INFO] [Plugin Manager] loading plugin CQHTTPMirai
 21:02:32 [ERROR] [Plugin Manager] failed to load plugin CQHTTPMirai , dependent class not found.
 21:02:32 [ERROR] [Plugin Manager] java.lang.NoClassDefFoundError: kotlinx/serialization/json/JsonException
        at tech.mihoyo.mirai.web.HttpApiServices.<init>(HttpApiServices.kt:9)
        at tech.mihoyo.mirai.PluginBase.<clinit>(PluginBase.kt:29)
        at sun.misc.Unsafe.ensureClassInitialized(Native Method)
        at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
        at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
        at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
        at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
        at java.lang.reflect.Field.get(Field.java:393)
        at kotlin.reflect.jvm.internal.KClassImpl$Data$objectInstance$2.invoke(KClassImpl.kt:116)
        at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:62)
        at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
        at kotlin.reflect.jvm.internal.KClassImpl$Data.getObjectInstance(KClassImpl.kt)
        at kotlin.reflect.jvm.internal.KClassImpl.getObjectInstance(KClassImpl.kt:241)
        at net.mamoe.mirai.console.plugins.PluginManager$loadPluginsImpl$3.invoke(PluginManager.kt:268)
        at net.mamoe.mirai.console.plugins.PluginManager.loadPluginsImpl$mirai_console(PluginManager.kt:295)
        at net.mamoe.mirai.console.plugins.PluginManager.loadPlugins(PluginManager.kt:79)
        at net.mamoe.mirai.console.plugins.PluginManager.loadPlugins$default(PluginManager.kt:79)
        at net.mamoe.mirai.console.MiraiConsole.start(MiraiConsole.kt:131)
        at net.mamoe.mirai.console.MiraiConsole.start$default(MiraiConsole.kt:113)
        at net.mamoe.mirai.console.pure.MiraiConsolePureLoader$Companion.load(MiraiConsolePureLoader.kt:22)
        at net.mamoe.mirai.console.pure.MiraiConsolePureLoader.load(MiraiConsolePureLoader.kt)
        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 net.mamoe.mirai.console.wrapper.WrapperMain.start$mirai_console_wrapper(WrapperMain.kt:236)
        at net.mamoe.mirai.console.wrapper.WrapperMain.preStartInNonNative$mirai_console_wrapper(WrapperMain.kt:207)
        at net.mamoe.mirai.console.wrapper.WrapperCli.run(WrapperMain.kt:143)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:154)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:14)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:252)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:249)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:267)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:290)
        at net.mamoe.mirai.console.wrapper.WrapperMain.main(WrapperMain.kt:176)
Caused by: java.lang.ClassNotFoundException: kotlinx.serialization.json.JsonException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 35 more

 21:02:32 [INFO] [Plugin Manager] 加载了0个插件
 21:02:32 [INFO] [Mirai 0.5.2 Pkmon] Mirai-console 启动完成
 21:02:32 [INFO] [Mirai 0.5.2 Pkmon] "login qqnumber qqpassword " to login a bot
 21:02:32 [INFO] [Mirai 0.5.2 Pkmon] "login qq号 qq密码 " 来登录一个BOT

Embedded0.2.1私聊nonebot命令重复触发Event: MessageSvcPbGetMsg.Response,群聊则不会

日志如下:
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbSendMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Recv: MessageSvcPbSendMsg.Response.SUCCESS
[INFO] [BOT xxxxxx] Friend(470131799) <- 咕噜灵波~
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
[INFO] [BOT xxxxxx] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=)
[INFO] [NETWORK] Send: MessageSvc.PbGetMsg
[INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg

富文本 content 未转义导致 cqhttp 客户端可能产生解析问题

https://github.com/yyuueexxiinngg/cqhttp-mirai/blob/e681eeddce41442d099eb46aa5a39a9432587c24/src/main/kotlin/tech/mihoyo/mirai/data/common/MessageDTO.kt#L79

content 可能包含 [, ], , 等字符,cqhttp客户端解析时会出现一些问题(比如 QQ 的小程序传来的就是一个 json,里面的逗号会干扰 CQ 码解析)

修复建议:转义

同时建议排查处理 Message.toCQString() 中其他类型的消息,同样可能包含需要转义的字符

https://github.com/yyuueexxiinngg/cqhttp-mirai/blob/4c96097a71b4a9c78bf6057b55a2b537c1ec2fbe/src/main/kotlin/tech/mihoyo/mirai/util/CQMessgeParser.kt#L270
(吐槽:这里写了没用上吗

挂在服务器上容易掉线

挂在服务器上基本上每天都要重上一次,然后qq群发消息,刚开始几分钟能发,过几分钟后消息的编号总是返回-1,然后不能成功发送.

发送GIF变成静态图片

通过nonebot的MessageSegment.image(f'file:///{os.path.abspath(self.path)}')
转成CQ码发送后,静态图片JPG PNG都没问题,gif就变成静态的了。都是本地图片文件。

发送消息时报错

发送消息时报错

[ERROR] [CQHTTPMirai] java.lang.IllegalStateException: Send temp message failed: MessageSvcPbSendMsg.Response.Failed(resultType=10, errorCode=0, errorMessage=)
        at net.mamoe.mirai.qqandroid.contact.UtilKt.sendMessageImpl(util.kt:63)
        at net.mamoe.mirai.qqandroid.contact.UtilKt$sendMessageImpl$1.invokeSuspend(util.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
        at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:113)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

发送的String 为:

[喵萌奶茶屋&LoliHouse] 魔王学院的不适任者 / Maou Gakuin no Futekigousha - 06 [WebRip 1080p HEVC-10bit AAC][简繁内封字幕]
【363.27 MB】| magnet:?xt=urn:btih:55baf2a5a25ddc9d608cb0064bf2c6ed42c87e10

[星空字幕组][魔王学院的不适合者~史上最强的魔王始祖,转生就读子孙们的学校~][05][简日双语][1080P][WEBrip][MP4](急招翻译、校对)
【409.5MB】| magnet:?xt=urn:btih:4c8fb74d3374b3babd724a6cffebd17eca7203ec

[星空字幕组][魔王学院的不适合者~史上最强的魔王始祖,转生就读子孙们的学校~][05][繁日双语][1080P][WEBrip][MP4](急招翻译、校对)
【409.5MB】| magnet:?xt=urn:btih:749e5935484fbc840858e10b220b08e48cc85754

【喵萌奶茶屋】★07月新番★[魔王学院的不适任者/Maou Gakuin no Futekigousha][06][1080p][繁体][招募翻译]
【425.22 MB】| magnet:?xt=urn:btih:153853a7847e997b1cf02b9ed5ec0f5c6cf6b065

同样的代码可以发送成功的String:

[Snow-Raws] 魔王勇者/Maoyuu Maou Yuusha/まおゆう魔王勇者 (BD 1920x1080 HEVC-YUV420P10 FLACx2)
【17.9GB】| magnet:?xt=urn:btih:3ca391337274bd405c1cb7c2fcadd741503379d4

[GM-Team][国漫][超兽武装 第2季 勇者无惧][Ultra Beast Force Ⅱ][2011][01-33 Fin][AVC][GB][1080P]
【15.4GB】| magnet:?xt=urn:btih:bc129563453bffac832c5f58f987db17d882863f

[Lilith-Raws] LAIDBACKERS:勇者的尼特族生活 / LAIDBACKERS [Baha][WEB-DL][1080p][AVC AAC][CHT][MKV]
【2.0GB】| magnet:?xt=urn:btih:4a904c313fce042f08b05254669a0e0dec6a2c7f

[SAIO-Raws] 盾之勇者成名录 第一季 Tate no Yuusha no Nariagari 1-25 [BD 1920x1080 HEVC-10bit OPUS][简繁内封字幕]
【13.6GB】| magnet:?xt=urn:btih:85c058bc4d385965d2ac78f5915219a6f6c64cc5

以及正常的返回信息:
[INFO] [BOT xxxxxxxx] Friend(xxxxxxxxx) <- [Snow-Raws] 魔王勇者/Maoyuu Maou Yuusha/まおゆう魔王勇者 (BD 1920x1080 HEVC-YUV420P10 FLACx2)\n【17.9GB】| magnet:?xt=urn:btih:3ca391337274bd405c1cb7c2fcadd741503379d4\n\n[GM-Team][国漫][超兽武装 第2季 勇者无惧][Ultra Beast Force Ⅱ][2011][01-33 Fin][AVC][GB][1080P]\n【15.4GB】| magnet:?xt=urn:btih:bc129563453bffac832c5f58f987db17d882863f\n\n[Lilith-Raws] LAIDBACKERS:勇者的尼特族生活 / LAIDBACKERS [Baha][WEB-DL][1080p][AVC AAC][CHT][MKV]\n【2.0GB】| magnet:?xt=urn:btih:4a904c313fce042f08b05254669a0e0dec6a2c7f\n\n[SAIO-Raws] 盾之勇者成名录 第一季 Tate no Yuusha no Nariagari 1-25 [BD 1920x1080 HEVC-10bit OPUS][简繁内封字幕]\n【13.6GB】| magnet:?xt=urn:btih:85c058bc4d385965d2ac78f5915219a6f6c64cc5

反向WS客户端连接检测机制内存泄露 原 - 配置反向客户端, 如果反向客户端没有启动时出错

18:35:28 [DEBUG] [CQHTTPMirai] 127.0.0.1:8011-Client-Universal 开始启动
18:35:29 [WARNING] [CQHTTPMirai] Websocket连接出错, 请检查服务器是否开启并确认正确监听端口, 将在3秒后重试连接, Host: 127.0.0.1:8011-Client-Universal Path: /ws
18:35:29 [INFO] [ConsoleAddition] [NETWORK] Received unknown commandName: ConfigPushSvc.PushDomain
18:35:30 [INFO] [ConsoleAddition] [NETWORK] Recv: ConfigPushSvc.PushReq.PushReqResponse.Success
18:35:30 [INFO] [ConsoleAddition] [NETWORK] Send: ConfigPushSvc.PushResp
18:35:30 [INFO] [ConsoleAddition] [NETWORK] ConfigPushSvc.PushReq: Success
18:35:32 [DEBUG] [CQHTTPMirai] 127.0.0.1:8011-Client-Universal 开始启动
18:35:32 [WARNING] [CQHTTPMirai] Websocket连接出错, 请检查服务器是否开启并确认正确监听端口, 将在3秒后重试连接, Host: 127.0.0.1:8011-Client-Universal Path: /ws
18:35:35 [DEBUG] [CQHTTPMirai] 127.0.0.1:8011-Client-Universal 开始启动
18:35:35 [WARNING] [CQHTTPMirai] Websocket连接出错, 请检查服务器是否开启并确认正确监听端口, 将在3秒后重试连接, Host: 127.0.0.1:8011-Client-Universal Path: /ws
[19,047s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
Exception in thread "DefaultDispatcher-worker-3" java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
at java.base/java.lang.Thread.start0(Native Method)
at java.base/java.lang.Thread.start(Thread.java:803)
at kotlinx.coroutines.scheduling.CoroutineScheduler.createNewWorker(CoroutineScheduler.kt:485)
at kotlinx.coroutines.scheduling.CoroutineScheduler.tryCreateWorker(CoroutineScheduler.kt:443)
at kotlinx.coroutines.scheduling.CoroutineScheduler.tryCreateWorker$default(CoroutineScheduler.kt:431)
at kotlinx.coroutines.scheduling.CoroutineScheduler.signalCpuWork$kotlinx_coroutines_core(CoroutineScheduler.kt:427)
at kotlinx.coroutines.scheduling.CoroutineScheduler.dispatch(CoroutineScheduler.kt:399)
at kotlinx.coroutines.scheduling.CoroutineScheduler.dispatch$default(CoroutineScheduler.kt:383)
at kotlinx.coroutines.scheduling.ExperimentalCoroutineDispatcher.dispatch(Dispatcher.kt:61)
at kotlinx.coroutines.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:288)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:49)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
at io.ktor.network.selector.ActorSelectorManager.(ActorSelectorManager.kt:40)
at io.ktor.client.engine.cio.CIOEngine$selectorManager$2.invoke(CIOEngine.kt:28)
at io.ktor.client.engine.cio.CIOEngine$selectorManager$2.invoke(CIOEngine.kt:19)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at io.ktor.client.engine.cio.CIOEngine.getSelectorManager(CIOEngine.kt)
at io.ktor.client.engine.cio.CIOEngine.(CIOEngine.kt:30)
at io.ktor.client.engine.cio.CIO.create(CIO.kt:20)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:39)
at io.ktor.client.HttpClientJvmKt.HttpClient(HttpClientJvm.kt:21)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient.startGeneralWebsocketClient(WebsocketReverseClient.kt:67)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient.startGeneralWebsocketClient(WebsocketReverseClient.kt:121)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient$startGeneralWebsocketClient$1.invokeSuspend(WebsocketReverseClient.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
18:35:38 [DEBUG] [CQHTTPMirai] 127.0.0.1:8011-Client-Universal 开始启动
[19,067s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
Exception in thread "DefaultDispatcher-worker-3" java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
at java.base/java.lang.Thread.start0(Native Method)
at java.base/java.lang.Thread.start(Thread.java:803)
at kotlinx.coroutines.scheduling.CoroutineScheduler.createNewWorker(CoroutineScheduler.kt:485)
at kotlinx.coroutines.scheduling.CoroutineScheduler.tryCreateWorker(CoroutineScheduler.kt:440)
at kotlinx.coroutines.scheduling.CoroutineScheduler.tryCreateWorker$default(CoroutineScheduler.kt:431)
at kotlinx.coroutines.scheduling.CoroutineScheduler.signalCpuWork$kotlinx_coroutines_core(CoroutineScheduler.kt:427)
at kotlinx.coroutines.scheduling.CoroutineScheduler.dispatch(CoroutineScheduler.kt:399)
at kotlinx.coroutines.scheduling.CoroutineScheduler.dispatch$default(CoroutineScheduler.kt:383)
at kotlinx.coroutines.scheduling.ExperimentalCoroutineDispatcher.dispatch(Dispatcher.kt:61)
at kotlinx.coroutines.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:288)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.async(Builders.common.kt:91)
at kotlinx.coroutines.BuildersKt.async(Unknown Source)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.async$default(Builders.common.kt:84)
at kotlinx.coroutines.BuildersKt.async$default(Unknown Source)
at io.ktor.client.engine.HttpClientEngine$DefaultImpls.executeWithinCallContext(HttpClientEngine.kt:78)
at io.ktor.client.engine.HttpClientEngine$install$1.invokeSuspend(HttpClientEngine.kt:65)
at io.ktor.client.engine.HttpClientEngine$install$1.invoke(HttpClientEngine.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:318)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:163)
at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:183)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:27)
at io.ktor.client.features.HttpSend$DefaultSender.execute(HttpSend.kt:115)
at io.ktor.client.features.HttpSend$Feature$install$1.invokeSuspend(HttpSend.kt:79)
at io.ktor.client.features.HttpSend$Feature$install$1.invoke(HttpSend.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:318)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:163)
at io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(PipelineContext.kt:173)
at io.ktor.client.features.websocket.WebSockets$Feature$install$1.invokeSuspend(WebSockets.kt:37)
at io.ktor.client.features.websocket.WebSockets$Feature$install$1.invoke(WebSockets.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:318)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:163)
at io.ktor.util.pipeline.SuspendFunctionGun.proceedWith(PipelineContext.kt:173)
at io.ktor.client.features.HttpCallValidator$Companion$install$1.invokeSuspend(HttpCallValidator.kt:89)
at io.ktor.client.features.HttpCallValidator$Companion$install$1.invoke(HttpCallValidator.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:318)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:163)
at io.ktor.client.features.HttpRequestLifecycle$Feature$install$1.invokeSuspend(HttpRequestLifecycle.kt:34)
at io.ktor.client.features.HttpRequestLifecycle$Feature$install$1.invoke(HttpRequestLifecycle.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(PipelineContext.kt:318)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(PipelineContext.kt:163)
at io.ktor.util.pipeline.SuspendFunctionGun.execute(PipelineContext.kt:183)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:27)
at io.ktor.client.HttpClient.execute(HttpClient.kt:164)
at io.ktor.client.statement.HttpStatement.executeUnsafe(HttpStatement.kt:104)
at io.ktor.client.features.websocket.BuildersKt.webSocket(builders.kt:199)
at io.ktor.client.features.websocket.BuildersKt.webSocket(builders.kt:68)
at io.ktor.client.features.websocket.BuildersKt.ws(builders.kt:101)
at io.ktor.client.features.websocket.BuildersKt.ws$default(builders.kt:100)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient.startGeneralWebsocketClient(WebsocketReverseClient.kt:79)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient.startGeneralWebsocketClient(WebsocketReverseClient.kt:121)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient$startGeneralWebsocketClient$1.invokeSuspend(WebsocketReverseClient.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Exception in thread "ktor-cio-dispatcher-worker-1" kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[ExperimentalCoroutineDispatcher@5f6e1761[scheduler = ktor-cio-dispatcher@2cbdd198[Pool Size {core = 4, max = 4}, Worker States {CPU = 1, blocking = 0, parked = 0, dormant = 2, terminated = 0}, running workers queues = [0c], global CPU queue size = 1, global blocking queue size = 0, Control State {created workers= 3, blocking tasks = 0, CPUs acquired = 1}]], Continuation at io.ktor.network.selector.ActorSelectorManager$1.invokeSuspend(ActorSelectorManager.kt)@6fe576e3]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(DispatchedTask.kt:93)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:64)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: java.lang.IllegalStateException: Job StandaloneCoroutine{Cancelled}@2c921518 is already complete or completing, but is being completed with CompletedExceptionally[kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelled}@2c921518]
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:828)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:172)
... 4 more
Caused by: kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelled}@2c921518
Caused by: java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
at java.base/java.lang.Thread.start0(Native Method)
at java.base/java.lang.Thread.start(Thread.java:803)
at kotlinx.coroutines.scheduling.CoroutineScheduler.createNewWorker(CoroutineScheduler.kt:485)
at kotlinx.coroutines.scheduling.CoroutineScheduler.tryCreateWorker(CoroutineScheduler.kt:443)
at kotlinx.coroutines.scheduling.CoroutineScheduler.tryCreateWorker$default(CoroutineScheduler.kt:431)
at kotlinx.coroutines.scheduling.CoroutineScheduler.signalCpuWork$kotlinx_coroutines_core(CoroutineScheduler.kt:427)
at kotlinx.coroutines.scheduling.CoroutineScheduler.dispatch(CoroutineScheduler.kt:399)
at kotlinx.coroutines.scheduling.CoroutineScheduler.dispatch$default(CoroutineScheduler.kt:383)
at kotlinx.coroutines.scheduling.ExperimentalCoroutineDispatcher.dispatch(Dispatcher.kt:61)
at kotlinx.coroutines.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:288)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:49)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
at io.ktor.network.selector.ActorSelectorManager.(ActorSelectorManager.kt:40)
at io.ktor.client.engine.cio.CIOEngine$selectorManager$2.invoke(CIOEngine.kt:28)
at io.ktor.client.engine.cio.CIOEngine$selectorManager$2.invoke(CIOEngine.kt:19)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at io.ktor.client.engine.cio.CIOEngine.getSelectorManager(CIOEngine.kt)
at io.ktor.client.engine.cio.CIOEngine.(CIOEngine.kt:30)
at io.ktor.client.engine.cio.CIO.create(CIO.kt:20)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:39)
at io.ktor.client.HttpClientJvmKt.HttpClient(HttpClientJvm.kt:21)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient.startGeneralWebsocketClient(WebsocketReverseClient.kt:67)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient.startGeneralWebsocketClient(WebsocketReverseClient.kt:121)
at tech.mihoyo.mirai.web.websocket.WebSocketReverseClient$startGeneralWebsocketClient$1.invokeSuspend(WebsocketReverseClient.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

cqhttp-mirai的编译环境

感谢大神开发的cqhttp转mirai的插件!
没有看到已发布的JAR包,自己在使用Gradle+JDK1.8编译的时候出了问题:
build.gradle.kts:81:30: Unresolved reference: transferTo
还请告知解决方法,谢谢!

求助 无法加载

Event processing: An exception occurred but no CoroutineExceptionHandler found,
either in coroutineContext from Handler job, or in subscriberContext
18:30:56 [INFO] [NETWORK ERROR] java.lang.NoSuchMethodError: kotlin.jvm.internal.PropertyReference1Impl.(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
at tech.mihoyo.mirai.web.http.HttpApiServerServiceConfig.(HttpApiServerConfig.kt)
at tech.mihoyo.mirai.web.http.HttpApiServer.(HttpApiServer.kt:20)
at tech.mihoyo.mirai.BotSession.(Session.kt:62)
at tech.mihoyo.mirai.SessionManager.createBotSession(Session.kt:29)
at tech.mihoyo.mirai.PluginBase$onEnable$2.invokeSuspend(PluginBase.kt:60)
at tech.mihoyo.mirai.PluginBase$onEnable$2.invoke(PluginBase.kt)
at net.mamoe.mirai.event.SubscriberKt__SubscriberKt$subscribeAlways$1.invokeSuspend(subscriber.kt:269)
at net.mamoe.mirai.event.SubscriberKt__SubscriberKt$subscribeAlways$1.invoke(subscriber.kt)
at net.mamoe.mirai.event.internal.Handler$onEvent$2.invokeSuspend(InternalEventListeners.kt:89)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

配置文件为空时报错

log:

[21:06:53.1464] I 此程序以Affero GPL3.0协议发布,使用时请遵守协议
[21:06:53.1464] I 代码库: github.com/LXY1226/MiraiOK gitee.com/LXY1226/MiraiOK
[21:06:53.4755] I JRE: java version "1.8.0_231"
[21:06:53.4755] I JRE: Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
[21:06:53.4755] I JRE: Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
[21:06:53.4755] I 删除.lastupdate来在下次强制检查更新
[21:06:53.4765] I 启动Mirai...
Using proxy: null
You are running Mirai-Console-Wrapper under D:\CQP\Mirai
All additional libraries are located at D:\CQP\Mirai\libraries
Starting Mirai Console Pure, reset by clear /content/
Starting version check...
Fetching Newest Core Version ..
Stay on current version.
Fetching Newest Console Version of Pure
Stay on current version.
Version check complete, starting Mirai
shadow-Protocol:D:\CQP\Mirai\content\mirai-core-qqandroid-1.1.3.jar
Console        :D:\CQP\Mirai\content\mirai-console-0.5.2.jar
Root           :D:\CQP\Mirai/
 21:06:54 [INFO] [Mirai 0.5.2 Pkmon] Mirai-console now running under D:\CQP\Mirai
 21:06:54 [INFO] [Mirai 0.5.2 Pkmon] Get news in github: https://github.com/mamoe/mirai
 21:06:54 [INFO] [Mirai 0.5.2 Pkmon] Mirai为开源项目,请自觉遵守开源项目协议
 21:06:54 [INFO] [Mirai 0.5.2 Pkmon] Powered by Mamoe Technologies and contributors
 21:06:54 [INFO] [Plugin Manager] 开始加载D:\CQP\Mirai/plugins/下的插件
 21:06:54 [INFO] [Plugin Manager] loading plugin CQHTTPMirai
 21:06:54 [INFO] [Plugin Manager] successfully loaded plugin CQHTTPMirai version 0.1.8 by yyuueexxiinngg
 21:06:54 [INFO] [Plugin Manager] Mirai to CoolQ HTTP API Plugin
 21:06:54 [INFO] [CQHTTPMirai] Plugin loaded! 0.1.8
 21:06:54 [INFO] [Plugin Manager] 加载了1个插件
 21:06:54 [INFO] [Mirai 0.5.2 Pkmon] Mirai-console 启动完成
 21:06:54 [INFO] [Mirai 0.5.2 Pkmon] "login qqnumber qqpassword " to login a bot
 21:06:54 [INFO] [Mirai 0.5.2 Pkmon] "login qq号 qq密码 " 来登录一个BOT
 21:06:54 [INFO] [Bot Login] login...
 21:06:57 [INFO] [BOT 3173857429] Logging in...
 21:06:57 [INFO] [NETWORK] Connected to server msfwifi.3g.qq.com:8080
 21:06:57 [INFO] [NETWORK] Send: wtlogin.login
 21:06:57 [INFO] [NETWORK] Recv: LoginPacketResponse.Success
 21:06:57 [INFO] [NETWORK] Login successful
 21:06:57 [INFO] [NETWORK] Send: StatSvc.register
 21:06:57 [INFO] [NETWORK] Recv: Response(StatSvc.register)
 21:06:57 [INFO] [NETWORK] 开始加载好友信息
 21:06:57 [INFO] [NETWORK] 开始加载群组列表与群成员列表
 21:06:57 [INFO] [NETWORK] Send: friendlist.getFriendGroupList
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopListReqV2
 21:06:57 [INFO] [NETWORK] Recv: FriendList.GetFriendGroupList.Response
 21:06:57 [INFO] [NETWORK] 正在加载好友列表 8/8
 21:06:57 [INFO] [NETWORK] 好友列表加载完成, 共 8个
 21:06:57 [INFO] [NETWORK] Recv: FriendList.GetFriendGroupList.Response
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:57 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:58 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:58 [INFO] [NETWORK] 群组列表与群成员加载完成, 共 13个
 21:06:58 [INFO] [NETWORK] Awaiting ConfigPushSvc.PushReq
 21:06:58 [INFO] [NETWORK] Syncing friend message history...
 21:06:58 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:58 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:58 [INFO] [BOT 3173857429] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=<Iterable>))
 21:06:58 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:59 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:59 [INFO] [BOT 3173857429] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=<Iterable>))
 21:06:59 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:59 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:59 [INFO] [BOT 3173857429] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, messages=<Iterable>))
 21:06:59 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:59 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:59 [INFO] [NETWORK] Syncing friend message history: Success
 21:06:59 [INFO] [BOT 3173857429] [Maple Tavern ? Minecraft(330986863)] 萌 BadLee 新(1742594439) ->[mirai:source:1608076,80408718][mirai:quote:1608070,-965793259][mirai:at:564193464,@以Minecraft为载体的再演绎(cover)] [mirai:at:564193464,@以Minecraft为载体的再演绎(cover)] 建议直接武器A
 21:06:59 [INFO] [BOT 3173857429] Event processing: An exception occurred but no CoroutineExceptionHandler found,
                        either in coroutineContext from Handler job, or in subscriberContext
 21:06:59 [INFO] [NETWORK ERROR] java.util.NoSuchElementException: 3173857429
        at net.mamoe.mirai.console.plugins.ConfigSection$DefaultImpls.getConfigSection(ConfigSection.kt:324)
        at net.mamoe.mirai.console.plugins.FileConfigImpl.getConfigSection(ConfigSection.kt:482)
        at tech.mihoyo.mirai.PluginBase$onEnable$1.invokeSuspend(PluginBase.kt:25)
        at tech.mihoyo.mirai.PluginBase$onEnable$1.invoke(PluginBase.kt)
        at net.mamoe.mirai.event.SubscriberKt__SubscriberKt$subscribeAlways$1.invokeSuspend(subscriber.kt:269)
        at net.mamoe.mirai.event.SubscriberKt__SubscriberKt$subscribeAlways$1.invoke(subscriber.kt)
        at net.mamoe.mirai.event.internal.Handler$onEvent$2.invokeSuspend(InternalEventListeners.kt:89)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
		
 21:06:59 [INFO] [BOT 3173857429] Login successful
 21:06:59 [INFO] [Command] 3173857429 login successes
 21:07:00 [INFO] [NETWORK] Received unknown commandName: ConfigPushSvc.PushDomain
 21:07:00 [INFO] [NETWORK] Recv: ConfigPushSvc.PushReq.PushReqResponse.Success
 21:07:00 [INFO] [NETWORK] Send: ConfigPushSvc.PushResp
 21:07:00 [INFO] [NETWORK] ConfigPushSvc.PushReq: Success
 21:07:01 [INFO] [BOT 3173857429] [Maple Tavern ? Minecraft(330986863)] Lemon tree(1595862564) -> [mirai:source:1608077,1992608905]foreign fart
 21:07:03 [INFO] [BOT 3173857429] [FTS||FTS's?Circuit for survival(1033662023)] xli9527(1172326686)-> [mirai:source:28443,355435764]??
 21:07:10 [INFO] [NETWORK] Send: OnlinePush.RespPush

纯属看着不舒服()

几个bug

cqhttp-embedded版本在加载了native插件后配置文件的路径会变为
..\plugins\MiraiNative
如图所示:

且升级到0.2.2后与mirai-native 1.8.6不兼容

websocket不支持ssl连接吗?

 19:22:01 [WARNING] [CQHTTPMirai] Websocket连接出错, 未知错误, 请检查配置, 如配置错误请修正后重启mirai Server error(https://botapi.dead-war.cn/ws: 502 Bad Gateway.io.ktor.client.features.ServerResponseException
 19:22:09 [WARNING] [CQHTTPMirai] Websocket连接出错, 未知错误, 请检查配置, 如配置错误请修正后重启mirai Server error(https://botapi.dead-war.cn/ws: 502 Bad Gateway.io.ktor.client.features.ServerResponseException
 19:22:17 [WARNING] [CQHTTPMirai] Websocket连接出错, 未知错误, 请检查配置, 如配置错误请修正后重启mirai Server error(https://botapi.dead-war.cn/ws: 502 Bad Gateway.io.ktor.client.features.ServerResponseException
 19:22:25 [WARNING] [CQHTTPMirai] Websocket连接出错, 未知错误, 请检查配置, 如配置错误请修正后重启mirai Server error(https://botapi.dead-war.cn/ws: 502 Bad Gateway.io.ktor.client.features.ServerResponseException
 19:22:33 [WARNING] [CQHTTPMirai] Websocket连接出错, 未知错误, 请检查配置, 如配置错误请修正后重启mirai Server error(https://botapi.dead-war.cn/ws: 502 Bad Gateway.io.ktor.client.features.ServerResponseException

目前的配置文件如下:

  ws_reverse:
    # 可选,是否启用反向客户端,默认不启用
    - enable: true
      # 上报消息格式,string 为字符串格式,array 为数组格式
      postMessageFormat: string
      # 反向Websocket主机
      reverseHost: botapi.dead-war.cn
      # 反向Websocket端口
      reversePort: 443
      # 访问口令, 默认为空, 即不设置Token
      accessToken: token
      # 反向Websocket路径
      reversePath: /ws
      # 反向 WebSocket 客户端断线重连间隔,单位毫秒
      reconnectInterval: 3000

Websocket 支持心跳事件

环境信息
cqhttp-mirai版本: 0.2.1
运行环境: windows server 2012+miraiOK win 386
连接方式: 反向WS

bug内容
反向ws链接没有heartbeat,长时间无指令上报后容易断开,只有在重启miraiOK才开始尝试重连(有时候也会触发自动重连,但有时候不会),且这条指令不会被上报。
确定bot没有被屏蔽,没有掉线,其他插件运行正常。

使用CQ file URI格式发送图片报错 - 原"如何发送图片"

试图用CQHTTPCQ码发送图片时,出现了一系列问题:

  • 使用file URI格式发送图片,如[CQ:image,file=file:///xxx/xxx/xxx.jpg]Mirai报如下错误:
    17:41:29 [ERROR] [CQHTTPMirai] java.lang.IllegalArgumentException: message is empty at net.mamoe.mirai.qqandroid.contact.FriendImpl.sendMessage(FriendImpl.kt:89) ...

  • 使用base64发送图片,如来自CQHTTP官方示例的[CQ:image,file=base64://iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAIAAADJt1n/AAAAKElEQVQ4EWPk5+RmIBcwkasRpG9UM4mhNxpgowFGMARGEwnBIEJVAAAdBgBNAZf+QAAAAABJRU5ErkJggg==]Mirai未报错,但QQ不能正常显示(提示“图片已过期”)

  • 使用HTTPS链接发送图片,如[CQ:image,file=https://i.loli.net/2020/05/28/uKvIAWadFC3csPO.jpg]Mirai报如下错误:
    18:00:22 [ERROR] [CQHTTPMirai] java.io.IOException: Server returned HTTP response code: 403 for URL: https://i.loli.net/2020/05/28/uKvIAWadFC3csPO.jpg at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900) ...

看了项目源码,感觉是支持CQ码发送图片的,请问我哪里存在错误,应该如何使用?
提前感谢帮助!

私聊长消息无法发送?

测试了一下,在群里可以发送长消息,如果是私发给群友就发不出去了。请问这是mirai的限制还是插件的bug?有解决办法吗?

更多登陆方式

  • 环境变量

Docker使用更方便

docker run -it -e ACCOUNT=xxx -e PASSWORD=xxx -e WS_URL="ws://1.2.3.4:8081/ws/universal/" lz1998/spring-cq-client
  • 参数

bash脚本更方便

mycli -u用户名 -p密码

cqhttpmirai cannot get image from network

image
image

日志如下

 17:26:28 [INFO] [NETWORK] Send: OnlinePush.RespPush
 17:26:31 [INFO] [NETWORK] unknown group 528 type 0x0000000000000115, data: 08 DB DA 9D D3 03 10 F8 B8 F8 8F 08 1A 14 08 00 10 05 18 C8 A5 C4 F9 05 20 02 28 FF FF FF FF 0F 32 00
 17:26:31 [INFO] [NETWORK] Send: OnlinePush.RespPush
 17:26:31 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 17:26:31 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 17:26:31 [INFO] [BOT 2180914296] (≧?≦)/(979856731) -> [mirai:source:42056,1955906449]/waifu
 17:26:32 [DEBUG] [CQHTTPMirai] {"action": "send_private_msg_async", "params": {"user_id": 979856731, "message": [{"type": "image", "data": {"file": "https://www.thiswaifudoesnotexist.net/example-21261.jpg"}}]}}
 17:26:32 [DEBUG] [CQHTTPMirai] {"status":"async","retcode":1,"data":null,"echo":null}
 17:26:34 [INFO] [NETWORK] Send: MessageSvc.PbSendMsg
 17:26:34 [INFO] [NETWORK] Recv: MessageSvcPbSendMsg.Response.SUCCESS
 17:26:34 [INFO] [BOT 2180914296] Friend(979856731) <- Bot发了一张图片, 但是插件获取不到, 它心累了不想尝试, 并给出了原图链接: https://www.thiswaifudoesnotexist.net/example-21261.jpg```

关于User-Agent导致无法使用部分服务的情况(FFXIVBOT)

说明

我想通过cqhttp-mirai来使用FFXIVBOT的服务。

FFXIVBOT也是个开源的项目,仓库位于:
https://github.com/Bluefissure/FFXIVBOT

但无论如何都连不上,经过排查发现是由于User-Agent导致访问被拒绝。

因为cqhttp-mirai是移植CQHTTP来开发的。

所以可以一起讨论一下,这个情况怎么解决比较好。

相关代码

https://github.com/yyuueexxiinngg/cqhttp-mirai/blob/f9d03db9129a1fb8640c176c6ed6e2038b5bcdb3/src/main/kotlin/tech/mihoyo/mirai/web/websocket/WebsocketReverseClient.kt#L109-L114

https://github.com/yyuueexxiinngg/cqhttp-mirai/blob/f9d03db9129a1fb8640c176c6ed6e2038b5bcdb3/src/main/kotlin/tech/mihoyo/mirai/web/http/ReportService.kt#L124-L130

https://github.com/Bluefissure/FFXIVBOT/blob/22731629b15fa676ea8b9a1fb9784a3f095692b4/ffxivbot/consumers.py#L92-L109
来自其他仓库的引用似乎无法解析,不过可以手动点进去。

环境

  • cqhttp-mirai 0.1.4
  • FFXIVBOT 0.1.0
  • mirai-console 0.5.2
  • CentOS 8

plugin目录问题

mirai不读取plugins下面的子目录,jar必须放在plugins内才能读取,和readme有出入

音乐分享 XML 消息在好友发送正常,但在群大概率不正常

一开始认为是Mirai的问题,因此在mamoe/mirai提了issue:
https://github.com/mamoe/mirai/issues/492
现经提示,可能是CQHTTPMirai的问题(或我的问题)
限于个人水平不能完全看懂源码……

现在主要想请教发送失败情况下"message_id":-1的含义以及可能的原因
以及另一位用户 @ls148478 提及的

我是用kt写的 我看了你的那个问题 原因是开头service不对 他不是60 他应该和下面的xml代码中的serviceID相同 所以他应该=2 我不清楚cqhttp应该怎么写 但是问题应该就是这个 因为当初我也遇到过

是否与这相关

发送消息乱码?

我调用HTTP api

POST /send_group_msg HTTP/1.1
Content-Length: 54
Content-Type: application/json
Host: 127.0.0.1:5700
{
  "group_id":1048307612,
  "message":"我试下at"
}

HTTP/1.1 200 OK
Content-Length: 89
Content-Type: application/json; charset=UTF-8
Connection: keep-alive
{"status":"ok","retcode":0,"data":{"type":"MessageData","message_id":110144},"echo":null}

log:

[21:06:28.9287] I 启动Mirai...
Using proxy: null
You are running Mirai-Console-Wrapper under D:\CQP\Mirai
All additional libraries are located at D:\CQP\Mirai\libraries
Starting Mirai Console Pure, reset by clear /content/
Starting version check...
Fetching Newest Core Version ..
Stay on current version.
Fetching Newest Console Version of Pure
Stay on current version.
Version check complete, starting Mirai
shadow-Protocol:D:\CQP\Mirai\content\mirai-core-qqandroid-1.1.3.jar
Console        :D:\CQP\Mirai\content\mirai-console-0.5.2.jar
Root           :D:\CQP\Mirai/
 21:06:29 [INFO] [Mirai 0.5.2 Pkmon] Mirai-console now running under D:\CQP\Mirai
 21:06:29 [INFO] [Mirai 0.5.2 Pkmon] Get news in github: https://github.com/mamoe/mirai
 21:06:29 [INFO] [Mirai 0.5.2 Pkmon] Mirai为开源项目,请自觉遵守开源项目协议
 21:06:29 [INFO] [Mirai 0.5.2 Pkmon] Powered by Mamoe Technologies and contributors
 21:06:29 [INFO] [Plugin Manager] 开始加载D:\CQP\Mirai/plugins/下的插件
 21:06:30 [INFO] [Plugin Manager] loading plugin CQHTTPMirai
 21:06:30 [INFO] [Plugin Manager] successfully loaded plugin CQHTTPMirai version 0.1.9 by yyuueexxii
nngg
 21:06:30 [INFO] [Plugin Manager] Mirai to CoolQ HTTP API Plugin
 21:06:30 [INFO] [CQHTTPMirai] Plugin loaded! 0.1.9
 21:06:30 [INFO] [Plugin Manager] 加载了1个插件
 21:06:30 [INFO] [Mirai 0.5.2 Pkmon] Mirai-console 启动完成
 21:06:30 [INFO] [Mirai 0.5.2 Pkmon] "login qqnumber qqpassword " to login a bot
 21:06:30 [INFO] [Mirai 0.5.2 Pkmon] "login qq号 qq密码 " 来登录一个BOT
 21:06:30 [INFO] [Bot Login] login...
 21:06:32 [INFO] [BOT 3173857429] Logging in...
 21:06:32 [INFO] [NETWORK] Connected to server 42.81.172.81:80
 21:06:33 [INFO] [NETWORK] Send: wtlogin.login
 21:06:33 [INFO] [NETWORK] Recv: LoginPacketResponse.Success
 21:06:33 [INFO] [NETWORK] Login successful
 21:06:33 [INFO] [NETWORK] Send: StatSvc.register
 21:06:33 [INFO] [NETWORK] Recv: Response(StatSvc.register)
 21:06:33 [INFO] [NETWORK] 开始加载好友信息
 21:06:33 [INFO] [NETWORK] 开始加载群组列表与群成员列表
 21:06:33 [INFO] [NETWORK] Send: friendlist.getFriendGroupList
 21:06:33 [INFO] [NETWORK] Send: friendlist.GetTroopListReqV2
 21:06:33 [INFO] [NETWORK] Recv: FriendList.GetFriendGroupList.Response
 21:06:33 [INFO] [NETWORK] 正在加载好友列表 8/8
 21:06:33 [INFO] [NETWORK] 好友列表加载完成, 共 8个
 21:06:33 [INFO] [NETWORK] Recv: FriendList.GetFriendGroupList.Response
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:33 [INFO] [NETWORK] Send: OidbSvc.0x88d_7
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:34 [INFO] [NETWORK] Send: friendlist.GetTroopMemberListReq
 21:06:35 [INFO] [NETWORK] Recv: FriendList.GetTroopMemberList.Response
 21:06:35 [INFO] [NETWORK] 群组列表与群成员加载完成, 共 13个
 21:06:35 [INFO] [NETWORK] Awaiting ConfigPushSvc.PushReq
 21:06:35 [INFO] [NETWORK] Syncing friend message history...
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:35 [INFO] [BOT 3173857429] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, me
ssages=<Iterable>))
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:35 [INFO] [BOT 3173857429] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, me
ssages=<Iterable>))
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:35 [INFO] [BOT 3173857429] Event: MessageSvcPbGetMsg.Response(syncFlagFromServer=CONTINUE, me
ssages=<Iterable>))
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbGetMsg
 21:06:35 [INFO] [NETWORK] Send: MessageSvc.PbDeleteMsg
 21:06:35 [INFO] [NETWORK] Syncing friend message history: Success
 21:06:35 [INFO] [CQHTTPMirai] Bot: 3173857429 HTTP API服务端是否配置开启: true
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
 21:06:35 [INFO] [CQHTTPMirai] Bot: 3173857429 正向Websocket服务端是否配置开启: true
 21:06:35 [INFO] [BOT 3173857429] Login successful
 21:06:35 [INFO] [Command] 3173857429 login successes
 21:06:36 [INFO] [NETWORK] Recv: ConfigPushSvc.PushReq.PushReqResponse.Success
 21:06:36 [INFO] [NETWORK] Recv: ConfigPushSvc.PushReq.PushReqResponse.Success
 21:06:36 [INFO] [NETWORK] Send: ConfigPushSvc.PushResp
 21:06:36 [INFO] [NETWORK] Send: ConfigPushSvc.PushResp
 21:06:36 [INFO] [NETWORK] ConfigPushSvc.PushReq: Success
 21:06:43 [INFO] [NETWORK] Send: MessageSvc.PbSendMsg
 21:06:43 [INFO] [NETWORK] Recv: MessageSvcPbSendMsg.Response.SUCCESS
 21:06:44 [INFO] [BOT 3173857429] Group(1048307612) <- ???è?????at

image

使用CQ码发图片有概率会导致WebSocket API call timeout

用的是yobot源码版,自己加了点搜图功能。使用CQ发送图片很容易出现这个情况。
下面是miraiOK里信息,貌似图片已经上传完成,但是cqhttp-mirai被阻塞了一样。最后图片依旧没发出来。要卡在这里好久等WebSocket API call timeout。期间miraiOK可以接收到qq的信息,yobot要等WebSocket API call timeout异常抛出后,才接收到miraiOK之前接收到的消息。

Send: ImgStore.GroupPicUp
17:35:39 [INFO] [NETWORK] Recv: RequireUpload(fileId=2903055332, uKey=[75, 37, -21, 88, 71, -22, 15, 10, -58, -43, 59, -120, -36, 112, 113, 112, -125, -56, -70, -45, -70, 12, -25, -101, -114, -78, -88, 116, -86, -108, 50, -1, 92, 54, 31, -100, -14, -2, -123, 105, 76, -99, -47, -110, 88, 106, 57, 12, 15, 114, -103, -5, -83, 54, -33, -108, 53, 117, -64, -114, 122, 0, 3, 1, -14, 123, -118, -105, 73, -34, -41, 126, 117, -72, 56, 7, 58, 58, 84, -63, 14, 7, 84, 91, -58, 65, 102, 66, -64, -34, 17, -7, -42, -16, 83, 57, -18, -35, -65, 12, -54, -81, 12, -4, 1, 125, -42, 16, 57, 7, 73, 122, -51, -51, 90, -102, -118, 9, 120, 46, 14, -102, 21, -55, 57, -80, -98, -102])
17:35:39 [INFO] [NETWORK] [Highway] Uploading group image to 203.205.236.76:8080, size=72.46 KiB

请问产生原因以及解决方法

Http方式返回的内容有错误

在私聊中使用Http方式连接时,似乎只会复读通过http上报的指令
如图,聊天窗口发送命令
image
可以看到响应的内容是正常的,但是返回给聊天窗口的内容是原指令的复读。
群聊则正常中有些会复读而有些不会复读
image

环境 :
cqhttp-mirai-0.2.2
mirai-core-qqandroid-1.2.1
mirai-console-0.5.2

您好,发现几个bug

您好,发现几个bug,plugins里的配置文件是这个
`# Debug日志输出选项
debug: false

要进行配置的QQ号 (Mirai支持多帐号登录, 故需要对每个帐号进行单独设置)

'q号':

是否缓存所有收到的图片, 默认为否 (仅包含图片信息, 不包含图片本身, < 0.5KB)

cacheImage: false

是否缓存所有收到的语音, 默认为否 (将下载完整语音进行保存)

cacheRecord: false

心跳包相关配置

heartbeat:
# 是否发送心跳包, 默认为否
enable: false
# 心跳包发送间隔, 默认为 15000毫秒
interval: 15000

HTTP 相关配置

http:
# 可选,是否启用HTTP API服务器, 默认为不启用, 此项开始与否跟postUrl无关
enable: true
# 可选,HTTP API服务器监听地址, 默认为0.0.0.0
host: 0.0.0.0
# 可选,HTTP API服务器监听端口, 5700
port: 5700
# 可选,访问口令, 默认为空, 即不设置Token
accessToken: ""
# 可选,事件及数据上报URL, 默认为空, 即不上报
postUrl: ""
# 可选,上报消息格式,string 为字符串格式,array 为数组格式, 默认为string
postMessageFormat: string
# 可选,上报数据签名密钥, 默认为空
secret: ""

可选,反向客户端服务

ws_reverse:
# 可选,是否启用反向客户端,默认不启用
- enable: true
# 上报消息格式,string 为字符串格式,array 为数组格式
postMessageFormat: string
# 反向Websocket主机
reverseHost: 127.0.0.1
# 反向Websocket端口
reversePort: 9999
# 访问口令, 默认为空, 即不设置Token
accessToken: ""
# 反向Websocket路径
reversePath: /ws
# 可选, 反向Websocket Api路径, 默认为reversePath
reverseApiPath: /api
# 可选, 反向Websocket Event路径, 默认为reversePath
reverseEventPath: /event
# 是否使用Universal客户端 默认为true
useUniversal: true
# 反向 WebSocket 客户端断线重连间隔,单位毫秒
reconnectInterval: 3000
- enable: true # 这里是第二个连接, 相当于CQHTTP分身版
postMessageFormat: string
reverseHost: 127.0.0.1
reversePort: 9222
reversePath: /ws
useUniversal: true
reconnectInterval: 3000

正向Websocket服务器

ws:
# 可选,是否启用正向Websocket服务器,默认不启用
enable: true
# 可选,上报消息格式,string 为字符串格式,array 为数组格式, 默认为string
postMessageFormat: string
# 可选,访问口令, 默认为空, 即不设置Token
accessToken: ""
# 监听主机
wsHost: "0.0.0.0"
# 监听端口
wsPort: 8080

'0987654321': # 这里是第二个QQ Bot的配置
ws_reverse:
- enable: true
postMessageFormat: string
reverseHost:
reversePort:
reversePath: /ws
reconnectInterval: 3000`

支持application/x-www-form-urlencoded形式的POST请求

原版cqhttp同时支持Content type为application/jsonapplication/x-www-form-urlencoded的POST请求,Python的requests库的POST类型默认使用后者,请问是否有可能让cqhttp-mirai也同时支持两种POST的解析?

反向Websocket模块启用状态: false

" 04:01:50 [INFO] [CQHTTPMirai] Bot:3096679609 反向Websocket模块启用状态: false"
服务器上的反向监听端口已经开启,但登录qq后一直报错:反向监听端口未开启

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.