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
23dd54b3
Commit
23dd54b3
authored
Jun 28, 2020
by
Him188
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
74af082a
510a041f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
18 deletions
+39
-18
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
...n/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
+7
-4
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/FriendImpl.kt
...in/kotlin/net/mamoe/mirai/qqandroid/contact/FriendImpl.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt
...irai/qqandroid/network/protocol/packet/chat/NewContact.kt
+3
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/group.kt
...c/commonMain/kotlin/net.mamoe.mirai/event/events/group.kt
+3
-3
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
...core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
+1
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
...c/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
+4
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt
.../commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt
+19
-2
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt
View file @
23dd54b3
...
...
@@ -143,7 +143,7 @@ internal class QQAndroidBot constructor(
@Suppress
(
"DuplicatedCode"
)
@OptIn
(
LowLevelAPI
::
class
)
override
suspend
fun
rejectMemberJoinRequest
(
event
:
MemberJoinRequestEvent
,
blackList
:
Boolean
)
{
override
suspend
fun
rejectMemberJoinRequest
(
event
:
MemberJoinRequestEvent
,
blackList
:
Boolean
,
message
:
String
)
{
checkGroupPermission
(
event
.
bot
,
event
.
group
)
{
event
::
class
.
simpleName
?:
"<anonymous class>"
}
check
(
event
.
responded
.
compareAndSet
(
false
,
true
))
{
"the request $this has already been responded"
...
...
@@ -159,7 +159,8 @@ internal class QQAndroidBot constructor(
fromNick
=
event
.
fromNick
,
groupId
=
event
.
groupId
,
accept
=
false
,
blackList
=
blackList
blackList
=
blackList
,
message
=
message
)
}
...
...
@@ -755,7 +756,8 @@ internal abstract class QQAndroidBotBase constructor(
fromNick
:
String
,
groupId
:
Long
,
accept
:
Boolean
?,
blackList
:
Boolean
blackList
:
Boolean
,
message
:
String
)
{
network
.
apply
{
NewContact
.
SystemMsgNewGroup
.
Action
(
...
...
@@ -765,7 +767,8 @@ internal abstract class QQAndroidBotBase constructor(
groupId
=
groupId
,
isInvited
=
false
,
accept
=
accept
,
blackList
=
blackList
blackList
=
blackList
,
message
=
message
).
sendWithoutExpect
()
if
(
accept
?:
return
)
groups
[
groupId
].
apply
{
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/contact/FriendImpl.kt
View file @
23dd54b3
...
...
@@ -114,7 +114,7 @@ internal class FriendImpl(
fileId
=
0
,
fileMd5
=
image
.
md5
,
fileSize
=
image
.
input
.
size
.
toInt
(),
fileName
=
image
.
md5
.
toUHexString
(
""
)
+
"."
+
ExternalImage
.
defaultF
ormatName
,
fileName
=
image
.
md5
.
toUHexString
(
""
)
+
"."
+
image
.
f
ormatName
,
imgOriginal
=
1
)
).
sendAndExpect
<
LongConn
.
OffPicUp
.
Response
>()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/NewContact.kt
View file @
23dd54b3
...
...
@@ -223,7 +223,8 @@ internal class NewContact {
groupId
:
Long
,
isInvited
:
Boolean
,
accept
:
Boolean
?,
blackList
:
Boolean
=
false
blackList
:
Boolean
=
false
,
message
:
String
=
""
)
=
buildOutgoingUniPacket
(
client
)
{
writeProtoBuf
(
...
...
@@ -236,7 +237,7 @@ internal class NewContact {
false
->
12
// reject
},
groupCode
=
groupId
,
msg
=
""
,
msg
=
message
,
remark
=
""
,
blacklist
=
blackList
),
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
23dd54b3
...
...
@@ -294,7 +294,7 @@ abstract class Bot internal constructor(
level
=
DeprecationLevel
.
ERROR
)
@JvmSynthetic
abstract
suspend
fun
rejectMemberJoinRequest
(
event
:
MemberJoinRequestEvent
,
blackList
:
Boolean
=
false
)
abstract
suspend
fun
rejectMemberJoinRequest
(
event
:
MemberJoinRequestEvent
,
blackList
:
Boolean
=
false
,
message
:
String
=
""
)
/**
* 忽略加群验证(需管理员权限)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/group.kt
View file @
23dd54b3
...
...
@@ -355,7 +355,7 @@ data class MemberJoinRequestEvent internal constructor(
suspend
fun
accept
()
=
bot
.
acceptMemberJoinRequest
(
this
)
@JvmSynthetic
suspend
fun
reject
(
blackList
:
Boolean
=
false
)
=
bot
.
rejectMemberJoinRequest
(
this
,
blackList
)
suspend
fun
reject
(
blackList
:
Boolean
=
false
,
message
:
String
=
""
)
=
bot
.
rejectMemberJoinRequest
(
this
,
blackList
,
message
)
@JvmSynthetic
suspend
fun
ignore
(
blackList
:
Boolean
=
false
)
=
bot
.
ignoreMemberJoinRequest
(
this
,
blackList
)
...
...
@@ -368,8 +368,8 @@ data class MemberJoinRequestEvent internal constructor(
@JavaFriendlyAPI
@JvmOverloads
@JvmName
(
"reject"
)
fun
__rejectBlockingForJava__
(
blackList
:
Boolean
=
false
)
=
runBlocking
{
bot
.
rejectMemberJoinRequest
(
this
@MemberJoinRequestEvent
,
blackList
)
}
fun
__rejectBlockingForJava__
(
blackList
:
Boolean
=
false
,
message
:
String
=
""
)
=
runBlocking
{
bot
.
rejectMemberJoinRequest
(
this
@MemberJoinRequestEvent
,
blackList
,
message
)
}
@JavaFriendlyAPI
@JvmOverloads
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt
View file @
23dd54b3
...
...
@@ -137,5 +137,5 @@ interface LowLevelBotAPIAccessor {
*/
@LowLevelAPI
@MiraiExperimentalAPI
suspend
fun
_lowLevelSolveMemberJoinRequestEvent
(
eventId
:
Long
,
fromId
:
Long
,
fromNick
:
String
,
groupId
:
Long
,
accept
:
Boolean
?,
blackList
:
Boolean
)
suspend
fun
_lowLevelSolveMemberJoinRequestEvent
(
eventId
:
Long
,
fromId
:
Long
,
fromNick
:
String
,
groupId
:
Long
,
accept
:
Boolean
?,
blackList
:
Boolean
,
message
:
String
=
""
)
}
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt
View file @
23dd54b3
...
...
@@ -73,7 +73,7 @@ expect interface Image : Message, MessageContent, CodableMessage {
*
* ### 格式
* 群图片:
* - [GROUP_IMAGE_ID_REGEX], 示例: `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.
mirai` (后缀一定为 `".mirai"`
)
* - [GROUP_IMAGE_ID_REGEX], 示例: `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.
ext` (ext系扩展名
)
*
* 好友图片:
* - [FRIEND_IMAGE_ID_REGEX_1], 示例: `/f8f1ab55-bf8e-4236-b55e-955848d7069f`
...
...
@@ -125,7 +125,7 @@ abstract class FriendImage internal constructor() : AbstractImage() { // change
/**
* 群图片.
*
* @property imageId 形如 `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.
mirai` (后缀一定为 `".mirai"`
)
* @property imageId 形如 `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.
ext` (ext系扩展名
)
* @see Image 查看更多说明
*/
// CustomFace
...
...
@@ -156,11 +156,11 @@ val FRIEND_IMAGE_ID_REGEX_2 = Regex("""/[0-9]*-[0-9]*-[0-9a-fA-F]{32}""")
/**
* 群图片 ID 正则表达式
*
* `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.
mirai
`
* `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.
ext
`
*/
@Suppress
(
"RegExpRedundantEscape"
)
// This is required on Android
// Java: MessageUtils.GROUP_IMAGE_ID_REGEX
val
GROUP_IMAGE_ID_REGEX
=
Regex
(
"""\{[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\}\.
mirai
"""
)
val
GROUP_IMAGE_ID_REGEX
=
Regex
(
"""\{[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\}\.
.{3,5}
"""
)
/**
* 通过 [Image.imageId] 构造一个 [Image] 以便发送.
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/ExternalImage.kt
View file @
23dd54b3
...
...
@@ -11,15 +11,18 @@
package
net.mamoe.mirai.utils
import
kotlinx.io.core.readBytes
import
kotlinx.io.core.use
import
net.mamoe.mirai.contact.Contact
import
net.mamoe.mirai.contact.Group
import
net.mamoe.mirai.contact.User
import
net.mamoe.mirai.message.MessageReceipt
import
net.mamoe.mirai.message.data.*
import
net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.sendTo
import
net.mamoe.mirai.message.data.toUHexString
import
net.mamoe.mirai.utils.internal.DeferredReusableInput
import
net.mamoe.mirai.utils.internal.ReusableInput
import
kotlin.jvm.JvmField
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmSynthetic
/**
...
...
@@ -35,6 +38,12 @@ class ExternalImage internal constructor(
internal
val
input
:
ReusableInput
)
{
internal
val
md5
:
ByteArray
get
()
=
this
.
input
.
md5
val
formatName
:
String
by
lazy
{
val
hex
=
input
.
asInput
().
use
{
it
.
readBytes
(
8
).
toUHexString
(
""
)
}
return
@
lazy
hex
.
detectFormatName
()
}
init
{
if
(
input
!
is
DeferredReusableInput
)
{
...
...
@@ -67,6 +76,14 @@ class ExternalImage internal constructor(
}
internal
fun
calculateImageResourceId
():
String
=
generateImageId
(
md5
)
private
fun
String
.
detectFormatName
():
String
=
when
{
startsWith
(
"FFD8"
)
->
"jpg"
startsWith
(
"89504E47"
)
->
"png"
startsWith
(
"47494638"
)
->
"gif"
startsWith
(
"424D"
)
->
"bmp"
else
->
defaultFormatName
}
}
/*
...
...
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