we both got in each others's ways; still respect the ignored players list (#1051)

This commit is contained in:
Fate-JH 2023-03-14 14:22:09 -04:00 committed by GitHub
parent 082d58108f
commit fdcce870d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 21 deletions

View file

@ -539,7 +539,8 @@ object AvatarActor {
* `false`, otherwise
*/
def onlineIfNotIgnored(onlinePlayerName: String, observerName: String): Boolean = {
LivePlayerList.WorldPopulation({ case (_, a) => a.name.equals(onlinePlayerName) }).headOption match {
val onlinePlayerNameLower = onlinePlayerName.toLowerCase()
LivePlayerList.WorldPopulation({ case (_, a) => a.name.toLowerCase().equals(onlinePlayerNameLower) }).headOption match {
case Some(onlinePlayer) => onlineIfNotIgnored(onlinePlayer, observerName)
case _ => false
}
@ -582,7 +583,8 @@ object AvatarActor {
* `false`, otherwise
*/
def onlineIfNotIgnored(onlinePlayer: Avatar, observedName: String): Boolean = {
!onlinePlayer.people.ignored.exists { f => f.name.equals(observedName) }
val observedNameLower = observedName.toLowerCase()
!onlinePlayer.people.ignored.exists { f => f.name.toLowerCase().equals(observedNameLower) }
}
/**

View file

@ -72,25 +72,40 @@ class ChatService(context: ActorContext[ChatService.Command]) extends AbstractBe
}
val subs = subscriptions.filter(_.channel == channel)
message.messageType match {
case CMT_TELL | CMT_GMTELL =>
subs.find(_.session.player.Name == session.player.Name).foreach {
case JoinChannel(sender, _, _) =>
case mtype @ (CMT_TELL | CMT_GMTELL) =>
val playerName = session.player.Name
val playerNameLower = playerName.toLowerCase()
val recipientName = message.recipient
val recipientNameLower = recipientName.toLowerCase()
(
subs.find(_.session.player.Name.toLowerCase().equals(playerNameLower)),
subs.find(_.session.player.Name.toLowerCase().equals(recipientNameLower))
) match {
case (Some(JoinChannel(sender, _, _)), Some(JoinChannel(receiver, _, _))) =>
val replyType = if (mtype == CMT_TELL) { U_CMT_TELLFROM } else { U_CMT_GMTELLFROM }
sender ! MessageResponse(
session,
message.copy(messageType = if (message.messageType == CMT_TELL) U_CMT_TELLFROM else U_CMT_GMTELLFROM),
message.copy(messageType = replyType),
channel
)
subs.find(_.session.player.Name.toLowerCase() == message.recipient.toLowerCase()) match {
case Some(JoinChannel(receiver, _, _)) =>
receiver ! MessageResponse(session, message.copy(recipient = session.player.Name), channel)
case None =>
sender ! MessageResponse(
session,
ChatMsg(ChatMessageType.UNK_45, wideContents = false, "", "@NoTell_Target", None),
channel
)
}
receiver ! MessageResponse(session, message.copy(recipient = playerName), channel)
case (None, Some(JoinChannel(receiver, _, _))) =>
log.warn(s"ChatMsg->$mtype: can not find subscription object for: sender=$playerName")
receiver ! MessageResponse(session, message.copy(recipient = playerName), channel)
case (Some(JoinChannel(sender, _, _)), None) =>
val replyType = if (mtype == CMT_TELL) { U_CMT_TELLFROM } else { U_CMT_GMTELLFROM }
sender ! MessageResponse(
session,
message.copy(messageType = replyType),
channel
)
sender ! MessageResponse(
session,
ChatMsg(ChatMessageType.UNK_45, wideContents = false, "", "@NoTell_Target", None),
channel
)
case (None, None) =>
log.error(s"ChatMsg->$mtype: can not find subscription object for: sender=$playerName")
}
case CMT_SILENCE =>
@ -117,13 +132,13 @@ class ChatService(context: ActorContext[ChatService.Command]) extends AbstractBe
if (recipient.session.player.silenced) {
sender.actor ! MessageResponse(
session,
ChatMsg(UNK_229, true, "", "@silence_disabled_ack", None),
ChatMsg(UNK_229, wideContents = true, "", "@silence_disabled_ack", None),
channel
)
} else {
sender.actor ! MessageResponse(
session,
ChatMsg(UNK_229, true, "", "@silence_enabled_ack", None),
ChatMsg(UNK_229, wideContents = true, "", "@silence_enabled_ack", None),
channel
)
}
@ -131,14 +146,14 @@ class ChatService(context: ActorContext[ChatService.Command]) extends AbstractBe
case None =>
sender.actor ! MessageResponse(
session,
ChatMsg(UNK_229, true, "", s"unknown player '$name'", None),
ChatMsg(UNK_229, wideContents = true, "", s"unknown player '$name'", None),
channel
)
}
case (Some(sender), _, _, error) =>
sender.actor ! MessageResponse(
session,
ChatMsg(UNK_229, false, "", error.getOrElse("usage: /silence <name> [<time>]"), None),
ChatMsg(UNK_229, wideContents = false, "", error.getOrElse("usage: /silence <name> [<time>]"), None),
channel
)