Whats was wrong with my code? It was the simple way to make it and he only would need to edit greet message in tcl, he could enable it in partyline...And also you forgot to make variable greeting globalawyeah wrote:Here you go.
Use this:
Code: Select all
#If you want greeting to read from greeting.txt set this to 0 #If you want it to read from the variable, set this to 1 set greetvar "1" #Set this to your channel greeting set greeting "Welcome to the channel. If you can see this message you are in the channel!" #Set this to your greeting channels set greetchans "#funchat #cyberparty #chatterz #beginner #allnitecafe" bind join - * proc:greet proc:greet {nick uhost hand chan} { global greetvar greetchans if {([lsearch -exact [split [string tolower $greetchans]] [string tolower $chan]] == -1)} { if {([string equal $greetvar "0"])} { regsub -all "\t" [split [exec [lindex "cat greeting.txt" 0] [join [lrange "cat greeting.txt" 1 end]]] \n] " " results foreach line $results { puthelp "Notice $nick :$line" } } if {([string equal $greetvar "1"])} { putquick "NOTICE $nick :$greeting" } } }
Code: Select all
# some examples - simple one line message
set greetem(#Chan1) {You just joined $chan...duh :P}
# multiline message with formatting (whitespace is trimmed off by init)
set greetem(#cHaN2) {
Welcome to $chan, $nick!
Enjoy your stay
oh...and please behave.
}
# global message used for channels that don't have their own message
# (comment out or leave blank to disable)
set greetem(*) {Hi $nick, my admin is lazy or stupid :/}
bind join - * greetem:join
proc greetem:join {nick uhost hand chan} {
global greetem
set c [string tolower $chan]
if {[info exists greetem($c)]||([info exists greetem(*)]&&[set c *]!={})} {
foreach line $greetem($c) {
putserv "NOTICE $nick :[subst -nob -noc $line]"
}
}
}
proc greetem:init {} {
variable greetem
set names {}
foreach {key val} [array get greetem] {
unset greetem($key)
foreach line [split $val[set val {}] \n] {
if {[string len [set line [string trim $line]]]} {
lappend val $line
}
}
if {[llength $val]} {
set greetem([string tolower $key]) $val
lappend names $key
}
}
if {[array size greetem]} {
putlog "greetem loaded - I'll greet people in [join $names {, }]."
} {
putlog "greetem loaded - wtf? no messages?"
}
}
greetem:init;# clean up array and display "loaded"-message