Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions bridgeipelago.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,30 @@ def SetupLogger():

#Optionaly Load in Meta Modules
def LoadMetaModules():
# Load Meta Modules if they are enabled in the config
if CoreConfig["MetaConfig"]["FlavorDeathlink"] == True:
from modules.DeathlinkFlavor import GetFlavorText
import importlib
#colors because.. yay
PURPLE = "\033[95m"
GREEN = "\033[92m"
RED = "\033[91m"
RESET = "\033[0m"
#Modified MetaConfig to autoload and inject modules.
for module_name, enabled in CoreConfig["MetaConfig"].items():
if enabled:
try:
module = importlib.import_module(f"modules.{module_name}")

# Inject functions to global
for attr in dir(module):
if not attr.startswith("_"):
globals()[attr] = getattr(module, attr)

# launch setup if exist
if hasattr(module, "setup"):
module.setup(discord_client, CoreConfig)

print(f"{PURPLE}[MetaModule]{RESET} {GREEN}Loaded: {module_name}{RESET}")
except Exception as e:
print(f"{PURPLE}[MetaModule]{RESET} {RED}Failed to load {module_name}: {e}{RESET}")

## ARCHIPELAGO TRACKER CLIENT + CORE FUNCTION
class TrackerClient():
Expand Down Expand Up @@ -773,7 +794,7 @@ async def ProcessDeathQueue():
if CoreConfig["RelayConfig"]["DeathlinkMessages"] == True:
DeathMessage = "**Deathlink!** "
# Flavour
if CoreConfig["MetaConfig"]["FlavorDeathlink"] == True:
if CoreConfig["MetaConfig"]["DeathlinkFlavor"] == True:
DeathMessage += GetFlavorText(str(chatmessage['data']['source']))
else:
DeathMessage += "Received from **" + str(chatmessage['data']['source']) + "**"
Expand Down
5 changes: 3 additions & 2 deletions config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
"DiscordBridgeEnabled": false
},
"MetaConfig": {
"FlavorDeathlink": false,
"DeathlinkLottery": false
"DeathlinkFlavor": false,
"DeathlinkLottery": false,
"ReactionRegister": false
},
"AdvancedConfig": {
"LoggingDirectory": "/logs/",
Expand Down
8 changes: 7 additions & 1 deletion modules/DeathlinkFlavor.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,10 @@ def GetFlavorText(PlayerName):
"PLAYER perished chasing progression.",
]
PlayerNameFormatted = f"**{PlayerName}**"
return (random.choice(FlavorList)).replace("PLAYER", PlayerNameFormatted)
return (random.choice(FlavorList)).replace("PLAYER", PlayerNameFormatted)

def setup(bot, CoreConfig):
import sys
main = sys.modules.get("bridgeipelago")
if main:
setattr(main, "GetFlavorText", GetFlavorText)
Loading