Merge pull request #1244 from psforever/fix-some-commands

Fix up some chat commands
This commit is contained in:
Resaec 2025-06-13 22:46:29 +02:00 committed by GitHub
commit 2cdb1aaf16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 6 deletions

View file

@ -236,7 +236,7 @@ class ChatLogic(val ops: ChatOperations, implicit val context: ActorContext) ext
message.note
)
)
false
true
}
} else {
false

View file

@ -143,7 +143,18 @@ class ChatLogic(val ops: ChatOperations, implicit val context: ActorContext) ext
case "list" => ops.customCommandList(session, params, message)
case "nearby" => ops.customCommandNearby(session)
case "loc" => ops.customCommandLoc(session, message)
case _ => false
case _ =>
// command was not handled
sendResponse(
ChatMsg(
ChatMessageType.CMT_GMOPEN, // CMT_GMTELL
message.wideContents,
"Server",
s"Unknown command !$command",
message.note
)
)
true
}
} else {
false

View file

@ -626,8 +626,9 @@ class ChatOperations(
}
def commandAddCertification(session: Session, message: ChatMsg, contents: String): Unit = {
val certs = cliTokenization(contents).map(name => Certification.values.find(_.name == name))
val result = if (certs.nonEmpty) {
val tokens = cliTokenization(contents)
val certs = tokens.map(name => Certification.values.find(_.name == name))
val result = if (tokens.nonEmpty) {
if (certs.contains(None)) {
s"@AckErrorCertifications"
} else {
@ -646,7 +647,7 @@ class ChatOperations(
}
def commandKick(session: Session, message: ChatMsg, contents: String): Unit = {
val inputs = cliTokenization(contents)
val inputs = cliTokenizationCaseSensitive(contents)
inputs.headOption match {
case Some(input) =>
val determination: Player => Boolean = input.toLongOption match {
@ -1299,7 +1300,11 @@ class ChatOperations(
}
def cliTokenization(str: String): List[String] = {
str.replaceAll("\\s+", " ").toLowerCase.trim.split("\\s").toList
str.replaceAll("\\s+", " ").toLowerCase.trim.split("\\s").toList.filter(!_.equals(""))
}
def cliTokenizationCaseSensitive(str: String): List[String] = {
str.replaceAll("\\s+", " ").trim.split("\\s").toList.filter(!_.equals(""))
}
def commandIncomingSend(message: ChatMsg): Unit = {