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.

TCM.tcl..

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
erotism
Voice
Posts: 13
Joined: Tue Aug 10, 2010 7:39 am
Location: Sofia, Bulgaria
Contact:

TCM.tcl..

Post by erotism »

Hi, I play with a script and something I can not understand how to take the receiver only the variable ..

Code: Select all

#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
  }
}
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
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
User avatar
erotism
Voice
Posts: 13
Joined: Tue Aug 10, 2010 7:39 am
Location: Sofia, Bulgaria
Contact:

Post by erotism »

can we help me.. ? :/
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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: Select all

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: Select all

proc someproc2 {from key text} {
  #...
  if {[regexp -- {^\*\*\* Notice -- Possible Flooder ([^[ ]+)\[([^] ]+)\] on ([^ ]+) target: ([^ ]+)$} $text match fnick fhost onserver target]} {
    #...
  }
}
NML_375
Post Reply