Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
7731a432
Commit
7731a432
authored
Jan 18, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use long instead of inline classes
parent
4ef6f7e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
21 deletions
+12
-21
mirai-japt/src/main/java/net/mamoe/mirai/japt/BlockingBot.java
...-japt/src/main/java/net/mamoe/mirai/japt/BlockingBot.java
+1
-10
mirai-japt/src/main/java/net/mamoe/mirai/japt/BlockingContacts.java
.../src/main/java/net/mamoe/mirai/japt/BlockingContacts.java
+1
-1
mirai-japt/src/main/java/net/mamoe/mirai/japt/BlockingGroup.java
...apt/src/main/java/net/mamoe/mirai/japt/BlockingGroup.java
+8
-6
mirai-japt/src/main/kotlin/net/mamoe/mirai/japt/BlockingBotImpl.kt
...t/src/main/kotlin/net/mamoe/mirai/japt/BlockingBotImpl.kt
+2
-4
No files found.
mirai-japt/src/main/java/net/mamoe/mirai/japt/BlockingBot.java
View file @
7731a432
...
...
@@ -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
getGroup
ByInternalId
(
long
internalId
);
// endregion
...
...
mirai-japt/src/main/java/net/mamoe/mirai/japt/BlockingContacts.java
View file @
7731a432
...
...
@@ -21,7 +21,7 @@ public final class BlockingContacts {
return
new
BlockingMemberImpl
(
member
);
}
public
static
BlockingBot
Impl
createBlocking
(
Bot
bot
)
{
public
static
BlockingBot
createBlocking
(
Bot
bot
)
{
return
new
BlockingBotImpl
(
bot
);
}
}
mirai-japt/src/main/java/net/mamoe/mirai/japt/BlockingGroup.java
View file @
7731a432
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
);
...
...
mirai-japt/src/main/kotlin/net/mamoe/mirai/japt/BlockingBotImpl.kt
View file @
7731a432
...
...
@@ -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
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment