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

Commit

Permalink
feat: 优化内容反馈
Browse files Browse the repository at this point in the history
  • Loading branch information
Catrainbow233 committed Aug 15, 2023
1 parent 8bc7e5b commit 09726a3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ProxyRespondEvent(bot: HoyoBot, private val data: JSONObject) : ProxyEvent

val botEntry = bot.getBot()
var headers: Map<String, String> = HashMap()
var body: String = ""
private var used = false

fun isUsed(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class VillaPatcher : ProxyActionInterface {
val requestJson = request.jsonData
val respondEvent = ProxyRespondEvent(HoyoBot.instance, requestJson)
respondEvent.headers = request.getHeaders()
respondEvent.body = request.body
HoyoBot.instance.getEventManager().callEvent(respondEvent)
//如果事件选择被使用则终止后面的操作
if (respondEvent.isUsed()) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import java.util.*
open class ProxyRequest private constructor(ctx: ChannelHandlerContext, private val nettyRequest: FullHttpRequest) {
val path: String
var jsonData: JSONObject = JSONObject()
var body: String = ""
private var ip: String? = null
private val headers: MutableMap<String, String> = HashMap()
private val params: MutableMap<String, Any> = HashMap()
private val cookies: MutableMap<String, Cookie> = HashMap()

init {
try {
this.body = nettyRequest.content().toString(Charsets.UTF_8)
if (nettyRequest.method() == HttpMethod.POST) this.jsonData =
JSONObject(nettyRequest.content().toString(Charsets.UTF_8))
if (this.jsonData.isEmpty()) {
Expand Down

0 comments on commit 09726a3

Please sign in to comment.