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 With This Auto Response TCL Im Making.

Old posts that have not been replied to for several years.
Locked
User avatar
CoMMy
Halfop
Posts: 99
Joined: Thu Jul 24, 2003 1:03 am
Location: Cyprus

Help With This Auto Response TCL Im Making.

Post by CoMMy »

Hi,

I am making an auto-response tcl and i need your help as i am at a loss.

This is what i have so far.

#Bind The Procedure.
bind pubm - "*" check_word

Code: Select all

set respond_words {
"lol:laughs out loud"
"brb:Be Right Back"
}

proc check_word {nick host handle chan text } {
global respond_words

foreach word $respond_words {
if {[string match -nocase "$text" "$word"]} {
set words_response [lrange [split $word :] 1 end]
send_response $nick $chan $words_response }}

return 0 }


#Send Response Proc
proc send_response {nick chan response} {
putquick "PRIVMSG $chan :$response" -next
return 0 }
I cant seem to make it respond to the words lol and brb only.

I need to make it respond to (for ex.) lol and say laughs out loud.

Can you help me do this.

Thanks
(c) CoMMy (c)
Resistance is Futile!!
We Are The Borg!!
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Re: Help With This Auto Response TCL Im Making.

Post by YooHoo »

seems like that's doin things the complicated way...why not just make two sets of variables, and do away with spliting $respond_words on the colon? There is a pretty good "auto responder" tcl available on Nerfbendr's website that might help :mrgreen:
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

http://tcl.tk/man/tcl8.5/TclCmd/string.htm#M35

...though, if all the keywords are single words, you could use an array and make things much faster and simpler.
Have you ever read "The Manual"?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Judging by which, if I think I am correct in what you are trying todo. Here this should do your job no doubt:

Code: Select all

set respond_words { 
"lol:Laughs Out Loud" 
"brb:Be Right Back" 
} 

proc check_word {nick uhost hand chan text} { 
 global respond_words
  foreach respond_word $respond_words {
   set acronym [lrange [split $respond_word ":"] 0 end]
   set acronym_definition [lrange [split $respond_word ":"] 1 end]
    if {([string match -nocase *$acronym* $text])} { 
     set response $acronym_definition
     send_response $nick $chan $response 
     }
   } 
 return 0
} 

proc send_response {nick chan response} { 
 putquick "PRIVMSG $chan :$response" -next 
 return 0
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked