| View previous topic :: View next topic |
| Author |
Message |
Elfriede Halfop
Joined: 07 Aug 2007 Posts: 67
|
Posted: Mon Jan 16, 2012 6:19 am Post subject: ping address |
|
|
Hi everyone
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 |
|
 |
iRoc Guest
|
Posted: Mon Jan 16, 2012 7:06 am Post subject: |
|
|
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 {{ } {} {\n} {}} $a]]
set b [string trim [string map {{ONLINE} {3ONLINE} {OFFLINE} {4OFFLINE} { } {} {\n} {}} $b]]
set c [string trim [string map {{ } {} {\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
|
Posted: Tue Jan 17, 2012 11:00 am Post subject: |
|
|
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 |
|
 |
CrunchyCap Voice
Joined: 17 Jan 2012 Posts: 2
|
Posted: Tue Jan 17, 2012 3:35 pm Post subject: |
|
|
Add this as first line of the script to get it to work.
"package require http"
Thanks thommey! |
|
| Back to top |
|
 |
|