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
df56c86f
Commit
df56c86f
authored
Feb 01, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build
parent
aa0bf81a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
37 additions
and
30 deletions
+37
-30
mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt
...otlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/SyncCookie.kt
...mirai/qqandroid/network/protocol/data/proto/SyncCookie.kt
+1
-1
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
+2
-3
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/TIMPC.kt
...impc/src/commonMain/kotlin/net.mamoe.mirai.timpc/TIMPC.kt
+7
-1
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
...n/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
+2
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotFactoryJvm.kt
...-core/src/jvmMain/kotlin/net/mamoe/mirai/BotFactoryJvm.kt
+15
-1
mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
...i-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
+4
-4
mirai-demos/mirai-demo-android/src/main/kotlin/net/mamoe/mirai/demo/MiraiService.kt
...roid/src/main/kotlin/net/mamoe/mirai/demo/MiraiService.kt
+1
-0
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
...rai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
+4
-19
No files found.
mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/utils/SystemDeviceInfo.kt
View file @
df56c86f
...
@@ -5,6 +5,7 @@ import android.net.wifi.WifiManager
...
@@ -5,6 +5,7 @@ import android.net.wifi.WifiManager
import
android.os.Build
import
android.os.Build
import
android.telephony.TelephonyManager
import
android.telephony.TelephonyManager
import
kotlinx.io.core.toByteArray
import
kotlinx.io.core.toByteArray
import
net.mamoe.mirai.utils.Context
import
net.mamoe.mirai.utils.localIpAddress
import
net.mamoe.mirai.utils.localIpAddress
import
net.mamoe.mirai.utils.md5
import
net.mamoe.mirai.utils.md5
import
java.io.File
import
java.io.File
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/data/proto/SyncCookie.kt
View file @
df56c86f
...
@@ -11,6 +11,6 @@ class SyncCookie(
...
@@ -11,6 +11,6 @@ class SyncCookie(
@SerialId
(
4
)
val
unknown2
:
Long
=
3497826378
,
@SerialId
(
4
)
val
unknown2
:
Long
=
3497826378
,
@SerialId
(
5
)
val
const1
:
Long
=
1680172298
,
@SerialId
(
5
)
val
const1
:
Long
=
1680172298
,
@SerialId
(
6
)
val
const2
:
Long
=
2424173273
,
@SerialId
(
6
)
val
const2
:
Long
=
2424173273
,
@SerialId
(
7
)
val
unknown3
:
Long
=
83
,
@SerialId
(
7
)
val
unknown3
:
Long
=
0
,
@SerialId
(
8
)
val
unknown4
:
Long
=
0
@SerialId
(
8
)
val
unknown4
:
Long
=
0
)
:
ProtoBuf
)
:
ProtoBuf
\ No newline at end of file
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt
View file @
df56c86f
...
@@ -27,7 +27,6 @@ import net.mamoe.mirai.qqandroid.utils.toRichTextElems
...
@@ -27,7 +27,6 @@ import net.mamoe.mirai.qqandroid.utils.toRichTextElems
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.cryptor.contentToString
import
net.mamoe.mirai.utils.currentTimeSeconds
import
net.mamoe.mirai.utils.currentTimeSeconds
import
net.mamoe.mirai.utils.io.hexToBytes
import
net.mamoe.mirai.utils.io.hexToBytes
import
net.mamoe.mirai.utils.io.toReadPacket
import
kotlin.math.absoluteValue
import
kotlin.math.absoluteValue
import
kotlin.random.Random
import
kotlin.random.Random
...
@@ -61,8 +60,8 @@ internal class MessageSvc {
...
@@ -61,8 +60,8 @@ internal class MessageSvc {
client
:
QQAndroidClient
,
client
:
QQAndroidClient
,
msgTime
:
Long
//PbPushMsg.msg.msgHead.msgTime
msgTime
:
Long
//PbPushMsg.msg.msgHead.msgTime
):
OutgoingPacket
=
buildOutgoingUniPacket
(
):
OutgoingPacket
=
buildOutgoingUniPacket
(
client
,
client
//
,
extraData
=
EXTRA_DATA
.
toReadPacket
()
//
extraData = EXTRA_DATA.toReadPacket()
)
{
)
{
writeProtoBuf
(
writeProtoBuf
(
MsgSvc
.
PbGetMsgReq
.
serializer
(),
MsgSvc
.
PbGetMsgReq
.
serializer
(),
...
...
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/TIMPC.kt
View file @
df56c86f
...
@@ -24,4 +24,10 @@ object TIMPC : BotFactory {
...
@@ -24,4 +24,10 @@ object TIMPC : BotFactory {
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
*/
fun
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
BotConfiguration
=
BotConfiguration
.
Default
):
Bot
=
TIMPCBot
(
BotAccount
(
qq
,
password
),
configuration
)
fun
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
BotConfiguration
=
BotConfiguration
.
Default
):
Bot
=
TIMPCBot
(
BotAccount
(
qq
,
password
),
configuration
)
}
}
\ No newline at end of file
/**
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
inline
fun
TIMPC
.
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
(
BotConfiguration
.()
->
Unit
)):
Bot
=
this
.
Bot
(
qq
,
password
,
BotConfiguration
().
apply
(
configuration
))
\ No newline at end of file
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt
View file @
df56c86f
...
@@ -91,7 +91,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -91,7 +91,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
heartbeatJob
?.
join
()
heartbeatJob
?.
join
()
}
}
override
fun
disp
ose
(
cause
:
Throwable
?)
{
override
fun
cl
ose
(
cause
:
Throwable
?)
{
super
.
close
(
cause
)
super
.
close
(
cause
)
this
.
heartbeatJob
?.
cancel
(
CancellationException
(
"handler closed"
))
this
.
heartbeatJob
?.
cancel
(
CancellationException
(
"handler closed"
))
...
@@ -312,6 +312,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
...
@@ -312,6 +312,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
else
->
error
(
"No decrypter is found"
)
else
->
error
(
"No decrypter is found"
)
}
as
?
D
?:
error
(
"Internal error: could not cast decrypter which is found for factory to class Decrypter"
)
}
as
?
D
?:
error
(
"Internal error: could not cast decrypter which is found for factory to class Decrypter"
)
@UseExperimental
(
MiraiInternalAPI
::
class
)
suspend
fun
onPacketReceived
(
packet
:
Any
)
{
//complex function, but it doesn't matter
suspend
fun
onPacketReceived
(
packet
:
Any
)
{
//complex function, but it doesn't matter
when
(
packet
)
{
when
(
packet
)
{
is
TouchPacket
.
TouchResponse
.
OK
->
{
is
TouchPacket
.
TouchResponse
.
OK
->
{
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotFactoryJvm.kt
View file @
df56c86f
...
@@ -4,6 +4,7 @@ package net.mamoe.mirai
...
@@ -4,6 +4,7 @@ package net.mamoe.mirai
import
net.mamoe.mirai.utils.BotConfiguration
import
net.mamoe.mirai.utils.BotConfiguration
import
net.mamoe.mirai.utils.Context
import
net.mamoe.mirai.utils.Context
import
net.mamoe.mirai.utils.ContextImpl
// Do not use ServiceLoader. Probably not working on MPP
// Do not use ServiceLoader. Probably not working on MPP
@PublishedApi
@PublishedApi
...
@@ -41,4 +42,17 @@ fun Bot(context: Context, qq: Long, password: String, configuration: BotConfigur
...
@@ -41,4 +42,17 @@ fun Bot(context: Context, qq: Long, password: String, configuration: BotConfigur
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
*/
inline
fun
Bot
(
context
:
Context
,
qq
:
Long
,
password
:
String
,
configuration
:
(
BotConfiguration
.()
->
Unit
)):
Bot
=
inline
fun
Bot
(
context
:
Context
,
qq
:
Long
,
password
:
String
,
configuration
:
(
BotConfiguration
.()
->
Unit
)):
Bot
=
factory
.
Bot
(
context
,
qq
,
password
,
configuration
)
factory
.
Bot
(
context
,
qq
,
password
,
configuration
)
\ No newline at end of file
/**
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
fun
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
BotConfiguration
=
BotConfiguration
.
Default
):
Bot
=
factory
.
Bot
(
ContextImpl
(),
qq
,
password
,
configuration
)
/**
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
*/
inline
fun
Bot
(
qq
:
Long
,
password
:
String
,
configuration
:
(
BotConfiguration
.()
->
Unit
)):
Bot
=
factory
.
Bot
(
ContextImpl
(),
qq
,
password
,
configuration
)
\ No newline at end of file
mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt
View file @
df56c86f
...
@@ -17,6 +17,7 @@ import net.mamoe.mirai.message.data.ImageId
...
@@ -17,6 +17,7 @@ import net.mamoe.mirai.message.data.ImageId
import
net.mamoe.mirai.message.data.PlainText
import
net.mamoe.mirai.message.data.PlainText
import
net.mamoe.mirai.message.data.firstOrNull
import
net.mamoe.mirai.message.data.firstOrNull
import
net.mamoe.mirai.message.sendAsImageTo
import
net.mamoe.mirai.message.sendAsImageTo
import
net.mamoe.mirai.timpc.Bot
import
net.mamoe.mirai.timpc.TIMPC
import
net.mamoe.mirai.timpc.TIMPC
import
net.mamoe.mirai.utils.suspendToExternalImage
import
net.mamoe.mirai.utils.suspendToExternalImage
import
java.io.File
import
java.io.File
...
@@ -39,10 +40,8 @@ private fun readTestAccount(): BotAccount? {
...
@@ -39,10 +40,8 @@ private fun readTestAccount(): BotAccount? {
@Suppress
(
"UNUSED_VARIABLE"
)
@Suppress
(
"UNUSED_VARIABLE"
)
suspend
fun
main
()
{
suspend
fun
main
()
{
val
bot
=
TIMPC
.
Bot
(
// JVM 下也可以不写 `TIMPC.` 引用顶层函数
val
bot
=
TIMPC
.
Bot
(
// JVM 下也可以不写 `TIMPC.` 引用顶层函数
readTestAccount
()
?:
BotAccount
(
//填写你的账号
1994701121
,
id
=
1994701121
,
"123456"
passwordPlainText
=
"123456"
)
)
{
)
{
// 覆盖默认的配置
// 覆盖默认的配置
randomDeviceName
=
false
randomDeviceName
=
false
...
@@ -134,6 +133,7 @@ fun Bot.messageDSL() {
...
@@ -134,6 +133,7 @@ fun Bot.messageDSL() {
reply
(
message
)
reply
(
message
)
}
}
listener
.
complete
()
// 停止监听
// 自定义的 filter, filter 中 it 为转为 String 的消息.
// 自定义的 filter, filter 中 it 为转为 String 的消息.
// 也可以用任何能在处理时使用的变量, 如 subject, sender, message
// 也可以用任何能在处理时使用的变量, 如 subject, sender, message
...
...
mirai-demos/mirai-demo-android/src/main/kotlin/net/mamoe/mirai/demo/MiraiService.kt
View file @
df56c86f
...
@@ -14,6 +14,7 @@ import kotlinx.io.core.IoBuffer
...
@@ -14,6 +14,7 @@ import kotlinx.io.core.IoBuffer
import
kotlinx.io.core.readBytes
import
kotlinx.io.core.readBytes
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.event.subscribeMessages
import
net.mamoe.mirai.timpc.Bot
import
net.mamoe.mirai.timpc.TIMPC
import
net.mamoe.mirai.timpc.TIMPC
import
net.mamoe.mirai.utils.LoginFailedException
import
net.mamoe.mirai.utils.LoginFailedException
import
net.mamoe.mirai.utils.LoginSolver
import
net.mamoe.mirai.utils.LoginSolver
...
...
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt
View file @
df56c86f
...
@@ -8,7 +8,6 @@ import kotlinx.coroutines.delay
...
@@ -8,7 +8,6 @@ import kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.Bot
import
net.mamoe.mirai.BotAccount
import
net.mamoe.mirai.alsoLogin
import
net.mamoe.mirai.alsoLogin
import
net.mamoe.mirai.contact.MemberPermission
import
net.mamoe.mirai.contact.MemberPermission
import
net.mamoe.mirai.event.Subscribable
import
net.mamoe.mirai.event.Subscribable
...
@@ -23,32 +22,18 @@ import net.mamoe.mirai.message.data.Image
...
@@ -23,32 +22,18 @@ import net.mamoe.mirai.message.data.Image
import
net.mamoe.mirai.message.data.buildXMLMessage
import
net.mamoe.mirai.message.data.buildXMLMessage
import
net.mamoe.mirai.message.data.getValue
import
net.mamoe.mirai.message.data.getValue
import
net.mamoe.mirai.message.sendAsImageTo
import
net.mamoe.mirai.message.sendAsImageTo
import
net.mamoe.mirai.utils.ContextImpl
import
java.io.File
import
java.io.File
import
java.util.*
import
java.util.*
import
javax.swing.filechooser.FileSystemView
import
javax.swing.filechooser.FileSystemView
import
kotlin.random.Random
import
kotlin.random.Random
private
fun
readTestAccount
():
BotAccount
?
{
val
file
=
File
(
"testAccount.txt"
)
if
(!
file
.
exists
()
||
!
file
.
canRead
())
{
return
null
}
val
lines
=
file
.
readLines
()
return
try
{
BotAccount
(
lines
[
0
].
toLong
(),
lines
[
1
])
}
catch
(
e
:
Throwable
)
{
null
}
}
@Suppress
(
"UNUSED_VARIABLE"
)
@Suppress
(
"UNUSED_VARIABLE"
)
suspend
fun
main
()
{
suspend
fun
main
()
{
val
bot
=
Bot
(
val
bot
=
Bot
(
readTestAccount
()
?:
BotAccount
(
ContextImpl
(),
id
=
913366033
,
913366033
,
passwordPlainText
=
"a18260132383"
"a18260132383"
)
)
{
)
{
// override config here.
// override config here.
}.
alsoLogin
()
}.
alsoLogin
()
...
...
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