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
dc7d73f1
Commit
dc7d73f1
authored
Mar 03, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Misc improvements
parent
cadbd7ff
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
39 deletions
+45
-39
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+11
-3
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
.../jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+1
-2
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt
+0
-11
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+1
-10
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
...core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
+31
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
+0
-11
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
dc7d73f1
...
...
@@ -542,7 +542,7 @@ internal class GroupImpl(
@UseExperimental
(
MiraiExperimentalAPI
::
class
)
override
fun
Member
(
memberInfo
:
MemberInfo
):
Member
{
return
MemberImpl
(
bot
.
QQ
(
memberInfo
)
as
QQImpl
,
bot
.
_lowLevelNewQQ
QQ
(
memberInfo
)
as
QQImpl
,
this
,
this
.
coroutineContext
,
memberInfo
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
dc7d73f1
...
...
@@ -12,6 +12,7 @@ package net.mamoe.mirai.qqandroid
import
io.ktor.client.request.get
import
io.ktor.client.statement.HttpResponse
import
io.ktor.utils.io.ByteReadChannel
import
kotlinx.coroutines.CoroutineName
import
net.mamoe.mirai.BotAccount
import
net.mamoe.mirai.BotImpl
import
net.mamoe.mirai.LowLevelAPI
...
...
@@ -67,14 +68,21 @@ internal abstract class QQAndroidBotBase constructor(
override
val
friends
:
ContactList
<
QQ
>
=
ContactList
(
LockFreeLinkedList
())
override
val
selfQQ
:
QQ
by
lazy
{
QQ
(
object
:
FriendInfo
{
@UseExperimental
(
LowLevelAPI
::
class
)
_lowLevelNewQQ
(
object
:
FriendInfo
{
override
val
uin
:
Long
get
()
=
this
@QQAndroidBotBase
.
uin
override
val
nick
:
String
get
()
=
this
@QQAndroidBotBase
.
nick
})
}
override
fun
QQ
(
friendInfo
:
FriendInfo
):
QQ
{
return
QQImpl
(
this
as
QQAndroidBot
,
coroutineContext
,
friendInfo
.
uin
,
friendInfo
)
@LowLevelAPI
override
fun
_lowLevelNewQQ
(
friendInfo
:
FriendInfo
):
QQ
{
return
QQImpl
(
this
as
QQAndroidBot
,
coroutineContext
+
CoroutineName
(
"QQ(${friendInfo.uin}"
),
friendInfo
.
uin
,
friendInfo
)
}
override
fun
createNetworkHandler
(
coroutineContext
:
CoroutineContext
):
QQAndroidBotNetworkHandler
{
...
...
mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
dc7d73f1
...
...
@@ -24,5 +24,4 @@ internal actual class QQAndroidBot actual constructor(
context
:
Context
,
account
:
BotAccount
,
configuration
:
BotConfiguration
)
:
QQAndroidBotBase
(
context
,
account
,
configuration
)
)
:
QQAndroidBotBase
(
context
,
account
,
configuration
)
\ No newline at end of file
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt
View file @
dc7d73f1
...
...
@@ -4,10 +4,8 @@ package net.mamoe.mirai
import
io.ktor.utils.io.ByteReadChannel
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Job
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.data.FriendInfo
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.MessageChain
...
...
@@ -127,15 +125,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
?:
throw
NoSuchElementException
(
"No such friend $id for bot ${this.uin}"
)
}
/**
* 构造一个 [QQ] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
*
* [Bot] 无法管理这个对象, 但这个对象会以 [Bot] 的 [Job] 作为父 Job.
* 因此, 当 [Bot] 被关闭后, 这个对象也会被关闭.
*/
@Suppress
(
"FunctionName"
)
actual
abstract
fun
QQ
(
friendInfo
:
FriendInfo
):
QQ
/**
* 机器人加入的群列表.
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
dc7d73f1
...
...
@@ -18,7 +18,6 @@ import kotlinx.coroutines.Job
import
kotlinx.coroutines.launch
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.data.FriendInfo
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.MessageChain
...
...
@@ -96,7 +95,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
// region contacts
/**
* [
QQ.id] 与 [Bot.uin] 相同的 [
QQ] 实例
* [
_lowLevelNewQQ.id] 与 [Bot.uin] 相同的 [_lowLevelNew
QQ] 实例
*/
abstract
val
selfQQ
:
QQ
...
...
@@ -136,14 +135,6 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
*/
fun
getFriend
(
id
:
Long
):
QQ
/**
* 构造一个 [QQ] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
*
* [Bot] 无法管理这个对象, 但这个对象会以 [Bot] 的 [Job] 作为父 Job.
* 因此, 当 [Bot] 被关闭后, 这个对象也会被关闭.
*/
abstract
fun
QQ
(
friendInfo
:
FriendInfo
):
QQ
/**
* 机器人加入的群列表.
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
View file @
dc7d73f1
...
...
@@ -9,11 +9,15 @@
package
net.mamoe.mirai
import
kotlinx.coroutines.Job
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.QQ
import
net.mamoe.mirai.data.FriendInfo
import
net.mamoe.mirai.data.GroupInfo
import
net.mamoe.mirai.data.MemberInfo
import
net.mamoe.mirai.message.data.MessageSource
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
import
net.mamoe.mirai.utils.WeakRef
/**
* 标示这个 API 是低级的 API.
...
...
@@ -35,7 +39,16 @@ annotation class LowLevelAPI
interface
LowLevelBotAPIAccessor
{
/**
* 向服务器查询群列表. 返回值前 32 bits 为 uin, 后 32 bits 为 groupCode
* 构造一个 [_lowLevelNewQQ] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
*
* [Bot] 无法管理这个对象, 但这个对象会以 [Bot] 的 [Job] 作为父 Job.
* 因此, 当 [Bot] 被关闭后, 这个对象也会被关闭.
*/
@LowLevelAPI
fun
_lowLevelNewQQ
(
friendInfo
:
FriendInfo
):
QQ
/**
* 向服务器查询群列表. 返回值高 32 bits 为 uin, 低 32 bits 为 groupCode
*/
@LowLevelAPI
suspend
fun
_lowLevelQueryGroupList
():
Sequence
<
Long
>
...
...
@@ -72,4 +85,21 @@ interface LowLevelBotAPIAccessor {
*/
@LowLevelAPI
suspend
fun
_lowLevelRecallGroupMessage
(
groupId
:
Long
,
messageId
:
Long
)
}
/**
* 撤回一条群里的消息. 可以是机器人发送也可以是其他群员发送.
*/
@Suppress
(
"FunctionName"
)
@MiraiExperimentalAPI
@LowLevelAPI
suspend
fun
LowLevelBotAPIAccessor
.
_lowLevelRecallGroupMessage
(
groupId
:
Long
,
messageSequenceId
:
Int
,
messageRandom
:
Int
)
{
this
.
_lowLevelRecallGroupMessage
(
groupId
,
messageSequenceId
.
toLong
().
shl
(
32
)
or
messageRandom
.
toLong
().
and
(
0
xFFFFFFFFL
)
)
}
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
View file @
dc7d73f1
...
...
@@ -4,10 +4,8 @@ package net.mamoe.mirai
import
io.ktor.utils.io.ByteReadChannel
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Job
import
net.mamoe.mirai.contact.*
import
net.mamoe.mirai.data.AddFriendResult
import
net.mamoe.mirai.data.FriendInfo
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.MessageChain
...
...
@@ -137,15 +135,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
?:
throw
NoSuchElementException
(
"No such friend $id for bot ${this.uin}"
)
}
/**
* 构造一个 [QQ] 对象. 它持有对 [Bot] 的弱引用([WeakRef]).
*
* [Bot] 无法管理这个对象, 但这个对象会以 [Bot] 的 [Job] 作为父 Job.
* 因此, 当 [Bot] 被关闭后, 这个对象也会被关闭.
*/
@Suppress
(
"FunctionName"
)
actual
abstract
fun
QQ
(
friendInfo
:
FriendInfo
):
QQ
/**
* 机器人加入的群列表.
*/
...
...
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