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
9ff791e5
Commit
9ff791e5
authored
Mar 14, 2020
by
luo123
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a little change
parent
6973488d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
30 deletions
+30
-30
README.md
README.md
+0
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
...mmonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
+26
-25
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
...core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
+4
-4
No files found.
README.md
View file @
9ff791e5
...
@@ -99,7 +99,6 @@ Demos: [mirai-demos](https://github.com/mamoe/mirai-demos)
...
@@ -99,7 +99,6 @@ Demos: [mirai-demos](https://github.com/mamoe/mirai-demos)
[
<img width="60px" height="60px" src="https://avatars0.githubusercontent.com/u/25280943?s=60&v=4" />
](
https://github.com/HoshinoTented
)
[
<img width="60px" height="60px" src="https://avatars0.githubusercontent.com/u/25280943?s=60&v=4" />
](
https://github.com/HoshinoTented
)
[
<img width="60px" height="60px" src="https://avatars3.githubusercontent.com/u/40517459?s=60&v=4" />
](
https://github.com/Cyenoch
)
[
<img width="60px" height="60px" src="https://avatars3.githubusercontent.com/u/40517459?s=60&v=4" />
](
https://github.com/Cyenoch
)
## 鸣谢
## 鸣谢
特别感谢
[
JetBrains
](
https://www.jetbrains.com/?from=mirai
)
为开源项目提供免费的
[
IntelliJ IDEA
](
https://www.jetbrains.com/idea/?from=mirai
)
等 IDE 的授权
特别感谢
[
JetBrains
](
https://www.jetbrains.com/?from=mirai
)
为开源项目提供免费的
[
IntelliJ IDEA
](
https://www.jetbrains.com/idea/?from=mirai
)
等 IDE 的授权
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt
View file @
9ff791e5
...
@@ -67,6 +67,10 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -67,6 +67,10 @@ internal abstract class QQAndroidBotBase constructor(
internal
var
firstLoginSucceed
:
Boolean
=
false
internal
var
firstLoginSucceed
:
Boolean
=
false
override
val
uin
:
Long
get
()
=
client
.
uin
override
val
uin
:
Long
get
()
=
client
.
uin
companion
object
{
val
json
=
Json
(
JsonConfiguration
(
ignoreUnknownKeys
=
true
,
encodeDefaults
=
true
))
}
@Deprecated
(
@Deprecated
(
"use friends instead"
,
"use friends instead"
,
level
=
DeprecationLevel
.
ERROR
,
level
=
DeprecationLevel
.
ERROR
,
...
@@ -206,7 +210,7 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -206,7 +210,7 @@ internal abstract class QQAndroidBotBase constructor(
}
}
}
}
@
OptIn
(
LowLevelAPI
::
class
)
@
LowLevelAPI
override
suspend
fun
_lowLevelRecallGroupMessage
(
groupId
:
Long
,
messageId
:
Long
)
{
override
suspend
fun
_lowLevelRecallGroupMessage
(
groupId
:
Long
,
messageId
:
Long
)
{
network
.
run
{
network
.
run
{
val
response
:
PbMessageSvc
.
PbMsgWithDraw
.
Response
=
val
response
:
PbMessageSvc
.
PbMsgWithDraw
.
Response
=
...
@@ -218,17 +222,15 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -218,17 +222,15 @@ internal abstract class QQAndroidBotBase constructor(
}
}
@LowLevelAPI
@OptIn
(
LowLevelAPI
::
class
)
@MiraiExperimentalAPI
@MiraiExperimentalAPI
override
suspend
fun
_lowLevelGetAnnouncements
(
groupId
:
Long
,
page
:
Int
,
amount
:
Int
):
GroupAnnouncementList
?
{
override
suspend
fun
_lowLevelGetAnnouncements
(
groupId
:
Long
,
page
:
Int
,
amount
:
Int
):
GroupAnnouncementList
{
val
json
=
Json
(
JsonConfiguration
(
ignoreUnknownKeys
=
true
))
val
data
=
network
.
async
{
val
data
=
network
.
async
{
HttpClient
().
post
<
String
>
{
HttpClient
().
post
<
String
>
{
url
(
"https://web.qun.qq.com/cgi-bin/announce/list_announce"
)
url
(
"https://web.qun.qq.com/cgi-bin/announce/list_announce"
)
body
=
MultiPartFormDataContent
(
formData
{
body
=
MultiPartFormDataContent
(
formData
{
append
(
"qid"
,
groupId
)
append
(
"qid"
,
groupId
)
append
(
"bkn"
,
getBkn
()
)
append
(
"bkn"
,
bkn
)
append
(
"ft"
,
23
)
//好像是一个用来识别应用的参数
append
(
"ft"
,
23
)
//好像是一个用来识别应用的参数
append
(
"s"
,
if
(
page
==
1
)
0
else
-(
page
*
amount
+
1
))
// 第一页这里的参数应该是-1
append
(
"s"
,
if
(
page
==
1
)
0
else
-(
page
*
amount
+
1
))
// 第一页这里的参数应该是-1
append
(
"n"
,
amount
)
append
(
"n"
,
amount
)
...
@@ -249,16 +251,15 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -249,16 +251,15 @@ internal abstract class QQAndroidBotBase constructor(
return
json
.
parse
(
GroupAnnouncementList
.
serializer
(),
rep
)
return
json
.
parse
(
GroupAnnouncementList
.
serializer
(),
rep
)
}
}
@
OptIn
(
LowLevelAPI
::
class
)
@
LowLevelAPI
@MiraiExperimentalAPI
@MiraiExperimentalAPI
override
suspend
fun
_lowLevelSendAnnouncement
(
groupId
:
Long
,
announcement
:
GroupAnnouncement
):
String
{
override
suspend
fun
_lowLevelSendAnnouncement
(
groupId
:
Long
,
announcement
:
GroupAnnouncement
):
String
{
val
json
=
Json
(
JsonConfiguration
.
Stable
)
val
rep
=
network
.
async
{
val
rep
=
network
.
async
{
HttpClient
().
post
<
String
>
{
HttpClient
().
post
<
String
>
{
url
(
"https://web.qun.qq.com/cgi-bin/announce/add_qun_notice"
)
url
(
"https://web.qun.qq.com/cgi-bin/announce/add_qun_notice"
)
body
=
MultiPartFormDataContent
(
formData
{
body
=
MultiPartFormDataContent
(
formData
{
append
(
"qid"
,
groupId
)
append
(
"qid"
,
groupId
)
append
(
"bkn"
,
getBkn
()
)
append
(
"bkn"
,
bkn
)
append
(
"text"
,
announcement
.
msg
.
text
)
append
(
"text"
,
announcement
.
msg
.
text
)
append
(
"pinned"
,
announcement
.
pinned
)
append
(
"pinned"
,
announcement
.
pinned
)
append
(
append
(
...
@@ -285,16 +286,16 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -285,16 +286,16 @@ internal abstract class QQAndroidBotBase constructor(
return
jsonObj
.
jsonObject
[
"new_fid"
]
?.
primitive
?.
content
return
jsonObj
.
jsonObject
[
"new_fid"
]
?.
primitive
?.
content
?:
throw
throw
IllegalStateException
(
"Send Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} content:${announcement.msg.text}"
)
?:
throw
throw
IllegalStateException
(
"Send Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} content:${announcement.msg.text}"
)
}
}
@OptIn
(
LowLevelAPI
::
class
)
@LowLevelAPI
@MiraiExperimentalAPI
@MiraiExperimentalAPI
override
suspend
fun
_lowLevelDeleteAnnouncement
(
groupId
:
Long
,
fid
:
String
)
{
override
suspend
fun
_lowLevelDeleteAnnouncement
(
groupId
:
Long
,
fid
:
String
)
{
val
json
=
Json
(
JsonConfiguration
.
Stable
)
val
rep
=
network
.
async
{
val
rep
=
network
.
async
{
HttpClient
().
post
<
String
>
{
HttpClient
().
post
<
String
>
{
url
(
"https://web.qun.qq.com/cgi-bin/announce/del_feed"
)
url
(
"https://web.qun.qq.com/cgi-bin/announce/del_feed"
)
body
=
MultiPartFormDataContent
(
formData
{
body
=
MultiPartFormDataContent
(
formData
{
append
(
"qid"
,
groupId
)
append
(
"qid"
,
groupId
)
append
(
"bkn"
,
getBkn
()
)
append
(
"bkn"
,
bkn
)
append
(
"fid"
,
fid
)
append
(
"fid"
,
fid
)
append
(
"format"
,
"json"
)
append
(
"format"
,
"json"
)
})
})
...
@@ -310,8 +311,8 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -310,8 +311,8 @@ internal abstract class QQAndroidBotBase constructor(
}
}
}
}
val
data
=
rep
.
await
()
val
data
=
rep
.
await
()
val
jsonObj
=
json
.
parseJson
(
data
)
val
jsonObj
=
json
.
parseJson
(
data
)
if
(
jsonObj
.
jsonObject
[
"ec"
]
?.
int
?:
1
!=
0
){
if
(
jsonObj
.
jsonObject
[
"ec"
]
?.
int
?:
1
!=
0
)
{
throw
throw
IllegalStateException
(
"delete Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} fid:$fid"
)
throw
throw
IllegalStateException
(
"delete Announcement fail group:$groupId msg:${jsonObj.jsonObject["
em
"]} fid:$fid"
)
}
}
}
}
...
@@ -319,13 +320,12 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -319,13 +320,12 @@ internal abstract class QQAndroidBotBase constructor(
@OptIn
(
LowLevelAPI
::
class
)
@OptIn
(
LowLevelAPI
::
class
)
@MiraiExperimentalAPI
@MiraiExperimentalAPI
override
suspend
fun
_lowLevelGetAnnouncement
(
groupId
:
Long
,
fid
:
String
):
GroupAnnouncement
{
override
suspend
fun
_lowLevelGetAnnouncement
(
groupId
:
Long
,
fid
:
String
):
GroupAnnouncement
{
val
json
=
Json
(
JsonConfiguration
(
ignoreUnknownKeys
=
true
))
val
data
=
network
.
async
{
val
data
=
network
.
async
{
HttpClient
().
post
<
String
>
{
HttpClient
().
post
<
String
>
{
url
(
"https://web.qun.qq.com/cgi-bin/announce/get_feed"
)
url
(
"https://web.qun.qq.com/cgi-bin/announce/get_feed"
)
body
=
MultiPartFormDataContent
(
formData
{
body
=
MultiPartFormDataContent
(
formData
{
append
(
"qid"
,
groupId
)
append
(
"qid"
,
groupId
)
append
(
"bkn"
,
getBkn
()
)
append
(
"bkn"
,
bkn
)
append
(
"fid"
,
fid
)
append
(
"fid"
,
fid
)
append
(
"format"
,
"json"
)
append
(
"format"
,
"json"
)
})
})
...
@@ -363,14 +363,15 @@ internal abstract class QQAndroidBotBase constructor(
...
@@ -363,14 +363,15 @@ internal abstract class QQAndroidBotBase constructor(
/**
/**
* 获取 获取群公告 所需的bkn参数
* 获取 获取群公告 所需的bkn参数
* */
* */
private
fun
getBkn
():
Int
{
val
bkn
:
Int
val
str
=
client
.
wLoginSigInfo
.
sKey
.
data
.
encodeToString
()
get
()
{
var
magic
=
5381
val
str
=
client
.
wLoginSigInfo
.
sKey
.
data
.
encodeToString
()
for
(
i
in
str
)
{
var
magic
=
5381
magic
+=
magic
.
shl
(
5
)
+
i
.
toInt
()
for
(
i
in
str
)
{
magic
+=
magic
.
shl
(
5
)
+
i
.
toInt
()
}
return
Int
.
MAX_VALUE
.
and
(
magic
)
}
}
return
Int
.
MAX_VALUE
.
and
(
magic
)
}
}
}
@Suppress
(
"DEPRECATION"
)
@Suppress
(
"DEPRECATION"
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
View file @
9ff791e5
...
@@ -99,7 +99,7 @@ interface LowLevelBotAPIAccessor {
...
@@ -99,7 +99,7 @@ interface LowLevelBotAPIAccessor {
* */
* */
@LowLevelAPI
@LowLevelAPI
@MiraiExperimentalAPI
@MiraiExperimentalAPI
suspend
fun
_lowLevelGetAnnouncements
(
groupId
:
Long
,
page
:
Int
=
1
,
amount
:
Int
=
10
):
GroupAnnouncementList
?
suspend
fun
_lowLevelGetAnnouncements
(
groupId
:
Long
,
page
:
Int
=
1
,
amount
:
Int
=
10
):
GroupAnnouncementList
/**
/**
* 发送群公告
* 发送群公告
...
@@ -108,7 +108,7 @@ interface LowLevelBotAPIAccessor {
...
@@ -108,7 +108,7 @@ interface LowLevelBotAPIAccessor {
* */
* */
@LowLevelAPI
@LowLevelAPI
@MiraiExperimentalAPI
@MiraiExperimentalAPI
suspend
fun
_lowLevelSendAnnouncement
(
groupId
:
Long
,
announcement
:
GroupAnnouncement
):
String
suspend
fun
_lowLevelSendAnnouncement
(
groupId
:
Long
,
announcement
:
GroupAnnouncement
):
String
/**
/**
...
@@ -117,7 +117,7 @@ interface LowLevelBotAPIAccessor {
...
@@ -117,7 +117,7 @@ interface LowLevelBotAPIAccessor {
* */
* */
@LowLevelAPI
@LowLevelAPI
@MiraiExperimentalAPI
@MiraiExperimentalAPI
suspend
fun
_lowLevelDeleteAnnouncement
(
groupId
:
Long
,
fid
:
String
)
suspend
fun
_lowLevelDeleteAnnouncement
(
groupId
:
Long
,
fid
:
String
)
/**
/**
* 获取一条群公告
* 获取一条群公告
...
@@ -125,7 +125,7 @@ interface LowLevelBotAPIAccessor {
...
@@ -125,7 +125,7 @@ interface LowLevelBotAPIAccessor {
* */
* */
@LowLevelAPI
@LowLevelAPI
@MiraiExperimentalAPI
@MiraiExperimentalAPI
suspend
fun
_lowLevelGetAnnouncement
(
groupId
:
Long
,
fid
:
String
):
GroupAnnouncement
suspend
fun
_lowLevelGetAnnouncement
(
groupId
:
Long
,
fid
:
String
):
GroupAnnouncement
}
}
...
...
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