Code: Select all
set responsetimer "1/2"
set responsetime "2secs"
#1 = defined time
#2 = random
set responsechans "#bla1 #bla2 #bla3"
set responsechantype "1/2"
set nobotnick "1/2"
set randomreply "0/1/2"
set randomreplyno "5"
set responsetimer "0/1"
set respond_words {
{ "lol" } { "Laughs Out Loud" "haha %nick" "yahoo!" }
{ "brb" } { "Be Right Back %nick" "ok" "I'm right here on %chan" }
{ "cya" } { "See you" "ok dude" "bye bye, %nick!" }
{ "hi" "hello" } { "hey %nick" "hows ya doing, %nick?" "whats up, %nick?" } }
#You can use %nick, %chan, %uhost and %hand for the reponses too,
#Example
set respond_words {
{ "trigger1" } { "random reply 1" "random reply 2" }
{ "trigger1" } { "random reply 1" "random reply 2" "random reply 3" }
{ "trigger1" "trigger2" } { "random reply 1" "random reply 2" "random reply 3" }
{ "trigger1" "trigger2" "trigger3" } { "random reply 1" "random reply 2" }
{ "trigger1" "trigger2" "trigger3" } { "random reply 1" "random reply 2" "random reply 3" }
{ "trigger1" "trigger2" "trigger3" } { "random reply 1" "random reply 2" "random reply 3" "random reply 4" }
#You can set any amount of triggers and random replies.
#Minimum for atleast 1 trigger there must be a reply set or vice versa.
if {($responsetype == 3) || ($responsetype == 4)} { bind notc - * check_word }
if {($responsetype == 2) || ($responsetype == 4)} { bind ctcp - ACTION check_word }
if {($responsetype == 1) || ($responsetype == 4)} { bind pubm - * check_response_word }
proc check_response_word {nick uhost hand chan text} {
global respond_words responsechantype nobotnick randomreply
if {([isbotnick $nick]) || ([isbotnick $chan]) || (![string equal "#" [string index $chan 0]])} { return 0 }
if {($responsechantype == 1) && ([lsearch -exact [split [string tolower $responsechans]] [string tolower $chan]] == -1)} { return 0 }
foreach {triggers responses} $respond_words {; foreach trigger $triggers {
if {($responsetimer == 2)} { set responsetime [rand 10] }
set filteredresponses [response:filter $filteredresponses $nick $uhost $hand $chan]
if {(($responsetimer == 1) && ($reponsetime != "") && ($reponsetime > 0)) || ($responsetimer == 2)} {
if {($randomreply == 0) && ($nobotnick == 1) && ([string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
utimer $responsetime [list putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"]; return 0 }
if {($randomreply == 0) && ($nobotnick == 2) && (![string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
utimer $responsetime [list putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"]; return 0 }
if {($randomreply == 1) && ([rand 2] == 1) && ($nobotnick == 1) && ([string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
utimer $responsetime [list putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"]; return 0 }
if {($randomreply == 1) && ([rand 2] == 1) && ($nobotnick == 2) && (![string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
utimer $responsetime [list putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"]; return 0 }
if {($randomreply == 2) && ($randomreplyno != "") && ($randomreplyno > 0) && ($nobotnick == 1) && ([string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
utimer $responsetime [list putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"]; return 0 }
if {($randomreply == 2) && ($randomreplyno != "") && ($randomreplyno > 0) && ($nobotnick == 2) && (![string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
utimer $responsetime [list putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"]; return 0 } }
if {($responsetimer == 0)} {
if {($randomreply == 0) && ($nobotnick == 1) && ([string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"; return 0 }
if {($randomreply == 0) && ($nobotnick == 2) && (![string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"; return 0 }
if {($randomreply == 1) && ([rand 2] == 1) && ($nobotnick == 1) && ([string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"; return 0 }
if {($randomreply == 1) && ([rand 2] == 1) && ($nobotnick == 2) && (![string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"; return 0 }
if {($randomreply == 2) && ($randomreplyno != "") && ($randomreplyno > 0) && ($nobotnick == 1) && ([string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"; return 0 }
if {($randomreply == 2) && ($randomreplyno != "") && ($randomreplyno > 0) && ($nobotnick == 2) && (![string match -nocase "* $botnick *" " $text "]) && ([string match -nocase "* $trigger *" " $text "])} {
putserv "PRIVMSG $chan :[lindex $filteredresponses [rand [llength $filteredresponses]]]"; return 0 }
}
}
}
proc check_word_act {nick uhost hand chan key text} {
check_response_word $nick $uhost $hand $chan $text
}
proc check_word_notc {nick uhost hand text {chan ""}} {
check_response_word $nick $uhost $hand $chan $text
}
proc response:filter {data nick uhost hand chan} {
global botnick
regsub -all -- %nick $data $nick data ; regsub -all -- %uhost $data $uhost data
regsub -all -- %botnick $data $botnick data
regsub -all -- %hand $data $hand data ; regsub -all -- %chan $data $chan data
regsub -all -- %b $data data ; regsub -all -- %r $data data
regsub -all -- %u $data data ; regsub -all -- %c $data data
return $data
}
The main problem I am having problem with the regsub. I want $nick to replace %nick in the triggers, %uhost for $uhost, %chan for $chan and so on...
But it doesn't seem to work correct. Can anyone help me? Would be kindly appreciated!
