mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-18 10:22:26 +08:00
Group events into mixed files
This commit is contained in:
parent
3c70f8fdba
commit
c69f2ab31e
@ -1,4 +1,4 @@
|
||||
package net.mamoe.mirai.event.events.bot
|
||||
package net.mamoe.mirai.event.events
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.Event
|
@ -1,4 +1,4 @@
|
||||
package net.mamoe.mirai.event.events.qq
|
||||
package net.mamoe.mirai.event.events
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.QQ
|
||||
@ -6,6 +6,11 @@ import net.mamoe.mirai.message.Message
|
||||
import net.mamoe.mirai.message.defaults.MessageChain
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* @author Him188moe
|
||||
*/
|
||||
abstract class FriendEvent(bot: Bot, val sender: QQ) : BotEvent(bot)
|
||||
|
||||
/**
|
||||
* 接受好友消息事件
|
||||
*
|
||||
@ -25,4 +30,4 @@ class FriendMessageEvent(bot: Bot, sender: QQ, val message: MessageChain) : Frie
|
||||
|
||||
@JvmSynthetic
|
||||
suspend inline fun reply(message: MessageChain) = sender.sendMessage(message)//shortcut
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package net.mamoe.mirai.event.events.group
|
||||
package net.mamoe.mirai.event.events
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.Group
|
||||
@ -7,6 +7,11 @@ import net.mamoe.mirai.message.Message
|
||||
import net.mamoe.mirai.message.defaults.MessageChain
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* @author Him188moe
|
||||
*/
|
||||
abstract class GroupEvent(bot: Bot, val group: Group) : BotEvent(bot)
|
||||
|
||||
/**
|
||||
* @author Him188moe
|
||||
*/
|
||||
@ -24,4 +29,4 @@ class GroupMessageEvent(bot: Bot, group: Group, val sender: QQ, val message: Mes
|
||||
|
||||
@JvmSynthetic
|
||||
suspend inline fun reply(message: MessageChain) = group.sendMessage(message)
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.mamoe.mirai.event.events
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.Cancellable
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.Packet
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/* Abstract */
|
||||
|
||||
/**
|
||||
* @author Him188moe
|
||||
*/
|
||||
sealed class PacketEvent<out P : Packet>(bot: Bot, open val packet: P) : BotEvent(bot)
|
||||
|
||||
|
||||
/* Client to Server */
|
||||
|
||||
sealed class ClientPacketEvent<out P : ClientPacket>(bot: Bot, packet: P) : PacketEvent<P>(bot, packet)
|
||||
|
||||
/**
|
||||
* 包已发送. 不可被取消
|
||||
*/
|
||||
class PacketSentEvent<P : ClientPacket>(bot: Bot, packet: P) : ClientPacketEvent<P>(bot, packet) {
|
||||
companion object : KClass<PacketSentEvent<*>> by PacketSentEvent::class
|
||||
}
|
||||
|
||||
/**
|
||||
* 包发送前. 可被取消
|
||||
*/
|
||||
class BeforePacketSendEvent<P : ClientPacket>(bot: Bot, packet: P) : ClientPacketEvent<P>(bot, packet), Cancellable {
|
||||
companion object : KClass<BeforePacketSendEvent<*>> by BeforePacketSendEvent::class
|
||||
}
|
||||
|
||||
|
||||
/* Server to Client */
|
||||
|
||||
sealed class ServerPacketEvent<out P : ServerPacket>(bot: Bot, packet: P) : PacketEvent<P>(bot, packet)
|
||||
|
||||
class ServerPacketReceivedEvent(bot: Bot, packet: ServerPacket) : ServerPacketEvent<ServerPacket>(bot, packet) {
|
||||
companion object : KClass<ServerPacketReceivedEvent> by ServerPacketReceivedEvent::class
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package net.mamoe.mirai.event.events.group
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.event.events.bot.BotEvent
|
||||
|
||||
/**
|
||||
* @author Him188moe
|
||||
*/
|
||||
abstract class GroupEvent(bot: Bot, val group: Group) : BotEvent(bot)
|
@ -1,22 +0,0 @@
|
||||
package net.mamoe.mirai.event.events.network
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.Cancellable
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
abstract class ClientPacketEvent<out P : ClientPacket>(bot: Bot, packet: P) : PacketEvent<P>(bot, packet)
|
||||
|
||||
/**
|
||||
* 包已发送. 不可被取消
|
||||
*/
|
||||
class PacketSentEvent<P : ClientPacket>(bot: Bot, packet: P) : ClientPacketEvent<P>(bot, packet) {
|
||||
companion object : KClass<PacketSentEvent<*>> by PacketSentEvent::class
|
||||
}
|
||||
|
||||
/**
|
||||
* 包发送前. 可被取消
|
||||
*/
|
||||
class BeforePacketSendEvent<P : ClientPacket>(bot: Bot, packet: P) : ClientPacketEvent<P>(bot, packet), Cancellable {
|
||||
companion object : KClass<BeforePacketSendEvent<*>> by BeforePacketSendEvent::class
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package net.mamoe.mirai.event.events.network
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.events.bot.BotEvent
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.Packet
|
||||
|
||||
/**
|
||||
* @author Him188moe
|
||||
*/
|
||||
abstract class PacketEvent<out P : Packet>(bot: Bot, open val packet: P) : BotEvent(bot)
|
@ -1,12 +0,0 @@
|
||||
package net.mamoe.mirai.event.events.network
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
abstract class ServerPacketEvent<out P : ServerPacket>(bot: Bot, packet: P) : PacketEvent<P>(bot, packet)
|
||||
|
||||
class ServerPacketReceivedEvent(bot: Bot, packet: ServerPacket) : ServerPacketEvent<ServerPacket>(bot, packet) {
|
||||
companion object : KClass<ServerPacketReceivedEvent> by ServerPacketReceivedEvent::class
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package net.mamoe.mirai.event.events.qq
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.QQ
|
||||
import net.mamoe.mirai.event.events.bot.BotEvent
|
||||
|
||||
/**
|
||||
* @author Him188moe
|
||||
*/
|
||||
abstract class FriendEvent(bot: Bot, val sender: QQ) : BotEvent(bot)
|
@ -6,10 +6,10 @@ import kotlinx.coroutines.sync.withLock
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.ListeningStatus
|
||||
import net.mamoe.mirai.event.broadcast
|
||||
import net.mamoe.mirai.event.events.bot.BotLoginSucceedEvent
|
||||
import net.mamoe.mirai.event.events.network.BeforePacketSendEvent
|
||||
import net.mamoe.mirai.event.events.network.PacketSentEvent
|
||||
import net.mamoe.mirai.event.events.network.ServerPacketReceivedEvent
|
||||
import net.mamoe.mirai.event.events.BeforePacketSendEvent
|
||||
import net.mamoe.mirai.event.events.BotLoginSucceedEvent
|
||||
import net.mamoe.mirai.event.events.PacketSentEvent
|
||||
import net.mamoe.mirai.event.events.ServerPacketReceivedEvent
|
||||
import net.mamoe.mirai.event.subscribe
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.LoginSession
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.mamoe.mirai.network.protocol.tim.handler
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.events.network.ServerPacketReceivedEvent
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler
|
||||
import net.mamoe.mirai.event.events.ServerPacketReceivedEvent
|
||||
import net.mamoe.mirai.network.LoginSession
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.ClientPacket
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.ServerPacket
|
||||
|
||||
|
@ -3,8 +3,8 @@ package net.mamoe.mirai.network.protocol.tim.handler
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.QQ
|
||||
import net.mamoe.mirai.event.broadcast
|
||||
import net.mamoe.mirai.event.events.group.GroupMessageEvent
|
||||
import net.mamoe.mirai.event.events.qq.FriendMessageEvent
|
||||
import net.mamoe.mirai.event.events.FriendMessageEvent
|
||||
import net.mamoe.mirai.event.events.GroupMessageEvent
|
||||
import net.mamoe.mirai.getGroupByNumber
|
||||
import net.mamoe.mirai.getQQ
|
||||
import net.mamoe.mirai.message.defaults.MessageChain
|
||||
|
@ -41,7 +41,7 @@ abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
|
||||
* Encode this packet.
|
||||
*
|
||||
*
|
||||
* Before sending the packet, a [tail][TIMProtocol.tail] will be added.
|
||||
* Before sending the packet, a [tail][TIMProtocol.tail] is added.
|
||||
*/
|
||||
@Throws(IOException::class)
|
||||
protected abstract fun encode()
|
||||
|
@ -7,7 +7,7 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.events.network.ServerPacketReceivedEvent
|
||||
import net.mamoe.mirai.event.events.ServerPacketReceivedEvent
|
||||
import net.mamoe.mirai.event.subscribeWhileTrue
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.PacketNameFormatter.adjustName
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.action.ServerCanAddFriendResponsePacket
|
||||
|
@ -85,7 +85,7 @@ object Main {
|
||||
* 4. 双击跳转
|
||||
* 5. 断点并在TIM发送消息以触发
|
||||
* 6. 运行到 `mov eax,dword ptr ss:[ebp+10]`
|
||||
* 7. 从 eax 开始的 16个 bytes 便是 `sessionKey`
|
||||
* 7. 查看内存, 从 `eax` 开始的 16 bytes 便是 `sessionKey`
|
||||
*/
|
||||
val sessionKey: ByteArray = "48 C0 11 42 2D FD 8F 36 6E BA BF FD D3 AA B7 AE".hexToBytes()
|
||||
|
||||
|
@ -2,8 +2,8 @@ package demo1
|
||||
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.event.events.group.GroupMessageEvent
|
||||
import net.mamoe.mirai.event.events.qq.FriendMessageEvent
|
||||
import net.mamoe.mirai.event.events.FriendMessageEvent
|
||||
import net.mamoe.mirai.event.events.GroupMessageEvent
|
||||
import net.mamoe.mirai.event.subscribeAll
|
||||
import net.mamoe.mirai.event.subscribeAlways
|
||||
import net.mamoe.mirai.event.subscribeUntilFalse
|
||||
|
Loading…
Reference in New Issue
Block a user