Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
add: 客户端消息发送事件
Browse files Browse the repository at this point in the history
  • Loading branch information
Catrainbow233 committed Sep 2, 2023
1 parent acd0fa6 commit c241877
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cn.hoyobot.sdk.event.proxy

import cn.hoyobot.sdk.event.CancellableEvent
import cn.hoyobot.sdk.event.types.ProxyEvent
import cn.hoyobot.sdk.network.BotEntry
import cn.hoyobot.sdk.network.protocol.mihoyo.Message

class ProxySendMessageEvent(val sender: BotEntry, val message: Message) : ProxyEvent(), CancellableEvent {

var roomID = 0
var villaID = ""

}
8 changes: 8 additions & 0 deletions sdk-main/src/main/kotlin/cn/hoyobot/sdk/network/BotEntry.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cn.hoyobot.sdk.network

import cn.hoyobot.sdk.HoyoBot
import cn.hoyobot.sdk.event.proxy.ProxySendMessageEvent
import cn.hoyobot.sdk.event.villa.VillaSendMessageEvent
import cn.hoyobot.sdk.network.protocol.mihoyo.*
import cn.hoyobot.sdk.network.protocol.type.TextType
Expand Down Expand Up @@ -103,6 +105,11 @@ class BotEntry {
}

fun sendMessage(room: Int, message: Message, type: TextType) {
val event = ProxySendMessageEvent(this, message)
event.roomID = room
event.villaID = this.villaID
HoyoBot.instance.getEventManager().callEvent(event)
if (event.isCancelled()) return
when (type) {
TextType.MESSAGE -> {
if (message is MsgContentInfo) {
Expand Down Expand Up @@ -159,6 +166,7 @@ class BotEntry {
fun recallMessage(event: VillaSendMessageEvent) {
this.recallMessage(event.getMsgID(), event.getRoomID(), event.getSendAt())
}

fun transferImage(originalLink: String): String {
val params = JSONObject()
params["url"] = originalLink;
Expand Down

0 comments on commit c241877

Please sign in to comment.