From 4db1fefaf2d116946eb3404b49e26b287ccbab4d Mon Sep 17 00:00:00 2001 From: Legit <96157236+D2RLegit@users.noreply.github.com> Date: Sun, 3 Apr 2022 19:16:27 -0500 Subject: [PATCH] Refactor: Condensed discord message will be the only option (#687) * Condsensed discord message will be the only option Condensed message will be default. removed the option from params. * Update game_stats.py * Update discord_embeds.py * Update bot.py * Update shenk_eld.py * Update config.py * removed a line removed e.set_thumbnail(url=f"{self._psnURL}36L4a4994.png") * Update README.md --- README.md | 1 - config/params.ini | 1 - src/bot.py | 10 +++++----- src/config.py | 1 - src/game_stats.py | 7 ++----- src/messages/discord_embeds.py | 2 -- src/run/shenk_eld.py | 4 ++-- 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 1d6894c2b..113525400 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ run_shenk=0 | difficulty | Set to `normal` `nightmare` or `hell` for game difficulty. | | message_api_type | Which api to use to send botty messages. Supports "generic_api" (basic discord), or "discord" (discord embeds with images). | | discord_status_count | Number of games between discord status messages being sent. Leave empty for no status reports. -| discord_status_condensed | Toggles condensed view of Discord status messages. 0 Full text, 1 Condensed text. | info_screenshots | If `1`, the bot takes a screenshot with timestamp on every stuck / chicken / timeout / inventory full event. This is 1 by Default, so remember to clean up the folder every once in a while. | | loot_screenshots | If `1`, the bot takes a screenshot with timestamp everytime he presses `show_items` button and saves it to `loot_screenshots` folder. Remember to clear them once in a while... | | saved_games_folder | [Optional] Defaults to `~\Saved Games\Diablo II Resurrected`. Used to store configuration settings for `f9` / auto settings. | diff --git a/config/params.ini b/config/params.ini index 8f05e2e1a..4a2d77131 100644 --- a/config/params.ini +++ b/config/params.ini @@ -12,7 +12,6 @@ difficulty=hell info_screenshots=1 loot_screenshots=0 discord_status_count=20 -discord_status_condensed=1 saved_games_folder= d2r_path=C:\Program Files (x86)\Diablo II Resurrected ; if you set this field to 1, botty will save the top-most visible character template just after diff --git a/src/bot.py b/src/bot.py index aaa0f3287..ed193cee1 100644 --- a/src/bot.py +++ b/src/bot.py @@ -472,7 +472,7 @@ def _ending_run_helper(self, res: Union[bool, tuple[Location, bool]]): def on_run_pindle(self): res = False self._do_runs["run_pindle"] = False - self._game_stats.update_location("Pin" if Config().general['discord_status_condensed'] else "Pindle") + self._game_stats.update_location("Pin") self._curr_loc = self._pindle.approach(self._curr_loc) if self._curr_loc: set_pause_state(False) @@ -491,7 +491,7 @@ def on_run_shenk(self): def on_run_trav(self): res = False self._do_runs["run_trav"] = False - self._game_stats.update_location("Trav" if Config().general['discord_status_condensed'] else "Travincal") + self._game_stats.update_location("Trav") self._curr_loc = self._trav.approach(self._curr_loc) if self._curr_loc: set_pause_state(False) @@ -501,7 +501,7 @@ def on_run_trav(self): def on_run_nihlathak(self): res = False self._do_runs["run_nihlathak"] = False - self._game_stats.update_location("Nihl" if Config().general['discord_status_condensed'] else "Nihlathak") + self._game_stats.update_location("Nihl") self._curr_loc = self._nihlathak.approach(self._curr_loc) if self._curr_loc: set_pause_state(False) @@ -511,7 +511,7 @@ def on_run_nihlathak(self): def on_run_arcane(self): res = False self._do_runs["run_arcane"] = False - self._game_stats.update_location("Arc" if Config().general['discord_status_condensed'] else "Arcane") + self._game_stats.update_location("Arc") self._curr_loc = self._arcane.approach(self._curr_loc) if self._curr_loc: set_pause_state(False) @@ -521,7 +521,7 @@ def on_run_arcane(self): def on_run_diablo(self): res = False self._do_runs["run_diablo"] = False - self._game_stats.update_location("Dia" if Config().general['discord_status_condensed'] else "Diablo") + self._game_stats.update_location("Dia") self._curr_loc = self._diablo.approach(self._curr_loc) if self._curr_loc: set_pause_state(False) diff --git a/src/config.py b/src/config.py index 4c9bed4c9..a4596fdbe 100644 --- a/src/config.py +++ b/src/config.py @@ -219,7 +219,6 @@ def load_data(self): "message_api_type": self._select_val("general", "message_api_type"), "custom_message_hook": self._select_val("general", "custom_message_hook"), "discord_status_count": False if not self._select_val("general", "discord_status_count") else int(self._select_val("general", "discord_status_count")), - "discord_status_condensed": bool(int(self._select_val("general", "discord_status_condensed"))), "info_screenshots": bool(int(self._select_val("general", "info_screenshots"))), "loot_screenshots": bool(int(self._select_val("general", "loot_screenshots"))), "d2r_path": _default_iff(self._select_val("general", "d2r_path"), "", "C:\Program Files (x86)\Diablo II Resurrected"), diff --git a/src/game_stats.py b/src/game_stats.py index cf21180aa..f4330b46f 100644 --- a/src/game_stats.py +++ b/src/game_stats.py @@ -194,7 +194,7 @@ def _create_msg(self): table.rows.append([location, len(stats["items"]), stats["chickens"], stats["deaths"], stats["merc_deaths"], stats["failed_runs"]]) table.rows.append([ - "T" if Config().general['discord_status_condensed'] else "Total", + "T", self._location_stats["totals"]["items"], self._location_stats["totals"]["chickens"], self._location_stats["totals"]["deaths"], @@ -202,10 +202,7 @@ def _create_msg(self): self._location_stats["totals"]["failed_runs"] ]) - if Config().general['discord_status_condensed']: - table.columns.header = ["Run", "I", "C", "D", "MD", "F"] - else: - table.columns.header = ["Run", "Items", "Chicken", "Death", "Merc Death", "Failed Runs"] + table.columns.header = ["Run", "I", "C", "D", "MD", "F"] msg += f"\n{str(table)}\n" return msg diff --git a/src/messages/discord_embeds.py b/src/messages/discord_embeds.py index 3305b2293..713aa4496 100644 --- a/src/messages/discord_embeds.py +++ b/src/messages/discord_embeds.py @@ -71,8 +71,6 @@ def send_gold(self): def send_message(self, msg: str): msg = f"{Config().general['name']}: {msg}" e = discord.Embed(title=f"Update:", description=f"```{msg}```", color=Color.dark_teal()) - if not Config().general['discord_status_condensed']: - e.set_thumbnail(url=f"{self._psnURL}36L4a4994.png") self._send_embed(e) def _send_embed(self, e, file = None): diff --git a/src/run/shenk_eld.py b/src/run/shenk_eld.py index c07465a52..169cdf70b 100644 --- a/src/run/shenk_eld.py +++ b/src/run/shenk_eld.py @@ -34,7 +34,7 @@ def approach(self, start_loc: Location) -> Union[bool, Location, bool]: def battle(self, do_shenk: bool, do_pre_buff: bool, game_stats) -> Union[bool, tuple[Location, bool]]: # Eldritch - game_stats.update_location("Eld" if Config().general['discord_status_condensed'] else "Eldritch") + game_stats.update_location("Eld") if not TemplateFinder().search_and_wait(["ELDRITCH_0", "ELDRITCH_START"], threshold=0.65, timeout=20).valid: return False if do_pre_buff: @@ -52,7 +52,7 @@ def battle(self, do_shenk: bool, do_pre_buff: bool, game_stats) -> Union[bool, t # Shenk if do_shenk: Logger.info("Run Shenk") - game_stats.update_location("Shk" if Config().general['discord_status_condensed'] else "Shenk") + game_stats.update_location("Shk") self._curr_loc = Location.A5_SHENK_START # No force move, otherwise we might get stuck at stairs! if not self._pather.traverse_nodes((Location.A5_SHENK_START, Location.A5_SHENK_SAFE_DIST), self._char):