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
4d09010c
Commit
4d09010c
authored
Oct 10, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
parent
00d8e268
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
16 deletions
+17
-16
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
+7
-9
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotHelper.kt
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotHelper.kt
+1
-1
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt
...ore/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt
+2
-2
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/packet/login/ClientLogin.kt
...oe/mirai/network/protocol/tim/packet/login/ClientLogin.kt
+3
-0
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/packet/login/ServerLoginResponseKeyExchangePacket.kt
.../tim/packet/login/ServerLoginResponseKeyExchangePacket.kt
+3
-3
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/BotAccount.kt
...re/src/jvmMain/kotlin/net/mamoe/mirai/utils/BotAccount.kt
+1
-1
No files found.
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt
View file @
4d09010c
...
...
@@ -8,9 +8,6 @@ import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler
import
net.mamoe.mirai.utils.BotAccount
import
net.mamoe.mirai.utils.ContactList
import
net.mamoe.mirai.utils.MiraiLogger
import
java.io.Closeable
import
java.util.*
import
java.util.concurrent.atomic.AtomicInteger
/**
* Mirai 的机器人. 一个机器人实例登录一个 QQ 账号.
...
...
@@ -40,9 +37,8 @@ import java.util.concurrent.atomic.AtomicInteger
* @author NatrualHG
* @see net.mamoe.mirai.contact.Contact
*/
class
Bot
(
val
account
:
BotAccount
,
val
logger
:
MiraiLogger
)
:
Closeable
{
val
id
=
createdBotsCount
.
getAndAdd
(
1
)
class
Bot
(
val
account
:
BotAccount
,
val
logger
:
MiraiLogger
)
{
val
id
=
nextId
()
val
contacts
=
ContactSystem
()
...
...
@@ -88,7 +84,7 @@ class Bot(val account: BotAccount, val logger: MiraiLogger) : Closeable {
}
}
override
fun
close
()
{
fun
close
()
{
this
.
network
.
close
()
this
.
contacts
.
groups
.
values
.
forEach
{
it
.
close
()
}
this
.
contacts
.
groups
.
clear
()
...
...
@@ -96,8 +92,10 @@ class Bot(val account: BotAccount, val logger: MiraiLogger) : Closeable {
}
companion
object
{
val
instances
:
MutableList
<
Bot
>
=
Collections
.
synchronizedList
(
LinkedList
()
)
val
instances
:
MutableList
<
Bot
>
=
mutableListOf
(
)
private
val
createdBotsCount
=
AtomicInteger
(
0
)
private
var
id
=
0
private
val
idLock
=
Any
()
fun
nextId
():
Int
=
synchronized
(
idLock
)
{
id
++
}
}
}
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotHelper.kt
View file @
4d09010c
...
...
@@ -58,7 +58,7 @@ fun Bot.green(o: Any?) = print(this, o.toString(), LoggerTextFormat.GREEN)
fun
Bot
.
debug
(
o
:
Any
?)
=
print
(
this
,
o
.
toString
(),
LoggerTextFormat
.
YELLOW
)
fun
Bot
.
debugPacket
(
packet
:
ServerPacket
)
{
fun
Bot
.
printPacketDebugging
(
packet
:
ServerPacket
)
{
debug
(
"Packet=$packet"
)
debug
(
"Packet size="
+
packet
.
input
.
goto
(
0
).
readAllBytes
().
size
)
debug
(
"Packet data="
+
packet
.
input
.
goto
(
0
).
readAllBytes
().
toUHexString
())
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt
View file @
4d09010c
...
...
@@ -26,8 +26,8 @@ abstract class Contact internal constructor(val bot: Bot, val number: Long) {
return
sendMessage
(
message
.
toChain
())
}
suspend
fun
sendMessage
(
message
:
String
)
{
this
.
sendMessage
(
PlainText
(
message
))
suspend
fun
sendMessage
(
plain
:
String
)
{
this
.
sendMessage
(
PlainText
(
plain
))
}
suspend
fun
sendMessage
(
message
:
List
<
Message
>)
{
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/packet/login/ClientLogin.kt
View file @
4d09010c
...
...
@@ -42,6 +42,9 @@ class ClientPasswordSubmissionPacket(
}
}
//实际上这些包性质都是一样的. 31 04 仅是一个序列 id, 可随机
//但为简化处理, 特固定这个 id
@PacketId
(
"08 36 31 04"
)
class
ClientLoginResendPacket3104
(
qq
:
Long
,
password
:
String
,
loginTime
:
Int
,
loginIP
:
String
,
privateKey
:
ByteArray
,
token0825
:
ByteArray
,
token00BA
:
ByteArray
,
tlv0006
:
ByteArray
?
=
null
)
:
ClientLoginResendPacket
(
qq
,
password
,
loginTime
,
loginIP
,
privateKey
,
token0825
,
token00BA
,
tlv0006
)
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/network/protocol/tim/packet/login/ServerLoginResponseKeyExchangePacket.kt
View file @
4d09010c
...
...
@@ -19,14 +19,14 @@ class ServerLoginResponseKeyExchangePacket(input: DataInputStream, val flag: Fla
OTHER
,
}
lateinit
var
tlv0006
:
ByteArray
;
//120bytes
lateinit
var
tlv0006
:
ByteArray
//120bytes
var
tokenUnknown
:
ByteArray
?
=
null
lateinit
var
privateKey
:
ByteArray
//16bytes
lateinit
var
privateKey
Update
:
ByteArray
//16bytes
@Tested
override
fun
decode
()
{
this
.
input
.
skip
(
5
)
privateKey
=
this
.
input
.
readNBytes
(
16
)
//22
privateKey
Update
=
this
.
input
.
readNBytes
(
16
)
//22
//this.input.skip(2)//25
this
.
input
.
goto
(
25
)
tlv0006
=
this
.
input
.
readNBytes
(
120
)
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/BotAccount.kt
View file @
4d09010c
...
...
@@ -5,5 +5,5 @@ package net.mamoe.mirai.utils
*/
data class
BotAccount
(
val
qqNumber
:
Long
,
//实际上是 UInt
val
password
:
String
val
password
:
String
//todo 不保存 password?
)
\ 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