add avatars for players and server user
This commit is contained in:
parent
75a64e49ad
commit
619e0541d7
|
@ -11,6 +11,16 @@ object MessageHandlerInst : MessageHandler() {
|
|||
}
|
||||
|
||||
fun transmit(msg: ApiMessage, cause: String, maxLines: Int = cfg.outgoing.inlineLimit) {
|
||||
if (msg.username.isEmpty()) {
|
||||
msg.username = cfg.outgoing.systemUser
|
||||
|
||||
if(msg.avatar.isEmpty() && cfg.outgoing.avatar.enable) {
|
||||
msg.avatar = cfg.outgoing.avatar.systemUserAvatar
|
||||
}
|
||||
}
|
||||
if (msg.gateway.isEmpty())
|
||||
msg.gateway = cfg.connect.gateway
|
||||
|
||||
if (msg.text.lines().count() >= maxLines) {
|
||||
try {
|
||||
val response = PasteUtil.paste(
|
||||
|
|
|
@ -4,8 +4,11 @@ import blue.endless.jankson.Jankson
|
|||
import blue.endless.jankson.JsonObject
|
||||
import blue.endless.jankson.impl.Marshaller
|
||||
import blue.endless.jankson.impl.SyntaxError
|
||||
import matterlink.*
|
||||
import matterlink.bridge.MessageHandlerInst
|
||||
import matterlink.getOrDefault
|
||||
import matterlink.logger
|
||||
import matterlink.registerTypeAdapter
|
||||
import matterlink.stackTraceString
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
|
||||
|
@ -65,6 +68,7 @@ data class BaseConfig(val rootDir: File) {
|
|||
val inlineLimit: Int = 5,
|
||||
|
||||
val joinPart: JoinPartOptions = JoinPartOptions(),
|
||||
var avatar: AvatarOptions = AvatarOptions(),
|
||||
val death: DeathOptions = DeathOptions()
|
||||
)
|
||||
|
||||
|
@ -104,6 +108,13 @@ data class BaseConfig(val rootDir: File) {
|
|||
)
|
||||
)
|
||||
|
||||
data class AvatarOptions(
|
||||
val enable: Boolean = true,
|
||||
val urlTemplate: String = "https://visage.surgeplay.com/head/512/{uuid}",
|
||||
// https://www.freepik.com/free-icon/right-arrow-angle-and-horizontal-down-line-code-signs_732795.htm
|
||||
val systemUserAvatar: String = "https://image.freepik.com/free-icon/right-arrow-angle-and-horizontal-down-line-code-signs_318-53994.jpg"
|
||||
)
|
||||
|
||||
data class JoinPartOptions(
|
||||
val enable: Boolean = true,
|
||||
val joinServer: String = "{username:antiping} has connected to the platform",
|
||||
|
@ -285,6 +296,11 @@ data class BaseConfig(val rootDir: File) {
|
|||
DeathOptions(),
|
||||
"Death messages settings"
|
||||
),
|
||||
avatar = it.getOrDefault(
|
||||
"avatar",
|
||||
AvatarOptions(),
|
||||
"Avatar options"
|
||||
),
|
||||
joinPart = it.getOrDefault(
|
||||
"joinPart",
|
||||
JoinPartOptions(),
|
||||
|
@ -323,6 +339,22 @@ data class BaseConfig(val rootDir: File) {
|
|||
)
|
||||
}
|
||||
}
|
||||
.registerTypeAdapter {
|
||||
with(AvatarOptions()) {
|
||||
AvatarOptions(
|
||||
enable = it.getOrDefault(
|
||||
"enable",
|
||||
enable,
|
||||
"enable ingame avatar"
|
||||
),
|
||||
urlTemplate = it.getOrDefault(
|
||||
"urlTemplate",
|
||||
urlTemplate,
|
||||
"template for constructing the user avatar url using the uuid"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
.registerTypeAdapter {
|
||||
with(JoinPartOptions()) {
|
||||
JoinPartOptions(
|
||||
|
|
|
@ -3,6 +3,7 @@ package matterlink.handlers
|
|||
import matterlink.api.ApiMessage
|
||||
import matterlink.bridge.MessageHandlerInst
|
||||
import matterlink.bridge.command.BridgeCommandRegistry
|
||||
import matterlink.config.cfg
|
||||
import matterlink.instance
|
||||
import matterlink.logger
|
||||
import matterlink.stripColorOut
|
||||
|
@ -21,7 +22,12 @@ object ChatProcessor {
|
|||
username = user.stripColorOut,
|
||||
text = message.stripColorOut,
|
||||
event = event
|
||||
),
|
||||
).apply {
|
||||
if(cfg.outgoing.avatar.enable) {
|
||||
if(uuid != null)
|
||||
avatar = cfg.outgoing.avatar.urlTemplate.replace("{uuid}", uuid.toString())
|
||||
}
|
||||
},
|
||||
cause = "Message from $user"
|
||||
)
|
||||
else -> logger.warn("WARN: dropped blank message by '$user'")
|
||||
|
|
Loading…
Reference in New Issue