mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-23 22:00:10 +08:00
Use long instead of inline classes
This commit is contained in:
parent
4ef6f7e723
commit
7731a4327d
@ -2,8 +2,6 @@ package net.mamoe.mirai.japt;
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket;
|
||||
import net.mamoe.mirai.BotAccount;
|
||||
import net.mamoe.mirai.contact.GroupId;
|
||||
import net.mamoe.mirai.contact.GroupInternalId;
|
||||
import net.mamoe.mirai.data.AddFriendResult;
|
||||
import net.mamoe.mirai.data.ImageLink;
|
||||
import net.mamoe.mirai.message.data.Image;
|
||||
@ -63,19 +61,12 @@ public interface BlockingBot {
|
||||
@NotNull
|
||||
BlockingGroup getGroup(long id);
|
||||
|
||||
/**
|
||||
* 获取缓存的群对象. 若没有对应的缓存, 则会线程安全地创建一个.
|
||||
* 若 {@code id} 无效, 将会抛出 {@link GroupNotFoundException}
|
||||
*/
|
||||
@NotNull
|
||||
BlockingGroup getGroup(@NotNull GroupId id);
|
||||
|
||||
/**
|
||||
* 获取缓存的群对象. 若没有对应的缓存, 则会线程安全地创建一个.
|
||||
* 若 {@code internalId} 无效, 将会抛出 {@link GroupNotFoundException}
|
||||
*/
|
||||
@NotNull
|
||||
BlockingGroup getGroup(@NotNull GroupInternalId internalId);
|
||||
BlockingGroup getGroupByInternalId(long internalId);
|
||||
|
||||
// endregion
|
||||
|
||||
|
@ -21,7 +21,7 @@ public final class BlockingContacts {
|
||||
return new BlockingMemberImpl(member);
|
||||
}
|
||||
|
||||
public static BlockingBotImpl createBlocking(Bot bot) {
|
||||
public static BlockingBot createBlocking(Bot bot) {
|
||||
return new BlockingBotImpl(bot);
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,42 @@
|
||||
package net.mamoe.mirai.japt;
|
||||
|
||||
import net.mamoe.mirai.contact.Group;
|
||||
import net.mamoe.mirai.data.GroupInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface BlockingGroup extends BlockingContact {
|
||||
/**
|
||||
* 内部 ID. 内部 ID 为 [GroupId] 的映射
|
||||
* 内部 ID
|
||||
*/
|
||||
long getInternalId();
|
||||
|
||||
/**
|
||||
* 群主 (同步事件更新)
|
||||
* 进行 [updateGroupInfo] 时将会更新这个值.
|
||||
* 进行 {@link #updateGroupInfo} 时将会更新这个值.
|
||||
*/
|
||||
@NotNull
|
||||
BlockingMember getOwner();
|
||||
|
||||
/**
|
||||
* 群名称 (同步事件更新)
|
||||
* 进行 [updateGroupInfo] 时将会更新这个值.
|
||||
* 进行 {@link #updateGroupInfo} 时将会更新这个值.
|
||||
*/
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* 入群公告, 没有时为空字符串. (同步事件更新)
|
||||
* 进行 [updateGroupInfo] 时将会更新这个值.
|
||||
* 进行 {@link #updateGroupInfo} 时将会更新这个值.
|
||||
*/
|
||||
@NotNull
|
||||
String getAnnouncement();
|
||||
|
||||
/**
|
||||
* 在 [Group] 实例创建的时候查询一次. 并与事件同步事件更新
|
||||
* 在 {@link Group} 实例创建的时候查询一次. 并与事件同步事件更新
|
||||
* <p>
|
||||
* **注意**: 获得的列表仅为这一时刻的成员列表的镜像. 它将不会被更新
|
||||
*/
|
||||
@ -42,7 +44,7 @@ public interface BlockingGroup extends BlockingContact {
|
||||
Map<Long, BlockingMember> getMembers();
|
||||
|
||||
/**
|
||||
* 获取群成员. 若此 ID 的成员不存在, 则会抛出 [kotlin.NoSuchElementException]
|
||||
* 获取群成员. 若此 ID 的成员不存在, 则会抛出 {@link NoSuchElementException}
|
||||
*/
|
||||
@NotNull
|
||||
BlockingMember getMember(long id);
|
||||
|
@ -4,7 +4,6 @@ import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.BotAccount
|
||||
import net.mamoe.mirai.contact.GroupId
|
||||
import net.mamoe.mirai.contact.GroupInternalId
|
||||
import net.mamoe.mirai.data.AddFriendResult
|
||||
import net.mamoe.mirai.data.ImageLink
|
||||
@ -27,9 +26,8 @@ internal class BlockingBotImpl(private val bot: Bot) : BlockingBot {
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
override fun getGroups(): List<BlockingGroup> = bot.groups.delegate.toList().map { it.blocking() }
|
||||
|
||||
override fun getGroup(id: Long): BlockingGroup = runBlocking { bot.getGroup(id) }.blocking()
|
||||
override fun getGroup(id: GroupId): BlockingGroup = runBlocking { bot.getGroup(id) }.blocking()
|
||||
override fun getGroup(internalId: GroupInternalId): BlockingGroup = runBlocking { bot.getGroup(internalId) }.blocking()
|
||||
override fun getGroup(id: Long): BlockingGroup = runBlocking { bot.getGroup(id).blocking() }
|
||||
override fun getGroupByInternalId(internalId: Long): BlockingGroup = runBlocking { bot.getGroup(GroupInternalId(internalId)).blocking() }
|
||||
override fun getNetwork(): BotNetworkHandler = bot.network
|
||||
override fun login() = runBlocking { bot.login() }
|
||||
override fun getLink(image: Image): ImageLink = bot.run { runBlocking { image.getLink() } }
|
||||
|
Loading…
Reference in New Issue
Block a user