diff --git a/overflow-core-api/src/main/kotlin/top/mrxiaom/overflow/contact/RemoteUser.kt b/overflow-core-api/src/main/kotlin/top/mrxiaom/overflow/contact/RemoteUser.kt new file mode 100644 index 00000000..d4294fcd --- /dev/null +++ b/overflow-core-api/src/main/kotlin/top/mrxiaom/overflow/contact/RemoteUser.kt @@ -0,0 +1,5 @@ +package top.mrxiaom.overflow.contact + +interface RemoteUser { + val onebotData: String +} diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/BotWrapper.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/BotWrapper.kt index 1b7093e7..3ced72e1 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/BotWrapper.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/BotWrapper.kt @@ -2,6 +2,7 @@ package top.mrxiaom.overflow.internal.contact import cn.evolvefield.onebot.sdk.response.contact.LoginInfoResp import cn.evolvefield.onebot.client.core.Bot +import cn.evolvefield.onebot.sdk.util.gson import kotlinx.coroutines.* import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge import net.mamoe.mirai.LowLevelApi @@ -18,6 +19,7 @@ import net.mamoe.mirai.supervisorJob import net.mamoe.mirai.utils.* import org.java_websocket.framing.CloseFrame import top.mrxiaom.overflow.contact.RemoteBot +import top.mrxiaom.overflow.contact.RemoteUser import top.mrxiaom.overflow.contact.Updatable import top.mrxiaom.overflow.internal.Overflow import top.mrxiaom.overflow.internal.contact.data.FallbackFriendGroups @@ -37,7 +39,7 @@ internal class BotWrapper private constructor( private var implBot: Bot, defLoginInfo: LoginInfoResp, override val configuration: BotConfiguration -) : QQAndroidBot(), RemoteBot, Updatable, CoroutineScope { +) : QQAndroidBot(), RemoteUser, RemoteBot, Updatable, CoroutineScope { val impl: Bot get() = implBot override val implGetter: () -> Bot = { impl } @@ -106,6 +108,9 @@ internal class BotWrapper private constructor( if (data.message.isEmpty()) return null return OnebotMessages.toMiraiMessage(data.isJsonMessage, data.message, this) } + + override val onebotData: String + get() = gson.toJson(loginInfo) override val id: Long get() = loginInfo.userId diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/FriendWrapper.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/FriendWrapper.kt index 611f232f..b198163b 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/FriendWrapper.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/FriendWrapper.kt @@ -2,6 +2,7 @@ package top.mrxiaom.overflow.internal.contact import cn.evolvefield.onebot.sdk.response.contact.FriendInfoResp +import cn.evolvefield.onebot.sdk.util.gson import kotlinx.coroutines.CoroutineName import net.mamoe.mirai.contact.Friend import net.mamoe.mirai.contact.friendgroup.FriendGroup @@ -17,6 +18,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi import net.mamoe.mirai.utils.currentTimeSeconds import top.mrxiaom.overflow.Overflow import top.mrxiaom.overflow.OverflowAPI +import top.mrxiaom.overflow.contact.RemoteUser import top.mrxiaom.overflow.internal.message.OnebotMessages import top.mrxiaom.overflow.internal.message.OnebotMessages.findForwardMessage import top.mrxiaom.overflow.internal.message.data.OutgoingSource @@ -28,7 +30,9 @@ import kotlin.coroutines.CoroutineContext internal class FriendWrapper( override val bot: BotWrapper, internal var impl: FriendInfoResp, -) : Friend { +) : Friend, RemoteUser { + override val onebotData: String + get() = gson.toJson(impl) override val id: Long = impl.userId override val nick: String = impl.nickname override val coroutineContext: CoroutineContext = CoroutineName("(Bot/${bot.id})Friend/$id") diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/GroupWrapper.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/GroupWrapper.kt index c9ae7940..6aba4d08 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/GroupWrapper.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/GroupWrapper.kt @@ -4,6 +4,7 @@ package top.mrxiaom.overflow.internal.contact import cn.evolvefield.onebot.sdk.entity.Anonymous import cn.evolvefield.onebot.sdk.response.group.GroupInfoResp import cn.evolvefield.onebot.sdk.response.group.GroupMemberInfoResp +import cn.evolvefield.onebot.sdk.util.gson import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.runBlocking import me.him188.kotlin.jvm.blocking.bridge.JvmBlockingBridge @@ -22,6 +23,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi import net.mamoe.mirai.utils.currentTimeSeconds import top.mrxiaom.overflow.Overflow import top.mrxiaom.overflow.contact.RemoteGroup +import top.mrxiaom.overflow.contact.RemoteUser import top.mrxiaom.overflow.contact.Updatable import top.mrxiaom.overflow.internal.contact.data.* import top.mrxiaom.overflow.internal.contact.data.AnnouncementsWrapper.Companion.fetchAnnouncements @@ -41,7 +43,9 @@ import kotlin.coroutines.CoroutineContext internal class GroupWrapper( override val bot: BotWrapper, internal var impl: GroupInfoResp -) : Group, RemoteGroup, Updatable { +) : Group, RemoteGroup, RemoteUser, Updatable { + override val onebotData: String + get() = gson.toJson(impl) private var membersInternal: ContactList? = null private var anonymousInternal: HashMap = hashMapOf() diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/MemberWrapper.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/MemberWrapper.kt index 939e3659..cfcfb59b 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/MemberWrapper.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/MemberWrapper.kt @@ -3,6 +3,7 @@ package top.mrxiaom.overflow.internal.contact import cn.evolvefield.onebot.sdk.entity.Anonymous import cn.evolvefield.onebot.sdk.response.group.GroupMemberInfoResp +import cn.evolvefield.onebot.sdk.util.gson import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.launch import net.mamoe.mirai.contact.* @@ -19,6 +20,7 @@ import net.mamoe.mirai.utils.ExternalResource import net.mamoe.mirai.utils.MiraiInternalApi import net.mamoe.mirai.utils.currentTimeSeconds import top.mrxiaom.overflow.Overflow +import top.mrxiaom.overflow.contact.RemoteUser import top.mrxiaom.overflow.contact.Updatable import top.mrxiaom.overflow.internal.check import top.mrxiaom.overflow.internal.contact.data.EmptyMemberActive @@ -36,7 +38,9 @@ import kotlin.coroutines.CoroutineContext internal class MemberWrapper( override val group: GroupWrapper, internal var impl: GroupMemberInfoResp -) : NormalMember, Updatable { +) : NormalMember, RemoteUser, Updatable { + override val onebotData: String + get() = gson.toJson(impl) override val bot: BotWrapper = group.bot val data: GroupMemberInfoResp get() = impl diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/OtherClientWrapper.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/OtherClientWrapper.kt index ded241df..93f2414a 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/OtherClientWrapper.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/OtherClientWrapper.kt @@ -1,11 +1,13 @@ @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package top.mrxiaom.overflow.internal.contact +import cn.evolvefield.onebot.sdk.util.gson import kotlinx.coroutines.CoroutineName import net.mamoe.mirai.contact.OtherClient import net.mamoe.mirai.contact.OtherClientInfo import net.mamoe.mirai.message.data.ShortVideo import net.mamoe.mirai.utils.ExternalResource +import top.mrxiaom.overflow.contact.RemoteUser import top.mrxiaom.overflow.internal.message.OnebotMessages import top.mrxiaom.overflow.spi.FileService import kotlin.coroutines.CoroutineContext @@ -13,7 +15,9 @@ import kotlin.coroutines.CoroutineContext internal class OtherClientWrapper( override val bot: BotWrapper, override var info: OtherClientInfo -) : OtherClient { +) : OtherClient, RemoteUser { + override val onebotData: String + get() = gson.toJson(info) override val coroutineContext: CoroutineContext = CoroutineName("(Bot/${bot.id})OtherClient/${info.deviceKind}") override suspend fun uploadShortVideo( diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/StrangerWrapper.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/StrangerWrapper.kt index f6d70c63..41f4d261 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/StrangerWrapper.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/contact/StrangerWrapper.kt @@ -2,6 +2,7 @@ package top.mrxiaom.overflow.internal.contact import cn.evolvefield.onebot.sdk.response.contact.StrangerInfoResp +import cn.evolvefield.onebot.sdk.util.gson import kotlinx.coroutines.CoroutineName import net.mamoe.mirai.contact.Stranger import net.mamoe.mirai.event.broadcast @@ -18,6 +19,7 @@ import net.mamoe.mirai.utils.MiraiInternalApi import net.mamoe.mirai.utils.currentTimeSeconds import top.mrxiaom.overflow.Overflow import top.mrxiaom.overflow.OverflowAPI +import top.mrxiaom.overflow.contact.RemoteUser import top.mrxiaom.overflow.internal.message.OnebotMessages import top.mrxiaom.overflow.internal.message.OnebotMessages.findForwardMessage import top.mrxiaom.overflow.internal.message.data.OutgoingSource @@ -29,7 +31,9 @@ import kotlin.coroutines.CoroutineContext internal class StrangerWrapper( override val bot: BotWrapper, internal var impl: StrangerInfoResp, -) : Stranger { +) : Stranger, RemoteUser { + override val onebotData: String + get() = gson.toJson(impl) override val id: Long = impl.userId override val nick: String = impl.nickname override val coroutineContext: CoroutineContext = CoroutineName("(Bot/${bot.id})Stranger/$id")