| View previous topic :: View next topic |
| Author |
Message |
erotism Voice

Joined: 10 Aug 2010 Posts: 13 Location: Sofia, Bulgaria
|
Posted: Tue Sep 28, 2010 9:34 pm Post subject: TCM.tcl.. |
|
|
Hi, I play with a script and something I can not understand how to take the receiver only the variable ..
| Code: | #Flood relay
proc *raw:flooder {from key arg} {
global botnick servername fnick ochan fhost onserver target whatdoing
if {[lindex $arg 5] == "Flooder"} {
set fnick [lindex $arg 6]
set fhost [lindex $arg 6]
set onserver [lindex $arg 8]
set target [lindex $arg 10]
set whatdoing [lrange $arg 4 end]
putquick "PRIVMSG $ochan :$whatdoing"
putquick "PRIVMSG $fnick :$fnick, detect flood from your host ($fhost) Please stop flooding $target. Thank You!"
return 0
}
}
|
| Quote: | Server notice is:
irc.server.com *** Notice -- Possible Flooder nick[id@0.0.0.0] on irc.server.com target: nick1 |
Can you tell me how to give nick ident@host from them last in the different values to allow the bot to send PRIMSG of that nickname and tell him that it has detected a violation by ident@host
I am writing here because I have no idea how to do this separation, since nick and hostname are held in arg 6
| Quote: | To summarize:
1 = ***
2 = Notice
3 = -
4 = Possible
5 = Flooder
6 = nick [id@0.0.0.0]
........
10 = nick1 |
in tcl I need these values: $target $nickflooder $nickflooderID@HOST...
Thanks in advance and apologize for bad English |
|
| Back to top |
|
 |
erotism Voice

Joined: 10 Aug 2010 Posts: 13 Location: Sofia, Bulgaria
|
Posted: Wed Sep 29, 2010 12:36 pm Post subject: |
|
|
| can we help me.. ? :/ |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Sep 29, 2010 1:18 pm Post subject: |
|
|
| erotism wrote: | | can we help me.. ? :/ |
I'd like to try, but I'm afraid I don't fully understand the question.
Can you re-state it? Perhaps provide another example of what you want? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Sep 29, 2010 2:47 pm Post subject: |
|
|
Step 1: Learn to handle strings and lists properly.
$arg is a string in this context, don't use lindex on strings!
Use the split command to split a string into a list..
| Code: | proc someproc1 {from key text} {
set arg [split $text " "]
if {[string equal [lindex $arg 4] "Flooder"]} {
#...
set temp [split [lindex $arg 5 {[]}]]
set thenick [lindex $temp 0]
set thehost [lindex $temp 1]
}
} |
Alternate Step 2: Use regexp to extract the value using regular expressions:
This should fetch all the values from the string in a single pass (without the need to convert the string to a list...)
| Code: | proc someproc2 {from key text} {
#...
if {[regexp -- {^\*\*\* Notice -- Possible Flooder ([^[ ]+)\[([^] ]+)\] on ([^ ]+) target: ([^ ]+)$} $text match fnick fhost onserver target]} {
#...
}
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|