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.

string match in text help

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

string match in text help

Post by juanamores »

I need to get the text that follows the word 'Founder:' and the word 'Registered:'

Code: Select all

set canal_admin "#channel1"
set canal_radio "#channel2" 

bind pub * !request ver_chan
bind msgm - * info:channel 


proc ver_chan {nick uhost hand chan text} {
   global canal_admin canal_djs canal_radio
   if {[string tolower $chan] != [string tolower $canal_radio]} {return 0}
    if {[llength $text] != 1} { putmsg $canal_radio "canal invalido XD"; return }
	set canal [lindex [split $text] 0] 
##Send your query to the bot CHaN by the channel info.
 putserv "PRIVMSG chan :info $canal"
}
proc info:channel {nick CHaN!-@- hand text} {
global canal_admin 
 if {[lsearch -exact -nocase "*Founder:*" $text]} {
###set founder ?????????
###set dateregistred ?????????
  putmsg $canal_admin "$text"
   } else {
return
}}
<oper> !request #test
result:
02:03 @mybot ¦ Channel information #test:
02:03 @mybot ¦ Status: ACTIVE
02:03 @mybot ¦ Founder: Susan
02:03 @mybot ¦ Description: Private channel testing
02:03 @mybot ¦ Registered: 19:57:24 09/Feb/2015 CET
02:03 @mybot ¦ Last used: 05:52:26 02/May/2015 CEST
02:03 @mybot ¦ Opcion: Retention topic,Secure
02:03 @mybot ¦ Lock modes: +s-i
02:03 @mybot ¦ End INFO channel #test.
I need to find in the text the nick of the founder and the date of registration of the channel.
Then, store the data in variables, which then will store in a file.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Re: string match in text help

Post by willyw »

juanamores wrote:I need to get the text that follows the word 'Founder:' and the word 'Registered:'
This is one way.
Play around with this. You'll get the idea.

Code: Select all


proc info:channel {nick CHaN!-@- hand text} {
global canal_admin

        if {[lindex [split $text] 0] eq "Founder:"} {
                putmsg $canal_admin "Founder is: [lindex [split $text] 1]"
          }

        if {[lindex [split $text] 0] eq "Registered:"} {
                putmsg $canal_admin "Registered is: [lindex [split $text] 1]"
        }
        return 0

}
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Post Reply