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
e33fea8a
Commit
e33fea8a
authored
Feb 12, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove override
parent
80a3a9a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
19 deletions
+18
-19
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+5
-12
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+13
-7
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
e33fea8a
...
...
@@ -12,7 +12,10 @@ package net.mamoe.mirai.qqandroid
import
kotlinx.io.core.ByteReadPacket
import
net.mamoe.mirai.BotAccount
import
net.mamoe.mirai.BotImpl
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.contact.ContactList
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.QQ
import
net.mamoe.mirai.contact.filteringGetOrNull
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.event.events.BotEvent
import
net.mamoe.mirai.message.data.Image
...
...
@@ -40,12 +43,7 @@ internal abstract class QQAndroidBotBase constructor(
override
val
uin
:
Long
get
()
=
client
.
uin
override
val
qqs
:
ContactList
<
QQ
>
=
ContactList
(
LockFreeLinkedList
())
val
selfQQ
:
QQ
by
lazy
{
QQ
(
uin
)
}
override
fun
getFriend
(
id
:
Long
):
QQ
{
if
(
id
==
uin
)
return
selfQQ
return
qqs
.
delegate
[
id
]
}
override
val
selfQQ
:
QQ
by
lazy
{
QQ
(
uin
)
}
override
fun
QQ
(
id
:
Long
):
QQ
{
return
QQImpl
(
this
as
QQAndroidBot
,
coroutineContext
,
id
)
...
...
@@ -61,11 +59,6 @@ internal abstract class QQAndroidBotBase constructor(
return
groups
.
delegate
.
filteringGetOrNull
{
(
it
as
GroupImpl
).
uin
==
uin
}
?:
throw
NoSuchElementException
(
"Can not found group with ID=${uin}"
)
}
override
fun
getGroup
(
id
:
Long
):
Group
{
return
groups
.
delegate
.
getOrNull
(
id
)
?:
throw
NoSuchElementException
(
"Can not found group with GroupCode=${id}"
)
}
override
fun
onEvent
(
event
:
BotEvent
):
Boolean
{
return
firstLoginSucceed
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
e33fea8a
...
...
@@ -17,10 +17,7 @@ import kotlinx.io.OutputStream
import
kotlinx.io.core.ByteReadPacket
import
kotlinx.io.core.IoBuffer
import
kotlinx.io.core.use
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.ContactList
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.QQ
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.network.BotNetworkHandler
...
...
@@ -38,8 +35,8 @@ import net.mamoe.mirai.utils.toList
*
* @see Contact
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
abstract
class
Bot
:
CoroutineScope
{
@UseExperimental
(
MiraiInternalAPI
::
class
)
companion
object
{
/**
* 复制一份此时的 [Bot] 实例列表.
...
...
@@ -75,6 +72,8 @@ abstract class Bot : CoroutineScope {
// region contacts
abstract
val
selfQQ
:
QQ
/**
* 机器人的好友列表. 它将与服务器同步更新
*/
...
...
@@ -105,7 +104,11 @@ abstract class Bot : CoroutineScope {
/**
* 获取一个好友对象. 若没有这个好友, 则会抛出异常 [NoSuchElementException]
*/
abstract
fun
getFriend
(
id
:
Long
):
QQ
fun
getFriend
(
id
:
Long
):
QQ
{
if
(
id
==
uin
)
return
selfQQ
return
qqs
.
delegate
.
getOrNull
(
id
)
?:
throw
NoSuchElementException
(
"No such friend $id for bot ${this.uin}"
)
}
/**
* 构造一个 [QQ] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
...
...
@@ -123,7 +126,10 @@ abstract class Bot : CoroutineScope {
/**
* 获取一个机器人加入的群. 若没有这个群, 则会抛出异常 [NoSuchElementException]
*/
abstract
fun
getGroup
(
id
:
Long
):
Group
fun
getGroup
(
id
:
Long
):
Group
{
return
groups
.
delegate
.
getOrNull
(
id
)
?:
throw
NoSuchElementException
(
"No such group $id for bot ${this.uin}"
)
}
// TODO 目前还不能构造群对象. 这将在以后支持
...
...
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