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")
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")):
print("The images under URL is not in the proper format. Accepted formats are: png, jpg, jpeg, webp, gif, detected: {}".format(response.headers.get('content-type',"none")))
returnFalse
except:
raise
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)\n"),
print("The images under URL is not in the proper format. Accepted formats are: png, jpg, jpeg, webp, gif, detected: {}".format(response.headers.get('content-type',"none")))
"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")
entry_types=[]
foretypeinoption.split(","):
ifetype.strip()insupported_logs:
entry_types.append(etype.strip())
else:
print("Type \"{}\" couldn't be added as it's not supported.".format(etype.strip()))
try:
ifyes_no(default_or_custom(input("Accept {} as ignored events? (Y/n)".format(", ".join(entry_types))),"y")):
settings["ignored"]=entry_types
returnTrue
exceptValueError:
print("Response not valid, please use y (yes) or n (no)")
"Please provide regex (in Python format) 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.")
"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"),
"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 from Special:BotPasswords. If not, just hit Enter/return \n"),
"")
if"@"notinoption:
print("Please provide proper nickname for login from {wiki}Special:BotPasswords".format(