egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Check if a website is down or not using isup.me

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
sadnem
Voice


Joined: 18 Mar 2010
Posts: 10

PostPosted: Sun Dec 19, 2010 1:30 pm    Post subject: [SOLVED] Check if a website is down or not using isup.me Reply with quote

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
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Sun Dec 19, 2010 3:59 pm    Post subject: Reply with quote

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 {&nbsp;} $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 {&gt;} $html {>} html
       regsub -all {&lt;} $html {<} html
       regsub -all {&amp;} $html {\&} html
       regsub -all {&times;} $html {*} html
       regsub -all {(?:\x91|\x92|’|‘|')} $html {'} html
       regsub -all {(?:\x93|\x94|“|”|&quot;)} $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
View user's profile Send private message Visit poster's website
sadnem
Voice


Joined: 18 Mar 2010
Posts: 10

PostPosted: Sun Dec 19, 2010 6:57 pm    Post subject: Reply with quote

It´s working as a charm, thank you.
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Dec 20, 2010 1:48 am    Post subject: Reply with quote

It's me or you forgot to define $isup(logo)? Smile 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
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Mon Dec 20, 2010 4:23 am    Post subject: Reply with quote

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 Razz
_________________
http://www.trixarian.net/Projects
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Dec 20, 2010 6:15 am    Post subject: Reply with quote

I see. What happens if I would do !isup [die] for instance? Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Mon Dec 20, 2010 7:43 am    Post subject: Reply with quote

caesar wrote:
I see. What happens if I would do !isup [die] for instance? Smile
[@GameBot] Illegal characters in url path ( [die] ) <--- that happens Razz
_________________
http://www.trixarian.net/Projects
Back to top
View user's profile Send private message Visit poster's website
Ashoq
Voice


Joined: 17 Jul 2010
Posts: 11

PostPosted: Wed Dec 22, 2010 2:35 pm    Post subject: Reply with quote

something wrong Razz

i tested a down website on www.isup.me it said 'down' on tcl it said 'up'
Back to top
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Wed Dec 22, 2010 8:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
teegg
Voice


Joined: 04 Apr 2012
Posts: 7

PostPosted: Thu Apr 19, 2012 9:43 am    Post subject: Reply with quote

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|“|”|&quot;)} $html {"} html

But anyhow I commented them out and the script works again.
Back to top
View user's profile Send private message
Cerberus
Voice


Joined: 01 Sep 2008
Posts: 7

PostPosted: Tue May 01, 2012 3:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber