mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-07 16:40:43 +08:00
update
This commit is contained in:
parent
e9b64c83f4
commit
2483dcc49d
@ -1,11 +1,8 @@
|
|||||||
package net.mamoe.mirai;
|
package net.mamoe.mirai;
|
||||||
|
|
||||||
|
|
||||||
import net.mamoe.mirai.event.MiraiEventHook;
|
|
||||||
import net.mamoe.mirai.event.events.server.ServerDisableEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
public final class MiraiMain {
|
public final class MiraiMain {
|
||||||
private static MiraiServer server;
|
private static MiraiServer server;
|
||||||
|
@ -3,7 +3,7 @@ package net.mamoe.mirai.contact
|
|||||||
/**
|
/**
|
||||||
* A contact is a QQ account or a QQ Group.
|
* A contact is a QQ account or a QQ Group.
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
abstract class Contact(val number: Int) {
|
abstract class Contact(val number: Int) {
|
||||||
|
|
||||||
|
@ -7,6 +7,10 @@ fun Int.asGroup(): Group = Instances.groups.stream().filter { t: Group? -> t?.nu
|
|||||||
|
|
||||||
fun String.withImage(id: String, type: String) = "{$id}.$type"
|
fun String.withImage(id: String, type: String) = "{$id}.$type"
|
||||||
|
|
||||||
|
fun String.withAt(qq: Int) = qq.asQQ().at()
|
||||||
|
|
||||||
|
fun String.withAt(qq: QQ) = qq.at()
|
||||||
|
|
||||||
object Instances {
|
object Instances {
|
||||||
var qqs = arrayListOf<QQ>()
|
var qqs = arrayListOf<QQ>()
|
||||||
var groups = arrayListOf<Group>()
|
var groups = arrayListOf<Group>()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.mamoe.mirai.contact
|
package net.mamoe.mirai.contact
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class QQ(number: Int) : Contact(number) {
|
class QQ(number: Int) : Contact(number) {
|
||||||
init {
|
init {
|
||||||
|
@ -4,7 +4,7 @@ import net.mamoe.mirai.event.events.MiraiEvent
|
|||||||
import net.mamoe.mirai.network.Robot
|
import net.mamoe.mirai.network.Robot
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class RobotLoginEvent(val robot: Robot) : MiraiEvent()
|
class RobotLoginEvent(val robot: Robot) : MiraiEvent()
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import java.util.*
|
|||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
interface Protocol {
|
interface Protocol {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -25,7 +25,7 @@ import java.net.InetSocketAddress
|
|||||||
/**
|
/**
|
||||||
* [number] is a QQ number.
|
* [number] is a QQ number.
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class Robot(val number: Int, private val password: String) {
|
class Robot(val number: Int, private val password: String) {
|
||||||
private var sequence: Int = 0
|
private var sequence: Int = 0
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.mamoe.mirai.network.packet;
|
package net.mamoe.mirai.network.packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
public interface Packet {
|
public interface Packet {
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.mamoe.mirai.network.packet;
|
package net.mamoe.mirai.network.packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
public final class PacketUtil {
|
public final class PacketUtil {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import java.net.InetAddress
|
|||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
|
abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.mamoe.mirai.network.packet.client
|
package net.mamoe.mirai.network.packet.client
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
class ClientSendMessagePacket : ClientPacket() {
|
class ClientSendMessagePacket : ClientPacket() {
|
||||||
|
@ -11,7 +11,7 @@ import net.mamoe.mirai.util.hexToBytes
|
|||||||
/**
|
/**
|
||||||
* Password submission (0836_622)
|
* Password submission (0836_622)
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@PacketId("08 36 31 03")
|
@PacketId("08 36 31 03")
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
@ -120,7 +120,7 @@ class ClientLoginSucceedConfirmationPacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
private fun ClientPacket.writePart1(qq: Int, password: String, loginTime: Int, loginIP: String, tgtgtKey: ByteArray, token0825: ByteArray) {
|
private fun ClientPacket.writePart1(qq: Int, password: String, loginTime: Int, loginIP: String, tgtgtKey: ByteArray, token0825: ByteArray) {
|
||||||
|
@ -10,7 +10,7 @@ import net.mamoe.mirai.util.ByteArrayDataOutputStream
|
|||||||
import net.mamoe.mirai.util.TEACryptor
|
import net.mamoe.mirai.util.TEACryptor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@PacketId("00 BA 31 01")
|
@PacketId("00 BA 31 01")
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
|
@ -13,7 +13,7 @@ import java.io.IOException
|
|||||||
/**
|
/**
|
||||||
* Server redirection (0825 response)
|
* Server redirection (0825 response)
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
@PacketId("08 25 31 02")
|
@PacketId("08 25 31 02")
|
||||||
|
@ -10,7 +10,7 @@ import net.mamoe.mirai.util.TEACryptor
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
@PacketId("00 58")//todo check
|
@PacketId("00 58")//todo check
|
||||||
|
@ -16,7 +16,7 @@ import java.io.IOException
|
|||||||
*
|
*
|
||||||
* @see net.mamoe.mirai.network.packet.server.ServerTouchResponsePacket
|
* @see net.mamoe.mirai.network.packet.server.ServerTouchResponsePacket
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
@PacketId("08 25 31 01")
|
@PacketId("08 25 31 01")
|
||||||
|
@ -10,7 +10,7 @@ import net.mamoe.mirai.util.toHexString
|
|||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
abstract class ServerPacket(val input: DataInputStream) : Packet {
|
abstract class ServerPacket(val input: DataInputStream) : Packet {
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import net.mamoe.mirai.network.packet.server.ServerPacket
|
|||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class ServerLoginResponseFailedPacket(val state: State, input: DataInputStream) : ServerPacket(input) {
|
class ServerLoginResponseFailedPacket(val state: State, input: DataInputStream) : ServerPacket(input) {
|
||||||
enum class State {
|
enum class State {
|
||||||
|
@ -5,7 +5,7 @@ import net.mamoe.mirai.network.packet.server.ServerPacket
|
|||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
@PacketId("08 36 31 03")
|
@PacketId("08 36 31 03")
|
||||||
class ServerLoginResponseResendPacket(input: DataInputStream, val flag: Flag) : ServerPacket(input) {
|
class ServerLoginResponseResendPacket(input: DataInputStream, val flag: Flag) : ServerPacket(input) {
|
||||||
|
@ -10,8 +10,8 @@ import net.mamoe.mirai.util.hexToShort
|
|||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
* @author NaturalHG @ Mirai Project
|
* @author NaturalHG
|
||||||
*/
|
*/
|
||||||
class ServerLoginResponseSuccessPacket(input: DataInputStream, val packetDataLength: Int) : ServerPacket(input) {
|
class ServerLoginResponseSuccessPacket(input: DataInputStream, val packetDataLength: Int) : ServerPacket(input) {
|
||||||
lateinit var _0828_rec_decr_key: ByteArray//16 bytes|
|
lateinit var _0828_rec_decr_key: ByteArray//16 bytes|
|
||||||
|
@ -4,7 +4,7 @@ import net.mamoe.mirai.network.packet.server.ServerPacket
|
|||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class ServerLoginResponseVerificationCodePacket(input: DataInputStream) : ServerPacket(input) {
|
class ServerLoginResponseVerificationCodePacket(input: DataInputStream) : ServerPacket(input) {
|
||||||
var verifyCodeLength: Int = 0
|
var verifyCodeLength: Int = 0
|
||||||
|
@ -8,7 +8,7 @@ import java.io.DataInputStream
|
|||||||
/**
|
/**
|
||||||
* Dispose_0828
|
* Dispose_0828
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class ServerSessionKeyResponsePacket(inputStream: DataInputStream) : ServerPacket(inputStream) {
|
class ServerSessionKeyResponsePacket(inputStream: DataInputStream) : ServerPacket(inputStream) {
|
||||||
lateinit var sessionKey: ByteArray
|
lateinit var sessionKey: ByteArray
|
||||||
@ -39,7 +39,7 @@ class ServerSessionKeyResponsePacket(inputStream: DataInputStream) : ServerPacke
|
|||||||
/**
|
/**
|
||||||
* Encrypted using []0828_rec_decr_key], decrypting in Robot
|
* Encrypted using []0828_rec_decr_key], decrypting in Robot
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class ServerSessionKeyResponsePacketEncrypted(inputStream: DataInputStream) : ServerPacket(inputStream) {
|
class ServerSessionKeyResponsePacketEncrypted(inputStream: DataInputStream) : ServerPacket(inputStream) {
|
||||||
override fun decode() {
|
override fun decode() {
|
||||||
|
@ -11,7 +11,7 @@ import java.io.DataInputStream
|
|||||||
* @see net.mamoe.mirai.network.packet.client.login.ClientServerRedirectionPacket
|
* @see net.mamoe.mirai.network.packet.client.login.ClientServerRedirectionPacket
|
||||||
* @see net.mamoe.mirai.network.packet.client.login.ClientPasswordSubmissionPacket
|
* @see net.mamoe.mirai.network.packet.client.login.ClientPasswordSubmissionPacket
|
||||||
*
|
*
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
class ServerTouchResponsePacket(private val type: Type, inputStream: DataInputStream) : ServerPacket(inputStream) {
|
class ServerTouchResponsePacket(private val type: Type, inputStream: DataInputStream) : ServerPacket(inputStream) {
|
||||||
var serverIP: String? = null;
|
var serverIP: String? = null;
|
||||||
|
@ -7,7 +7,7 @@ import java.util.*
|
|||||||
import java.util.zip.CRC32
|
import java.util.zip.CRC32
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
object Utils {
|
object Utils {
|
||||||
fun toHexString(byteArray: ByteArray, separator: String = " "): String = byteArray.joinToString(separator) {
|
fun toHexString(byteArray: ByteArray, separator: String = " "): String = byteArray.joinToString(separator) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
public class NetworkTest {
|
public class NetworkTest {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package net.mamoe.mirai.util;
|
package net.mamoe.mirai.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe
|
||||||
*/
|
*/
|
||||||
public final class TeaEncryption {
|
public final class TeaEncryption {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user