modified: app.py
This commit is contained in:
47
app.py
47
app.py
@@ -127,6 +127,14 @@ T_LEVEL_MULTIPLIERS = {
|
|||||||
3: 1.2 # T3 countries get more points
|
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
|
# Emoji and formatting helpers
|
||||||
def _all_accessible_emojis(ctx: commands.Context) -> List[discord.Emoji]:
|
def _all_accessible_emojis(ctx: commands.Context) -> List[discord.Emoji]:
|
||||||
"""Return emojis from current guild plus all guilds the bot is in."""
|
"""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, "🔹")
|
return {1: "🔹", 2: "🔸", 3: "🔺"}.get(t_level, "🔹")
|
||||||
|
|
||||||
def get_team_emoji(ctx: commands.Context, team_name: str) -> str:
|
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()
|
name = (team_name or "").lower()
|
||||||
if any(k in name for k in ["axis", "achse"]):
|
|
||||||
custom = find_custom_emoji(ctx, ["axis", "hoi4_axis"])
|
def pick(keywords: List[str], override_key: str) -> str:
|
||||||
return custom or "⚫"
|
# Try specific keywords (ideology-first), then generic ones
|
||||||
if any(k in name for k in ["allies", "alliierten", "ally"]):
|
custom = find_custom_emoji(ctx, keywords)
|
||||||
custom = find_custom_emoji(ctx, ["allies", "hoi4_allies"])
|
if custom:
|
||||||
return custom or "🔵"
|
return custom
|
||||||
if any(k in name for k in ["comintern", "ussr", "soviet"]):
|
# As an extra attempt, try a couple generic HOI4 icons
|
||||||
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:
|
|
||||||
custom = find_custom_emoji(ctx, ["eagle_hoi", "peace_hoi", "navy_hoi", "secretweapon_hoi"])
|
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]:
|
def _flag_from_iso2(code: str) -> Optional[str]:
|
||||||
"""Return unicode flag from 2-letter ISO code (e.g., 'DE' -> 🇩🇪)."""
|
"""Return unicode flag from 2-letter ISO code (e.g., 'DE' -> 🇩🇪)."""
|
||||||
|
|||||||
Reference in New Issue
Block a user