From b2a01d20d5ffd5d98c2e56a47fce168b4bd5bcd1 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Thu, 5 Oct 2023 12:29:02 -0400 Subject: [PATCH] diva: add configurable banner_msg --- example_config/diva.yaml | 1 + titles/diva/base.py | 9 ++++----- titles/diva/config.py | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/example_config/diva.yaml b/example_config/diva.yaml index ad1842a..61b5fbf 100644 --- a/example_config/diva.yaml +++ b/example_config/diva.yaml @@ -1,6 +1,7 @@ server: enable: True loglevel: "info" + banner_msg: "" mods: unlock_all_modules: True diff --git a/titles/diva/base.py b/titles/diva/base.py index ac01f72..97a8b87 100644 --- a/titles/diva/base.py +++ b/titles/diva/base.py @@ -57,7 +57,7 @@ class DivaBase: def handle_ping_request(self, data: bytes) -> str: encoded = "&" params = { - "ping_b_msg": f"Welcome to {self.core_cfg.server.name} network!", + "ping_b_msg": f"Welcome to {self.core_cfg.server.name} network!" if not self.game_config.server.banner_msg else self.game_config.server.banner_msg, "ping_m_msg": "xxx", "atnd_lut": f"{self.time_lut}", "fi_lut": f"{self.time_lut}", @@ -93,9 +93,8 @@ class DivaBase: "nblss_ltt_ed_tm": "2019-09-22 12:00:00.0", } - encoded += parse.urlencode(params) + encoded += parse.urlencode(params, safe=",") encoded = encoded.replace("+", "%20") - encoded = encoded.replace("%2C", ",") return encoded @@ -287,8 +286,8 @@ class DivaBase: "fi_add_vp": "20,5", "fi_mul_vp": "1,2", "fi_st": "2019-01-01 00:00:00.0,2019-01-01 00:00:00.0", - "fi_et": "2029-01-01 00:00:00.0,2029-01-01 00:00:00.0", - "fi_lut": "{self.time_lut}", + "fi_et": "2029-01-01 00:00:00.0,2029-01-01 00:00:00.0", # TODO: make this last longer + "fi_lut": f"{self.time_lut}", } encoded += parse.urlencode(params) diff --git a/titles/diva/config.py b/titles/diva/config.py index efa327e..b7f6b32 100644 --- a/titles/diva/config.py +++ b/titles/diva/config.py @@ -18,6 +18,12 @@ class DivaServerConfig: self.__config, "diva", "server", "loglevel", default="info" ) ) + + @property + def banner_msg(self) -> str: + CoreConfig.get_config_field( + self.__config, "diva", "server", "banner_msg", default="" + ) class DivaModsConfig: