| View previous topic :: View next topic |
| Author |
Message |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Apr 15, 2021 2:08 pm Post subject: |
|
|
forgot about this post.
Yes willyw, that would make the ping reply proc output to the $nick
I also changed to | Code: | | unset pingchan($nick) | and it works great  _________________ ComputerTech |
|
| Back to top |
|
 |
DasBrain Voice
Joined: 08 Apr 2021 Posts: 12
|
Posted: Thu Apr 15, 2021 2:33 pm Post subject: |
|
|
There is an other way - as you can pass any data through the CTCP ping (the other side will return the data back to you), you can use this to keep track of who this PING belongs to.
In other words, if you send a "/CTCP <somenick> PING FOO", they will reply with "/CTCR <yournick> PING FOO".
| Code: |
set pingspending [dict create]
set pingcounter 0
proc ct:pub:ping {nick host hand chan text} {
global pingpending pingcounter
incr pingcounter
set who [lindex [split $text] 0]
dict set pingpending $pingcounter nick $nick
dict set pingpending $pingcounter chan $chan
dict set pingpending $pingcounter who $who
dict set pingpending $pingcounter time [clock clicks -milliseconds]
putquick "PRIVMSG $pingwho :\001PING $pingcounter\001"
}
proc ct:pingr {nick uhost hand dest keyword text} {
global pingpending
if {![dict exists $pingpending $text]} {return}
set data [dict get pingpending $text]
dict unset pingpending $text
set time [expr {([clock clicks -milliseconds] - [dict get $data time]) / 1000.000}]
set char "="
if {[expr {round($time / 0.5)}] > 10} {set red 10} else {set red [expr {round($time / 0.5)}]}
set green [expr {10 - $red}]
set output \00303[string repeat $char $green]\003\00304[string repeat $char $red]\003
if {($ctping(msg) == "0")} {
putquick "PRIVMSG [dict get $data chan] :\[\0030${colo}PING\003\] reply from $nick: \[\0030${colo}$time\003\] seconds $output"
} else {
putquick "NOTICE [dict get $data nick] :\[\0030${colo}PING\003\] reply from $nick: \[\0030${colo}$time\003\] seconds"
}
} |
Last edited by DasBrain on Thu Apr 15, 2021 3:07 pm; edited 2 times in total |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Apr 15, 2021 2:42 pm Post subject: |
|
|
Interesting DasBrain, thanks very much for that  _________________ ComputerTech |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Thu Apr 15, 2021 5:37 pm Post subject: |
|
|
Really interesting, I never tested this way to use ping (or probably other ctcp commands), it could help for some scripts.
Gonne read another time the rfc-1459  _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
|