Skip to content

Commit

Permalink
Bandaid AutoBroadcastUserConfig (accept both UI format as one string …
Browse files Browse the repository at this point in the history
…and the JSON format)
  • Loading branch information
cemathey committed May 21, 2024
1 parent 2728724 commit c2ab2c5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions rcon/user_config/auto_broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,17 @@ def save_to_db(values: AutoBroadcastType, dry_run=False):
validated_messages = []
raw_message: str
for raw_message in raw_messages:
raw_message = raw_message.replace("\\n", "\n")
time, message = RawAutoBroadCastMessage(value=raw_message).time_and_message
# TODO: Fix this bandaid once the UI gets overhauled
# Accept dict like objects when not set through the UI
if isinstance(raw_message, dict):
time = raw_message["time_sec"]
message = raw_message["message"]
# The UI passes these in as strings
else:
raw_message = raw_message.replace("\\n", "\n")
time, message = RawAutoBroadCastMessage(
value=raw_message
).time_and_message
validated_messages.append(
AutoBroadcastMessage(time_sec=int(time), message=message)
)
Expand Down

0 comments on commit c2ab2c5

Please sign in to comment.