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.

Ai.tcl by KuNgFo0 - Responds to certain words said in the set channels.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Arnold_X-P
Master
Posts: 247
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Ai.tcl by KuNgFo0 - Responds to certain words said in the set channels.

Post by Arnold_X-P »

I found this TCL in the forum, it's very good.

Code: Select all

 ###################################
# Ai.tcl by KuNgFo0 (#eggfaq@efnet)
#VERSION 0.3
#DESCRIPTION Responds to certain words said in the set channels.
# Set the next lines as the triggers and random responses you want
# (wildcards may be used)
set ai_data {
 {"Hello" "Hi" "Hey"} {
  "Hey what's up, $nick?"
  "Yo"
  "Hello!"
 }
 {"What time is it?" "What is the time?" "What's the time?" "Anyone have the time?"} {
  "$nick, it's [clock format [clock seconds]]"
 }
}
# Set the next line as the channels you want to run in
set ai_chans "#testchannel1 #testchannel2"

proc pub_ai {nick uhost hand chan arg} {
 global ai_data ai_chans botnick
 if {(([lsearch -exact [string tolower $ai_chans] [string tolower $chan]] != -1) || ($ai_chans == "*")) && (![matchattr $hand b]) && ($nick != $botnick)} {
  foreach {triggers responses} $ai_data {
   foreach trigger $triggers {
    if {[string match [string tolower $trigger] [string tolower $arg]]} { putserv "PRIVMSG $chan :[subst [lindex $responses [rand [llength $responses]]]]" ; return }
   }
  }
 }
}

bind pubm - * pub_ai

putlog "*** Ai.tcl 0.3 by KuNgFo0 loaded"

But the bot nickname variant is missing.
And I'd like to change this.

Code: Select all

 {"Hello" "Hi" "Hey"} { 

to use $botnick example: line 9

Code: Select all

 {"Hello" "Hi $botnick" "$botnick Hey"} { 

Could you help me get that variant?

I tried using this variant, but it doesn't work for me.

Code: Select all

 regsub -all -- {$botnick} $responses $botnick responses
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
networks: DALnet #tcls ChatZona #tcl Libera.Chat #tcls
User avatar
CrazyCat
Revered One
Posts: 1357
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Ai.tcl by KuNgFo0 - Responds to certain words said in the set channels.

Post by CrazyCat »

Try using subst with $trigger too
if {[string match [string tolower [subst $trigger]] [string tolower subst $arg]]} {
   putserv "PRIVMSG $chan :[subst [lindex $responses [rand [llength $responses]]]]";
   return
}
And in your ai_datas, use $::botnick rather than $botnick
Post Reply