Identify if a link exists

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

FabricioSouza

Well-Known Member
Mar 15, 2018
267
3
0
I was wondering if there is any way to notice that a player has sent a valid link or sent a link to a site that exists. If you still do not understand it is very well: if the player says in argument 1 this: https://khjbdhjbdvfvfhdjkssd.net, that site does not exist, so if a player announces an invalid link or website or does not exist it will give an error. Another example:
 
you could try something like
code_language.skript:
if text from arg-1 is not "<none>":
 
it works. duplicate thread btw
no, it does not. In the event that the http request failed which is essentially what OP is looking for, the result would be null not <none> and thus the comparison would fail on a dead link
 
no, it does not. In the event that the http request failed which is essentially what OP is looking for, the result would be null not <none> and thus the comparison would fail on a dead link
the result is <none> i tested it
 
code_language.skript:
command /test <string>:
    trigger:
        broadcast "%text from arg-1%"

code_language.skript:
command /test <string>:
    trigger:
        if text from arg-1 is not "<none>":
            broadcast "Valid link."
        else:
            broadcast "Invalid link"
works like a charm
 
code_language.skript:
command /test <string>:
    trigger:
        broadcast "%text from arg-1%"

code_language.skript:
command /test <string>:
    trigger:
        if text from arg-1 is not "<none>":
            broadcast "Valid link."
        else:
            broadcast "Invalid link"
works like a charm
No kidding. You are stringifying null, which Skript represents as <none>. The actual returned value is *not* <none> and thus the two will not be equivalent. If you were to broadcast
code_language.skript:
broadcast "%check [text from arg-1 is ""<none>""]%"
you would see the result is false for an invalid URL. Anyways, text from url isn't something anyone should use anymore. The correct solution here is to not do any checking because someone could always just put some random valid URL. If OP really wants to do this, the proper way to do it is Reqn.
 
ok why does it matter if it works
yeah you're right i love it when my server lags for multiple seconds whenever someone uses a command. plus, it has no cooldown so if someone just spammed this command the server will hang and eventually crash due to Watchdog.
[doublepost=1523839128,1523838992][/doublepost]
ok why does it matter if it works
plus it doesnt work lol
 
you really over-exaggerate things. the lag is non-existent and please try to crash a server with this and let me know how it goes
[doublepost=1523839671,1523839494][/doublepost]
Capture.PNG

spamming as fast i could for a solid 30 seconds. no crash in sight. the seconds is the difference between the time at the start of the command and at the end
 
you really over-exaggerate things. the lag is non-existent and please try to crash a server with this and let me know how it goes
until you factor in that with an invalid input the lag would be very much because the server waits for the connection to time out. I'll be back in a couple minutes with code to crash a server
 
code_language.skript:
command lag:
  trigger:
    broadcast text from url "https://www.needomart.com/"
run that and watch your server burn. Really though, I'm not the only person who has ever thought that doing synchronous web requests is a bad idea. If you google it, you can see all sorts of reasons from people much smarter than either of us explaining why it's bad. Not to mention skquery's creator made Reqn because there were no suitable web request addons.
[doublepost=1523840180,1523840115][/doublepost]
what do you mean an invalid input? i was putting hello as the url
that's faster because the DNS lookup fails so it fails pretty speedily. If I were to give it a URL that is slow to load, or a valid domain that points to an IP that will never respond, you will see what I mean.
 
I did not understand, what I have to do so that the player places a valid link and if the player puts an invalid link from an error.
[doublepost=1523841454,1523840934][/doublepost]I wanted argument 1 to be a valid link or a site that exists. And if the player put in argument 1 a link type: https://hghsdgbdshj.net, it would give an error. But why would you give an error: Because the site does not exist.
 
I did not understand, what I have to do so that the player places a valid link and if the player puts an invalid link from an error.
[doublepost=1523841454,1523840934][/doublepost]I wanted argument 1 to be a valid link or a site that exists. And if the player put in argument 1 a link type: https://hghsdgbdshj.net, it would give an error. But why would you give an error: Because the site does not exist.
This might work using reqn
code_language.skript:
send a request to arg-1
if last http response is not set:
  send "invalid"
 
Status
Not open for further replies.