This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Ping error ?

Help for those learning Tcl or writing their own scripts.
Post Reply
p
pektek
Halfop
Posts: 55
Joined: Sat Jul 01, 2023 4:51 pm

Ping error ?

Post by pektek »

I ran tcl for myself but I got an error

!ping

[02:48:07] Tcl error [ping_cevabi]: can't read "ping_suresi(cengiz)": no such element in array

Code: Select all

set ping_bklm_srsi 15000
set ping_kanal "#Sohbet"
 
bind pub - !ping ping
bind ctcr - PING ping_cevabi

proc ping {nick uhost handle chan arg} {
    global botnick ping_suresi ping_kanal ping_bklm_srsi
    if {[lindex $arg 0] == ""} { set nick $nick }
    if {[lindex $arg 0] != ""} { set nick [string tolower [lindex $arg 0]] }
    set ms [clock clicks -milliseconds]
    if {[info exists ping_suresi($nick)]} {
	if {[expr $ms - $ping_suresi($nick)] < $ping_bklm_srsi} {
	    putserv "NOTICE $nick :Henüz bir ping istediniz, lütfen biraz sonra tekrar deneyin."
	    return
	}
    }
    set ping_suresi($nick) $ms
    set ping_kanal $chan
    putserv "PRIVMSG $nick :\001PING $ping_suresi($nick)\001";
}

proc ping_cevabi {nick uhost handle {dest ""} keyword text} {
    global botnick ping_suresi ping_kanal
    set cnick [string tolower $nick]
    if {$dest == ""} {set dest $botnick}
    if {$dest == $botnick} {
	set ms [clock clicks -milliseconds]
	set fark [expr [expr $ms - $ping_suresi($cnick)]/1000.0]
	putserv "PRIVMSG $ping_kanal :$nick ping süreniz $fark saniye."
    }
}
putlog "pingkanal.tcl"
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Ping error ?

Post by CrazyCat »

This is because if you don't put any argument when doing !ping, you use the nick of the person without lowercase it:
if {[lindex $arg 0] == ""} { set nick $nick }
Correct that with:
if {[lindex $arg 0] == ""} { set nick [string tolower $nick] }
User avatar
aslpls
Halfop
Posts: 52
Joined: Mon May 02, 2016 9:41 am

Re: Ping error ?

Post by aslpls »

it is working with the updated code from Crzy..

the output is

Code: Select all

<Botname> aslpls ping süreniz 2.177 saniye.
<Botname> aslpls ping süreniz 2.321 saniye.
2 ping results in the channel. how can we remove the second ping output? it is redundant to have two output when you
type !ping in the channel.
It was FUNNY!
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Ping error ?

Post by CrazyCat »

Check if you don't have 2 binds ctcr loaded (multiple loading of script without restarting it ?)
When I tested it, I only got one response from the eggdrop. And as your ping aren't the same, I suspect it's due to a side-effect in your eggdrop (restart could be a good idea) or the network you're on, or anything else but not related to the script itself.
User avatar
aslpls
Halfop
Posts: 52
Joined: Mon May 02, 2016 9:41 am

Re: Ping error ?

Post by aslpls »

Restarted the bot last night, after 8hrs of sleep. I tried it and it is working perfect. You are right Crzy.
Pektek, now you're script is working properly.
It was FUNNY!
p
pektek
Halfop
Posts: 55
Joined: Sat Jul 01, 2023 4:51 pm

Re: Ping error ?

Post by pektek »

thank you everyone in advance
Post Reply