-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
243 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
kotlin.code.style=official | ||
|
||
libVersion=1.3.1 | ||
libVersion=1.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright © 2024 RTAkland | ||
* Author: RTAkland | ||
* Date: 2024/8/31 | ||
*/ | ||
|
||
|
||
package cn.rtast.rob.entity.misc | ||
|
||
data class PokeMessage( | ||
val name: String, | ||
val type: Int, | ||
val id: Int | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright © 2024 RTAkland | ||
* Author: RTAkland | ||
* Date: 2024/8/31 | ||
*/ | ||
|
||
|
||
package cn.rtast.rob.enums | ||
|
||
enum class MusicShareType(val type: String) { | ||
QQ("qq"), Netease("163"), Xiami("xm") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright © 2024 RTAkland | ||
* Author: RTAkland | ||
* Date: 2024/8/31 | ||
*/ | ||
|
||
|
||
package cn.rtast.rob.enums | ||
|
||
import cn.rtast.rob.entity.misc.PokeMessage | ||
|
||
object PokeEnums { | ||
val Poke = PokeMessage("戳一戳", 1, -1) | ||
val ShowLove = PokeMessage("比心", 2, -1) | ||
val Like = PokeMessage("点赞", 3, -1) | ||
val Heartbroken = PokeMessage("心碎", 4, -1) | ||
val SixSixSix = PokeMessage("666", 5, -1) | ||
val FangDaZhao = PokeMessage("放大招", 6, -1) | ||
val BaoBeiQiu = PokeMessage("宝贝球", 126, 2011) | ||
val Rose = PokeMessage("玫瑰花", 126, 2007) | ||
val ZhaoHuanShu = PokeMessage("召唤术", 126, 2006) | ||
val RangNiPi = PokeMessage("让你皮", 126, 2009) | ||
val JieYin = PokeMessage("结印", 126, 2005) | ||
val ShouLei = PokeMessage("手雷", 126, 2004) | ||
val GouYin = PokeMessage("勾引", 126, 2003) | ||
val ZhuaYiXia = PokeMessage("抓一下", 126, 2001) | ||
val SuiPing = PokeMessage("碎屏", 126, 2002) | ||
val QiaoMen = PokeMessage("敲门", 126, 2002) | ||
} |
148 changes: 148 additions & 0 deletions
148
src/main/kotlin/cn/rtast/rob/util/message/MessageChain.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* | ||
* Copyright © 2024 RTAkland | ||
* Author: RTAkland | ||
* Date: 2024/8/31 | ||
*/ | ||
|
||
|
||
package cn.rtast.rob.util.message | ||
|
||
import cn.rtast.rob.entity.misc.PokeMessage | ||
import cn.rtast.rob.enums.MusicShareType | ||
|
||
class MessageChain internal constructor(builder: StringBuilder) { | ||
|
||
internal val finalString = builder.toString() | ||
|
||
class Builder { | ||
private val stringBuilder = StringBuilder() | ||
|
||
fun addAt(userId: Long): Builder { | ||
stringBuilder.append("[CQ:at,qq=$userId]") | ||
return this | ||
} | ||
|
||
fun addText(text: String): Builder { | ||
stringBuilder.append(text) | ||
return this | ||
} | ||
|
||
fun addImage(file: String): Builder { | ||
stringBuilder.append("[CQ:image,file=$file]") | ||
return this | ||
} | ||
|
||
fun addFace(id: Int): Builder { | ||
stringBuilder.append("[CQ:face,id=$id]") | ||
return this | ||
} | ||
|
||
fun addRecord(file: String): Builder { | ||
stringBuilder.append("[CQ:record,file=$file]") | ||
return this | ||
} | ||
|
||
fun addVideo(file: String): Builder { | ||
stringBuilder.append("[CQ:video,file=$file]") | ||
return this | ||
} | ||
|
||
fun addRPS(): Builder { | ||
stringBuilder.append("[CQ:rps]") | ||
return this | ||
} | ||
|
||
fun addDice(): Builder { | ||
stringBuilder.append("[CQ:dice]") | ||
return this | ||
} | ||
|
||
fun addShake(): Builder { | ||
stringBuilder.append("[CQ:shake]") | ||
return this | ||
} | ||
|
||
fun addPoke(poke: PokeMessage): Builder { | ||
stringBuilder.append("[CQ:poke,type=${poke.type},id=${poke.id}]") | ||
return this | ||
} | ||
|
||
fun addShare(url: String, title: String): Builder { | ||
stringBuilder.append("[CQ:share,url=$url,title=$title]") | ||
return this | ||
} | ||
|
||
fun addContactUser(userId: Long): Builder { | ||
stringBuilder.append("[CQ:contact,type=qq,id=$userId]") | ||
return this | ||
} | ||
|
||
fun addContactGroup(groupId: Long): Builder { | ||
stringBuilder.append("[CQ:contact,type=group,id=$groupId]") | ||
return this | ||
} | ||
|
||
fun addLocation(lat: Double, lon: Double, title: String? = null, content: String? = null): Builder { | ||
stringBuilder.append("[CQ:location,lat=${lat},lon=${lon}") | ||
if (title != null) stringBuilder.append(",title=$title") | ||
if (content != null) stringBuilder.append(",content=$content") | ||
stringBuilder.append("]") | ||
return this | ||
} | ||
|
||
fun addMusicShare(type: MusicShareType, id: String): Builder { | ||
stringBuilder.append("[CQ:music,type=${type.type},id=$id]") | ||
return this | ||
} | ||
|
||
fun addCustomMusicShare( | ||
url: String, | ||
audio: String, | ||
title: String, | ||
content: String? = null, | ||
image: String? = null | ||
): Builder { | ||
stringBuilder.append("[CQ:music,type=custom,url=$url,audio=$audio,title=$title") | ||
if (image != null) stringBuilder.append(",image=$image") | ||
if (content != null) stringBuilder.append(",content=$content") | ||
stringBuilder.append("]") | ||
return this | ||
} | ||
|
||
fun addReply(messageId: Long): Builder { | ||
stringBuilder.append("[CQ:reply,id=$messageId]") | ||
return this | ||
} | ||
|
||
fun addForwardMessage(messageId: String): Builder { | ||
stringBuilder.append("[CQ:forward,id=$messageId]") | ||
return this | ||
} | ||
|
||
fun addForwardNodeMessage(messageId: String): Builder { | ||
stringBuilder.append("[CQ:node,id=$messageId]") | ||
return this | ||
} | ||
|
||
fun addXMLMessage(xml: String): Builder { | ||
stringBuilder.append("[CQ:xml,data=$xml]") | ||
return this | ||
} | ||
|
||
fun addJsonMessage(json: String): Builder { | ||
stringBuilder.append("[CQ:json,data=$json]") | ||
return this | ||
} | ||
|
||
fun addNewLine(repeatTimes: Int = 1): Builder{ | ||
repeat(repeatTimes) { | ||
stringBuilder.append("\n") | ||
} | ||
return this | ||
} | ||
|
||
fun build(): MessageChain { | ||
return MessageChain(stringBuilder) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters