kimi gone wild

This commit is contained in:
ra
2026-02-14 23:12:33 -07:00
parent bbd205ecbe
commit 0222be36c5
98 changed files with 39726 additions and 309 deletions

View File

@@ -9,6 +9,7 @@ defmodule Odinsea.Channel.Handler.Chat do
alias Odinsea.Net.Packet.In
alias Odinsea.Channel.Packets
alias Odinsea.Game.Character
alias Odinsea.Admin.Handler, as: AdminHandler
@max_chat_length 80
@max_staff_chat_length 512
@@ -36,21 +37,25 @@ defmodule Odinsea.Channel.Handler.Chat do
{:ok, client_state}
true ->
# TODO: Process commands (CommandProcessor.processCommand)
# TODO: Check if muted
# TODO: Anti-spam checks
# Check if this is an admin command
if AdminHandler.admin_command?(message) do
handle_admin_command(message, client_state)
else
# TODO: Check if muted
# TODO: Anti-spam checks
# Broadcast chat to map
chat_packet = Packets.user_chat(character.id, message, false, only_balloon == 1)
# Broadcast chat to map
chat_packet = Packets.user_chat(character.id, message, false, only_balloon == 1)
Odinsea.Game.Map.broadcast(map_pid, chat_packet)
Odinsea.Game.Map.broadcast(map_pid, chat_packet)
# Log chat
Logger.info(
"Chat [#{character.name}] (Map #{character.map_id}): #{message}"
)
# Log chat
Logger.info(
"Chat [#{character.name}] (Map #{character.map_id}): #{message}"
)
{:ok, client_state}
{:ok, client_state}
end
end
else
{:error, reason} ->
@@ -263,4 +268,28 @@ defmodule Odinsea.Channel.Handler.Chat do
{:ok, client_state}
end
end
# ============================================================================
# Admin Command Handling
# ============================================================================
defp handle_admin_command(message, client_state) do
command_name = AdminHandler.extract_command_name(message)
Logger.info("Admin command detected: #{command_name} from character #{client_state.character_id}")
case AdminHandler.handle_command(message, client_state) do
{:ok, result} ->
Logger.info("Admin command succeeded: #{command_name} - #{result}")
{:ok, client_state}
{:error, reason} ->
Logger.warning("Admin command failed: #{command_name} - #{reason}")
{:ok, client_state}
:not_command ->
# Shouldn't happen since we checked, but handle gracefully
{:ok, client_state}
end
end
end