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.
Help for those learning Tcl or writing their own scripts.
err0r
Voice
Posts: 6 Joined: Sat Apr 21, 2012 9:00 pm
Post
by err0r » Sat Apr 21, 2012 9:06 pm
i have this text :
CONNECT Zet^ (~
CHAT2ME.c@41-135-29-27.dsl.mweb.co.za , CHAT2ME.co.za) [41.135.29.27] has connected to the network
i would like to capture the nickname, in this case its zet^
also the ident which in this case is CHAT2ME.c
the isp which is 41-135-29-27.dsl.mweb.co.za in the example
and finally : 41.135.29.27 which is wrapped between [ ]
any help would be usefull, i understand i need lindex
thanks Err0r
willyw
Revered One
Posts: 1209 Joined: Thu Jan 15, 2009 12:55 am
Post
by willyw » Sun Apr 22, 2012 2:44 am
err0r wrote: i have this text :
CONNECT Zet^ (~
CHAT2ME.c@41-135-29-27.dsl.mweb.co.za , CHAT2ME.co.za) [41.135.29.27] has connected to the network
i would like to capture the nickname, in this case its zet^
also the ident which in this case is CHAT2ME.c
the isp which is 41-135-29-27.dsl.mweb.co.za in the example
and finally : 41.135.29.27 which is wrapped between [ ]
any help would be usefull, i understand i need lindex
Code: Select all
bind pub - "!capture" captureit
proc captureit {nick uhost handle chan text} {
set nname [lindex [split $text] 1]
putserv "privmsg $chan :nname is: $nname"
set temp [lindex [split $text] 2]
set temp [string trimleft $temp ~(]
set ident [lindex [split $temp @] 0]
putserv "privmsg $chan :ident is: $ident"
set isp [lindex [split $temp @] 1]
set isp [string trimright $isp ,]
putserv "privmsg $chan :isp is: $isp"
set ip [lindex [split $text] 4]
set ip [string trim $ip \[\]]
putserv "privmsg $chan :ip is: $ip"
}
This could be condensed.
Do this in the channel with your bot:
Code: Select all
!capture CONNECT Zet^ (~CHAT2ME.c@41-135-29-27.dsl.mweb.co.za, CHAT2ME.co.za) [41.135.29.27] has connected to the network
and it will respond with the data in the manner you described.
I'm not sure what you are doing with it, but I hope this is enough of an example to get you going.
Reference :
http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
err0r
Voice
Posts: 6 Joined: Sat Apr 21, 2012 9:00 pm
Post
by err0r » Mon Apr 30, 2012 7:43 pm
Not what i really wanted, but it has given me all i needed to get it going, many thanks willyw
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue May 01, 2012 1:08 am
Here is a simple method to get the same thing:
Code: Select all
set text [split $text]
set nickname [lindex $text 1]
scan [string trim [lindex $text 2] {(),}] {%[^@]@%s} ident isp
set ip [string trim [lindex $text 4] {[]}]
where $text is the:
Once the game is over, the king and the pawn go back in the same box.