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
a9972dc0
Commit
a9972dc0
authored
Mar 24, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce code redundancy
parent
ed467809
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
85 deletions
+59
-85
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
...ndroid/network/protocol/packet/chat/receive/MessageSvc.kt
+1
-1
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Contact.kt
...src/androidMain/kotlin/net/mamoe/mirai/contact/Contact.kt
+0
-1
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Group.kt
...e/src/androidMain/kotlin/net/mamoe/mirai/contact/Group.kt
+9
-40
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
.../src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
+0
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
...re/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
+41
-4
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt
...ore/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt
+0
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Group.kt
...-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Group.kt
+8
-37
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
View file @
a9972dc0
...
...
@@ -198,7 +198,7 @@ internal class MessageSvc {
if
(
group
.
members
.
contains
(
msg
.
msgHead
.
authUin
))
{
return
@
mapNotNull
null
}
return
@
mapNotNull
MemberJoinEvent
(
group
.
Member
(
object
:
MemberInfo
{
return
@
mapNotNull
MemberJoinEvent
(
group
.
new
Member
(
object
:
MemberInfo
{
override
val
nameCard
:
String
get
()
=
""
override
val
permission
:
MemberPermission
get
()
=
MemberPermission
.
MEMBER
override
val
specialTitle
:
String
get
()
=
""
...
...
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Contact.kt
View file @
a9972dc0
...
...
@@ -32,7 +32,6 @@ import net.mamoe.mirai.utils.WeakRefProperty
*
* @author Him188moe
*/
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
@OptIn
(
MiraiInternalAPI
::
class
,
JavaHappyAPI
::
class
)
actual
abstract
class
Contact
:
CoroutineScope
,
ContactJavaHappyAPI
()
{
/**
...
...
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Group.kt
View file @
a9972dc0
...
...
@@ -25,7 +25,6 @@ import net.mamoe.mirai.utils.OverFileSizeMaxException
/**
* 群. 在 QQ Android 中叫做 "Troop"
*/
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
actual
abstract
class
Group
:
Contact
(),
CoroutineScope
{
/**
* 群名称.
...
...
@@ -101,7 +100,7 @@ actual abstract class Group : Contact(), CoroutineScope {
actual
abstract
val
owner
:
Member
/**
* [Bot] 在群内的 [Member] 实例
* [Bot] 在群内的 [
new
Member] 实例
*/
@MiraiExperimentalAPI
actual
abstract
val
botAsMember
:
Member
...
...
@@ -158,13 +157,12 @@ actual abstract class Group : Contact(), CoroutineScope {
actual
abstract
suspend
fun
quit
():
Boolean
/**
* 构造一个 [Member].
* 构造一个 [
new
Member].
* 非特殊情况请不要使用这个函数. 优先使用 [get].
*/
@JvmName
(
"newMember"
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
,
"FunctionName"
)
@Suppress
(
"FunctionName"
)
@MiraiExperimentalAPI
(
"dangerous"
)
actual
abstract
fun
Member
(
memberInfo
:
MemberInfo
):
Member
actual
abstract
fun
new
Member
(
memberInfo
:
MemberInfo
):
Member
/**
* 向这个对象发送消息.
...
...
@@ -193,40 +191,11 @@ actual abstract class Group : Contact(), CoroutineScope {
actual
abstract
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
OfflineGroupImage
actual
companion
object
{
/**
* by @kar98k
*/
actual
fun
calculateGroupUinByGroupCode
(
groupCode
:
Long
):
Long
{
var
left
:
Long
=
groupCode
/
1000000L
when
(
left
)
{
in
0
..
10
->
left
+=
202
in
11
..
19
->
left
+=
480
-
11
in
20
..
66
->
left
+=
2100
-
20
in
67
..
156
->
left
+=
2010
-
67
in
157
..
209
->
left
+=
2147
-
157
in
210
..
309
->
left
+=
4100
-
210
in
310
..
499
->
left
+=
3800
-
310
}
return
left
*
1000000L
+
groupCode
%
1000000L
}
actual
fun
calculateGroupCodeByGroupUin
(
groupUin
:
Long
):
Long
{
var
left
:
Long
=
groupUin
/
1000000L
when
(
left
)
{
in
0
+
202
..
10
+
202
->
left
-=
202
in
11
+
480
-
11
..
19
+
480
-
11
->
left
-=
480
-
11
in
20
+
2100
-
20
..
66
+
2100
-
20
->
left
-=
2100
-
20
in
67
+
2010
-
67
..
156
+
2010
-
67
->
left
-=
2010
-
67
in
157
+
2147
-
157
..
209
+
2147
-
157
->
left
-=
2147
-
157
in
210
+
4100
-
210
..
309
+
4100
-
210
->
left
-=
4100
-
210
in
310
+
3800
-
310
..
499
+
3800
-
310
->
left
-=
3800
-
310
}
return
left
*
1000000L
+
groupUin
%
1000000L
}
actual
fun
calculateGroupUinByGroupCode
(
groupCode
:
Long
):
Long
=
CommonGroupCalculations
.
calculateGroupUinByGroupCode
(
groupCode
)
actual
fun
calculateGroupCodeByGroupUin
(
groupUin
:
Long
):
Long
=
CommonGroupCalculations
.
calculateGroupCodeByGroupUin
(
groupUin
)
}
@MiraiExperimentalAPI
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt
View file @
a9972dc0
...
...
@@ -36,7 +36,6 @@ import kotlin.jvm.JvmSynthetic
* @author Him188moe
*/
// 不要删除多平台结构 !!! kotlin bug
@OptIn
(
MiraiInternalAPI
::
class
,
JavaHappyAPI
::
class
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
expect
abstract
class
Contact
()
:
CoroutineScope
,
ContactJavaHappyAPI
{
/**
* 这个联系人所属 [Bot].
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt
View file @
a9972dc0
...
...
@@ -99,7 +99,7 @@ expect abstract class Group() : Contact, CoroutineScope {
abstract
val
owner
:
Member
/**
* [Bot] 在群内的 [Member] 实例
* [Bot] 在群内的 [
new
Member] 实例
*/
@MiraiExperimentalAPI
abstract
val
botAsMember
:
Member
...
...
@@ -158,13 +158,13 @@ expect abstract class Group() : Contact, CoroutineScope {
abstract
suspend
fun
quit
():
Boolean
/**
* 构造一个 [Member].
* 构造一个 [
new
Member].
* 非特殊情况请不要使用这个函数. 优先使用 [get].
*/
@MiraiExperimentalAPI
(
"dangerous"
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
,
"FunctionName"
)
@JvmName
(
"newMember"
)
abstract
fun
Member
(
memberInfo
:
MemberInfo
):
Member
abstract
fun
new
Member
(
memberInfo
:
MemberInfo
):
Member
/**
* 向这个对象发送消息.
...
...
@@ -203,9 +203,46 @@ expect abstract class Group() : Contact, CoroutineScope {
fun
toFullString
():
String
}
internal
object
CommonGroupCalculations
{
/**
* by @kar98k
*/
fun
calculateGroupUinByGroupCode
(
groupCode
:
Long
):
Long
{
var
left
:
Long
=
groupCode
/
1000000L
when
(
left
)
{
in
0
..
10
->
left
+=
202
in
11
..
19
->
left
+=
480
-
11
in
20
..
66
->
left
+=
2100
-
20
in
67
..
156
->
left
+=
2010
-
67
in
157
..
209
->
left
+=
2147
-
157
in
210
..
309
->
left
+=
4100
-
210
in
310
..
499
->
left
+=
3800
-
310
}
return
left
*
1000000L
+
groupCode
%
1000000L
}
fun
calculateGroupCodeByGroupUin
(
groupUin
:
Long
):
Long
{
var
left
:
Long
=
groupUin
/
1000000L
when
(
left
)
{
in
0
+
202
..
10
+
202
->
left
-=
202
in
11
+
480
-
11
..
19
+
480
-
11
->
left
-=
480
-
11
in
20
+
2100
-
20
..
66
+
2100
-
20
->
left
-=
2100
-
20
in
67
+
2010
-
67
..
156
+
2010
-
67
->
left
-=
2010
-
67
in
157
+
2147
-
157
..
209
+
2147
-
157
->
left
-=
2147
-
157
in
210
+
4100
-
210
..
309
+
4100
-
210
->
left
-=
4100
-
210
in
310
+
3800
-
310
..
499
+
3800
-
310
->
left
-=
3800
-
310
}
return
left
*
1000000L
+
groupUin
%
1000000L
}
}
/**
* 返回机器人是否正在被禁言
*
* @see Group.botMuteRemaining 剩余禁言时间
*/
val
Group
.
isBotMuted
:
Boolean
get
()
=
this
.
botMuteRemaining
!=
0
inline
val
Group
.
isBotMuted
:
Boolean
get
()
=
this
.
botMuteRemaining
!=
0
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt
View file @
a9972dc0
...
...
@@ -31,7 +31,6 @@ import net.mamoe.mirai.utils.WeakRefProperty
*
* @author Him188moe
*/
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
@OptIn
(
MiraiInternalAPI
::
class
,
JavaHappyAPI
::
class
)
actual
abstract
class
Contact
:
CoroutineScope
,
ContactJavaHappyAPI
()
{
/**
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Group.kt
View file @
a9972dc0
...
...
@@ -101,7 +101,7 @@ actual abstract class Group : Contact(), CoroutineScope {
actual
abstract
val
owner
:
Member
/**
* [Bot] 在群内的 [Member] 实例
* [Bot] 在群内的 [
new
Member] 实例
*/
@MiraiExperimentalAPI
actual
abstract
val
botAsMember
:
Member
...
...
@@ -159,13 +159,13 @@ actual abstract class Group : Contact(), CoroutineScope {
actual
abstract
suspend
fun
quit
():
Boolean
/**
* 构造一个 [Member].
* 构造一个 [
new
Member].
* 非特殊情况请不要使用这个函数. 优先使用 [get].
*/
@JvmName
(
"newMember"
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
,
"FunctionName"
)
@MiraiExperimentalAPI
(
"dangerous"
)
actual
abstract
fun
Member
(
memberInfo
:
MemberInfo
):
Member
actual
abstract
fun
new
Member
(
memberInfo
:
MemberInfo
):
Member
/**
* 向这个对象发送消息.
...
...
@@ -194,40 +194,11 @@ actual abstract class Group : Contact(), CoroutineScope {
actual
abstract
override
suspend
fun
uploadImage
(
image
:
ExternalImage
):
OfflineGroupImage
actual
companion
object
{
/**
* by @kar98k
*/
actual
fun
calculateGroupUinByGroupCode
(
groupCode
:
Long
):
Long
{
var
left
:
Long
=
groupCode
/
1000000L
when
(
left
)
{
in
0
..
10
->
left
+=
202
in
11
..
19
->
left
+=
480
-
11
in
20
..
66
->
left
+=
2100
-
20
in
67
..
156
->
left
+=
2010
-
67
in
157
..
209
->
left
+=
2147
-
157
in
210
..
309
->
left
+=
4100
-
210
in
310
..
499
->
left
+=
3800
-
310
}
return
left
*
1000000L
+
groupCode
%
1000000L
}
actual
fun
calculateGroupCodeByGroupUin
(
groupUin
:
Long
):
Long
{
var
left
:
Long
=
groupUin
/
1000000L
when
(
left
)
{
in
0
+
202
..
10
+
202
->
left
-=
202
in
11
+
480
-
11
..
19
+
480
-
11
->
left
-=
480
-
11
in
20
+
2100
-
20
..
66
+
2100
-
20
->
left
-=
2100
-
20
in
67
+
2010
-
67
..
156
+
2010
-
67
->
left
-=
2010
-
67
in
157
+
2147
-
157
..
209
+
2147
-
157
->
left
-=
2147
-
157
in
210
+
4100
-
210
..
309
+
4100
-
210
->
left
-=
4100
-
210
in
310
+
3800
-
310
..
499
+
3800
-
310
->
left
-=
3800
-
310
}
return
left
*
1000000L
+
groupUin
%
1000000L
}
actual
fun
calculateGroupUinByGroupCode
(
groupCode
:
Long
):
Long
=
CommonGroupCalculations
.
calculateGroupUinByGroupCode
(
groupCode
)
actual
fun
calculateGroupCodeByGroupUin
(
groupUin
:
Long
):
Long
=
CommonGroupCalculations
.
calculateGroupCodeByGroupUin
(
groupUin
)
}
@MiraiExperimentalAPI
...
...
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