That request was deleted, but not before the script was almost done:)
Code: Select all
###################################################################
## SayGreet ver. 0.1 by SpiKe^^ www.mytclscripts.com ##
###################################################################
##################################################### 06/01/2019 ##
# #
# onjoin greeting script, with nick and/or chan specific greets. #
# #
# You Must create the file with all available greeting messages! #
# Each greeting message goes on its own file line. #
# The order of the lines doesn't matter. Blank lines are ignored. #
# If the script finds multiple valid greets, picks one randomly. #
# #
# -Example- adding 2 script default greeting messages. #
# Welcome to %c% : Stay & Play some Trivia with us. #
# Welcome to %c% : Use .triv to start the Trivia game. #
# #
# You can also set Nick and/or Chan Specific greeting messages. #
# -Example- adding 2 nick specific greetings (both same nick). #
# Houdini :: Welcome back %n% : Behave yourself:) #
# houdini :: The king has returned. Welcome back %n% #
# -Example- adding 2 channel specific default greetings. #
# #lamechat :: [%n%] Don't be Lame. Say something witty. #
# #lameChat :: Welcome to %c% %n% : Don't be Lame:) #
# -Example- adding 2 nick and channel specific greetings. #
# houdini@#trivial :: The king has returned. Top trivia champ! #
# houdini@#Trivial :: Welcome back %n% : 99583 Points Last week! #
# #
###################################################################
namespace eval saygreet { variable greet
#######################################################
## - Begin Script Settings - Begin Script Settings - ##
#######################################################
# Set the channel(s) to run this script in. #
set greet(chans) "" ;# ("" = all channels) #
# Set the route/file.name to the greetings file. #
set greet(file) "scripts/greets.txt"
# Set the file line divider between nick/chan and the message. #
# Use any string that will Never be in a greeting message. #
set greet(fdiv) "::"
# 1 = Send greets by message # 2 = Send greets by notice #
set greet(how) "1"
# 1 = Send greets to channel # 2 = Send greets to nick #
set greet(who) "1"
# Prefix all greetings with the users nick?? (1+=yes 0=no) #
# 1 = Prefix all greetings with users nick. #
# 2 = Add users nick Only if no %n% in the greet message. #
set greet(unick) "2"
#######################################################
#### - End Script Settings - End Script Settings - ####
#######################################################
bind join - * [namespace current]::saygreet
set greet(chans) [string trim $greet(chans)]
if {$greet(chans) eq "" || $greet(chans) eq "*"} { set greet(_chans) ""
} else { set greet(_chans) [split [string tolower $greet(chans)]] }
if {$greet(how) ne "2"} { set greet(how) 1 }
if {$greet(who) ne "2"} { set greet(who) 1 }
if {$greet(unick) ni {0 1}} { set greet(unick) 2 }
proc saygreet {nk uh hn ch} { variable greet
set que "puthelp"
set nklo [string tolower $nk] ; set chlo [string tolower $ch]
if {$greet(_chans) ne "" && [lsearch -exact $greet(_chans) $chlo]<0} {
return 0
}
if {[isbotnick $nk] || ![file exists $greet(file)]} { return 0 }
set open [open $greet(file) r]
set greets [split [string trim [read $open]] \n]
close $open
set defls "" ; set cdefls "" ; set sayls "" ; set csayls ""
set divider $greet(fdiv)
foreach gr $greets { set gr [string trim $gr]
if {$gr eq ""} { continue }
set rest [join [lassign [split $gr] nkch div]]
set nkch [string tolower $nkch]
if {$div eq $divider} {
if {$nkch eq "!def" || $nkch eq "!default"} {
lappend defls $rest
} elseif {[string match "*,${nklo}@${chlo},*" ",${nkch},"]} {
lappend csayls $rest
} elseif {[string match "*,${nklo},*" ",${nkch},"]} {
lappend sayls $rest
} elseif {[string match "*,${chlo},*" ",${nkch},"]} {
lappend cdefls $rest
} elseif {[string match "*,@${chlo},*" ",${nkch},"]} {
lappend cdefls $rest
}
} elseif {$nkch eq $divider} {
lappend defls "$div $rest"
} else { lappend defls $gr }
}
if {$csayls ne ""} { set gotls $csayls
} elseif {$sayls ne ""} { set gotls $sayls
} elseif {$cdefls ne ""} { set gotls $cdefls
} elseif {$defls ne ""} { set gotls $defls
} else { set gotls "" }
if {$gotls eq ""} { return 0 }
set got [lindex $gotls [rand [llength $gotls]]]
set say [string map [list %n% $nk %c% $ch] $got]
if {$greet(unick)==2 && ![string match "*%n%*" $got]} {
set say "$nk : $say"
} elseif {$greet(unick)==1} { set say "$nk : $say" }
if {$greet(how)==2} { set how "NOTICE" } else { set how "PRIVMSG" }
if {$greet(who)==2} { set who $nk } else { set who $ch }
$que "$how $who :$say"
}
putlog "SayGreet ver. 0.1 Loaded."
} ;## - End namespace eval - ##