Fix up some chat commands

This commit is contained in:
Resaec 2024-10-14 19:51:47 +02:00
parent 360c3264bd
commit 32194e88fb
2 changed files with 10 additions and 5 deletions

View file

@ -234,7 +234,7 @@ class ChatLogic(val ops: ChatOperations, implicit val context: ActorContext) ext
)
)
}
result
true // do not accidentally send mistyped commands to chat
} else {
false // not a handled command
}

View file

@ -603,8 +603,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 {
@ -623,7 +624,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 {
@ -1269,7 +1270,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 = {