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
e57215a6
Commit
e57215a6
authored
Mar 14, 2020
by
luo123
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
send announcement
parent
aa61e944
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
22 deletions
+74
-22
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
...ommonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+40
-9
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/WtLogin.kt
.../mirai/qqandroid/network/protocol/packet/login/WtLogin.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
...re/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
+8
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/GroupAnnouncement.kt
...mmonMain/kotlin/net.mamoe.mirai/data/GroupAnnouncement.kt
+16
-11
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Group.kt
...-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Group.kt
+9
-1
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
View file @
e57215a6
...
@@ -579,9 +579,9 @@ internal class GroupImpl(
...
@@ -579,9 +579,9 @@ internal class GroupImpl(
append
(
"qid"
,
id
)
append
(
"qid"
,
id
)
append
(
"bkn"
,
getBkn
())
append
(
"bkn"
,
getBkn
())
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
)
append
(
"ni"
,
if
(
page
==
1
)
1
else
0
)
append
(
"ni"
,
if
(
page
==
1
)
1
else
0
)
append
(
"format"
,
"json"
)
append
(
"format"
,
"json"
)
})
})
headers
{
headers
{
...
@@ -594,12 +594,43 @@ internal class GroupImpl(
...
@@ -594,12 +594,43 @@ internal class GroupImpl(
}
}
val
rep
=
data
.
await
()
val
rep
=
data
.
await
()
bot
.
network
.
logger
.
error
(
rep
)
// bot.network.logger.error(rep)
return
json
.
parse
(
GroupAnnouncementList
.
serializer
(),
rep
)
return
json
.
parse
(
GroupAnnouncementList
.
serializer
(),
rep
)
}
}
@MiraiExperimentalAPI
override
suspend
fun
sendAnnouncement
(
announcement
:
GroupAnnouncement
)
{
val
json
=
Json
(
JsonConfiguration
.
Stable
)
bot
.
network
.
launch
{
HttpClient
().
post
<
String
>
{
url
(
"https://web.qun.qq.com/cgi-bin/announce/add_qun_notice"
)
body
=
MultiPartFormDataContent
(
formData
{
append
(
"qid"
,
id
)
append
(
"bkn"
,
getBkn
())
append
(
"text"
,
announcement
.
msg
.
text
)
append
(
"pinned"
,
announcement
.
pinned
)
append
(
"settings"
,
json
.
stringify
(
GroupAnnouncementSettings
.
serializer
(),
announcement
.
settings
?:
GroupAnnouncementSettings
()))
append
(
"format"
,
"json"
)
})
headers
{
append
(
"cookie"
,
"uin=o${bot.selfQQ.id};"
+
" skey=${bot.client.wLoginSigInfo.sKey.data.encodeToString()};"
+
" p_uin=o${bot.selfQQ.id};"
+
" p_skey=${bot.client.wLoginSigInfo.psKeyMap["
qun
.
qq
.
com
"]?.data?.encodeToString()}; "
)
}
}.
also
{
val
jsonObj
=
json
.
parseJson
(
it
)
if
(
jsonObj
.
jsonObject
[
"ec"
]
?.
int
?:
1
!=
0
){
throw
IllegalStateException
(
"Send Announcement fail group:$id msg:${jsonObj.jsonObject["
em
"]} content:${announcement.msg.text}"
)
}
}
}
}
@OptIn
(
MiraiExperimentalAPI
::
class
)
@OptIn
(
MiraiExperimentalAPI
::
class
)
override
fun
Member
(
memberInfo
:
MemberInfo
):
Member
{
override
fun
Member
(
memberInfo
:
MemberInfo
):
Member
{
return
MemberImpl
(
return
MemberImpl
(
...
@@ -761,10 +792,10 @@ internal class GroupImpl(
...
@@ -761,10 +792,10 @@ internal class GroupImpl(
return this.id == other.id && this.bot == other.bot
return this.id == other.id && this.bot == other.bot
}
}
/*
/*
*
* 获取 获取群公告 所需的bkn参数
* 获取 获取群公告 所需的bkn参数
* */
* */
fun get
Bkn
():
Int
{
private
fun get
Bkn
():
Int
{
val
str
=
bot
.
client
.
wLoginSigInfo
.
sKey
.
data
.
encodeToString
()
val
str
=
bot
.
client
.
wLoginSigInfo
.
sKey
.
data
.
encodeToString
()
var
magic
=
5381
var
magic
=
5381
for
(
i
in
str
)
{
for
(
i
in
str
)
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/WtLogin.kt
View file @
e57215a6
...
@@ -602,7 +602,7 @@ internal class WtLogin {
...
@@ -602,7 +602,7 @@ internal class WtLogin {
userA5
=
UserA5
(
tlvMap119
.
getOrEmpty
(
0
x10b
),
creationTime
),
userA5
=
UserA5
(
tlvMap119
.
getOrEmpty
(
0
x10b
),
creationTime
),
userA8
=
UserA8
(
tlvMap119
.
getOrEmpty
(
0
x102
),
creationTime
,
expireTime
)
userA8
=
UserA8
(
tlvMap119
.
getOrEmpty
(
0
x102
),
creationTime
,
expireTime
)
)
)
//bot.network.logger.error(client.wLoginSigInfo.
sKey.data
.encodeToString())
//bot.network.logger.error(client.wLoginSigInfo.
psKeyMap["qun.qq.com"]?.data?
.encodeToString())
}
}
}
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
View file @
e57215a6
...
@@ -16,6 +16,7 @@ import kotlinx.serialization.SerialInfo
...
@@ -16,6 +16,7 @@ import kotlinx.serialization.SerialInfo
import
kotlinx.serialization.SerialName
import
kotlinx.serialization.SerialName
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.data.GroupAnnouncement
import
net.mamoe.mirai.data.GroupAnnouncementList
import
net.mamoe.mirai.data.GroupAnnouncementList
import
net.mamoe.mirai.data.MemberInfo
import
net.mamoe.mirai.data.MemberInfo
import
net.mamoe.mirai.event.events.*
import
net.mamoe.mirai.event.events.*
...
@@ -159,6 +160,13 @@ expect abstract class Group() : Contact, CoroutineScope {
...
@@ -159,6 +160,13 @@ expect abstract class Group() : Contact, CoroutineScope {
@MiraiExperimentalAPI
@MiraiExperimentalAPI
abstract
suspend
fun
getAnnouncements
(
page
:
Int
=
1
,
amount
:
Int
=
10
):
GroupAnnouncementList
?
abstract
suspend
fun
getAnnouncements
(
page
:
Int
=
1
,
amount
:
Int
=
10
):
GroupAnnouncementList
?
/**
* 发送群公告
*
* */
@MiraiExperimentalAPI
abstract
suspend
fun
sendAnnouncement
(
announcement
:
GroupAnnouncement
)
/**
/**
* 让机器人退出这个群. 机器人必须为非群主才能退出. 否则将会失败
* 让机器人退出这个群. 机器人必须为非群主才能退出. 否则将会失败
*/
*/
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/GroupAnnouncement.kt
View file @
e57215a6
...
@@ -7,34 +7,39 @@ import kotlinx.serialization.Serializable
...
@@ -7,34 +7,39 @@ import kotlinx.serialization.Serializable
* 群公告数据类
* 群公告数据类
* getGroupAnnouncementList时,如果page=1,那么你可以在inst里拿到一些置顶公告
* getGroupAnnouncementList时,如果page=1,那么你可以在inst里拿到一些置顶公告
*
*
* 发公告时只需要填写text,
*
*
*/
*/
@Serializable
@Serializable
data class
GroupAnnouncementList
(
data class
GroupAnnouncementList
(
val
ec
:
Int
,
//状态码 0 是正常的
val
ec
:
Int
,
//状态码 0 是正常的
@SerialName
(
"em"
)
val
msg
:
String
,
//信息
@SerialName
(
"em"
)
val
msg
:
String
,
//信息
val
feeds
:
List
<
GroupAnnouncement
>?,
//群公告列表
val
feeds
:
List
<
GroupAnnouncement
>?
=
null
,
//群公告列表
val
inst
:
List
<
GroupAnnouncement
>?
//置顶列表?
val
inst
:
List
<
GroupAnnouncement
>?
=
null
//置顶列表?
)
)
@Serializable
@Serializable
data class
GroupAnnouncement
(
data class
GroupAnnouncement
(
@SerialName
(
"u"
)
val
sender
:
Long
,
@SerialName
(
"u"
)
val
sender
:
Long
=
0
,
val
msg
:
GroupAnnouncementMsg
,
val
msg
:
GroupAnnouncementMsg
,
val
settings
:
GroupAnnouncementSettings
val
settings
:
GroupAnnouncementSettings
?
=
null
,
@SerialName
(
"pubt"
)
val
time
:
Long
=
0
,
@SerialName
(
"read_num"
)
val
readNum
:
Int
=
0
,
@SerialName
(
"is_read"
)
val
isRead
:
Int
=
0
,
val
pinned
:
Int
=
0
)
)
@Serializable
@Serializable
data class
GroupAnnouncementMsg
(
data class
GroupAnnouncementMsg
(
val
text
:
String
,
val
text
:
String
,
val
text_face
:
String
,
val
text_face
:
String
?
=
null
,
val
title
:
String
val
title
:
String
?
=
null
)
)
@Serializable
@Serializable
data class
GroupAnnouncementSettings
(
data class
GroupAnnouncementSettings
(
@SerialName
(
"is_show_edit_card"
)
val
isShowEditCard
:
Int
,
@SerialName
(
"is_show_edit_card"
)
val
isShowEditCard
:
Int
=
0
,
@SerialName
(
"remind_ts"
)
val
remindTs
:
Int
,
@SerialName
(
"remind_ts"
)
val
remindTs
:
Int
=
0
,
@SerialName
(
"tip_window_type"
)
val
tipWindowType
:
Int
,
@SerialName
(
"tip_window_type"
)
val
tipWindowType
:
Int
=
0
,
@SerialName
(
"confirm_required"
)
val
confirmRequired
:
Int
@SerialName
(
"confirm_required"
)
val
confirmRequired
:
Int
=
0
)
)
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Group.kt
View file @
e57215a6
...
@@ -11,6 +11,7 @@ package net.mamoe.mirai.contact
...
@@ -11,6 +11,7 @@ package net.mamoe.mirai.contact
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.CoroutineScope
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.data.GroupAnnouncement
import
net.mamoe.mirai.data.GroupAnnouncementList
import
net.mamoe.mirai.data.GroupAnnouncementList
import
net.mamoe.mirai.data.MemberInfo
import
net.mamoe.mirai.data.MemberInfo
import
net.mamoe.mirai.event.events.*
import
net.mamoe.mirai.event.events.*
...
@@ -153,7 +154,14 @@ actual abstract class Group : Contact(), CoroutineScope {
...
@@ -153,7 +154,14 @@ actual abstract class Group : Contact(), CoroutineScope {
*
*
* */
* */
@MiraiExperimentalAPI
@MiraiExperimentalAPI
actual
suspend
abstract
fun
getAnnouncements
(
page
:
Int
,
amount
:
Int
):
GroupAnnouncementList
?
actual
suspend
abstract
fun
getAnnouncements
(
page
:
Int
,
amount
:
Int
):
GroupAnnouncementList
?
/**
* 发送群公告
* */
@MiraiExperimentalAPI
actual
suspend
abstract
fun
sendAnnouncement
(
announcement
:
GroupAnnouncement
)
/**
/**
* 检查此 id 的群成员是否存在
* 检查此 id 的群成员是否存在
...
...
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