;if someone types ".trr-site" in #toontownwritten channel, and the script isn't already active, set the nick who said the command,
;and execute the website check
on *:TEXT:*:*:{
if ($chan == #toontownrewritten) {
if ($1 == .ttr-site || $2 == .ttr-site) {
if (!%active) {
set %active $nick
check
}
}
}
}
;if I type ".trr-site" in #toontownwritten channel, and the script isn't already active, set me as the nick, and execute the website ;check
on *:INPUT:#toontownrewritten:{
if ($1 == .ttr-site) {
if (!%active) {
set %active $me
check
}
}
}
;Starts the website check process for www.downforeveryoneorjustme.com, a website that checks if the website is online or offline
;with a simple input. I am marking www.toontownrewritten.com as the website to check
alias check {
doublecheck
if ($sock(sitecheck)) { sockclose sitecheck }
sockopen sitecheck www.downforeveryoneorjustme.com 80
sockmark sitecheck toontownrewritten.com
}
;Opens the website check process and inputs www.toontownrewritten.com it into www.downforeveryoneorjustme.com to check if its online or offline.
on *:sockopen:sitecheck: {
sockwrite -n $sockname GET $+(/,$sock(sitecheck).mark) HTTP/1.1
sockwrite -n $sockname Host: www.downforeveryoneorjustme.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
;Once www.downforeveryoneorjustme.com is open, grab the HTML coding, read it, and just display the results of the website,
;stripping ;the HTML from the results as well.
on *:sockread:sitecheck: {
;Read the Socket
var %x | sockread %x
;Strip the Sockets HTML and just display the website online/offline results
if ($regex(%x,(.+)<a href="(.+)"\sclass="domain">.+<\/a>(.+))) {
;If the www.downforeveryoneorjustme.com says the website is up,
if (up isin %x) {
;then lets initiate our doublecheck, but searching the toontownrewritten.com itself for any error messages from their server
doublecheck {
;if the website displays error messages on it,
if (%doublecheck == down) {
;In 2 seconds, we will start unsetting the doublecheck process and the nick, so I wont get spam commands and so the process can restart
.timer 1 2 unset %active
.timer 1 2 unset %doublecheck
;Message #toontownrewritten channel, displaying the nick who said the command, and saying the status of the website,
;stripping the http:// part, and simply showing the website and the status. Since doublecheck == down, this will say the websites down.
msg #toontownrewritten $+ %active $+ : $gettok($replace($regsubex($+($regml(1), $regml(2), $regml(3)), /(<[^>]*>)/g,), http://, ), 2, 46)) $+ .com looks down from here.
}
;If the website is truely up, then display the actual status from www.downforeveryoneorjustme and unset the variables in 2 seocnds
;to prevent spam, and restart the process.
else {
.timer 1 2 unset %active
.timer 1 2 unset %doublecheck
msg #toontownrewritten $+ %active $+ : $deltok($replace($regsubex($+($regml(1), $regml(2), $regml(3)), /(<[^>]*>)/g,), http://, ), 1 ,46)) $+ .
}
}
}
}
}
;Intiate the doublecheck process for toontownrewritten.com. If this socket is still open, lets close it.
;This is a "HTTPS://" ;website vice "HTTP://" so we have to go into SSL mode with the "-e" on sockopen and the websites port of 443.
alias doublecheck {
if ($sock(doublecheck)) { sockclose doublecheck }
sockopen -e doublecheck toontownrewritten.com 443
sockmark doublecheck toontownrewritten.com
}
;Opening of toontownwritten.com - Can't figure out the website coding they use, I've tried index.php, index.html, index.htm,
;index.asp, index.aspx, with no luck so I just directed the website to /news/ folder, which is the default folder anyway.
on *:sockopen:doublecheck: {
sockwrite -n $sockname GET /news/ HTTPS/1.0
sockwrite -n $sockname Host: www.toontownrewritten.com
sockwrite -n $sockname Connection: closed
sockwrite -n $sockname $crlf
}
;Once the website is actually open, read the socket. Don't need to strip it, but just search if the words *application error*
;are displayed on the page, since this is what shows up when the website is online, but with errors. If it does display,
;set doublecheck as down, and continue with the sitecheck socket from www.downforeveryoneorjustme.com website.
on *:sockread:doublecheck: {
var %y
sockread %y
if (*application error* iswm %y) {
set %doublecheck down
}
}