Skip to content

Chatbox

This page documents hooks in the chatbox category.


AddFilteredWord(word)View Source

Purpose

Adds a normalized word to the chat filter list when it is not already present.

Category

Chatbox

Realm

Server

Parameters

string word The word to normalize and add to the stored filter list.

Returns

boolean, string Returns whether the add succeeded and either the normalized word or an error tag.

Example Usage

  hook.Add("AddFilteredWord", "liaExampleAddFilteredWord", function(word)
      local normalized = string.Trim(string.lower(word))
      if normalized == "" then return false, "invalidWord" end
      return true, normalized
  end)

CanManageFilteredWords(client)View Source

Purpose

Determines whether a player is allowed to manage the chat filter word list.

Category

Chatbox

Realm

Server

Parameters

Player client The player whose chat filter management permission should be checked.

Returns

boolean True if the player has the manageChatFilter privilege.

Example Usage

  hook.Add("CanManageFilteredWords", "liaExampleCanManageFilteredWords", function(client)
      return true
  end)

ChatboxTextAdded()View Source

Purpose

Called on the client after a new chat line is added to the chatbox.

Category

Chatbox

Realm

Client

Example Usage

  hook.Add("ChatboxTextAdded", "liaExampleChatboxTextAdded", function()
      print("[MyModule] handled ChatboxTextAdded")
  end)

ChatParsed(client, chatType, message, anonymous)View Source

Purpose

Allows code to adjust a parsed chat message before it is dispatched.

Category

Chatbox

Realm

Shared

Parameters

Player client The player who sent the message.

string chatType The parsed chat class unique ID.

string message The parsed message text.

boolean anonymous Whether the message is currently treated as anonymous.

Returns

string|nil, string|nil, boolean|nil Return replacement values for the chat type, message, or anonymous state.

Example Usage

  hook.Add("ChatParsed", "liaExampleChatParsed", function(client, chatType, message, anonymous)
      if chatType == "ooc" and IsValid(client) then
          local decorated = string.format("[Dispatch] %s", message)
          return chatType, decorated, anonymous
      end
  end)

GetFilteredWords()View Source

Purpose

Returns the normalized chat filter word list currently used by the module.

Category

Chatbox

Realm

Server

Returns

table The sequential list of filtered words.

Example Usage

  hook.Add("GetFilteredWords", "liaExampleGetFilteredWords", function()
      return {
          {name = "Example", value = 1}
      }
  end)

GetOOCDelay(speaker)View Source

Purpose

Allows code to override the out-of-character chat cooldown for a player.

Category

Chatbox

Realm

Shared

Parameters

Player speaker The player attempting to send an OOC message.

Returns

number|nil Return a replacement OOC delay in seconds.

Example Usage

  hook.Add("GetOOCDelay", "liaExampleGetOOCDelay", function(speaker)
      return 15
  end)

OnChatReceived(client, chatType, text, anonymous)View Source

Purpose

Allows plugins or modules to adjust incoming chat text before it is added to the local chatbox.

Category

Chatbox

Realm

Client

Parameters

Player client The player who sent the message.

string chatType The resolved chat class for the message.

string text The parsed chat text about to be displayed.

boolean anonymous Whether the message is being shown anonymously.

Returns

string|nil Return a replacement string to override the displayed message text. Returning nil allows the default text to continue.

Example Usage

  hook.Add("OnChatReceived", "liaExampleOnChatReceived", function(client, chatType, text, anonymous)
      if chatType == "radio" then
          return "[Encrypted] " .. text
      end
  end)

OnOOCMessageSent(client, message)View Source

Purpose

Called after an out-of-character message is accepted for sending.

Category

Chatbox

Realm

Shared

Parameters

Player client The player who sent the OOC message.

string message The message text that was sent.

Example Usage

  hook.Add("OnOOCMessageSent", "liaExampleOnOOCMessageSent", function(client, message)
      if not IsValid(client) or message == "" then return end
      print(string.format("[MyModule] %s: %s", client:Name(), message))
  end)

PlayerMessageSend(client, chatType, message, anonymous, receivers)View Source

Purpose

Allows code to adjust the final chat message text before recipients receive it.

Category

Chatbox

Realm

Shared

Parameters

Player client The player who sent the message.

string chatType The chat class unique ID being used.

string message The message text that is about to be sent.

boolean anonymous Whether the message is anonymous.

table receivers optional The resolved recipient list when available.

Returns

string|nil Return replacement message text to override the final output.

Example Usage

  hook.Add("PlayerMessageSend", "liaExamplePlayerMessageSend", function(client, chatType, message, anonymous, receivers)
      if chatType == "ooc" and #receivers > 10 then
          return "[Broadcast] " .. message
      end
  end)

PostPlayerSay(client, message, chatType, anonymous)View Source

Purpose

Runs after the parsed chat message has been sent through the active chat class.

Category

Chatbox

Realm

Server

Parameters

Player client The player who sent the message.

string message The parsed message text that was sent.

string chatType The resolved chat class identifier.

boolean anonymous Whether the message was sent anonymously.

Example Usage

  hook.Add("PostPlayerSay", "liaExamplePostPlayerSay", function(client, message, chatType, anonymous)
      print(client:Nick(), chatType, message)
  end)

RemoveFilteredWord(word)View Source

Purpose

Removes a normalized word from the chat filter list when it exists.

Category

Chatbox

Realm

Server

Parameters

string word The word to normalize and remove from the stored filter list.

Returns

boolean, string Returns whether the removal succeeded and either the normalized word or an error tag.

Example Usage

  hook.Add("RemoveFilteredWord", "liaExampleRemoveFilteredWord", function(word)
      local normalized = string.Trim(string.lower(word))
      if normalized == "" then return false, "invalidWord" end
      return true, normalized
  end)

SyncFilteredWords(targets)View Source

Purpose

Sends the current filtered-word list to one player, a list of players, or every eligible manager.

Category

Chatbox

Realm

Server

Parameters

Player|table targets optional An optional recipient player, recipient list, or `nil` to broadcast to all eligible recipients.

Example Usage

  hook.Add("SyncFilteredWords", "liaExampleSyncFilteredWords", function(targets)
      print("[MyModule] handled SyncFilteredWords")
  end)