Skip to content

Commit

Permalink
Streamline manage bot function
Browse files Browse the repository at this point in the history
  • Loading branch information
BBArikL committed Dec 18, 2022
1 parent 73aa40d commit e7a793f
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions bdbot/bdbot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,40 @@ def manage_bot():
"""Manage the bot and its settings"""
action = ""
while action != "Return":
choices = {
"Database tools - Not implemented": todo,
"Verify requests - Not implemented": todo,
"Create image link cache": link_cache_generate,
"Refresh configuration files (to do after every update": refresh_conf_files,
"Setup Bot": setup_bot,
"Uninstall Bot": uninstall_bot,
"Return": todo,
}

action = inquirer.select(
message="What do you want to do?",
choices=[
"Database tools - Not implemented",
"Verify requests - Not implemented",
"Create image link cache",
"Setup Bot",
"Uninstall Bot",
"Return",
],
choices=list(choices.keys()),
mandatory=False,
).execute()

if action == "Create image link cache":
logger.info("Running link cache, please wait up to 1-2 minutes...")
os.makedirs("data", exist_ok=True)
create_link_cache(logger)
logger.info("Link cache created!")
elif action == "Setup Bot":
setup_bot()
elif action == "Uninstall Bot":
conf = inquirer.confirm(
"Are you sure you want to uninstall the bot?"
).execute()
if conf:
os.rmdir(BASE_DATA_PATH)
else:
logger.info("Canceled bot uninstallation")
choices[action]()


def uninstall_bot():
"""Uninstall bot files"""
conf = inquirer.confirm("Are you sure you want to uninstall the bot?").execute()
if conf:
os.rmdir(BASE_DATA_PATH)
else:
logger.info("Canceled bot uninstallation")


def link_cache_generate():
"""Regenerate the link cache"""
logger.info("Running link cache, please wait up to 1-2 minutes...")
os.makedirs("data", exist_ok=True)
create_link_cache(logger)
logger.info("Link cache created!")


def setup_bot():
Expand Down

0 comments on commit e7a793f

Please sign in to comment.