Skip to content

Commit

Permalink
feat[onebot11]: support segment plus Any type value(cast to String)
Browse files Browse the repository at this point in the history
  • Loading branch information
RTAkland committed Nov 24, 2024
1 parent 093bc7d commit 61207c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ sealed class Segment {
operator fun plus(other: List<Segment>): List<Segment> {
return mutableListOf(this).apply { addAll(other) }
}

/**
* 追加任意类型的数据
*/
operator fun plus(other: Any): List<Segment> {
return mutableListOf(this, Text(other))
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ fun main() {
val l2 = listOf(Text("3"), Text("4"))
val a = listOf(Text("1"), Text("2"), Text("3"), Text("4")).toMessageChain()
println(a)
println(Text("1") + Text("2") + Text("3") + "" + Text("4"))
}

0 comments on commit 61207c7

Please sign in to comment.