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
85ea4563
Commit
85ea4563
authored
Feb 26, 2020
by
Him188
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
dc02278c
e951ea43
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
18 deletions
+22
-18
mirai-api-http/README_CH.md
mirai-api-http/README_CH.md
+12
-11
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt
...rc/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt
+1
-0
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt
...c/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt
+9
-7
No files found.
mirai-api-http/README_CH.md
View file @
85ea4563
...
@@ -96,16 +96,17 @@ fun main() {
...
@@ -96,16 +96,17 @@ fun main() {
}
}
```
```
| 状态码 | 原因 |
| 状态码 | 原因 |
| ------ | ----------------------------------- |
| ------ | ---------------------------------------- |
| 0 | 正常 |
| 0 | 正常 |
| 1 | 错误的auth key |
| 1 | 错误的auth key |
| 2 | 指定的Bot不存在 |
| 2 | 指定的Bot不存在(常发生在Session认证时) |
| 3 | Session失效或不存在 |
| 3 | Session失效或不存在 |
| 4 | Session未认证(未激活) |
| 4 | Session未认证(未激活) |
| 5 | 发送消息目标不存在(指定对象不存在) |
| 5 | 发送消息目标不存在(指定对象不存在) |
| 10 | 无操作权限,指Bot没有对应操作的限权 |
| 10 | 无操作权限,指Bot没有对应操作的限权 |
| 400 | 错误的访问,如参数错误等 |
| 20 | Bot被禁言,指Bot当前无法向指定群发送消息 |
| 400 | 错误的访问,如参数错误等 |
...
@@ -904,7 +905,7 @@ Content-Type:multipart/form-data
...
@@ -904,7 +905,7 @@ Content-Type:multipart/form-data
使用此方法获取群员资料
使用此方法获取群员资料
```
```
[Get] /
groupConfig
?sessionKey=YourSessionKey&target=123456789
[Get] /
memberInfo
?sessionKey=YourSessionKey&target=123456789
```
```
#### 请求:
#### 请求:
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt
View file @
85ea4563
...
@@ -20,6 +20,7 @@ open class StateCode(val code: Int, var msg: String) : DTO {
...
@@ -20,6 +20,7 @@ open class StateCode(val code: Int, var msg: String) : DTO {
object
NotVerifySession
:
StateCode
(
4
,
"Session未认证"
)
object
NotVerifySession
:
StateCode
(
4
,
"Session未认证"
)
object
NoElement
:
StateCode
(
5
,
"指定对象不存在"
)
object
NoElement
:
StateCode
(
5
,
"指定对象不存在"
)
object
PermissionDenied
:
StateCode
(
10
,
"无操作权限"
)
object
PermissionDenied
:
StateCode
(
10
,
"无操作权限"
)
object
BotMuted
:
StateCode
(
20
,
"Bot被禁言"
)
// KS bug: 主构造器中不能有非字段参数 https://github.com/Kotlin/kotlinx.serialization/issues/575
// KS bug: 主构造器中不能有非字段参数 https://github.com/Kotlin/kotlinx.serialization/issues/575
@Serializable
@Serializable
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt
View file @
85ea4563
...
@@ -126,17 +126,19 @@ internal inline fun <reified T : VerifyDTO> Route.miraiVerify(
...
@@ -126,17 +126,19 @@ internal inline fun <reified T : VerifyDTO> Route.miraiVerify(
internal
inline
fun
Route
.
intercept
(
crossinline
blk
:
suspend
PipelineContext
<
Unit
,
ApplicationCall
>.()
->
Unit
)
=
handle
{
internal
inline
fun
Route
.
intercept
(
crossinline
blk
:
suspend
PipelineContext
<
Unit
,
ApplicationCall
>.()
->
Unit
)
=
handle
{
try
{
try
{
blk
(
this
)
blk
(
this
)
}
catch
(
e
:
IllegalSessionException
)
{
}
catch
(
e
:
NoSuchBotException
)
{
// Bot不存在
call
.
respondStateCode
(
StateCode
.
NoBot
)
}
catch
(
e
:
IllegalSessionException
)
{
// Session过期
call
.
respondStateCode
(
StateCode
.
IllegalSession
)
call
.
respondStateCode
(
StateCode
.
IllegalSession
)
}
catch
(
e
:
NotVerifiedSessionException
)
{
}
catch
(
e
:
NotVerifiedSessionException
)
{
// Session未认证
call
.
respondStateCode
(
StateCode
.
NotVerifySession
)
call
.
respondStateCode
(
StateCode
.
NotVerifySession
)
}
catch
(
e
:
NoSuchBotException
)
{
}
catch
(
e
:
NoSuchElementException
)
{
// 指定对象不存在
call
.
respondStateCode
(
StateCode
.
NoBot
)
}
catch
(
e
:
NoSuchElementException
)
{
call
.
respondStateCode
(
StateCode
.
NoElement
)
call
.
respondStateCode
(
StateCode
.
NoElement
)
}
catch
(
e
:
PermissionDeniedException
)
{
}
catch
(
e
:
PermissionDeniedException
)
{
// 缺少权限
call
.
respondStateCode
(
StateCode
.
PermissionDenied
)
call
.
respondStateCode
(
StateCode
.
PermissionDenied
)
}
catch
(
e
:
IllegalAccessException
)
{
}
catch
(
e
:
IllegalStateException
)
{
// Bot被禁言
call
.
respondStateCode
(
StateCode
.
BotMuted
)
}
catch
(
e
:
IllegalAccessException
)
{
// 错误访问
call
.
respondStateCode
(
StateCode
(
400
,
e
.
message
),
HttpStatusCode
.
BadRequest
)
call
.
respondStateCode
(
StateCode
(
400
,
e
.
message
),
HttpStatusCode
.
BadRequest
)
}
catch
(
e
:
Throwable
)
{
}
catch
(
e
:
Throwable
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
...
...
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