diff --git a/.env.template b/.env.template index cfa6a37..2071c1c 100644 --- a/.env.template +++ b/.env.template @@ -52,6 +52,7 @@ DiscordBridgeEnabled=false # #---[Meta Config]--- FlavorDeathlink=false +AdvancedDeathLink=false DeathlinkLottery=false # #---[Advanced Config]--- diff --git a/README.md b/README.md index 7b0a4e8..a6ff782 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ Hopefully that makes sense. ||| |**Meta Config**|| |FlavorDeathLink|Will change deathlink messages to have a little more personality$| +|AdvancedDeathLink|Will change deathlink messages to throw that shade allowing you to have each player have their own deathlink messages in their own respective file| |DeathLinkLottery|Unused... for now >:) | ||| |**Advanced Config**|| diff --git a/bridgeipelago.py b/bridgeipelago.py index 303ef26..ddb6bdb 100644 --- a/bridgeipelago.py +++ b/bridgeipelago.py @@ -89,6 +89,7 @@ EnableDiscordBridge = os.getenv('DiscordBridgeEnabled') EnableFlavorDeathlink = os.getenv('FlavorDeathlink') +EnableadvancedDeathlink = os.getenv('advancedDeathlink') EnableDeathlinkLottery = os.getenv('DeathlinkLottery') LoggingDirectory = os.getcwd() + os.getenv('LoggingDirectory') + UniqueID + '/' @@ -179,6 +180,9 @@ # Load Meta Modules if they are enabled in the .env if EnableFlavorDeathlink == "true": from modules.DeathlinkFlavor import GetFlavorText +if EnableadvancedDeathlink == "true": + from modules.advancedDeathlinkFlavor import GetFlavorText + ## ARCHIPELAGO TRACKER CLIENT + CORE FUNCTION class TrackerClient: @@ -771,7 +775,7 @@ async def ProcessDeathQueue(): o.write(DeathLogMessage) o.close() if EnableDeathlinkMessages == "true": - if EnableFlavorDeathlink == "true": + if EnableFlavorDeathlink or EnableadvancedDeathlink == "true": FlavorMessage = "Deathlink: " + GetFlavorText(str(chatmessage['data']['source'])) await SendMainChannelMessage(FlavorMessage) else: diff --git a/flavor_data/deathlink.txt b/flavor_data/deathlink.txt new file mode 100644 index 0000000..9e44def --- /dev/null +++ b/flavor_data/deathlink.txt @@ -0,0 +1,102 @@ + +PLAYER forgot how to live., + PLAYER took a dirt nap., + PLAYER died, it was a skill issue., + PLAYER was owned. Hard., + PLAYER went full noob., + PLAYER became XP for others., + PLAYER tried their best. Lol., + PLAYER got rekt, GG., + PLAYER died of style points., + PLAYER pressed F too late., + PLAYER got clapped., + PLAYER mistimed that jump., + PLAYER lagged to death., + PLAYER got surprise deleted., + PLAYER failed the tutorial., + PLAYER got memed to death., + PLAYER was a free kill., + PLAYER tripped over victory., + PLAYER ran out of luck., + PLAYER underestimated gravity., + PLAYER embraced the respawn., + PLAYER blinked and died., + PLAYER died of embarrassment., + PLAYER got outplayed. Badly., + PLAYER walked into that one., + PLAYER forgot to dodge., + PLAYER stood still. Oof., + PLAYER forgot their armor., + PLAYER panic-rolled to death., + PLAYER touched the red zone., + PLAYER was too curious., + PLAYER went out with a whimper., + PLAYER joined the ghost club., + PLAYER rage-alt-F4’d IRL., + PLAYER found the kill zone., + PLAYER mistook friend for foe., + PLAYER died doing a TikTok., + PLAYER got yeeted., + PLAYER pressed the wrong key., + PLAYER caught a stray., + PLAYER lost the plot., + PLAYER was deleted by karma., + PLAYER forgot how guns work., + PLAYER got combo’d to bits., + PLAYER became loot., + PLAYER was fragged into history., + PLAYER got sniped by fate., + PLAYER died like a true gamer., + PLAYER failed their last quest., + PLAYER was out of heals., + Took an L, and it was fatal for PLAYER., + Gravity had beef with PLAYER., + One moment alive, then poof — PLAYER., + The floor betrayed PLAYER., + Respawn incoming for PLAYER., + That explosion really liked PLAYER., + Bad timing ended PLAYER., + Death speedran PLAYER., + It was a trap... PLAYER fell for it., + That boss just deleted PLAYER., + Lag claimed PLAYER again., + That frag had PLAYER’s name on it., + An NPC outplayed PLAYER., + The final flash seen by PLAYER., + A bad idea took PLAYER out., + That wall won against PLAYER., + Surprise mechanics ended PLAYER., + A door said no to PLAYER., + PLAYER became background lore., + That rocket found PLAYER., + Loot was a trap. Sorry, PLAYER., + A bug ate PLAYER whole., + A bush sniped PLAYER., + PLAYER got distracted... permanently., + The stairs fought back at PLAYER., + The respawn screen comforted PLAYER., + It was a bold move by PLAYER., + The scoreboard laughed at PLAYER., + Physics took revenge on PLAYER., + One misstep later, no more PLAYER., + A crit ended PLAYER’s dreams., + PLAYER misread the situation., + A chicken outplayed PLAYER., + The AFK gods punished PLAYER., + That corner had it out for PLAYER., + A no-scope ended PLAYER’s run., + PLAYER went exploring... and died., + Style over survival — classic PLAYER., + A barrel ruined PLAYER’s day., + PLAYER joined the “Oops” club., + PLAYER died waiting for an item., + PLAYER needed a sword... and died., + Archipelago rerouted PLAYER to death., + PLAYER got nothing... except dead., + PLAYER trusted a hint. Mistake., + A fetch quest killed PLAYER., + PLAYER died before the item arrived., + A trap chest claimed PLAYER., + PLAYER walked into logic’s trap., + + PLAYER perished chasing progression., diff --git a/modules/DeathlinkFlavor.py b/modules/DeathlinkFlavor.py index 9290575..9691486 100644 --- a/modules/DeathlinkFlavor.py +++ b/modules/DeathlinkFlavor.py @@ -1,107 +1,27 @@ - +import os import random +FLAVOR = "flavor_data" +DEATHLINK_FILE = "deathlink" +_flavor_cache = {} + + +def load_deathlink(): + file_path = os.path.join(FLAVOR, f"{DEATHLINK_FILE}.txt") + + if not os.path.exists(file_path): + raise FileNotFoundError(f"Missing required file: {file_path}") + + with open(file_path, 'r', encoding='utf-8') as f: + lines = [line.strip() for line in f if line.strip()] + _flavor_cache[DEATHLINK_FILE] = lines + + def GetFlavorText(PlayerName): - FlavorList = [ - "PLAYER forgot how to live.", - "PLAYER took a dirt nap.", - "PLAYER died, it was a skill issue.", - "PLAYER was owned. Hard.", - "PLAYER went full noob.", - "PLAYER became XP for others.", - "PLAYER tried their best. Lol.", - "PLAYER got rekt, GG.", - "PLAYER died of style points.", - "PLAYER pressed F too late.", - "PLAYER got clapped.", - "PLAYER mistimed that jump.", - "PLAYER lagged to death.", - "PLAYER got surprise deleted.", - "PLAYER failed the tutorial.", - "PLAYER got memed to death.", - "PLAYER was a free kill.", - "PLAYER tripped over victory.", - "PLAYER ran out of luck.", - "PLAYER underestimated gravity.", - "PLAYER embraced the respawn.", - "PLAYER blinked and died.", - "PLAYER died of embarrassment.", - "PLAYER got outplayed. Badly.", - "PLAYER walked into that one.", - "PLAYER forgot to dodge.", - "PLAYER stood still. Oof.", - "PLAYER forgot their armor.", - "PLAYER panic-rolled to death.", - "PLAYER touched the red zone.", - "PLAYER was too curious.", - "PLAYER went out with a whimper.", - "PLAYER joined the ghost club.", - "PLAYER rage-alt-F4’d IRL.", - "PLAYER found the kill zone.", - "PLAYER mistook friend for foe.", - "PLAYER died doing a TikTok.", - "PLAYER got yeeted.", - "PLAYER pressed the wrong key.", - "PLAYER caught a stray.", - "PLAYER lost the plot.", - "PLAYER was deleted by karma.", - "PLAYER forgot how guns work.", - "PLAYER got combo’d to bits.", - "PLAYER became loot.", - "PLAYER was fragged into history.", - "PLAYER got sniped by fate.", - "PLAYER died like a true gamer.", - "PLAYER failed their last quest.", - "PLAYER was out of heals.", - "Took an L, and it was fatal for PLAYER.", - "Gravity had beef with PLAYER.", - "One moment alive, then poof — PLAYER.", - "The floor betrayed PLAYER.", - "Respawn incoming for PLAYER.", - "That explosion really liked PLAYER.", - "Bad timing ended PLAYER.", - "Death speedran PLAYER.", - "It was a trap... PLAYER fell for it.", - "That boss just deleted PLAYER.", - "Lag claimed PLAYER again.", - "That frag had PLAYER’s name on it.", - "An NPC outplayed PLAYER.", - "The final flash seen by PLAYER.", - "A bad idea took PLAYER out.", - "That wall won against PLAYER.", - "Surprise mechanics ended PLAYER.", - "A door said no to PLAYER.", - "PLAYER became background lore.", - "That rocket found PLAYER.", - "Loot was a trap. Sorry, PLAYER.", - "A bug ate PLAYER whole.", - "A bush sniped PLAYER.", - "PLAYER got distracted... permanently.", - "The stairs fought back at PLAYER.", - "The respawn screen comforted PLAYER.", - "It was a bold move by PLAYER.", - "The scoreboard laughed at PLAYER.", - "Physics took revenge on PLAYER.", - "One misstep later, no more PLAYER.", - "A crit ended PLAYER’s dreams.", - "PLAYER misread the situation.", - "A chicken outplayed PLAYER.", - "The AFK gods punished PLAYER.", - "That corner had it out for PLAYER.", - "A no-scope ended PLAYER’s run.", - "PLAYER went exploring... and died.", - "Style over survival — classic PLAYER.", - "A barrel ruined PLAYER’s day.", - "PLAYER joined the “Oops” club.", - "PLAYER died waiting for an item.", - "PLAYER needed a sword... and died.", - "Archipelago rerouted PLAYER to death.", - "PLAYER got nothing... except dead.", - "PLAYER trusted a hint. Mistake.", - "A fetch quest killed PLAYER.", - "PLAYER died before the item arrived.", - "A trap chest claimed PLAYER.", - "PLAYER walked into logic’s trap.", - "PLAYER perished chasing progression.", - ] - return (random.choice(FlavorList)).replace("PLAYER", PlayerName) \ No newline at end of file + if DEATHLINK_FILE not in _flavor_cache: + load_deathlink() + + if _flavor_cache[DEATHLINK_FILE]: + return random.choice(_flavor_cache[DEATHLINK_FILE]).replace("PLAYER", PlayerName) + else: + return f"No deathlink flavor text available for {PlayerName}." diff --git a/modules/advancedDeathlinkFlavor.py b/modules/advancedDeathlinkFlavor.py new file mode 100644 index 0000000..4223d6c --- /dev/null +++ b/modules/advancedDeathlinkFlavor.py @@ -0,0 +1,50 @@ +import os +import random +import glob + +FLAVOR = "flavor_data" +_flavor_cache = {} +DEATHLINK_FILE = "deathlink" + +os.makedirs(FLAVOR, exist_ok=True) + + +def BuildFlavorFile(PlayerName): + file_path = os.path.join(FLAVOR, f"{PlayerName}.txt") + if not os.path.exists(file_path): + with open(file_path, 'w', encoding='utf-8') as f: + print(f"Flavor file created: {file_path}") + else: + print(f"Flavor file already exists: {file_path}") + + +def load_flavor(PlayerName): + pattern = os.path.join(FLAVOR, f"{PlayerName}*.txt") + matched_files = glob.glob(pattern) + + if not matched_files: + BuildFlavorFile(PlayerName) + matched_files = glob.glob(pattern) + + all_lines = [] + for filepath in matched_files: + with open(filepath, 'r', encoding='utf-8') as f: + lines = [line.strip() for line in f if line.strip()] + all_lines.extend(lines) + + _flavor_cache[PlayerName] = all_lines + + +def GetFlavorText(PlayerName): + if PlayerName not in _flavor_cache: + load_flavor(PlayerName) + + if not _flavor_cache[PlayerName]: + if DEATHLINK_FILE not in _flavor_cache: + load_flavor(DEATHLINK_FILE) + + if _flavor_cache[DEATHLINK_FILE]: + return random.choice(_flavor_cache[DEATHLINK_FILE]).replace("PLAYER", PlayerName) + + else: + return random.choice(_flavor_cache[PlayerName]).replace("PLAYER", PlayerName)