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 Sep 2, 2023
1 parent eb018a9 commit acd0fa6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cn.hoyobot.sdk.network.protocol.mihoyo

class MessageBadge {

var enable = false
var iconUrl = ""
var value = ""
var url = ""

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MsgContentInfo(var value: String) : Message {

private val entities: ArrayList<MessageEntity> = ArrayList()
private val quotedParent = QuoteInfo()
private val messageBadge = MessageBadge()
override fun build(): JSONObject {
val jsonObject = JSONObject()
jsonObject.putByPath("content.text", this.value)
Expand Down Expand Up @@ -47,6 +48,11 @@ class MsgContentInfo(var value: String) : Message {
jsonObject.putByPath("quote.quoted_message_id", this.quotedParent.quotedMessageID)
jsonObject.putByPath("quote.quoted_message_send_time", this.quotedParent.quotedMessageSendAt)
}
if (this.messageBadge.enable) {
jsonObject.putByPath("content.badge.icon_url", this.messageBadge.iconUrl)
jsonObject.putByPath("content.badge.text", this.messageBadge.value)
jsonObject.putByPath("content.badge.url", this.messageBadge.url)
}
return jsonObject
}

Expand Down Expand Up @@ -113,6 +119,14 @@ class MsgContentInfo(var value: String) : Message {
return this
}

fun addBadge(icon: String, value: String, link: String): MsgContentInfo {
this.messageBadge.enable = true
this.messageBadge.iconUrl = icon
this.messageBadge.value = value
this.messageBadge.url = link
return this
}

fun appendLinkWithoutUrlText(url: String): MsgContentInfo {
val entity = MessageEntity()
entity.type = MessageEntityType.LINK
Expand Down

0 comments on commit acd0fa6

Please sign in to comment.