From da3b67742676eb9a0222b5b42ca39dff24345126 Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Mon, 27 Oct 2025 16:40:05 +0100 Subject: [PATCH] modified: app.py --- app.py | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/app.py b/app.py index 788ff56..0f60a72 100644 --- a/app.py +++ b/app.py @@ -127,6 +127,14 @@ T_LEVEL_MULTIPLIERS = { 3: 1.2 # T3 countries get more points } +# Preferred team emoji overrides (will be used if no guild/file match is found) +TEAM_EMOTE_OVERRIDES: Dict[str, str] = { + "axis": "<:fascism:1432391685127536762>", + "allies": "<:democracy:1432391686612586528>", + "comintern": "<:communism:1432391682267025479>", + "default": "<:neutrality:1432391681059197102>", +} + # Emoji and formatting helpers def _all_accessible_emojis(ctx: commands.Context) -> List[discord.Emoji]: """Return emojis from current guild plus all guilds the bot is in.""" @@ -182,22 +190,33 @@ def get_t_emoji(ctx: commands.Context, t_level: int) -> str: return {1: "🔹", 2: "🔸", 3: "🔺"}.get(t_level, "🔹") def get_team_emoji(ctx: commands.Context, team_name: str) -> str: - """Return an emoji for common HOI4 team names like Axis/Allies/Comintern or a generic HOI4 emoji if available.""" + """Return a team emoji using user's preferred overrides, with guild/file matches first.""" name = (team_name or "").lower() - if any(k in name for k in ["axis", "achse"]): - custom = find_custom_emoji(ctx, ["axis", "hoi4_axis"]) - return custom or "⚫" - if any(k in name for k in ["allies", "alliierten", "ally"]): - custom = find_custom_emoji(ctx, ["allies", "hoi4_allies"]) - return custom or "🔵" - if any(k in name for k in ["comintern", "ussr", "soviet"]): - custom = find_custom_emoji(ctx, ["comintern", "hoi4_comintern"]) - return custom or "🔴" - # Generic HOI4 emoji or fallback - custom = find_custom_emoji(ctx, ["hoi4", "hearts_of_iron", "iron"]) - if not custom: + + def pick(keywords: List[str], override_key: str) -> str: + # Try specific keywords (ideology-first), then generic ones + custom = find_custom_emoji(ctx, keywords) + if custom: + return custom + # As an extra attempt, try a couple generic HOI4 icons custom = find_custom_emoji(ctx, ["eagle_hoi", "peace_hoi", "navy_hoi", "secretweapon_hoi"]) - return custom or "🎖️" + if custom: + return custom + # Fall back to explicit override mapping + return TEAM_EMOTE_OVERRIDES.get(override_key, TEAM_EMOTE_OVERRIDES.get("default", "🎖️")) + + if any(k in name for k in ["axis", "achse"]): + return pick(["fascism", "axis", "hoi4_axis"], "axis") + if any(k in name for k in ["allies", "alliierten", "ally"]): + return pick(["democracy", "allies", "hoi4_allies"], "allies") + if any(k in name for k in ["comintern", "ussr", "soviet"]): + return pick(["communism", "comintern", "hoi4_comintern"], "comintern") + + # Default/other + custom = find_custom_emoji(ctx, ["neutrality", "hoi4", "hearts_of_iron", "iron"]) + if custom: + return custom + return TEAM_EMOTE_OVERRIDES.get("default", "🎖️") def _flag_from_iso2(code: str) -> Optional[str]: """Return unicode flag from 2-letter ISO code (e.g., 'DE' -> 🇩🇪)."""