print("Welcome in RcGcDw config builder! You can accept the default value if provided in the question by using Enter key without providing any other input.\nWARNING! Your current settings.json will be overwritten if you continue!")
try:# load settings
withopen("settings.json.example")assfile:
settings=json.load(sfile)
exceptFileNotFoundError:
ifyes_no(default_or_custom(input("Template config (settings.json.example) could not be found. Download the most recent stable one from master branch? (https://gitlab.com/piotrex43/RcGcDw/raw/master/settings.json.example)? (Y/n)"),"y")):
"Webhook URL is required. You can get it on Discord by following instructions on this page: https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks\n")
print("The webhook URL does not seem right. Reason: {}".format(test_webhook.json()["message"]))
returnFalse
else:
settings["webhookURL"]=option
returnTrue
else:
print("The webhook URL should start with https://discordapp.com/api/webhooks/, are you sure it's the right URL?")
returnFalse
defset_wikiname():
option=input("Please provide any wiki name for the wiki (can be whatever, but should be a full name of the wiki, for example \"Minecraft Wiki\")\n")# TODO Fetch the wiki yourself using api by default
settings["wikiname"]=option
returnTrue
defset_displaymode():
option=default_or_custom(input(
"Please choose the display mode for the feed. More on how they look like on https://gitlab.com/piotrex43/RcGcDw/wikis/Presentation. Valid values: compact or embed. Default: embed\n"),"embed").lower()
option=default_or_custom(input("Limit for amount of changes fetched every {} seconds. (default: 10, minimum: 1, the less active wiki is the lower the value should be)\n".format(settings["cooldown"])),10)
try:
option=int(option)
ifoption<2:
print("Please give a value higher than 1!")
returnFalse
else:
settings["limit"]=option
returnTrue
exceptValueError:
print("Please give a valid number.")
returnFalse
defset_refetch_limit():
option=default_or_custom(input("Limit for amount of changes fetched every time the script starts. (default: 28, minimum: {})\n".format(settings["limit"])),28)
try:
option=int(option)
ifoption<settings["limit"]:
print("Please give a value higher than {}!".format(settings["limit"]))
returnFalse
else:
settings["limit"]=option
returnTrue
exceptValueError:
print("Please give a valid number.")
returnFalse
defset_updown_messages():
try:
option=yes_no(default_or_custom(input("Should the script send messages when the wiki becomes unavailable? (Y/n)"),"y"))
settings["show_updown_messages"]=option
returnTrue
exceptValueError:
print("Response not valid, please use y (yes) or n (no)")
returnFalse
defset_downup_avatars():
option=default_or_custom(input("Provide a link for a custom webhook avatar when the wiki goes DOWN. (default: no avatar)"),"")#TODO Add a check for the image
settings["avatars"]["connection_failed"]=option
option=default_or_custom(
input("Provide a link for a custom webhook avatar when the connection to the wiki is RESTORED. (default: no avatar)"),
"")# TODO Add a check for the image
settings["avatars"]["connection_failed"]=option
returnTrue
defset_ignored_events():
option=default_or_custom(
input("Provide a list of entry types that are supposed to be ignored. Separate them using commas. Example: external, edit, upload/overwrite. (default: external)"),"external")# TODO Add a check for the image
entry_types=[]
foretypeinoption.split(","):
entry_types.append(etype.strip())
settings["ignored"]=entry_types
defset_overview():
try:
option=yes_no(default_or_custom(input("Should the script send daily overviews of the actions done on the wiki for past 24 hours? (y/N)"),"n"))
settings["overview"]=option
returnTrue
exceptValueError:
print("Response not valid, please use y (yes) or n (no)")
returnFalse
defset_overview_time():
try:
option=default_or_custom(input("At what time should the daily overviews be sent? (script uses local machine time, the format of the time should be HH:MM, default is 00:00)"),"00:00")
re.match(r"$\d{2}:\d{2}^")
settings["overview"]=option
returnTrue
exceptValueError:
print("Response not valid, please use y (yes) or n (no)")