I haven't scripted anything in a while, so I decided to make something simple with some regex, also so that I don't lose my familiarity with mIRC scripting.
This snippet is a website checker. Simply put, it checks to see if the site is "up" or "down".
[size=16]Syntax: /check [/size]
For example:
/check www.hawkee.com
Enjoy! :D
alias check {
if ($sock(sitecheck)) { sockclose sitecheck }
sockopen sitecheck www.downforeveryoneorjustme.com 80
sockmark sitecheck $$1
}
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
}
on *:sockread:sitecheck: {
var %x | sockread %x
if ($regex(%x,(.+)<a href="(.+)"\sclass="domain">.+<\/a>(.+))) {
echo -a $regsubex($+($regml(1),,$regml(2),,$regml(3)),/(<[^>]*>)/g,)
}
}
@Grant-:
Must correct (Grammar nazi mode on)
Code:
if ($sock(sitecheck)) { sockclose sitecheck }
if ($sock(sitecheck)) sockclose sitecheck
That actually slows the script down. ^_^
Using brackets speeds up processing. If an alias uses too few brackets then the statement might be ambiguous and the alias will take longer to parse, might be parsed incorrectly, or might not be parsed at all.
In retrospect, what I'm saying is true.
@Cheiron:
oh crap i know what i did forget to ask .. for the bot version .. how do i restrict it to ops only to use it and if a non op tried to use it.. it will message the user they need ops to use it
Just add:
if ($nick(#,$nick,o)) {
awesome Kirby :)
that does me perfect for what i needed. got both personal and the bot one loaded and all looking sweet as .. bumping this to a 8
thankies
oh crap i know what i did forget to ask .. for the bot version .. how do i restrict it to ops only to use it and if a non op tried to use it.. it will message the user they need ops to use it
i tried editing the first line to on @*:text: and it wouldnt work heh
Something like this Cheiron?
on $*:text:/^[.!@]check*/Si:#: {
if ($sock(check)) { sockclose check }
sockopen check www.downforeveryoneorjustme.com 80
sockmark check $$2 # $nick
}
on *:sockopen:check: {
sockwrite -n $sockname GET $+(/,$gettok($sock(check).mark,1,32)) HTTP/1.1
sockwrite -n $sockname Host: www.downforeveryoneorjustme.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:sockread:check: {
var %x | sockread %x
if ($regex(%x,(.+)<a href="(.+)"\sclass="domain">.+<\/a>(.+))) {
tokenize 32 $sock(check).mark
msg $2 $+($3,:) $regsubex($+($regml(1),,$regml(2),,$regml(3)),/(<[^>]*>)/g,)
}
}
[size=14]Syntax: .check [/size]
Intended for a bot...renamed the sock name...
..and thank you.
I wanted this to be simple, for personal use, rather than bot use. Otherwise, use the code above.
works nicely Kirby. good job. a few ideas for an update for you.. instead of the echo .. possibly get it to msg channel or notice the nick .. other than that .. turn it to a bot use. running off of a trigger for users :)
as it is .. i like it.. it gets a like and 6. will up that if any of the updates are done