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 

Setting $chan when not a arg
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Thu Apr 15, 2021 2:08 pm    Post subject: Reply with quote

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 Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DasBrain
Voice


Joined: 08 Apr 2021
Posts: 12

PostPosted: Thu Apr 15, 2021 2:33 pm    Post subject: Reply with quote

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


Joined: 22 Feb 2020
Posts: 374

PostPosted: Thu Apr 15, 2021 2:42 pm    Post subject: Reply with quote

Interesting DasBrain, thanks very much for that Wink
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Thu Apr 15, 2021 5:37 pm    Post subject: Reply with quote

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 Smile
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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