Skip to content

Commit

Permalink
Handle no hosts found for match-chat-name
Browse files Browse the repository at this point in the history
  • Loading branch information
Beherith committed Mar 13, 2024
1 parent c5c6ce3 commit 1a5e4e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
Empty file modified bin/build
100644 → 100755
Empty file.
56 changes: 32 additions & 24 deletions lib/teiserver/battle/servers/match_monitor_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -248,30 +248,38 @@ defmodule Teiserver.Battle.MatchMonitorServer do
[_all, username, _user_num, to, msg] ->
host = Client.get_client_by_id(from_id)
user = CacheUser.get_user_by_name(username)

case to do
"d" ->
# We don't persist this as it's already persisted elsewhere
# ChatLib.persist_message(user, "g: #{msg}", host.lobby_id, :say)
:ok

"dallies" ->
ChatLib.persist_message(user, "a: #{msg}", host.lobby_id, :say)

PubSub.broadcast(
Teiserver.PubSub,
"teiserver_liveview_lobby_chat:#{host.lobby_id}",
{:liveview_lobby_chat, :say, user.id, "a: #{msg}"}
)

"dspectators" ->
ChatLib.persist_message(user, "s: #{msg}", host.lobby_id, :say)

PubSub.broadcast(
Teiserver.PubSub,
"teiserver_liveview_lobby_chat:#{host.lobby_id}",
{:liveview_lobby_chat, :say, user.id, "s: #{msg}"}
)
if host == nil do
Logger.error("No host found for from_id: #{from_id} for message #{to}:#{msg}")
# Optionally, handle the case here, such as by sending a message back to the user or taking other corrective actions.
# Just returning {:noreply, state} for now.
{:noreply, state}
else

case to do
"d" ->
# We don't persist this as it's already persisted elsewhere
# ChatLib.persist_message(user, "g: #{msg}", host.lobby_id, :say)
:ok

"dallies" ->
ChatLib.persist_message(user, "a: #{msg}", host.lobby_id, :say)

PubSub.broadcast(
Teiserver.PubSub,
"teiserver_liveview_lobby_chat:#{host.lobby_id}",
{:liveview_lobby_chat, :say, user.id, "a: #{msg}"}
)

"dspectators" ->
ChatLib.persist_message(user, "s: #{msg}", host.lobby_id, :say)

PubSub.broadcast(
Teiserver.PubSub,
"teiserver_liveview_lobby_chat:#{host.lobby_id}",
{:liveview_lobby_chat, :say, user.id, "s: #{msg}"}
)
end
{:noreply, state}
end

_ ->
Expand Down

0 comments on commit 1a5e4e8

Please sign in to comment.