Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持Lagrange端FileMessage的接收 #111

Open
EvolvedGhost opened this issue Nov 25, 2024 · 1 comment
Open

支持Lagrange端FileMessage的接收 #111

EvolvedGhost opened this issue Nov 25, 2024 · 1 comment
Labels
feature 新功能请求

Comments

@EvolvedGhost
Copy link
Contributor

在Onebot中没有定义文件的消息段,但是定义了group_upload事件,应该对应Mirai的FileMessage;但是因为历史缘故,Mirai的FileMessage实现为:public fun FileMessage(id: String, internalId: Int, name: String, size: Long),name 与 size 只供本地使用, 发送消息时只会使用 id 和 internalId.

而Onebot的group_upload为

字段名 数据类型 可能的值 说明
time number (int64) - 事件发生的时间戳
self_id number (int64) - 收到事件的机器人 QQ 号
post_type string notice 上报类型
notice_type string group_upload 通知类型
group_id number (int64) - 群号
user_id number (int64) - 发送者 QQ 号
file object - 文件信息

其中 file 字段的内容如下:

字段名 数据类型 说明
id string 文件 ID
name string 文件名
size number (int64) 文件大小(字节数)
busid number (int64) busid(目前不清楚有什么作用)

差距挺大,感觉无从下手

Onebot(Lagrange)日志为:

2024-11-25 17:25:38 D/Onebot: [Recv] <-- {"message_type":"group","sub_type":"normal","message_id":MSG_ID,"group_id":GROUP_ID,"user_id":USER_ID,"anonymous":null,"message":[],"raw_message":"","font":0,"sender":{"user_id":USER_ID,"nickname":"NICKNAME","card":"username","sex":"unknown","age":0,"area":"","level":"100","role":"owner","title":""},"time":1732526738,"self_id":BOT_ID,"post_type":"message"}
2024-11-25 17:25:38 D/Onebot: [Recv] <-- {"group_id":GROUP_ID,"user_id":USER_ID,"file":{"id":"/81xxxxxd-axx7-4xx0-8xx8-axxxxxxxxxxa","name":"xxx.exe","size":700000,"busid":0,"url":"FILE_URL"},"notice_type":"group_upload","time":1732526738,"self_id":BOT_ID,"post_type":"notice"}

Onebot(Lagrange)会传递一条空的消息提供message_id,再用group_upload提供文件详情

如果要作为FileMessage的话还需要将这两条消息组合起来才能正常进行回复、撤回等操作

感觉会很麻烦,先留个issue在这儿

@EvolvedGhost EvolvedGhost added the feature 新功能请求 label Nov 25, 2024
@EvolvedGhost EvolvedGhost changed the title 支持FileMessage的接收 支持Lagrange端FileMessage的接收 Nov 25, 2024
@MrXiaoM
Copy link
Owner

MrXiaoM commented Nov 26, 2024

写 go cqhttp 的文件支持的时候见过 busid,把它当成这个文件的id来使用就好了

对于这个 file 字段,写过类似的转换

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 新功能请求
Projects
None yet
Development

No branches or pull requests

2 participants