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.

return value raw binding

Old posts that have not been replied to for several years.
Locked
s
sege

return value raw binding

Post by sege »

I'm working on a !whois-script among other stuff and I'd like to return a value when doing 'bind raw - 311 foo:bar' (just example). Right now my code is (like):

Code: Select all

bind raw - 311 sege:whois
putserv "WHOIS $text" -next

proc sege:whois { from key arg } {
   set realname [string trimleft [join [lrange [split $arg] 5 end]] :]
   puthelp "NOTICE $target :$nick utger sig för att vara: $realname" -next
}
Very shortened. But my problem here is that i dont want to print stuff in sege:whois, I just want to save into a variable and print later. How do I achieve (sp?) this?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Re: return value raw binding

Post by ppslim »

Simply do as you said you want to

Code: Select all

bind raw - 311 sege:whois
putserv "WHOIS $text" -next

set outputbuffer {}

proc sege:whois { from key arg } {
   global outputbuffer
   set realname [string trimleft [join [lrange [split $arg] 5 end]] :]
   #puthelp "NOTICE $target :$nick utger sig för att vara: $realname" -next
    lappend outputbuffer "NOTICE $target :$nick utger sig för att vara: $realname"
}
You can then output the contents of $outputbuffer late on
s
sege

Post by sege »

Hmm, the problem is that it always seems to be one step after. I really cant get around this. The variable is set first when WHOIS is executed, but it prints before. You want to see more code or do you understand my problem?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

If using the code above, there should be no ouput, until you tell it to.

A ssuch, I guess we would need to see more code.
s
sege

Post by sege »

Code: Select all

proc sege:whois:main { nick uhost hand targ text } {
        bind raw - 313 sege:whois:ircop
        bind raw - 301 sege:whois:away
        bind raw - 311 sege:whois:realname
        putserv "WHOIS $text" -next
}

proc sege:whois:realname { from key arg } {
        global target

        set nick [lindex [split $arg] 1]
        set username [lindex [split $arg] 2]
        set hostname [lindex [split $arg] 3]
        set realname [string trimleft [join [lrange [split $arg] 5 end]] :]
        unbind raw - 311 sege:whois:realname
        puthelp "NOTICE $target :$nick utger sig för att vara: $realname" -next
}
proc sege:whois:ircop { from key arg } {
        global target awayreason
        set nick [lindex [split $arg] 1]
        unbind raw - 313 sege:whois:ircop
        puthelp "NOTICE $target :$nick är en av administratörerna på den här chatten" -next
}
  
proc sege:whois:away { from key arg } {
        global target
        set nick [lindex [split $arg] 1]
        set awayreason ""
        set awayreason [string trimleft [lrange $arg 2 end] :]
        unbind raw - 301 sege:whois:away
        puthelp "NOTICE $target :$nick is away with reason: $awayreason" -next
}
This is what it is now. In the nice future I'd like my procs to give me a variable back that I can print in sege:whois:main or other called proc. I also want some true/false-procs with nickserv-check and stuff in some other scripts. And I just can't get this to work. If I set variable in like sege:whois:away it's always one person behind. Do I have to make a delay/sleep or something before I print, or is my thought totally wrong?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

You will not be able to use sage:whois:main to output anything.

After executing the putserv line in sage:whois:main, the script will terminate, and pass control back to eggdrop. It is not until control is back with eggdrop, that the "WHOIS" line is sent to the server.

Don't use putserv lines in the other procedures, as this sends the text ot the server, which you have allready stated you don't want.

You should store the data instead.

I have given an example which you claim you had used, but failed, but in reality hasn't been used.
s
sege

Post by sege »

You missunderstand me, or I missunderstand you.

This is my script now, working.

I tried to rewrite it by using your example and got like

Code: Select all

bind raw - 313 sege:whois:ircop
bind raw - 301 sege:whois:away
bind raw - 311 sege:whois:realname
putserv "WHOIS $text" -next
puthelp "NOTICE $target :$foo"
return 1
And instead of puthelp "NOTICE $target :" in sege:whois:[ircop|away|realname] I tried to save variables there.

As said, I can't get it to work. Maybe I'm dumb or something. =)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

As I sated, you can't do this inside sage:whois:main.

Lets look through it step by step.

Code: Select all

bind raw - 313 sege:whois:ircop 
bind raw - 301 sege:whois:away 
bind raw - 311 sege:whois:realname 
putserv "WHOIS $text" -next 
puthelp "NOTICE $target :$foo" 
return 1
bind raw - 313 sege:whois:ircop
This sets a script that is designed to capture the incoming 313 raw event (IE, ircop status).

bind raw - 301 sege:whois:ircop
Again, sets a cript that will capture part of the whois

bind raw - 311 sege:whois:ircop
And again, another part of the whois.

putserv "WHOIS $text" -next
This inserts the text "WHOIS $text" (with $text being replaced correctly) into the server queue, but places it as the next line to be sent because of the -next.

The text is not sent right away. When Tcl scripts are run, eggdrop is frozen in a point in time, until the script completes. Besides this, eggdrop can't call sege:whois:ircop, or any of the others until it's completed, as it has currecntly passed control to Tcl.

Until eggdrop has gained control again, it won't even process the incoming reply. As stated though, this reply will not be waiting, as it hasn't been requested yet.

THere is a "End of whois" rar that can be used. Setup you script to use this. When it receives it, you can then output the stored information.

You will also have to drop the -next flag for the output for this ifnormation, as there will be no guarentee on the order it is dispalyed.
s
sege

Post by sege »

Aah, now I understand. I haven't figured out how to solve the waiting for 318 (end of whois) and if I can do that in the same script but a until()-procedure or something maybe.

But I also got a problem cause I want -next so !whois-info doesn't have to wait until some !help-texts and stuff are printed.

Hmm.
Damn.

Thanks!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Again, you need to post a better discription, as your question is not entirly obvious.
s
sege

Post by sege »

I was just thinking loud.. or something like that.

My problem is that i want to use -next on putserv/puthelp in my whois-script cause I have som rules/help/memo-scripts which can produce like 15-30 rows, and I dont want a !whois to be put on hold for that long. When someone do a whois my bot should reply to it asap and then continue printing rules/or whatever it was doing. And now you say I wont be able to do this if I have this solution..

My other thought was this 318 'end of whois'-row which I have to wait for before I print start to print my variables produced by WHOIS.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

No, this is not true, you just have to use the correct command.

The putserv command, has priority over puthelp.

As such, if you place 20 lines in the queue with puthelp, placeing 1 line in the putserve queue will allways be displayed before puthelp. This applies with or without the -next.

If the only reason you wish to use -next for, is to beat any other data, then use puthelp for bulk data like your rules script, and putserv for the whois script, however, don't use -next.

The reason. If there are important commands being injected into the putserv queue, you don't want a whois script delaying there output, just like you don't want your rules delaying the whois.
Locked