| View previous topic :: View next topic |
| Author |
Message |
geek Voice
Joined: 24 Oct 2008 Posts: 37
|
Posted: Sat Dec 26, 2020 7:33 pm Post subject: raw binding |
|
|
I write this small tcl script to understand raw binding:
| Code: | #
# raw 352 risposta al WHO "vanilla"
#
# raw 354 risposta al WHOX che è la versione "extended"
#
#
#
# nel RFC 1459 ( https://www.rfc-editor.org/rfc/rfc1459.txt )
# 402 ERR_NOSUCHSERVER
# 352 RPL_WHOREPLY
# 315 RPL_ENDOFWHO
#
bind pub - !testraw ldm:who
proc ldm:who {nick host hand chan arg} {
set nickname [stripcodes * $arg]
set nickname [string trim $nickname]
set arguments [llength $nickname]
if { $arguments > 1 } {
puthelp "PRIVMSG $chan :specificare un utente alla volta"
return
} elseif { $arguments == 0 } {
puthelp "PRIVMSG $chan :specificare il nickname"
return
}
if { ![onchan $nickname $chan] } {
puthelp "PRIVMSG $chan :nickname non trovato"
return
}
putserv "WHO $nickname"
# bind raw - "315" ldm:whoraw
bind raw - "352" ldm:whoraw
# bind raw - "354" ldm:whoraw
# bind raw - "402" ldm:whoraw
return
}
proc ldm:whoraw {from key text} {
puthelp "PRIVMSG #prova :$text"
return
}
|
is this script secure? are there potential problems with other scripts?
the question is: when I use it, does "ldm:whoraw" capture ONLY the /who command inside this script or is there the possibility that catch /who command from others scripts too?
(sorry for my english) |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sat Dec 26, 2020 8:06 pm Post subject: |
|
|
The ldm:whoraw will catch any who response sent to the eggdrop.
You can simply test that: in party-line, do a .tcl putserv "WHO $botnick" and your proc will work.
A bind catch a specific server event, it's totally independant of who/what asked the server to react.
But your script is secure as it just displays server's who replies to a particular channel. If it's just a test script, you'd better use a putlog and check in party-line, to avoid flood on your server. _________________ 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 |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sun Dec 27, 2020 3:15 am Post subject: Re: raw binding |
|
|
| geek wrote: |
...
the question is: when I use it, does "ldm:whoraw" capture ONLY the /who command inside this script or is there the possibility that catch /who command from others scripts too?
...
|
If this is a concern, here's an idea to consider. It is what I usually do.
| Code: |
proc ldm:who {nick host hand chan arg} {
bind raw - "352" ldm:whoraw
utimer 5 [list unbind raw - "352" ldm:whoraw]
< continue with the rest of the procedure's code here >
}
|
The idea is to create the bind that you will need.
Then, a few seconds later, unbind it.
Of course, you should adjust the value of the utimer to whatever you think is best.
I hope this helps. _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
geek Voice
Joined: 24 Oct 2008 Posts: 37
|
Posted: Sun Dec 27, 2020 6:05 am Post subject: |
|
|
| CrazyCat wrote: | | The ldm:whoraw will catch any who response sent to the eggdrop. |
and if are there more than one scripts that catch the same raw number? is it a problem?
very tnx CrazyCat
| willyw wrote: | It is what I usually do.
The idea is to create the bind that you will need.
Then, a few seconds later, unbind it. |
yes, I'll use your code :)
and very tnx willyw |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sun Dec 27, 2020 6:18 am Post subject: |
|
|
| geek wrote: | | CrazyCat wrote: | | The ldm:whoraw will catch any who response sent to the eggdrop. |
and if are there more than one scripts that catch the same raw number? is it a problem?
very tnx CrazyCat |
You can have multiple scripts using the same raw number without any trouble.
| geek wrote: | | willyw wrote: | It is what I usually do.
The idea is to create the bind that you will need.
Then, a few seconds later, unbind it. |
yes, I'll use your code
and very tnx willyw |
This is a quite good idea to use utimer to unbind, but you can have side effects. _________________ 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 |
|
 |
geek Voice
Joined: 24 Oct 2008 Posts: 37
|
Posted: Sun Dec 27, 2020 7:35 am Post subject: |
|
|
| CrazyCat wrote: |
You can have multiple scripts using the same raw number without any trouble. |
thanks :)
| CrazyCat wrote: | | This is a quite good idea to use utimer to unbind, but you can have side effects. |
what kind of side effects? |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sun Dec 27, 2020 11:10 am Post subject: |
|
|
| geek wrote: | ...
yes, I'll use your code
and very tnx willyw |
And test it. Then test it some more.
One way: use
.binds raw
from the partyline, to be sure that the bind is first there, and then gone, when you expect both. _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
geek Voice
Joined: 24 Oct 2008 Posts: 37
|
Posted: Sun Dec 27, 2020 11:38 am Post subject: |
|
|
and if I want pass a variable from ldm:whoraw to ldm:who ?
something like:
| Code: | proc ldm:whoraw {from key text} {
set ident [lindex $text 2]
return
} |
and in ldm:who
| Code: | | puthelp "PRIVMSG #test :$ident" |
I get always Tcl error: can't read "ident": no such variable |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sun Dec 27, 2020 12:07 pm Post subject: |
|
|
Use global variable:
| Code: | set ::ident [lindex $text 2]
...
puthelp "PRIVMSG #test :$::ident" |
Take care about 2 things:
1. ident is too generic, better to use something like ldmident
2. your variable is set with the answer of the /who command, but the /who is initiated by your ldm:who proc. So you can't already have this value. _________________ 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 |
|
 |
geek Voice
Joined: 24 Oct 2008 Posts: 37
|
Posted: Sun Dec 27, 2020 12:27 pm Post subject: |
|
|
| CrazyCat wrote: |
1. ident is too generic, better to use something like ldmident |
yes :)
| CrazyCat wrote: | | 2. your variable is set with the answer of the /who command, but the /who is initiated by your ldm:who proc. So you can't already have this value. |
you mean in ldm:who:
example1)
puthelp "PRIVMSG #test :$::ldmident"
putserv "WHO $nickname"
example2)
putserv "WHO $nickname"
puthelp "PRIVMSG #test :$::ldmident"
1 -> not work / error
2 -> work
right?
EDIT: NO!
perhaps now I have understand
I try example2 and I get "no such variable" error again
You mean that "it takes some time" for ::ldmident to be available and use it
right? |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sun Dec 27, 2020 1:47 pm Post subject: |
|
|
Check out:
http://www.tcl.tk/man/tcl8.6/TclCmd/global.htm _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
geek Voice
Joined: 24 Oct 2008 Posts: 37
|
Posted: Sun Dec 27, 2020 2:56 pm Post subject: |
|
|
yes tnx, global var ::ldmident works
BUT
there is a kind of "lag" between the WHO command and the availability of the value compute in ldm:whoraw
SO
the first execution I get "no such variable", the following I get a result but is "the old" ident, lol
THIS OCCURS:
(fresh restart of the eggdrop)
first time:
!testraw nickONE -> I get "no such variable"
second time:
!testraw nickTWO -> I get identONE
third time:
!testraw nickTHREE -> I get identTWO
and so on... |
|
| Back to top |
|
 |
geek Voice
Joined: 24 Oct 2008 Posts: 37
|
Posted: Sat Jan 02, 2021 6:12 am Post subject: |
|
|
to avoid the "lag" problem, I put the rest of the code in ldm:whoraw instead of ldm:who
but now
when bot enter in a new channel, I think eggdrop performs a global "WHO #channel" command and so it runs my procedure that catch raw 352 too :)
How can solve this problem? with utimer method of willyw? right? |
|
| Back to top |
|
 |
|