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
b59ae076
Commit
b59ae076
authored
Feb 17, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add context getter
parent
aed2f3f7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+10
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
+2
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
b59ae076
...
...
@@ -43,7 +43,7 @@ internal abstract class QQAndroidBotBase constructor(
context
:
Context
,
account
:
BotAccount
,
configuration
:
BotConfiguration
)
:
BotImpl
<
QQAndroidBotNetworkHandler
>(
account
,
configuration
)
{
)
:
BotImpl
<
QQAndroidBotNetworkHandler
>(
context
,
account
,
configuration
)
{
val
client
:
QQAndroidClient
=
QQAndroidClient
(
context
,
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
b59ae076
...
...
@@ -44,7 +44,8 @@ abstract class Bot : CoroutineScope {
* 复制一份此时的 [Bot] 实例列表.
*/
@JvmStatic
val
instances
:
List
<
WeakRef
<
Bot
>>
get
()
=
BotImpl
.
instances
.
toList
()
val
instances
:
List
<
WeakRef
<
Bot
>>
get
()
=
BotImpl
.
instances
.
toList
()
/**
* 遍历每一个 [Bot] 实例
...
...
@@ -58,6 +59,14 @@ abstract class Bot : CoroutineScope {
fun
instanceWhose
(
qq
:
Long
):
Bot
=
BotImpl
.
instanceWhose
(
qq
=
qq
)
}
/**
* [Bot] 运行的 [Context].
*
* 在 JVM 的默认实现为 `class ContextImpl : Context`
* 在 Android 实现为 `android.content.Context`
*/
abstract
val
context
:
Context
/**
* 账号信息
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
View file @
b59ae076
...
...
@@ -32,6 +32,7 @@ import kotlin.coroutines.CoroutineContext
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
@MiraiInternalAPI
abstract
class
BotImpl
<
N
:
BotNetworkHandler
>
constructor
(
context
:
Context
,
account
:
BotAccount
,
val
configuration
:
BotConfiguration
)
:
Bot
(),
CoroutineScope
{
...
...
@@ -39,6 +40,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
override
val
coroutineContext
:
CoroutineContext
=
configuration
.
parentCoroutineContext
+
botJob
+
(
configuration
.
parentCoroutineContext
[
CoroutineExceptionHandler
]
?:
CoroutineExceptionHandler
{
_
,
e
->
logger
.
error
(
"An exception was thrown under a coroutine of Bot"
,
e
)
})
override
val
context
:
Context
by
context
.
unsafeWeakRef
()
@Suppress
(
"CanBePrimaryConstructorProperty"
)
// for logger
final
override
val
account
:
BotAccount
=
account
...
...
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