Skip to content

Commit d0620c5

Browse files
committed
[core] Fix replying unavailable member's message
1 parent 8f3e7d5 commit d0620c5

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

mirai-core/src/commonMain/kotlin/message/protocol/impl/QuoteReplyProtocol.kt

+17-7
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,27 @@ internal class QuoteReplyProtocol : MessageProtocol(PRIORITY_METADATA) {
157157
markAsConsumed()
158158
collect(ImMsgBody.Elem(srcMsg = source.toJceData()))
159159
if (sourceCommon.kind == MessageSourceKind.GROUP) {
160-
if (source is OnlineMessageSource.Incoming.FromGroup) {
161-
val sender0 = source.sender
162-
if (sender0 !is AnonymousMember) {
163-
processAlso(At(sender0))
160+
161+
@Suppress("RemoveExplicitTypeArguments")
162+
val needPlusAt = sequence<Boolean> {
163+
if (source is OnlineMessageSource.Incoming.FromGroup) {
164+
try {
165+
val sender0 = source.sender
166+
yield(sender0 !is AnonymousMember)
167+
} catch (_: IllegalStateException) {
168+
// Member not available now
169+
}
164170
}
171+
172+
yield(sourceCommon.fromId != 80000000L)
173+
}
174+
175+
if (needPlusAt.first()) {
176+
processAlso(At(sourceCommon.fromId))
177+
165178
// transformOneMessage(PlainText(" "))
166179
// removed by https://github.com/mamoe/mirai/issues/524
167180
// 发送 QuoteReply 消息时无可避免的产生多余空格 #524
168-
} else if (sourceCommon.fromId != 80000000L) {
169-
// https://github.com/mamoe/mirai/issues/2501 OfflineMessageSource quote replying
170-
processAlso(At(sourceCommon.fromId))
171181
}
172182
}
173183
}

0 commit comments

Comments
 (0)