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

修复群ID构造的图片发送缓慢,以及无法添加到ForwardMessage中 #1640

Closed
wants to merge 1 commit into from

Conversation

mcdoeswhat
Copy link
Contributor

修复前:发送由ID构造的图片到群内需要调用GroupPicUp(发送缓慢),私聊却不会,修改为闪照在群内发送也不会
并且添加到ForwardMessage中会无法显示

修复后: ID构造的图片在群内发送不会调用GroupPicUp,跟私聊和闪照时一样,秒发,并且可以添加到ForwardMessage中
只有upload的时候会调用GroupPicUp,用户也可以自行实现ExternalResource检查图片是否过期

其实主要是因为本人写了个涩图插件,用图片ID的方式储存图片,并不需要任何的API获取图片链接下载,或读取本地的文件,主要是为了速度快,已经测试过构造50个图片ID的ForwardMessage 1秒发送完成,机器人发送消息,接收消息
发送离线ID构造的图片,发送upload的图片,发送闪照都是正常的
并且fileID的可见性为internal,也就是其他模块不可调用,修改后不会对其他使用miria的项目造成影响

此次修改内容构造的mirai和插件已经发送给多人进行测试,未发现任何问题

@mcdoeswhat mcdoeswhat changed the title 修复群图片发送缓慢,以及无法添加到ForwardMessage中 修复群ID构造的图片发送缓慢,以及无法添加到ForwardMessage中 Nov 2, 2021
@Him188 Him188 requested a review from Karlatemp November 2, 2021 13:25
Comment on lines 339 to 341
@Transient
internal var fileId: Int? = null
internal var fileId: Int? = -1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1636
其实只要改这个fileID就能解决问题,其他的代码可能没有必要,因为fileID不会为null了,本人不是很熟悉kotlin语法

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null is designed

@@ -279,6 +281,17 @@ internal suspend fun <C : Contact> SendMessageHandler<C>.transformSpecialMessage
forward.nodeList.sumOf { it.messageChain.size }
)
forward.nodeList.forEach { tmp.addAll(it.messageChain) }
tmp.forEach {
val tmpContact = contact;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep kotlin style

Comment on lines +290 to +292
if (it is FriendImage) {
tmpContact.updateFriendImageForGroupMessage(it)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resp ignored

@Him188 Him188 added this to the 2.9 milestone Nov 7, 2021
@Him188 Him188 added t:enhancement 类型: 现有功能上的优化 N 优先级: 一般 x:protocol 属性: 协议相关 labels Nov 7, 2021
@Him188 Him188 modified the milestones: 2.9, 2.9.0-M1 Nov 9, 2021
@Karlatemp Karlatemp mentioned this pull request Nov 12, 2021
@Karlatemp
Copy link
Member

因为您长时间未进行修改,所以我将会关闭此 PR 并以 #1667 替代

@Karlatemp Karlatemp closed this Nov 12, 2021
@Karlatemp Karlatemp removed this from the 2.9.0-M1 milestone Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N 优先级: 一般 t:enhancement 类型: 现有功能上的优化 x:protocol 属性: 协议相关
Projects
None yet
Development

Successfully merging this pull request may close these issues.

在一条消息中发送同一个 ID 构造的多个 OfflineGroupImage 实例还会调用多次 GroupPicUp
3 participants