mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-30 02:30:12 +08:00
Support decode the join request by member invite (#882)
* Support detect official bot, fix #439 * Fix wrong command name and add missed value * Adapt to changed invite event * Internal MessageData * Fix build * Fix wording * Support decode the join request by member invite * Fix shadow warning * Fix build * Adapt to MemberJoinEvent broadcast logic when accepted * Downgrade blockingBridge version to 1.7.2 for passing build * Fix binary compatibility * Reformat code * Update api Co-authored-by: Him188 <Him188@mamoe.net>
This commit is contained in:
parent
c77f94cd52
commit
209b2b7616
@ -2704,7 +2704,10 @@ public final class net/mamoe/mirai/event/events/MemberJoinEvent$Retrieve : net/m
|
||||
}
|
||||
|
||||
public final class net/mamoe/mirai/event/events/MemberJoinRequestEvent : net/mamoe/mirai/event/AbstractEvent, net/mamoe/mirai/event/events/BotEvent, net/mamoe/mirai/internal/network/Packet {
|
||||
public fun <init> (Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;)V
|
||||
public static final field Companion Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent$Companion;
|
||||
public synthetic fun <init> (Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;)V
|
||||
public fun <init> (Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/Long;)V
|
||||
public synthetic fun <init> (Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/Long;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun accept ()Lkotlin/Unit;
|
||||
public final fun accept (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public final fun component1 ()Lnet/mamoe/mirai/Bot;
|
||||
@ -2714,8 +2717,11 @@ public final class net/mamoe/mirai/event/events/MemberJoinRequestEvent : net/mam
|
||||
public final fun component5 ()J
|
||||
public final fun component6 ()Ljava/lang/String;
|
||||
public final fun component7 ()Ljava/lang/String;
|
||||
public final fun copy (Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;)Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;
|
||||
public static synthetic fun copy$default (Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;
|
||||
public final fun component8 ()Ljava/lang/Long;
|
||||
public final synthetic fun copy (Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;)Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;
|
||||
public final fun copy (Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/Long;)Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;
|
||||
public static final synthetic fun copy$default (Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;
|
||||
public static synthetic fun copy$default (Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;Lnet/mamoe/mirai/Bot;JLjava/lang/String;JJLjava/lang/String;Ljava/lang/String;Ljava/lang/Long;ILjava/lang/Object;)Lnet/mamoe/mirai/event/events/MemberJoinRequestEvent;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public fun getBot ()Lnet/mamoe/mirai/Bot;
|
||||
public final fun getEventId ()J
|
||||
@ -2724,6 +2730,8 @@ public final class net/mamoe/mirai/event/events/MemberJoinRequestEvent : net/mam
|
||||
public final fun getGroup ()Lnet/mamoe/mirai/contact/Group;
|
||||
public final fun getGroupId ()J
|
||||
public final fun getGroupName ()Ljava/lang/String;
|
||||
public final fun getInvitor ()Lnet/mamoe/mirai/contact/NormalMember;
|
||||
public final fun getInvitorId ()Ljava/lang/Long;
|
||||
public final fun getMessage ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public final fun ignore (Z)Lkotlin/Unit;
|
||||
|
@ -365,13 +365,22 @@ public data class MemberJoinRequestEvent @MiraiInternalApi constructor(
|
||||
/**
|
||||
* 申请人昵称
|
||||
*/
|
||||
val fromNick: String
|
||||
val fromNick: String,
|
||||
/**
|
||||
* 邀请人 id(如果是邀请入群)
|
||||
*/
|
||||
val invitorId: Long? = null
|
||||
) : BotEvent, Packet, AbstractEvent() {
|
||||
/**
|
||||
* 相关群. 若在事件发生后机器人退出这个群, [group] 为 `null`.
|
||||
*/
|
||||
public val group: Group? get() = this.bot.getGroup(groupId)
|
||||
|
||||
/**
|
||||
* 邀请入群的成员. 若在事件发生时机器人或该成员退群, [invitor] 为 `null`.
|
||||
*/
|
||||
public val invitor: NormalMember? by lazy { invitorId?.let { group?.get(it) } }
|
||||
|
||||
@JvmField
|
||||
@PublishedApi
|
||||
internal val responded: AtomicBoolean = AtomicBoolean(false)
|
||||
@ -395,6 +404,50 @@ public data class MemberJoinRequestEvent @MiraiInternalApi constructor(
|
||||
*/
|
||||
@JvmBlockingBridge
|
||||
public suspend fun ignore(blackList: Boolean = false): Unit = Mirai.ignoreMemberJoinRequest(this, blackList)
|
||||
|
||||
@Deprecated("For binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public constructor(
|
||||
bot: Bot, eventId: Long, message: String,
|
||||
fromId: Long, groupId: Long, groupName: String, fromNick: String
|
||||
) : this(bot, eventId, message, fromId, groupId, groupName, fromNick, null)
|
||||
|
||||
@Deprecated("For binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public fun copy(
|
||||
bot: Bot, eventId: Long, message: String,
|
||||
fromId: Long, groupId: Long, groupName: String, fromNick: String
|
||||
): MemberJoinRequestEvent = copy(
|
||||
bot = bot, eventId = eventId, message = message, fromId = fromId,
|
||||
groupId = groupId, groupName = groupName, fromNick = fromNick, invitorId = null
|
||||
)
|
||||
|
||||
internal companion object {
|
||||
@Deprecated("For binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
@JvmStatic
|
||||
@JvmName("copy\$default") // avoid being mangled
|
||||
fun `copy$default`(
|
||||
var0: MemberJoinRequestEvent, var1: Bot, var2: Long, var4: String, var5: Long, var7: Long,
|
||||
var9: String, var10: String, var11: Int, @Suppress("UNUSED_PARAMETER") var12: Any
|
||||
): MemberJoinRequestEvent {
|
||||
var bot = var1
|
||||
var eventId = var2
|
||||
var message = var4
|
||||
var fromId = var5
|
||||
var groupId = var7
|
||||
var groupName = var9
|
||||
var fromNick = var10
|
||||
if (var11 and 1 != 0) bot = var0.bot
|
||||
if (var11 and 2 != 0) eventId = var0.eventId
|
||||
if (var11 and 4 != 0) message = var0.message
|
||||
if (var11 and 8 != 0) fromId = var0.fromId
|
||||
if (var11 and 16 != 0) groupId = var0.groupId
|
||||
if (var11 and 32 != 0) groupName = var0.groupName
|
||||
if (var11 and 64 != 0) fromNick = var0.fromNick
|
||||
return var0.copy(
|
||||
bot = bot, eventId = eventId, message = message,
|
||||
fromId = fromId, groupId = groupId, groupName = groupName, fromNick = fromNick
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
@ -181,7 +181,11 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
|
||||
)
|
||||
|
||||
event.group?.getMember(event.fromId)?.let { member ->
|
||||
MemberJoinEvent.Active(member).broadcast()
|
||||
if (event.invitor != null) {
|
||||
MemberJoinEvent.Invite(member, event.invitor!!).broadcast()
|
||||
} else {
|
||||
MemberJoinEvent.Active(member).broadcast()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,12 +166,19 @@ internal class NewContact {
|
||||
)
|
||||
}
|
||||
2 -> {
|
||||
// 被邀请入群
|
||||
// Bot 被邀请入群
|
||||
BotInvitedJoinGroupRequestEvent(
|
||||
bot, struct.msgSeq, actionUin,
|
||||
groupCode, groupName, actionUinNick
|
||||
)
|
||||
}
|
||||
22 -> {
|
||||
// 成员邀请入群
|
||||
MemberJoinRequestEvent(
|
||||
bot, struct.msgSeq, msgAdditional,
|
||||
struct.reqUin, groupCode, groupName, reqUinNick, actionUin
|
||||
)
|
||||
}
|
||||
else -> throw contextualBugReportException(
|
||||
"parse SystemMsgNewGroup, subType=1",
|
||||
this._miraiContentToString(),
|
||||
|
Loading…
Reference in New Issue
Block a user