I would probably use caesar's code, due to his expertise, but I did make something exactly like this a while back for someone. This uses a setudef (user defined setting), allowing you to enable/disable per channel.
This method allows for you to utilise $nick and $chan like normal, inside your message list.
# $Id: greeter.tcl,v1.1 18/01/2016 06:20:47am GMT +12 (NZST) IRCSpeed Exp $
## SYNTAX:
# !greet on|off
# Feel free to edit this setting. Change the ! to any character you would like as a trigger.
set greettrig "!"
# Set here what flags you wish to allow to enable/disable this script. (change them to "-|-" for anyone)
set greetflags "ovf|ovf"
# Set here the greetings you wish to send each user that joins.
set mymsgs {
"Hi, how are you?"
"Hi $nick!"
"Hello $nick, welcome to $chan"
"Hi [$nick], you have to pay $20 to enter here"
}
### DONT EDIT BELOW ###
proc getTrig {} {
global greettrig
return $greettrig
}
setudef flag autogreet
bind join - * greet:msg
bind pub - ${greettrig}greet greet:pub
proc greet:msg {nick host hand chan} {
global mymsgs
if {[validuser [nick2hand $nick]] && ![channel get $chan autogreet]} {return}
set greetmsg [lindex $mymsgs [rand [llength $mymsgs]]]
set greetmsg [subst -nocommands $greetmsg]
putserv "NOTICE $nick :$greetmsg"
}
proc greet:pub {nick uhost hand chan arg} {
global greetflags
if {[matchattr [nick2hand $nick] $greetflags $chan]} {
if {[lindex [split $arg] 0] == ""} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrig]greets on|off"; return}
if {[lindex [split $arg] 0] == "on"} {
if {[channel get $chan autogreet]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
channel set $chan +autogreet
puthelp "PRIVMSG $chan :Enabled Onjoin Greeter for $chan"
savechannels
return 0
}
if {[lindex [split $arg] 0] == "off"} {
if {![channel get $chan autogreet]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
channel set $chan -autogreet
puthelp "PRIVMSG $chan :Disabled Onjoin Greeter for $chan"
savechannels
return 0
}
}
}
putlog ".:greeter.tcl,v1.1:. Loaded!"
Last edited by Get_A_Fix on Sat Jul 09, 2016 12:56 pm, edited 1 time in total.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.