print("Found {}, setting URL in the settings to {}".format(tested["sitename"],url))
returnurl
else:
print(
"Could not verify wikis paths. Please make sure you have given the proper wiki URLs in settings.json ({path} should be script path to your wiki) and your Internet connection is working.".format(
path=path))
@staticmethod
defset_cooldown():
option=default_or_custom(input("Interval for fetching recent changes in seconds (min. 30, default 60).\n"),
60)
try:
option=int(option)
ifoption<29:
print("Please give a value higher than 30!")
returnFalse
else:
settings["cooldown"]=option
returnTrue
exceptValueError:
print("Please give a valid number.")
defset_wiki(self):
option=input(
"Please give the wiki URL to be monitored. Can be any link to a script path of the MediaWiki wiki.)\n")
path=self.prepare_paths(option)
ifpath:
settings["wiki"]=path
returnTrue
print("Couldn't find a MediaWiki wiki under given URL.")
settings["fandom_discussions"]["enabled"]=yes_no(default_or_custom(input("Would you like to have discussions feed enabled for the wiki you previously specified? (available only for Fandom wikis)"),"n"))
ifsettings["fandom_discussions"]["enabled"]:
print("Retrieving necessary information from Fandom servers...")
print("Could not setup the discussions, please report the issue on the issue tracker at {tracker} with the following information:".format(tracker="https://gitlab.com/piotrex43/RcGcDw/-/issues/new"))
pprint(response.json())
exceptValueError:
print("Could not setup the discussions, please report the issue on the issue tracker at {tracker} with the following information:".format(tracker="https://gitlab.com/piotrex43/RcGcDw/-/issues/new"))
"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(
"A Discord webhook URL should start with https://discord.com/api/webhooks/, are you sure it's the right URL?")
returnFalse
defset_wikiname(self):
option=default_or_custom(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\") otherwise it will be {}\n".format(self.site_name)),self.site_name)# TODO Fetch the wiki yourself using api by default
settings["wikiname"]=option
returnTrue
@staticmethod
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()
ifoptionin["embed","compact"]:
settings["appearance"]["mode"]=option
returnTrue
print("Invalid mode given! (can be embed or compact, {} given)".format(option))
print("Welcome in RcGcDw config builder! This script is still work in progress so beware! 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!")
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")):
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"]))
option=default_or_custom(input("Provide a link for a custom webhook avatar when the wiki goes DOWN. (default: no avatar)\n"),"")#TODO Add a check for the image
input("Provide a list of entry types that are supposed to be ignored. Separate them using commas. Example: external, edit, upload/overwrite. (default: external)\n"),"external")# TODO Add a check for the image
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)\n"),"00:00")
check=re.match(r"^\d{2}:\d{2}$",option)
ifcheckisnotNone:
settings["overview_time"]=option
returnTrue
else:
print("Response not valid, please enter a time in format HH:MM like for example 00:00 or 15:21!")
option=yes_no(default_or_custom(input("Should the script detect licenses in the newly uploaded images? (Y/n)\n"),"y"))
settings["license_detection"]=option
returnTrue
exceptValueError:
print("Response not valid, please use y (yes) or n (no)")
returnFalse
defset_license_detection_regex():
try:
option=default_or_custom(input("Please provide regex for license detection (only to find it, the next step will be a regex to determine the type of the license). Default: \{\{(license|lizenz|licence|copyright)\n"),"\{\{(license|lizenz|licence|copyright)")
re.compile(option)
settings["license_regex_detect"]=option
returnTrue
exceptre.error:
print("Given regex expression could not be compiled. Please provide a proper regex expression in Python.")
returnFalse
defset_license_classification_regex():
try:
option=default_or_custom(input("Please provide regex for license classification where named capture group \"license\" is used as a license type for the image. Default: \{\{(license|lizenz|licence|copyright)(\ |\|)(?P<license>.*?)\}\}\n"),"\{\{(license|lizenz|licence|copyright)(\ |\|)(?P<license>.*?)\}\}")
re.compile(option)
settings["license_regex"]=option
returnTrue
exceptre.error:
print("Given regex expression could not be compiled. Please provide a proper regex expression in Python.")
returnFalse
defset_login():
option=default_or_custom(input("You can provide bot credentials if you want the script to use higher limits than usual. If that's the case, please provide the login. If not, just skip this option \n"),"")
settings["wiki_bot_login"]=option
returnTrue
defset_password():
option=default_or_custom(input("Please give bot password now.\n"),"")