##################### =/\= greetster v0.2 =/\= ########################
###
### v0.2 - 26. may 2001 by aerosoul
###
### features: random greets, notice and msg greets, limit greets
### ######### to added or not added users... or just greet all,
### ######### simple flood protection
###
### bugs: only a eggdrop bug I guess: don't use umlauts (äöü and stuff)
### ##### use "\\" if you want to display a "\" inside the greet
###
### enter channel names in lower case !
###
### this script needs alltools.tcl i think :)
###
### mail bugs to soul@gmx.net or come to IRCNet #playaz 
###
### script was inspired by greetd.tcl 0.05b. I needed some more features
### and as greetwonder is huge and has many errors... here I go =)
### If you make some useful additions to this script, please send them
### to me. You can also request features but don't expect that I will
### rewrite the whole script or something :)
###
### _\|/_ peace & piece to all the eggheads out there B-)-~ _\|/_
###
############################# _\|/_ ###################################

#######################################################################
# explaination of settings:
#
# set greetster_stuff(#lamerchan) {
#  "0"		### show random greet? 0 = nope.. 1 = yep
#  "NOTICE"	### type? NOTICE or PRIVMSG
#  "all"	### greet who? all or added or nadded users
# }
#
# set greetster_greet(#lamerchan) {
#  "greet1"
#  "..."
#  "greetX"
# }
#
# set greets_min <greet count> ## show how many greets per minute (flood protection)
#
##################################################################

### example config: ################################ #### ### ## #

set greets_min 5

###[ #LamerChan ]###########################

set greetster_stuff(#lamerchan) {
 "0"
 "PRIVMSG"
 "nadded"
}

set greetster_greet(#lamerchan) {
 "(¯`·._(¯`·._(¯`·._( hello unknown user )_.·´¯)_.·´¯)_.·´¯)"
 "welcome to the lamers club =/\= lamer scripts appreciated"
}

###[ #23TRiBE ]##############################

set greetster_stuff(#23tribe) {
"1"
"NOTICE"
"added"
}

set greetster_greet(#23tribe) {
"-=/\=- there is no coincidence -=/\=-"
"_\|/_ there is no coincidence _\|/_"
"(¯`·.¸¸.-> there is no coincidence <-.¸¸.·´¯)"
}

### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #

### don't edit anything below this line if you want the script to work ;) ###

### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #

bind join - *!*@* greetster_main

set g_queue 0

proc greetster_main {nick uhost hand chan} {
global greetster_stuff greetster_greet botnick greets_min g_queue
 if {$g_queue >= $greets_min} { return 0 }
 if {$nick == $botnick} { return 0 }
 set chan [string tolower $chan]
 if {![info exists greetster_greet($chan)]} { return 0 }
 if {![info exists greetster_stuff($chan)]} { 
	putlog "<greetster.tcl> missing configuration for $chan"
	return 0
 }
 set g_rand [lindex $greetster_stuff($chan) 0]
 set g_type [lindex $greetster_stuff($chan) 1]
 set g_who [lindex $greetster_stuff($chan) 2]
 if {$g_who == "added"} {
  if {![validuser $hand]} { return 0 }
 }
 if {$g_who == "nadded"} {
  if {[validuser $hand]} { return 0 }
 }
 if {$g_rand == 0} {
  foreach g $greetster_greet($chan) {
   putserv "$g_type $nick :$g"
  }
 } else {
  set g_reply [lindex $greetster_greet($chan) [rand [llength $greetster_greet($chan)]]]
  putserv "$g_type $nick :$g_reply"
 }
 set g_queue [expr $g_queue +1]
 if {$g_queue == 1} {
  timer 1 "set g_queue 0"
 }
}

putlog "<greetster.tcl> v0.2 by aerosoul loaded. I love you mary jane :)"
