| View previous topic :: View next topic |
| Author |
Message |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Sat Dec 15, 2007 11:17 pm Post subject: [SOLVED] A little problem with the INVITE raw |
|
|
Hello guys, I`m having a issue with my code
The Code
| Code: |
set si(mc) "#monitoringchan"
set si(ac) "#alertchan"
set si(except) {
"*!cservice@undernet.org"
"*!*@me.users.undernet.org"
}
bind raw - INVITE show:invite
proc show:invite { nick uhost key args } {
global botnick si
set nik [lindex [split $nick !] 0]
set host [lindex [split $nick !] 1]
set ban [lindex [split $nick @] 1]
set text [lindex [split $args #] 1]
foreach ehost $si(except) {
if {[string match $ehost "$nik!$host"]} { return 0 }
}
putserv "PRIVMSG $si(ac) :INVITE SPAM by\0032 $nik \003\[$host\]: invited to $text"
putserv "PRIVMSG $si(mc) :.ban *!*@$ban Inviter!"
} |
The Error:
| Quote: | On Alert chan
(05:03:22) <bot> INVITE SPAM by XXXX [~xxx@127.0.0.1]: invited to ...... |
I can't get the right setting for $text so that will see in the alert chan, .... the channel that the bot got invited to by XXXX
Have any ideas ? _________________ I am a man of few words, but many riddles
Last edited by Riddler on Sun Dec 16, 2007 8:56 pm; edited 2 times in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Dec 16, 2007 10:36 am Post subject: |
|
|
First off, it would appear you've got the parameters for your proc slightly off..
| Quote: | (17) RAW (stackable)
bind raw <flags> <keyword> <proc>
procname <from> <keyword> <text>
Description: previous versions of Eggdrop required a special compile
option to enable this binding, but it's now standard. The keyword
is either a numeric, like "368", or a keyword, such as "PRIVMSG".
from will be the server name or the source user (depending on
the keyword); flags are ignored. The order of the arguments is
identical to the order that the IRC server sends to the bot. The
pre-processing only splits it apart enough to determine the
keyword. If the proc returns 1, Eggdrop will not process the line
any further (this could cause unexpected behavior in some cases).
Module: server
|
That is, there should be only three arguments. Furthermore, in your case, you are using the special argument "args" wich may take 0 or more parameters, and concatenates them into a list (in this case, an empty list as there is no 4th or further parameters).
Now, what will your variables contain? (assuming rfc1459 compliant server)
nick: "nick"
uhost: "INVITE"
key: "botnick #channel"
args: ""
First off, I would suggest that you adjust your proc's argument-list, using "args" when it's not needed is a very bad idea. Also, using names that clearly illustrate the contents helps alot.
Secondly, as rfc1459 requires the server to provide the nickname of the provider, and not full host, you'll need to use the "getchanhost" command. Keep in mind that this will only work if the nick is currently in any of the eggdrop's channels. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Sun Dec 16, 2007 6:54 pm Post subject: |
|
|
Hey,
I do agree with you nml375, I`ve just made the script yesterday and never worked with the INVITE raw before
So thanks for the info about how to use that raw... I`ll paste the code again with the modifications...
| Code: | set si(mc) "#monitoringchan"
set si(ac) "#alertchan"
set si(except) {
"*!cservice@undernet.org"
"*!*@me.users.undernet.org"
}
bind raw - INVITE show:invite
proc show:invite {from key args} {
global botnick si
set nick [lindex [split $from !] 0]
set host [lindex [split $from !] 1]
set ban [lindex [split $from @] 1]
set text [lindex [split $args] 1]
foreach ehost $si(except) {
if {[string match $ehost "$nick!$host"]} { return 0 }
}
putserv "PRIVMSG $si(ac) :INVITE SPAM by\0032 $nick \003\[$host\]: invited me to $text"
putserv "PRIVMSG $si(mc) :.ban *!*@$ban Inviter!"
} |
So I've made try this code with the modification and now it's working a little better but still ...
| Quote: | | (20:48:06) <bot> INVITE SPAM by XXXX [~ident@127.0.0.1]: invited me to #chan} |
the rest of the script is working great, only that "}" I need to remove...
And if I change this:
| Code: | | set text [lindex [split $args] 1] |
with this:
the result will be this:
| Quote: | | (20:34:11) <bot> INVITE SPAM by XXXX [~ident@127.0.0.1]: invited me to {bot #chan} |
So... how do I extract the #chan from $args ?! _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Dec 16, 2007 7:40 pm Post subject: |
|
|
| nml375 wrote: | | Furthermore, in your case, you are using the special argument "args" wich may take 0 or more parameters, and concatenates them into a list | Guess you didn't read this part. Your use of args is making those { } in creating the list, and your further splitting complicates it. Your getting two words you see, in one as a string. You need to split the string and then lindex it for its 2nd part. Using args creates a list containing a single two word element, not what you had intended.. | Code: | proc show:invite {from key text} {
...
set text [lindex [split $text] 1] |
perhaps?
edit: or even, if you insist on using args: | Code: | | set text [lindex [split [lindex $args 0]] 1] |
Last edited by speechles on Sun Dec 16, 2007 8:06 pm; edited 4 times in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Dec 16, 2007 7:56 pm Post subject: |
|
|
Riddler:
As I said, don't use "args" as a argument name unless you really understand how it works, and really need it's behaviour.
A somewhat common misconception is that eggdrop will add one argument for each word in the message. That is not the case, the number of parameters is always the same, and thus your proc should accept a fixed number of arguments. Hence there is no need or use for "args". Follow speechles suggestion and use "text" instead, which has no special function. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Riddler Halfop
Joined: 20 May 2007 Posts: 60 Location: Brasov, Romania
|
Posted: Sun Dec 16, 2007 8:55 pm Post subject: |
|
|
Upsss.... sorry if I didn't pay attention
@speechles: thanks for the ideea, the script it's working great now
@nml375: I didn't really know untill now, what's the real function of the "args" argument... sorry again... but I`ve saw some other codes ( I needed a example on how the raw INVITE proc works )....... so that's why my code wasn't "by the book".... as you guys ar tryin to make me understand
Maybe next time I should ask you guys first and not only trust a tcl code ( not all of them ar very good coded )
Anyway thanks again speechles & nml375 for the support on this issue  _________________ I am a man of few words, but many riddles |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Dec 16, 2007 9:10 pm Post subject: |
|
|
Studying other peoples code is a good start on learning any coding language, just remember to cross-reference with a good instruction documentation or similar when you find something "interresting" or new.
None can be expected to make flawless code from the beginning, keep up the good work. And don't be afraid of asking whenever something is unclear or you can't seem to find the right answer on your own. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|
|
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
|
|