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
1e9b34a6
Commit
1e9b34a6
authored
Feb 29, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add low-level apis
parent
b2f07d71
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
37 deletions
+73
-37
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+23
-24
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+4
-13
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
...core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
+46
-0
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
1e9b34a6
...
...
@@ -96,7 +96,8 @@ internal abstract class QQAndroidBotBase constructor(
).
sendAndExpect
<
GroupInfoImpl
>(
retry
=
2
)
}
override
suspend
fun
queryGroupMemberList
(
groupUin
:
Long
,
groupCode
:
Long
,
ownerId
:
Long
):
Sequence
<
MemberInfo
>
=
network
.
run
{
override
suspend
fun
queryGroupMemberList
(
groupUin
:
Long
,
groupCode
:
Long
,
ownerId
:
Long
):
Sequence
<
MemberInfo
>
=
network
.
run
{
var
nextUin
=
0L
var
sequence
=
sequenceOf
<
MemberInfoImpl
>()
while
(
true
)
{
...
...
@@ -137,26 +138,24 @@ internal abstract class QQAndroidBotBase constructor(
source
.
sequenceId
,
source
.
messageRandom
,
source
.
time
)
.
sendAndExpect
()
).
sendAndExpect
()
}
else
{
PbMessageSvc
.
PbMsgWithDraw
.
Group
(
bot
.
client
,
source
.
groupId
,
source
.
sequenceId
,
source
.
messageRandom
)
.
sendAndExpect
()
).
sendAndExpect
()
}
check
(
response
is
PbMessageSvc
.
PbMsgWithDraw
.
Response
.
Success
)
{
"Failed to recall message #${source.id}: $response"
}
}
}
override
suspend
fun
_lowLevelRecallFriendMessage
(
friendId
:
Long
,
messageId
:
Long
)
{
override
suspend
fun
_lowLevelRecallFriendMessage
(
friendId
:
Long
,
messageId
:
Long
,
time
:
Long
)
{
network
.
run
{
val
response
:
PbMessageSvc
.
PbMsgWithDraw
.
Response
=
PbMessageSvc
.
PbMsgWithDraw
.
Friend
(
client
,
friendId
,
(
messageId
shr
32
).
toInt
(),
messageId
.
toInt
(),
0
)
PbMessageSvc
.
PbMsgWithDraw
.
Friend
(
client
,
friendId
,
(
messageId
shr
32
).
toInt
(),
messageId
.
toInt
(),
time
)
.
sendAndExpect
()
check
(
response
is
PbMessageSvc
.
PbMsgWithDraw
.
Response
.
Success
)
{
"Failed to recall message #${messageId}: $response"
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
1e9b34a6
...
...
@@ -42,7 +42,7 @@ import kotlin.jvm.JvmStatic
* @see kotlinx.coroutines.isActive 判断 [Bot] 是否正常运行中. (在线, 且没有被 [close])
*/
@UseExperimental
(
MiraiInternalAPI
::
class
)
abstract
class
Bot
:
CoroutineScope
{
abstract
class
Bot
:
CoroutineScope
,
LowLevelBotAPIAccessor
{
companion
object
{
/**
* 复制一份此时的 [Bot] 实例列表.
...
...
@@ -214,22 +214,13 @@ abstract class Bot : CoroutineScope {
* @param source 消息源. 可从 [MessageReceipt.source] 获得, 或从消息事件中的 [MessageChain] 获得.
*
* @throws PermissionDeniedException 当 [Bot] 无权限操作时
*
* @see Bot.recall (扩展函数) 接受参数 [MessageChain]
* @see _lowLevelRecallFriendMessage 低级 API
* @see _lowLevelRecallGroupMessage 低级 API
*/
abstract
suspend
fun
recall
(
source
:
MessageSource
)
/**
* 撤回一条由机器人发送给好友的消息
*/
@MiraiExperimentalAPI
abstract
suspend
fun
_lowLevelRecallFriendMessage
(
friendId
:
Long
,
messageId
:
Long
)
/**
* 撤回一条群里的消息. 可以是机器人发送也可以是其他群员发送.
*/
@MiraiExperimentalAPI
abstract
suspend
fun
_lowLevelRecallGroupMessage
(
groupId
:
Long
,
messageId
:
Long
)
/**
* 获取图片下载链接
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
0 → 100644
View file @
1e9b34a6
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
net.mamoe.mirai
import
net.mamoe.mirai.message.data.MessageSource
import
net.mamoe.mirai.utils.MiraiExperimentalAPI
/**
* 标示这个 API 是低级的 API.
*
* 使用低级的 API 无法带来任何安全和便捷保障.
* 仅在某些使用结构化 API 可能影响性能的情况下使用这些低级 API.
*/
@Retention
(
AnnotationRetention
.
BINARY
)
@Target
(
AnnotationTarget
.
CLASS
,
AnnotationTarget
.
TYPE
,
AnnotationTarget
.
FUNCTION
,
AnnotationTarget
.
PROPERTY
)
annotation
class
LowLevelAPI
/**
* [Bot] 相关协议层低级 API.
*/
@MiraiExperimentalAPI
@Suppress
(
"FunctionName"
,
"unused"
)
@LowLevelAPI
interface
LowLevelBotAPIAccessor
{
/**
* 撤回一条由机器人发送给好友的消息
* @param messageId [MessageSource.id]
*/
@MiraiExperimentalAPI
(
"还未实现"
)
@LowLevelAPI
suspend
fun
_lowLevelRecallFriendMessage
(
friendId
:
Long
,
messageId
:
Long
,
time
:
Long
)
/**
* 撤回一条群里的消息. 可以是机器人发送也可以是其他群员发送.
* @param messageId [MessageSource.id]
*/
@LowLevelAPI
suspend
fun
_lowLevelRecallGroupMessage
(
groupId
:
Long
,
messageId
:
Long
)
}
\ No newline at end of file
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