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.

CTCP returns

Old posts that have not been replied to for several years.
Locked
M
Monty_
Voice
Posts: 23
Joined: Wed May 19, 2004 11:51 pm

CTCP returns

Post by Monty_ »

How do I capture the return of a CTCP TIME command. The most informative document I can find on scripting this comes from SUNiNET and gives the format:

putserv "PRIVMSG $chan :\001 TIME $nick"

I see that the command executes, but I want to capture the output for processing. Any suggestions?

Thanks
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Re: CTCP returns

Post by egghead »

Monty_ wrote:How do I capture the return of a CTCP TIME command. The most informative document I can find on scripting this comes from SUNiNET and gives the format:

putserv "PRIVMSG $chan :\001 TIME $nick"

I see that the command executes, but I want to capture the output for processing. Any suggestions?

Thanks
Create a binding to CTCR.
M
Monty_
Voice
Posts: 23
Joined: Wed May 19, 2004 11:51 pm

Post by Monty_ »

the CTCP binding...I read about that in the tcl-commands documentation that comes with the eggdrop. Is there a better explanation somewhere? It seems the docs I have are good if you already know what you're doing, but I'm not there yet.

Thanks
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Hi

try something like this:

to send a ctcp time request

Code: Select all

putserv "PRIVMSG $nick :\001TIME"  
and to read the reply

Code: Select all

bind ctcr - TIME time_reply
proc time_reply {nick host handle dest keyword args} {
 set reply [lindex $args 0]
 # ....
} 
M
Monty_
Voice
Posts: 23
Joined: Wed May 19, 2004 11:51 pm

Post by Monty_ »

Ok, that's starting to make sense. I'm presuming, if I read tcl-commands corrctly, that dest will contain the bot's nick; keyword I'm unsure of, but I can always display it to verify (probably the word "TIME"?); and args will contain the time and date information from the user.

Thanks, I really appreciate this. Seeing an example clears things up dramatically.

Monty
M
Monty_
Voice
Posts: 23
Joined: Wed May 19, 2004 11:51 pm

Post by Monty_ »

Just when I thought I had things down, nothing happens. I wrote the following code:

bind join - * time_hack

proc time_hack { nick uhost hand chan } {

putserv "PRIVMSG Monty_ :\001TIME $nick"

}

bind ctcr - TIME get_date

proc get_date { nick uhost hand dest keyword text } {

putserv "privmsg Monty_ :nick = $nick"
putserv "privmsg Monty_ :uhost = $uhost"
putserv "privmsg Monty_ :hand = $hand"
putserv "privmsg Monty_ :dest = $dest"
putserv "privmsg Monty_ :keyword = $keyword"
putserv "privmsg Monty_ :text = $text"

}

And I see the ctcp time go out, but I get no response at all. Is there anything wrong with this code?

Thanks
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Instead of:

Code: Select all

putserv "PRIVMSG Monty_ :\001TIME $nick"
Try:

Code: Select all

putserv "PRIVMSG Monty_ :\001TIME $nick\001"
M
Monty_
Voice
Posts: 23
Joined: Wed May 19, 2004 11:51 pm

Post by Monty_ »

Yeah, I tried that too. Still no reply. It's weird.

Monty
M
Monty_
Voice
Posts: 23
Joined: Wed May 19, 2004 11:51 pm

Post by Monty_ »

Here's a thought...

Would it make a difference that I run this bot on a Windows system? I don't have the bot running in a shell on an internet server, just my local PC that's connected to the net.

Monty
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Monty_ wrote:Here's a thought...

Would it make a difference that I run this bot on a Windows system? I don't have the bot running in a shell on an internet server, just my local PC that's connected to the net.

Monty
It is unclear what you want to do.

Send out a CTCP to the channel, have users respond to that CTCP and then the bot needs to catch the CTCP resonses?

Or do you want to send a CTCP to the bot and have the bot catch that CTCP?
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Use the following piece of code to do the following:

1. Upon a public !time the bot will send a TIME CTCP to itself
2. The bot should reply something to it (not done by the below piece of code)
3. The ctcr binding catches this reply

Code: Select all

bind pub - !time time_hack

proc time_hack { nick uhost hand chan text } {
   global botnick
   putserv "PRIVMSG $botnick :\001TIME\001"
}

bind ctcr - TIME get_date

proc get_date { nick uhost hand dest keyword text } {
   putlog "nick = $nick"
   putlog "uhost = $uhost"
   putlog "hand = $hand"
   putlog "dest = $dest"
   putlog "keyword = $keyword"
   putlog "text = $text"
} 
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Um.. you're not sending a TIME ctcp to the person joining the channel, you are sending it to yourself, hence the "privmsg Monty_" ...

Code: Select all

bind join - * time {nick uhost hand chan} {
  putserv "PRIVMSG $nick :\001TIME\001"
  putserv "PRIVMSG Monty_ :Sent TIME request to $nick" ;# <- i assume this is what you meant by messaging yourself
}

# rest of code the same ....
<edit>
Meh.. egghead answered before me..
M
Monty_
Voice
Posts: 23
Joined: Wed May 19, 2004 11:51 pm

Post by Monty_ »

Ah, things aren't as clear as I thought. Sorry for the confusion. The idea is to have the bot send a ctcp TIME to a person joining a channel and capture the result for processing. I had coded all the

putserv "PRIVMSG Monty_ :nick = $nick"

...type statements so I could just see it work.
Locked