| View previous topic :: View next topic |
| Author |
Message |
sadnem Voice
Joined: 18 Mar 2010 Posts: 10
|
Posted: Sun Dec 19, 2010 1:30 pm Post subject: [SOLVED] Check if a website is down or not using isup.me |
|
|
Hello, I´m currently searching for a tcl script that will retrieve info from isup.me (aka downforeveryoneorjustme.com )
an example output would be like:
| Code: | !isup google.com
<bot> It's just you. http://google.com is up. |
| Code: | !isup fakewebsite81823.com
<bot> It's not just you! http://fakewebsite81823.com looks down from here. |
| Code: | !isup website
<bot> Huh? http://website doesn't look like a site on the interwho. |
To directly access to the site´s output of a website you can directly access http://isup.me/website to retrieve the desired information.
It doesn´t seems complicated although I have no tcl skills at all and my curl knowledge it´s pretty poor so I don´t really know where to start, if someone could do this script for me I'd be very grateful.
Last edited by sadnem on Sun Dec 19, 2010 6:57 pm; edited 1 time in total |
|
| Back to top |
|
 |
Trixar_za Op

Joined: 18 Nov 2009 Posts: 143 Location: South Africa
|
Posted: Sun Dec 19, 2010 3:59 pm Post subject: |
|
|
Ok, I tested it and it works: | Code: | # Isup.me Script by Trixar_za
# Type in partyline: .chanset #channel +isup to enable it.
# Sets the user agent
set isup(agent) "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)"
setudef flag isup
if {[catch {package require http 2.5} e] != 0} {
set isup(noutf8) 1
package require http
}
bind pub - !isup proc:isup
proc proc:isup {nick uhand handle chan input} {
if {[channel get $chan isup]} {
global isup
if {![llength [split $input]]} {
putquick "PRIVMSG $chan Please supply a website address. Ex: !isup google.com"
} else {
if {[info exists isup(noutf8)]} {
set http [::http::config -useragent $isup(agent)]
} else {
set http [::http::config -useragent $isup(agent) -urlencoding "utf-8"]
}
catch { set http [::http::geturl "http://www.isup.me/$input" -timeout 10000]} error
if {![string match -nocase "::http::*" $error]} {
putquick "PRIVMSG $chan [string totitle [string map {"\n" " | "} $error]] \( $input \)"
return 0
}
if {![string equal -nocase [::http::status $http] "ok"]} {
putquick "PRIVMSG $chan [string totitle [::http::status $http]] \( $input \)"
return 0
}
set html [::http::data $http]
# Clean up :P
regsub -all {\n} $html { } html
regsub -all {\t} $html { } html
regsub -all {<br/>} $html { } html
regsub -all { } $html { } html
regsub -all { } $html { } html
regsub -all { } $html { } html
regsub -all { } $html { } html
regsub -all {<a.+?>} $html {} html
regsub -all {</a>} $html {} html
regsub -all {<span.+?>} $html {} html
regsub -all {</span>} $html {} html
regsub -all {—} $html {-} html
regsub -all {>} $html {>} html
regsub -all {<} $html {<} html
regsub -all {&} $html {\&} html
regsub -all {×} $html {*} html
regsub -all {(?:\x91|\x92|’|‘|')} $html {'} html
regsub -all {(?:\x93|\x94|“|”|")} $html {"} html
regsub -all {×} $html {x} html
if {[regexp -- {<div.+?>(.+?)<p>} $html - upsite]} {
set upsite [string trim $upsite]
}
if {[info exists upsite]} {
putquick "PRIVMSG $chan $upsite"
} else {
putquick "PRIVMSG $chan Ironically, I couldn't get anything from isup.me!"
}
}
}
}
putlog "Isup.me Script by Trixar_za Loaded" |
_________________ http://www.trixarian.net/Projects
Last edited by Trixar_za on Mon Dec 20, 2010 4:20 am; edited 1 time in total |
|
| Back to top |
|
 |
sadnem Voice
Joined: 18 Mar 2010 Posts: 10
|
Posted: Sun Dec 19, 2010 6:57 pm Post subject: |
|
|
| It´s working as a charm, thank you. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Dec 20, 2010 1:48 am Post subject: |
|
|
It's me or you forgot to define $isup(logo)? Also, shouldn't it be:
| Code: |
putquick "PRIVMSG $chan :$upsite"
|
(notice the missing ':' after the $chan variable)? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Trixar_za Op

Joined: 18 Nov 2009 Posts: 143 Location: South Africa
|
Posted: Mon Dec 20, 2010 4:23 am Post subject: |
|
|
I forgot to remove that last $isup(logo) yes and in the strictest sense you don't need that : in privmsg, except on IRCds that STRICTLY adheres to the IRC protocol. So far I've found only one such server and that's with bitlbee, the rest seem to work just as well without it  _________________ http://www.trixarian.net/Projects |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Dec 20, 2010 6:15 am Post subject: |
|
|
I see. What happens if I would do !isup [die] for instance?  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Trixar_za Op

Joined: 18 Nov 2009 Posts: 143 Location: South Africa
|
Posted: Mon Dec 20, 2010 7:43 am Post subject: |
|
|
| caesar wrote: | I see. What happens if I would do !isup [die] for instance?  | [@GameBot] Illegal characters in url path ( [die] ) <--- that happens  _________________ http://www.trixarian.net/Projects |
|
| Back to top |
|
 |
Ashoq Voice

Joined: 17 Jul 2010 Posts: 11
|
Posted: Wed Dec 22, 2010 2:35 pm Post subject: |
|
|
something wrong
i tested a down website on www.isup.me it said 'down' on tcl it said 'up' |
|
| Back to top |
|
 |
Trixar_za Op

Joined: 18 Nov 2009 Posts: 143 Location: South Africa
|
Posted: Wed Dec 22, 2010 8:23 pm Post subject: |
|
|
Eh, then it was down for a bit. All the script does is grab the text from the website each time the command is invoked. So what your seeing isn't cached at all and is the website's response as it happens. _________________ http://www.trixarian.net/Projects |
|
| Back to top |
|
 |
teegg Voice
Joined: 04 Apr 2012 Posts: 7
|
Posted: Thu Apr 19, 2012 9:43 am Post subject: |
|
|
this script was not working for me..so i played around with it a. It turns out the following codes were not pasted correctly into vi. Maybe vi doesnt support these codes?
| Code: |
regsub -all {—} $html {-} html
regsub -all {(?:\x91|\x92|’|‘|')} $html {'} html
regsub -all {(?:\x93|\x94|“|”|")} $html {"} html
|
But anyhow I commented them out and the script works again. |
|
| Back to top |
|
 |
Cerberus Voice
Joined: 01 Sep 2008 Posts: 7
|
Posted: Tue May 01, 2012 3:27 pm Post subject: |
|
|
with a few edit script worked great.
removed extra close brace from end of script
changed useragent to:
Mozilla/5.0 (X11; U; Linux i686; el-GR; rv:1.8.1) Gecko/2010112223 Firefox/3.6.12
and removed the -urlencode section.
i also added this so script can be turned on or off via public command by bot master.
| Code: |
bind pub m|m &isup-script WSS-Settings
proc WSS-Settings {nick host hand chan text} {
if {![channel get $chan isup] && $text == "on"} {
catch {channel set $chan +isup}
putserv "notice $nick :Web Site Statuc Checker: enabled for $chan"
putlog "Web Site Statuc Checker: script enabled (by $nick for $chan)"
} elseif {[channel get $chan isup] && $text == "off"} {
catch {channel set $chan -isup}
putserv "notice $nick :Web Site Statuc Checker: disabled for $chan"
putlog "Web Site Statuc Checker: script disabled (by $nick for $chan)"
} else {
putserv "notice $nick :Web Site Statuc Checker: &isup-script (on|off) enables or disables script for active channel"
}
}
|
|
|
| Back to top |
|
 |
|