bind pub - "!radio-request" req
set chan1 "#requestchannel"
set chan2 "#supportchannel"

#set userreq "30"

proc req {nick uhost hand chan txt} {
global chan2 chan1 requester
set requester $nick
set requ [lindex $txt 0]
if {$chan != $chan1} { return 0 }
if {([channel get $chan vipa]==1) } {
	channel add $requ
	utimer 10 [list join:checkwait $requ]
	} else { 
		putserv "PRIVMSG $chan1 :4,0»»1,0 Request zur Zeit Offline"
}
}
			
proc join:checkwait { chan } {
	global requester chan2 chan1 userreq
	if {[botonchan $chan]} {
    set users [llength [chanlist $chan]]
    if {$users >= $userreq} {
	    putserv "PRIVMSG $chan2 :4,0|>1,0 Neuer RadioBot Request4,0 ::1,0 Nick: $requester4,0 ::1,0 Chan: $chan" 
	    putserv "PRIVMSG $chan :»» Channel Request Accept! :: An admin will join and chek the channel in few minutes."
	    putserv "PRIVMSG $chan :»» Stay Tuned. Do not request again! Only 1 RadioBot Request per Chan"
	    channel remove $chan
    } else {
	    putserv "PRIVMSG $chan :»» Your Channel is not large enough to Request a RadioBot! $userreq users are needed!"
	    putserv "PRIVMSG $chan :»» Channel blocked for 30 mins :: I will part now."
	    channel remove $chan 
    }
  } else {
    putlog "Error retrieving channel size: Not on channel ($chan)"
    channel remove $chan
  }
}

#bind pub n| !joincheck join:check
proc join:check {nick uhost hand chan rest} {
  set tojoin [lindex [split $rest] 0]
  channel add $tojoin
  utimer 10 [list join:checkwait2 $tojoin]
}
proc join:checkwait2 { chan } {
  if {[botonchan $chan]} {
    set users [llength [chanlist $chan]]
    if {$users >= 30} {
      putserv "PRIVMSG $chan :Bot will join the channel because u have enough users!"
    } else {
      putserv "PRIVMSG $chan :Channel not accepted! Only $users users in the chan! 30 are needed"
    }
  } else {
    putlog "Error retrieving channel size: Not on channel ($chan)"
    channel remove $chan
  }
}