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
143e3e54
Commit
143e3e54
authored
Dec 15, 2019
by
liujiahua123123
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
98768dcb
f7710775
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
54 deletions
+43
-54
UpdateLog.md
UpdateLog.md
+4
-0
gradle.properties
gradle.properties
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt
...onMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/event/MessageEvent.kt
...e.mirai/network/protocol/tim/packet/event/MessageEvent.kt
+37
-34
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/MiraiEnvironmentJvm.kt
...src/jvmMain/kotlin/net/mamoe/mirai/MiraiEnvironmentJvm.kt
+0
-18
No files found.
UpdateLog.md
View file @
143e3e54
...
@@ -4,6 +4,10 @@
...
@@ -4,6 +4,10 @@
开发版本. 频繁更新, 不保证高稳定性
开发版本. 频繁更新, 不保证高稳定性
### `0.8.1` *2019/12/15*
-
修复有时群资料无法获取的情况
-
现在
`At.qq`
,
`Long.qq`
等函数不再是
`suspend`
### `0.8.0` *2019/12/14*
### `0.8.0` *2019/12/14*
协议
协议
-
现在查询群资料时可处理群号无效的情况
-
现在查询群资料时可处理群号无效的情况
...
...
gradle.properties
View file @
143e3e54
# style guide
# style guide
kotlin.code.style
=
official
kotlin.code.style
=
official
# config
# config
mirai_version
=
0.8.
0
mirai_version
=
0.8.
1
kotlin.incremental.multiplatform
=
true
kotlin.incremental.multiplatform
=
true
kotlin.parallel.tasks.in.project
=
true
kotlin.parallel.tasks.in.project
=
true
# kotlin
# kotlin
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt
View file @
143e3e54
...
@@ -139,7 +139,7 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
...
@@ -139,7 +139,7 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
@MessageDsl
@MessageDsl
suspend
inline
fun
always
(
noinline
onEvent
:
@MessageDsl
suspend
T
.(
String
)
->
Unit
)
{
suspend
inline
fun
always
(
noinline
onEvent
:
@MessageDsl
suspend
T
.(
String
)
->
Unit
)
{
content
({
true
},
onEvent
)
content
({
true
},
onEvent
)
}
// TODO: 2019/12/4 这些 onEvent 都应该为 crossinline, 而这会导致一个 CompilationException
}
// TODO: 2019/12/4 这些 onEvent 都应该为 cross
-
inline, 而这会导致一个 CompilationException
/**
/**
* 如果消息内容 `==` [equals], 就执行 [onEvent]
* 如果消息内容 `==` [equals], 就执行 [onEvent]
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet/event/MessageEvent.kt
View file @
143e3e54
...
@@ -17,7 +17,10 @@ import net.mamoe.mirai.network.protocol.tim.packet.PacketVersion
...
@@ -17,7 +17,10 @@ import net.mamoe.mirai.network.protocol.tim.packet.PacketVersion
import
net.mamoe.mirai.network.protocol.tim.packet.action.ImageLink
import
net.mamoe.mirai.network.protocol.tim.packet.action.ImageLink
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.internal.coerceAtLeastOrFail
import
net.mamoe.mirai.utils.internal.coerceAtLeastOrFail
import
net.mamoe.mirai.utils.io.*
import
net.mamoe.mirai.utils.io.printTLVMap
import
net.mamoe.mirai.utils.io.read
import
net.mamoe.mirai.utils.io.readTLVMap
import
net.mamoe.mirai.utils.io.readUShortLVByteArray
import
net.mamoe.mirai.withSession
import
net.mamoe.mirai.withSession
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmName
...
@@ -89,11 +92,11 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact> : EventPacket
...
@@ -89,11 +92,11 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact> : EventPacket
suspend
inline
fun
Image
.
download
():
ByteReadPacket
=
getLink
().
download
()
suspend
inline
fun
Image
.
download
():
ByteReadPacket
=
getLink
().
download
()
// endregion
// endregion
suspend
inline
fun
At
.
qq
():
QQ
=
bot
.
getQQ
(
this
.
target
)
fun
At
.
qq
():
QQ
=
bot
.
getQQ
(
this
.
target
)
suspend
inline
fun
Int
.
qq
():
QQ
=
bot
.
getQQ
(
this
.
coerceAtLeastOrFail
(
0
).
toUInt
())
fun
Int
.
qq
():
QQ
=
bot
.
getQQ
(
this
.
coerceAtLeastOrFail
(
0
).
toUInt
())
suspend
inline
fun
Long
.
qq
():
QQ
=
bot
.
getQQ
(
this
.
coerceAtLeastOrFail
(
0
))
fun
Long
.
qq
():
QQ
=
bot
.
getQQ
(
this
.
coerceAtLeastOrFail
(
0
))
suspend
inline
fun
UInt
.
qq
():
QQ
=
bot
.
getQQ
(
this
)
fun
UInt
.
qq
():
QQ
=
bot
.
getQQ
(
this
)
suspend
inline
fun
Int
.
group
():
Group
=
bot
.
getGroup
(
this
.
coerceAtLeastOrFail
(
0
).
toUInt
())
suspend
inline
fun
Int
.
group
():
Group
=
bot
.
getGroup
(
this
.
coerceAtLeastOrFail
(
0
).
toUInt
())
suspend
inline
fun
Long
.
group
():
Group
=
bot
.
getGroup
(
this
.
coerceAtLeastOrFail
(
0
))
suspend
inline
fun
Long
.
group
():
Group
=
bot
.
getGroup
(
this
.
coerceAtLeastOrFail
(
0
))
...
@@ -140,42 +143,42 @@ internal object GroupMessageEventParserAndHandler : KnownEventParserAndHandler<G
...
@@ -140,42 +143,42 @@ internal object GroupMessageEventParserAndHandler : KnownEventParserAndHandler<G
readUShortLVByteArray
()
readUShortLVByteArray
()
discardExact
(
2
)
//2个0x00
discardExact
(
2
)
//2个0x00
with
(
this
.
debugPrint
(
"群消息"
))
{
//debugPrintIfFail {
val
message
=
readMessageChain
()
val
message
=
readMessageChain
()
var
senderPermission
:
MemberPermission
=
MemberPermission
.
MEMBER
var
senderPermission
:
MemberPermission
=
MemberPermission
.
MEMBER
var
senderName
=
""
var
senderName
=
""
val
map
=
readTLVMap
(
true
)
val
map
=
readTLVMap
(
true
)
if
(
map
.
containsKey
(
18
u
))
{
if
(
map
.
containsKey
(
18
u
))
{
map
.
getValue
(
18
u
).
read
{
map
.
getValue
(
18
u
).
read
{
val
tlv
=
readTLVMap
(
true
)
val
tlv
=
readTLVMap
(
true
)
senderPermission
=
when
(
tlv
.
takeIf
{
it
.
containsKey
(
0
x04u
)
}
?.
get
(
0
x04u
)
?.
getOrNull
(
3
)
?.
toUInt
())
{
senderPermission
=
when
(
tlv
.
takeIf
{
it
.
containsKey
(
0
x04u
)
}
?.
get
(
0
x04u
)
?.
getOrNull
(
3
)
?.
toUInt
())
{
null
->
MemberPermission
.
MEMBER
null
->
MemberPermission
.
MEMBER
0
x08u
->
MemberPermission
.
OWNER
0
x08u
->
MemberPermission
.
OWNER
0
x10u
->
MemberPermission
.
ADMINISTRATOR
0
x10u
->
MemberPermission
.
ADMINISTRATOR
else
->
{
else
->
{
tlv
.
printTLVMap
(
"TLV(tag=18) Map"
)
tlv
.
printTLVMap
(
"TLV(tag=18) Map"
)
MiraiLogger
.
warning
(
"Could not determine member permission, default permission MEMBER is being used"
)
MiraiLogger
.
warning
(
"Could not determine member permission, default permission MEMBER is being used"
)
MemberPermission
.
MEMBER
MemberPermission
.
MEMBER
}
}
}
}
senderName
=
when
{
senderName
=
when
{
tlv
.
containsKey
(
0
x01u
)
->
String
(
tlv
.
getValue
(
0
x01u
))
//这个人的qq昵称
tlv
.
containsKey
(
0
x01u
)
->
String
(
tlv
.
getValue
(
0
x01u
))
//这个人的qq昵称
tlv
.
containsKey
(
0
x02u
)
->
String
(
tlv
.
getValue
(
0
x02u
))
//这个人的群名片
tlv
.
containsKey
(
0
x02u
)
->
String
(
tlv
.
getValue
(
0
x02u
))
//这个人的群名片
else
->
{
else
->
{
tlv
.
printTLVMap
(
"TLV(tag=18) Map"
)
tlv
.
printTLVMap
(
"TLV(tag=18) Map"
)
MiraiLogger
.
warning
(
"Could not determine senderName"
)
MiraiLogger
.
warning
(
"Could not determine senderName"
)
"null"
"null"
}
}
}
}
}
}
}
val
group
=
bot
.
getGroup
(
groupNumber
)
return
GroupMessage
(
group
,
senderName
,
senderPermission
,
group
.
getMember
(
qq
),
message
).
apply
{
this
.
botVar
=
bot
}
}
}
val
group
=
bot
.
getGroup
(
groupNumber
)
return
GroupMessage
(
group
,
senderName
,
senderPermission
,
group
.
getMember
(
qq
),
message
).
apply
{
this
.
botVar
=
bot
}
// }
}
}
}
}
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/MiraiEnvironmentJvm.kt
View file @
143e3e54
...
@@ -2,26 +2,8 @@
...
@@ -2,26 +2,8 @@
package
net.mamoe.mirai
package
net.mamoe.mirai
import
kotlinx.io.core.buildPacket
import
kotlinx.io.core.readBytes
import
net.mamoe.mirai.contact.GroupInternalId
import
net.mamoe.mirai.contact.toId
import
net.mamoe.mirai.utils.io.toByteArray
import
net.mamoe.mirai.utils.io.toUHexString
actual
object
MiraiEnvironment
{
actual
object
MiraiEnvironment
{
@JvmStatic
@JvmStatic
actual
val
platform
:
Platform
actual
val
platform
:
Platform
get
()
=
Platform
.
JVM
get
()
=
Platform
.
JVM
}
@ExperimentalUnsignedTypes
fun
main
()
{
println
(
GroupInternalId
(
2793514141
u
).
toId
().
value
.
toLong
())
println
(
GroupInternalId
(
2040208217
u
).
toId
().
value
.
toLong
())
println
(
289942298
u
.
toByteArray
().
toUHexString
())
println
(
1040400290
u
.
toByteArray
().
toUHexString
())
println
(
buildPacket
{
writeStringUtf8
(
"信用卡"
)
}.
readBytes
().
toUByteArray
().
toUHexString
())
}
}
\ 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