Add getGroupByUinOrNull (internal)

This commit is contained in:
Him188 2020-02-12 16:10:58 +08:00
parent 32b526b0b1
commit eaf3782b5c

View File

@ -38,7 +38,12 @@ internal abstract class QQAndroidBotBase constructor(
configuration: BotConfiguration
) : BotImpl<QQAndroidBotNetworkHandler>(account, configuration) {
val client: QQAndroidClient =
QQAndroidClient(context, account, bot = @Suppress("LeakingThis") this as QQAndroidBot, device = configuration.deviceInfo?.invoke(context) ?: SystemDeviceInfo(context))
QQAndroidClient(
context,
account,
bot = @Suppress("LeakingThis") this as QQAndroidBot,
device = configuration.deviceInfo?.invoke(context) ?: SystemDeviceInfo(context)
)
internal var firstLoginSucceed: Boolean = false
override val uin: Long get() = client.uin
override val qqs: ContactList<QQ> = ContactList(LockFreeLinkedList())
@ -60,6 +65,11 @@ internal abstract class QQAndroidBotBase constructor(
return groups.delegate.filteringGetOrNull { (it as GroupImpl).uin == uin } ?: throw NoSuchElementException("Can not found group with ID=${uin}")
}
fun getGroupByUinOrNull(uin: Long): Group? {
return groups.delegate.filteringGetOrNull { (it as GroupImpl).uin == uin }
}
override fun onEvent(event: BotEvent): Boolean {
return firstLoginSucceed
}