mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 23:50:08 +08:00
Fix group detection; fix #1661
This commit is contained in:
parent
92ab2bf50b
commit
4db04e2a76
@ -5027,7 +5027,7 @@ public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$
|
||||
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
|
||||
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Member;
|
||||
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
|
||||
public final fun getSubject ()Lnet/mamoe/mirai/contact/Group;
|
||||
public fun getSubject ()Lnet/mamoe/mirai/contact/Group;
|
||||
public synthetic fun getTarget ()Lnet/mamoe/mirai/contact/ContactOrBot;
|
||||
public final fun getTarget ()Lnet/mamoe/mirai/contact/Group;
|
||||
}
|
||||
|
@ -5027,7 +5027,7 @@ public abstract class net/mamoe/mirai/message/data/OnlineMessageSource$Incoming$
|
||||
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
|
||||
public abstract fun getSender ()Lnet/mamoe/mirai/contact/Member;
|
||||
public synthetic fun getSubject ()Lnet/mamoe/mirai/contact/Contact;
|
||||
public final fun getSubject ()Lnet/mamoe/mirai/contact/Group;
|
||||
public fun getSubject ()Lnet/mamoe/mirai/contact/Group;
|
||||
public synthetic fun getTarget ()Lnet/mamoe/mirai/contact/ContactOrBot;
|
||||
public final fun getTarget ()Lnet/mamoe/mirai/contact/Group;
|
||||
}
|
||||
|
@ -558,9 +558,9 @@ public sealed class OnlineMessageSource : MessageSource() { // TODO: 2021/1/10 E
|
||||
AbstractPolymorphicMessageKey<Incoming, FromGroup>(Incoming, { it.safeCast() })
|
||||
|
||||
public abstract override val sender: Member
|
||||
public final override val subject: Group get() = sender.group
|
||||
public final override val target: Group get() = group
|
||||
public inline val group: Group get() = sender.group
|
||||
public override val subject: Group get() = sender.group
|
||||
public final override val target: Group get() = subject
|
||||
public inline val group: Group get() = subject
|
||||
}
|
||||
|
||||
public companion object Key :
|
||||
|
@ -467,9 +467,9 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
|
||||
is OnlineMessageSourceToGroupImpl,
|
||||
is OnlineMessageSourceFromGroupImpl
|
||||
-> {
|
||||
val group = when (source) {
|
||||
is OnlineMessageSourceToGroupImpl -> source.target
|
||||
is OnlineMessageSourceFromGroupImpl -> source.group
|
||||
val group: Group = when (source) {
|
||||
is OnlineMessageSourceToGroupImpl -> source.subject
|
||||
is OnlineMessageSourceFromGroupImpl -> source.subject
|
||||
else -> error("stub")
|
||||
}
|
||||
if (bot.id != source.fromId) {
|
||||
|
@ -18,6 +18,7 @@ import net.mamoe.mirai.contact.Friend
|
||||
import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.contact.Stranger
|
||||
import net.mamoe.mirai.internal.asQQAndroidBot
|
||||
import net.mamoe.mirai.internal.contact.GroupImpl
|
||||
import net.mamoe.mirai.internal.contact.checkIsGroupImpl
|
||||
import net.mamoe.mirai.internal.contact.newAnonymous
|
||||
import net.mamoe.mirai.internal.getGroupByUinOrCodeOrFail
|
||||
@ -174,13 +175,19 @@ internal class OnlineMessageSourceFromGroupImpl(
|
||||
}
|
||||
override val originalMessage: MessageChain get() = originalMessageLazy.value
|
||||
|
||||
override val sender: Member by lazy {
|
||||
override val subject: GroupImpl by lazy {
|
||||
val groupCode = msg.first().msgHead.groupInfo?.groupCode
|
||||
?: error("cannot find groupCode for OnlineMessageSourceFromGroupImpl. msg=${msg._miraiContentToString()}")
|
||||
|
||||
val group = bot.getGroup(groupCode)?.checkIsGroupImpl()
|
||||
?: error("cannot find group for OnlineMessageSourceFromGroupImpl. msg=${msg._miraiContentToString()}")
|
||||
|
||||
group
|
||||
}
|
||||
|
||||
override val sender: Member by lazy {
|
||||
val group = subject
|
||||
|
||||
val member = group[msg.first().msgHead.fromUin]
|
||||
if (member != null) return@lazy member
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user