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 

ping address

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


Joined: 07 Aug 2007
Posts: 67

PostPosted: Mon Jan 16, 2012 6:19 am    Post subject: ping address Reply with quote

Hi everyone Smile

Im looking for a script, that pings a given address and replies ping time / if url is up or down / in seconds.

Like:

!ping 173.194.69.104

bot: ping reply 1.4s

or !ping 177.777.154
bot: down / not reachable

if possible a configurable timeout would be appreciated.

Hope someone is willing to do me this favour!

Thanks!
Back to top
View user's profile Send private message
iRoc
Guest





PostPosted: Mon Jan 16, 2012 7:06 am    Post subject: Reply with quote

5:01:33pm / * <iRoc> !ping 74.125.235.49
5:01:36pm / * <iB0T> Address: 74.125.235.49 Status: ONLINE PING Speed: 71.82 ms

5:07:39pm / * <iRoc> !ping google.com
5:07:41pm / * <iB0T> Address: google.com Status: ONLINE PING Speed: 11.53 ms

5:01:54pm / * <iRoc> !ping 205.234.179.173
5:01:56pm / * <iB0T> Address: 205.234.179.173 Status: OFFLINE PING Speed: 0 ms

Code:

bind pub -!- !ping ping
proc ping {nick uhost hand chan text} {
   set ping(page) http://www.iwebtool.com/ping?domain=
   set t [::http::geturl "$ping(page)$text" -timeout 30000]
   set data [::http::data $t]
   set text [lindex [split $text] 0]
   ::http::cleanup $t
   
   putlog "$ping(page)$text"
   
#   putlog "$l"

   if {[string is space $text]} {
   putserv "PRIVMSG $chan :No IP given. Usage : !ping <IPADDRESS>"
   return 0   
   } else {


   set l [regexp -all -inline -- {<tr><td align="center">.*?</td><td>(.*?)</td><td align="center"><font color="#.*?"><b>(.*?)</b></font></td><td align="center">(.*?)</td></tr>} $data]

   foreach {black a b c} $l {
   
      set a [string trim [string map {{&nbsp;} {} {\n} {}} $a]]
      set b [string trim [string map {{ONLINE} {3ONLINE} {OFFLINE} {4OFFLINE} {&nbsp;} {} {\n} {}} $b]]
      set c [string trim [string map {{&nbsp;} {} {\n} {}} $c]]
      
      putserv "PRIVMSG $chan :Address:14 $a Status: $b PING Speed:14 $c "

      return 0      
   }
   putserv "privmsg $chan :Sorry, $nick $text Not Valid IP"   
   
   }
}
Back to top
CrunchyCap
Voice


Joined: 17 Jan 2012
Posts: 2

PostPosted: Tue Jan 17, 2012 11:00 am    Post subject: Reply with quote

I tried this out but get this error
Quote:
Tcl error [ping]: invalid command name "::http::geturl"


Means I am missing a package or?
Back to top
View user's profile Send private message
CrunchyCap
Voice


Joined: 17 Jan 2012
Posts: 2

PostPosted: Tue Jan 17, 2012 3:35 pm    Post subject: Reply with quote

Add this as first line of the script to get it to work.

"package require http"

Thanks thommey!
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