diff --git a/dependency.lic b/dependency.lic index 484eb47809..6d96fca2ad 100644 --- a/dependency.lic +++ b/dependency.lic @@ -10,7 +10,7 @@ require 'ostruct' require 'digest/sha1' require 'monitor' -$DEPENDENCY_VERSION = '1.7.4' +$DEPENDENCY_VERSION = '1.7.5' $MIN_RUBY_VERSION = '3.2.2' DRINFOMON_IN_CORE_LICH ||= false @@ -242,7 +242,44 @@ class ScriptManager end def update_status_url - @status_url = 'https://api.github.com/repos/' + @status_repo + '/git/trees/' + @status_branch + defaulturl = 'https://api.github.com/repos/' + @status_repo + '/git/trees/' + @status_branch + mainurl = 'https://api.github.com/repos/rpherbig/dr-scripts/git/trees/main' + fallbackurl = 'https://api.github.com/repos/rpherbig/dr-scripts/git/trees/master' + eo_drscripts = 'https://api.github.com/repos/elanthia-online/dr-scripts/git/trees/main' + + unless url_exist?(defaulturl) + _respond Lich::Messaging.monsterbold("Default URL #{defaulturl} not responding. Using an alternate repo+branch combindation.") + _respond Lich::Messaging.monsterbold("Unsetting custom repo settings, if any.") + Settings['status_repo'] = nil if Settings['status_repo'] + Settings['status_branch'] = nil if Settings['status_branch'] + end + + if url_exist?(defaulturl) + @status_url = defaulturl + _respond Lich::Messaging.monsterbold("Using set Status URL. #{defaulturl}") + elsif url_exist?(mainurl) + _respond Lich::Messaging.monsterbold("Using alternate Status URL. #{mainurl}") + @status_url = mainurl + elsif url_exist?(fallbackurl) + _respond Lich::Messaging.monsterbold("Using fallback Status URL. #{fallbackurl}") + @status_url = fallbackurl + elsif url_exist?(eo_drscripts) + _respond Lich::Messaging.monsterbold("Using Elanthia Online Status URL. #{eo_drscripts}") + @status_url = eo_drscripts + else + _respond Lich::Messaging.monsterbold("Could not set Status URL. Please seek help on Discord.") + end + end + + def url_exist?(url_string) + url = URI.parse(url_string) + req = Net::HTTP.new(url.host, url.port) + req.use_ssl = (url.scheme == 'https') + path = url.path + res = req.request_head(path || '/') + res.code != "404" # false if returns 404 - not found + rescue Errno::ENOENT, URI::InvalidURIError + false # false if can't find the server, or URI invalid somehow end def set_custom_status_repo(repo, branch)