<commit_before>package lila.round

import akka.actor.ActorRef
import akka.actor.ActorSelection

import actorApi._
import lila.chat.actorApi._
import lila.game.Game
import lila.i18n.I18nKey.{ Select => SelectI18nKey }
import lila.i18n.I18nKeys

final class Messenger(
    val chat: ActorSelection,
    i18nKeys: I18nKeys) {

  def system(game: Game, message: SelectI18nKey, args: Any*) {
    val translated = message(i18nKeys).en(args: _*)
    chat ! SystemTalk(game.id + "/w", translated)
    if (game.nonAi) chat ! SystemTalk(game.id, translated)
  }

  def systemForOwners(gameId: String, message: SelectI18nKey, args: Any*) {
    val translated = message(i18nKeys).en(args: _*)
    chat ! SystemTalk(gameId, translated)
  }

  def watcher(gameId: String, member: Member, text: String) =
    member.userId foreach { userId =>
      chat ! UserTalk(gameId + "/w", userId, text)
    }

  private val whisper = "/whisper "

  def owner(gameId: String, member: Member, text: String) =
    chat ! (member.userId match {
      case Some(userId) if text startsWith whisper =>
        UserTalk(gameId + "/w", userId, text drop whisper.size)
      case Some(userId) =>
        UserTalk(gameId, userId, text, public = false)
      case None => PlayerTalk(gameId, member.color.white, text)
    })
}<commit_msg>allow "\w" as "/whisper" alias<commit_after>package lila.round

import akka.actor.ActorRef
import akka.actor.ActorSelection

import actorApi._
import lila.chat.actorApi._
import lila.game.Game
import lila.i18n.I18nKey.{ Select => SelectI18nKey }
import lila.i18n.I18nKeys

final class Messenger(
    val chat: ActorSelection,
    i18nKeys: I18nKeys) {

  def system(game: Game, message: SelectI18nKey, args: Any*) {
    val translated = message(i18nKeys).en(args: _*)
    chat ! SystemTalk(watcherId(game.id), translated)
    if (game.nonAi) chat ! SystemTalk(game.id, translated)
  }

  def systemForOwners(gameId: String, message: SelectI18nKey, args: Any*) {
    val translated = message(i18nKeys).en(args: _*)
    chat ! SystemTalk(gameId, translated)
  }

  def watcher(gameId: String, member: Member, text: String) =
    member.userId foreach { userId =>
      chat ! UserTalk(watcherId(gameId), userId, text)
    }

  private val whisperCommands = List("/whisper ", "/w ")

  def owner(gameId: String, member: Member, text: String) =
    chat ! (member.userId match {
      case Some(userId) =>
        whisperCommands.collectFirst {
          case command if text startsWith command =>
            UserTalk(watcherId(gameId), userId, text drop command.size)
        } | UserTalk(gameId, userId, text, public = false)
      case None => PlayerTalk(gameId, member.color.white, text)
    })

  private def watcherId(gameId: String) = s"$gameId/w"
}
{'fraction_non_alphanumeric': 0.1205519244734931, 'fraction_numerical': 0.01597676107480029, 'mean_word_length': 3.669491525423729, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6186739', 'n_tokens_mistral': 953, 'n_tokens_neox': 919, 'n_words': 230}