;***** START UP JOTI-IRC ******

on *:START: {
	/set %tmp.startup 1
	/set %ff $regex($date, /\d{2}\/\d{2}\/(\d{4})/)
	/set %currentyear $regml(1);
	
	/checkvars
	if ($file($+($adiircdir,\pix\iconbar.bmp))) {
  	/background -hte $adiircdir\pix\iconbar.bmp
  }
  if ($file($+($adiircdir,\pix\switchbar.bmp))) {
  	/background -lte $adiircdir\pix\switchbar.bmp
  }
  /.toolbar -c
  /titlebar This JOTA-JOTI has been made possible by 4scouts.nl
	/showversions
  /checkfileversions
}

alias showversions {
  /echo 4 ***************************************
  /echo 4 START UP JOTI-IRC 
  /echo 4 SCRIPT VERSION: %script.version 
  /echo 4 MODE: %setup.joti.mode 
  /echo 4 RUNNINGDIR: $adiircdir 
  /echo 4 CLIENTID: %setup.joti.clientid
  /echo 4 ***************************************
}

alias runstartup {
 	if ((%setup.joti.mode == setup) || (%setup.joti.mode == $null)) {
 		/echo -sg first time setup
 		/.load -rs $adiircdir $+ Scripts\scoutlinksetup-eng.ini
   	/startsetup
 	} elseif (%setup.joti.mode == single) {
 		/toolbarsetup
 		/toolbarupdate
  	/dialog -m usernick usernick
 	} elseif (%setup.joti.mode == group) {
 		/toolbarsetup
 		/toolbarupdate
   	/dialog -m usernick usernick
 	} else {
   	/echo 4 ERROR: CONFIGURATION CORRUPTED!!! 
 	}
 	/set %tmp.startup 0
}	


alias checkvars {
  /set %script.version 2024.1
  
  /set %connection disconnected
  /set %usermode on
  /set %mynickname $null
  /set %setup.url.filebase https://www.4scouts.nl/jotiirc
  /set %localadminmode 0
  /set %operator.chan #beneluxops
  
	if (%tmp.toolbaricons == $null) {
		/set %tmp.toolbaricons more
	}
  if (%tmp.chanfilter == $null) {
  	/set %tmp.chanfilter dutch
  }
  if (%timedisplay == $null) {
  	/set %timedisplay on
  }
  if (%sounds == $null) {
  	/set %sounds on
  }
  if (%fonts == $null) {
  	/set %fonts large
  }
 	if (%setup.joti.afsluitbericht == $null) {
		/set %setup.joti.afsluitbericht Have a great JOTA-JOTI
	}  
	if (%setup.joti.clientid == $null) {
		/set %setup.joti.clientid $+(jotistation_,$rand(10000,50000))
	}
	
	/.setoption Server QuitMsg Have a great JOTA-JOTI %currentyear
	
	if ($exists($adiircdir $+ upp.exe)) {
		/.remove $adiircdir $+ upp.exe
	}	
	/set %tmp.ircupdate 0
}

;***** TOOLBAR JOTI-IRC ******

alias toolbarsetup {
	/set %toolbaricons $+($adiircdir,pix\)
	/set %brokenicon $+(%toolbaricons,jj.ico)
	/toolbar -c 
	
	/noop $createbutton(start,"Connect with the scoutLink network",start.ico,"/dialog -m usernick usernick")
	/noop $createbutton(stop,"Disconnect from the scoutLink network",stop.ico,"/quit %setup.joti.afsluitbericht")
	/noop $createbutton(nick,"Change nickname",nick.ico,"/dialog -m usernick usernick")
	/noop $createbutton(channel,"Visit a channel",join.ico,"/bezoek")
	/noop $createbutton(listall,"Fetch the complete channel list",listall.ico,"/fetchchannels")
	/noop $createbutton(listdutch,"Fetch the english channel list",listdutch.ico,"/fetchchannels #english")
	/noop $createbutton(arrangewindows,"Arrange windows",windows.ico,"/arrangewindows")
  /noop $createbutton(smallfont,"Do you want small characters?",smallfont.ico,"/klein")
  /noop $createbutton(largefont,"Do you want large characters?",largefont.ico,"/groot")
;  /noop $createbutton(info,"Information about this ADIIRC version",info.ico,"/dialog -m clientinfo clientinfo")
  /noop $createbutton(scoutlink,"Visit the ScoutLink website",scoutlink.ico,"/url https://www.scoutlink.nl")
  /noop $createbutton(timeon,"Timestamp on",timer.ico,"/timeon")
  /noop $createbutton(timeoff,"Timestamp off",notimer.ico,"/timeoff")
  /noop $createbutton(sounds,"Geluid aan",sound.ico,"/switchsound")
  /noop $createbutton(nosounds,"Geluid uit",nosound.ico,"/switchsound")
  /noop $createbutton(viewlog,"View registration log",viewlog.ico,"/url  $adiircdir\records\index.html")
  /noop $createbutton(addlog,"Manually add a log entry",addlog.ico,"/addlog")
  /noop $createbutton(games,"Game channels",games.ico,"/startgames")
  /noop $createbutton(badges,"Overview of your badges",badges.ico,"/badgeoverzicht")
  /noop $createbutton(more,"More buttons",more.ico,"/more")
  /noop $createbutton(less,"Less buttons",less.ico,"/less")
  /noop $createbutton(panic,"I need help!",panic.ico,"/panic")
  /noop $createbutton(setupid,"Set the station ID",config.ico,"/setupid")
  /noop $createbutton(registernick,"Register your nickname on ScoutLink!",regnick.ico,"/registernick")
	/noop $createbutton(usermodeoff,"spamfilter off",usermodeoff.ico,"/switchspam")
  /noop $createbutton(usermodeon,"spamfilter on",usermodeon.ico,"/switchspam")
  	
	/toolbarupdate
	/unset %toolbaricons
	/unset %brokenicon
}

alias createbutton {
	if ($0 != 4) {
		/echo -sg invalid call
	} else {
		var %iconfile = $+(%toolbaricons,$3)
		if ($exists(%iconfile)) {
			/toolbar -a $1 $2 %iconfile $4
		} else {
			/echo icon $3 not found
			/toolbar -a $1 $2 %brokenicon $4
		}
	}
	return $null
}

alias toolbarupdate {
  if (%connection == connected) {
    /toolbar -h start
    /toolbar -w stop
    /toolbar -w nick
    /toolbar -w channel
    /toolbar -w listall
    /toolbar -w listdutch
;    /toolbar -w info
    /toolbar -w games
    /toolbar -w badges
    /toolbar -w panic
    /toolbar -w registernick
    
    if (%usermode == on) {
			/toolbar -w usermodeoff
			/toolbar -h usermodeon
		} else {
			/toolbar -h usermodeoff
			/toolbar -w usermodeon
		}
  } else {
    /toolbar -w start
    /toolbar -h stop
    /toolbar -h nick
    /toolbar -h channel
    /toolbar -h listall
    /toolbar -h listdutch
;    /toolbar -h info   
    /toolbar -h games
    /toolbar -h badges
    /toolbar -h panic
    /toolbar -h registernick
    /toolbar -h usermodeoff
    /toolbar -h usermodeon
  }
	 	
  if (%font == small) {
    /toolbar -h smallfont
    /toolbar -w largefont
  } else {
 	 /toolbar -w smallfont
 	 /toolbar -h largefont
	}

  if (%sounds == on) {
  	/toolbar -h sounds
    /toolbar -w nosounds
  } else {
    /toolbar -w sounds
    /toolbar -h nosounds
  }
	
  
  if (%timedisplay == off) {
   	/toolbar -w timeon
   	/toolbar -h timeoff    	
	} else {
 		/toolbar -h timeon
 		/toolbar -w timeoff
  }

 	if ((%setup.joti.localadmin == 1) || (%setup.joti.mode == single)) {
 		/toolbar -w setupid
 	} else {
		/toolbar -h setupid
 	}

  if (%toolbaricons == less) {
;    /toolbar -h info
    /toolbar -h games
    /toolbar -h badges
    /toolbar -h scoutlink 
    /toolbar -h timeon
    /toolbar -h timeoff
    /toolbar -h listall
    /toolbar -h setupid
    /toolbar -h less
    /toolbar -w more    
  } else {
    /toolbar -w less
    /toolbar -h more
	} 
}

alias groot {
  /font -z 16 arial
  /set %font large
  /toolbarupdate
}

alias klein {
  /font -z 11 arial
  /set %font small
  /toolbarupdate
}

alias timeon {
  /timestamp on
  /set %timedisplay on
  /toolbarupdate
}

alias timeoff {
  /timestamp off
  /set %timedisplay off
  /toolbarupdate
}

alias arrangewindows {
  inc %arrwindow
  if (%arrwindow == 1) { /mdi -c }
  if (%arrwindow == 2) { /mdi -t }
  if (%arrwindow == 3) { /set %arrwindow 1 }
}

alias more {
	/set %toolbaricons more
	/toolbarupdate
}

alias less {
	/set %toolbaricons less
	/toolbarupdate
}

alias bezoek {
  /join $$?="Enter the channel you would like to visit, including the # sign"
}

alias mme { 
  /return $address($me,2)
}

alias nickid {
  /NICKSERV identify $$?*="Enter the password for your nickname:"
}

alias nickghost { 
  /NICKSERV ghost $me $$?="Enter your registered nickname:" $$?*="Enter your password:" 
}

alias panic {
  if (%setup.joti.mode == group) {
    /noticeadmin HELP!
    /playsound panic.mp3
  } else {
    /query $nick(#,3,o) 4,8HELP! <<<<PANICBUTTON>>>>
  }
}

alias switchsound {
	if (%sounds == on) {
		%sounds = off
	} else {
		%sounds = on
	}
	/toolbarupdate
}

alias switchspam {
	if (%usermode == off) {
		/mode $me +R
		/set %usermode on
	} else {
		/mode $me -R
		/set %usermode off
	}
	/toolbarupdate
}

alias setupid {
  /set %setup.joti.clientid $$?="Enter the station ID (i.e. PC1 table1 etc)"
  /echo setting %setup.joti.clientid
  /toolbarupdate
}

;dialog clientinfo {
;  title "Info JOTI-IRC %currentyear"
;  size -1 -1 400 320
;  icon 1, 1 1 400 188, $adiircdir\pix\banner8.jpg
;  text "This IRC client is based on ADIIRC and is developed for scouts that either participate in JOTA-JOTI or would like to connect with the ScoutLink network. This client is developed by: Martin Boer (Coldforged) and Gert-Jan HAvermans (geejee). Please send any comment, ideas and bugreports to: dutchops@scoutlink.nl",2, 15 195 370 100
;  button "close",3, 150 290 100 25, OK 
;}

;on *:DIALOG:clientinfo:sclick:3: {
;  /dialog -x clientinfo
;}

;***** USER DIALOGS JOTI-IRC *****
alias nick {
	/echo setting nickname to $1
	/set %mynickname $1
	/.nick $1
	}

dialog usernick {
  title "Choose nickname"
  size -1 -1 350 460
  icon 1, 1 1 350 350, $adiircdir\pix\logo.png
  text "Please enter your nickname and select your section",2, 20 375 250 24
  edit "$+(Nick_,$rand(10000,99999))",3, 20 400 150 24
  combo 4, 180 400 150 80,drop
  button "Continue",5, 125 430 100 25, OK 
}

on *:DIALOG:usernick:init:0: { 
  did -a usernick 4 Beavers 
  did -a usernick 4 Cubscouts
  did -a usernick 4 Scouts 
  did -a usernick 4 Explorers
  did -a usernick 4 Roverscouts
  did -a usernick 4 Leader
  did -a usernick 4 Operator
}

on *:DIALOG:usernick:sclick:5: {
  set %schuilnaam $did(usernick,3).text
  set %speltak $did(usernick,4).seltext
  
  if (%schuilnaam == $null) {
  	%schuilnaam = $+(GUEST_,$rand(10000,99999))
  }
  
  /set %mynickname %schuilnaam

	if (%setup.joti.prefix != $null) {
		if (%schuilnaam != %setup.joti.localadmin) {
			/set %mynickname %setup.joti.prefix $+ _ $+ %schuilnaam 
		}
	}

  /unset %schuilnaam
  if (%connection == disconnected) {
  	/conn
  } else {
  	/nick %mynickname
  }
}


alias requestnick {
	/playsound nicknameallreadyinuse.wav
	/echo -g Your nickname can not be used
	/dialog -m usernick usernick
}

raw 432:*: {
	/requestnick
	/halt
}
raw 433:*: {
	/requestnick
	/halt
}


;***** CONNECTING JOTI-IRC ******
alias playsound {
	if (%sounds == on) {
		var %tmp.sound = $adiircdir $+ sounds\ $+ $$1
		if ($exists(%tmp.sound)) {
			/splay -c %tmp.sound
		}
	}
}
	
alias conn {
  var %connectdelay = $rand(1,5) 
  if (%connectdelay == 1) { /timerCONN1 1 1 /conn2 }
  if (%connectdelay == 2) { /timerCONN1 1 2 /conn2 }
  if (%connectdelay == 3) { /timerCONN1 1 3 /conn2 }
  if (%connectdelay == 4) { /timerCONN1 1 4 /conn2 }
  if (%connectdelay == 5) { /timerCONN1 1 5 /conn2 }
}

alias conn2 {  
  /server chat.scoutlink.net -nick %mynickname -real %mynickname -f
}

on *:CONNECTFAIL: {
  /disconnect
  /timerFAIL 1 1 /conn 
}

on *:CONNECT: {
  /echo 12 *********************************
  /echo 12 *  have lots of fun online!!!   *
  /echo 12 *********************************
  /set %connection connected
  
  if (%setup.joti.mode == group) {
  	if (%setup.joti.clientid == $null) {
  		%setup.joti.clientid = $host
  	}
  	if ($me == %setup.joti.localadmin) {
  		/echo 12 local admin mode
  		/adminconnected
  	} else {
  	  /noticeadmin connected
  	}
  }  	
  /playsound connected.wav
	/toolbarupdate  
  /loadbwlist
  /timerCONN2 1 1 /list
  /list
}

on *:NOTICE:*This nickname is registered*:?: {  
  if ($nick == NickServ) { 
    /timerNICKID 1 1 /nickid  
    /
    }
}

on *:DISCONNECT: {
  /set %connection disconnected
 	/admindisconnect
  /playsound disconnected.wav
  /toolbarupdate
}


on *:NICK: {
	if ($nick == $me) {
		/playsound userchangednick.wav
		/echo -sg User nickchange from $nick to $newnick
		if (%setup.joti.mode == group) {
  		if ($newnick != %setup.joti.localadmin) {
    		/noticeadmin nickchange %mynickname $newnick
    		if (%localadminmode == 1) {
 					/admindisconnect
 				}
  		} else {
  			/adminconnected
  		}
  	}
  	/set %mynickname $newnick
  }
}

on *:JOIN:*: {
	if ($nick == $me) {
		/playsound channeljoined.wav
  	if ( ($nick != %setup.joti.localadmin) && (%setup.joti.mode == group) ) {
    	/noticeadmin channeljoin $chan 
  	}
  }
}

on *:OPEN:?:*: {
	if ($nick == $me) {
		/playsound privatemessage.wav
  	if ( ($nick != %setup.joti.localadmin) && (%setup.joti.mode == group) ) {
    	/noticeadmin querywindow $nick 
  	}
  }
}

on *:PART:#: {
	if ($nick == $me) {
		/playsound channelleft.wav
  	if (($nick != %setup.joti.localadmin) && (%setup.joti.mode == group)) {
    	/noticeadmin channelpart $chan
  	}
  }
}

on *:KICK:*: {
	if ($knick == $me) {
		/playsound userkicked.wav
 		if (%setup.joti.mode == group) {
 	  	/noticeadmin kicked $nick $chan
 		}
 		/window -c $chan
 		/echo -sg 4 You have been kicked from the channel $chan by $nick. The reason is: $1-
	}
}

on *:BAN:*: {
	if ($bnick != $null) {
		if ($bnick == $me) {
			/playsound userbanned.wav
  		if (%setup.joti.mode == group) {
  	  	/noticeadmin banned $banmask $chan
  		}
  		/window -c $chan
  		/echo -sg 4 You are banned from channel $chan by $nick. Reason: $2-
  	}
  }
}

on *:TEXT:into the wild!:#dutch-opening: {
	if ($nick == geejee) {
  	 /msg #dutch-opening We are born, born to be WILD!
	}
}

;***** ADMIN SCRIPT JOTI-IRC ******
alias adminconnected {
  /window -dk0 @Usermonitor 150,50,250,500 
  /font -d @Usermonitor 14 arial
  /aline @Usermonitor 4All events from your users will be shown here
  /echo 4 **************************
  /echo 4 *  LOCAL ADMIN MODE!!!   *
  /echo 4 ************************** 
  /set %localadminmode 1
}

alias admindisconnect {
	/set %localadminmode = $null
	/window -c @Usermonitor
}

dialog waarschuwing {
	title "Warning from your local administrator"
	option dbu
	size -1 -1 300 100
	text "",2,5 5 200 80
	button "close", 10, 125 85 34 10, cancel
}

alias noticeadmin {
	/.notice %setup.joti.localadmin $1- %setup.joti.clientid
	/set %tmp.ignorenonick 1
}

raw 401:*: {
	if (%tmp.ignorenonick == 1) {
		/unset %tmp.ignorenonick
		/halt
	}
}

alias dodebug {
	/debug -ets @debugging
}

menu nicklist,channel,query {
 	$iif((%localadminmode == 1) && (%setup.joti.mode == group),Admin functions) 
 		.ID: /.notice $$1 ID
	 	.Warning: /.notice $$1 warning $$?="Please enter the warning tekst"
 		.Nickname: /.notice $$1 changenick $$?="Please enter the new nickname"
 		.Remove: /.notice $$1 verdwijn
 		.Exit: /.notice $$1 exit
}

on *:NOTICE:*:* {
	if (%localadminmode == 1 ) {
		var %tmp.color = $null
		var %tmp.line = $null	
		
		if ($$1 == connected) {
			var %tmp.color = 2
			var %tmp.line = $nick is online on Joti-station $$2
		}
  	
		if ($$1 == nickchange) {
			var %tmp.color = 12
			var %tmp.line = $nick changed the nickname to $$2 on Joti-station $$3
		}
		
		if ($$1 == channeljoin) {
			var %tmp.color = 3
			var %tmp.line = $nick joins channel $$2 Joti-station $$3
		}
  	
		if ($$1 == channelpart) {
			var %tmp.color = 0
			var %tmp.line = $nick leaves channel $$2 Joti-station $$3
		}
		
		if ($$1 == kicked) {
			var %tmp.color = 4
			var %tmp.line = $nick is kicked from $$3 by $$2 on Joti-station $$4
		}
  	
		if ($$1 == banned) {
			var %tmp.color = 4
			var %tmp.line = $nick is kicked and banned from $$3 by $$2 on Joti-station $$4
		}
  	
		if ($$1 == querywindow) {
			var %tmp.color = 12
			var %tmp.line = $nick started a privat conversation with $$2 on Joti-station $$4
		}
		if ($$1 == ID) {
			var %tmp.color 0
			var %tmp.line = $nick has station id $$2
		}
		
		if ($$1 == HELP!) {
			var %tmp.color = 4
			var %tmp.line = $nick needs help on Joti-station $$1
			/playsound panic.mp3
		}
  } else {
	
		if (($nick == %setup.joti.localadmin) && (%setup.joti.mode == group)) {

			if ($$1 == ID) {
				/noticeadmin ID
			}
			
			if ($$1 == warning) {
				/dialog -m waarschuwing waarschuwing
				/did -a waarschuwing 2 $2-
			}  	
			if ($$1 == verdwijn) {
				/echo -sg $nick removed you from all chats!
				/playsound killed.wav
				/quit 4Oops, this scout has behaved inappropriate and has been removed!
			}
			if ($$1 == changenick) {
				/echo -sg Your nickname was changed to $$2 by $nick
				/nick $$2
			}
			
			if ($$1 == exit) {
				/echo -sg $nick has closed down your chat.
				/exit -n
			}
		}
	}
		
  	
	if (%tmp.line != $null) {
		/echo -g @Usermonitor %tmp.color $time - %tmp.line
		/write $adiircdir\logs\log%currentyear.txt $fulldate - %tmp.line
	}
}
	

;***** CHANNEL LISTING JOTI-IRC ******

alias fetchchannels {
	if ($1 == $null) {
		/set %tmp.chanfilter $null
	} else {
  	/set %tmp.chanfilter $1
	}
	/.list
}


alias channelfilter { 
	if (%tmp.chanfilter != $null) {
  	var %myfilter = $+(*,%tmp.chanfilter,*)
  	/filter -cdio chat_channels 3 chat_channels 2 %myfilter
  } else {
  	/filter -cdio chat_channels 3 chat_channels 2 *
	}
	
}

alias list { 
	if ($1 != $null) {
  	set %tmp.chanfilter $1
	}
	/dialog -m chat_channels chat_channels
	/.raw list
}

dialog chat_channels {
	title "Select your chat channel"
	option dbu
	size -1 -1 300 200
	text "Channel filter",20,5 5 35 8
	edit %tmp.chanfilter, 21, 50 3 100 10
	list 2, 1 15 300 165, sort
	button "filter list", 11, 155 3 50 10
	button "close", 10, 125 185 34 10, cancel
	list 3, 400 1 1 1,
}

on *:DIALOG:chat_channels:sclick:11 {
	set %tmp.chanfilter $did(21)
	/channelfilter
}

on *:DIALOG:chat_channels:sclick:2 {
	var %line = $did(2,$did(2).sel).text
	var %naam, %dump = $regsub(%line,/\t.*/,$null,%naam)
	/join %naam
}

raw 322:*: {
	inc %listcounter
	var %x,%y = $regsub($2-,/.*?\]\s/,$null,%x)
	var %naam, %dump = $regsub($2-,/\s+.*/,$null,%naam);
	var %regel = %naam $chr(9)
	if ($len(%naam) < 8) { 
		%regel = %regel $chr(9) 
	}
	%regel = %regel $3 $chr(9) %x
	/did -a chat_channels 3 %regel
	/halt
}

raw 323:*: {
	/channelfilter
	/setusermode
	/halt
}

raw 221:*: {
	/setusermode
}

alias setusermode {
	if (R isincs $usermode) {
	 /set %usermode on
	} else {
	 /set %usermode off
	}
	/toolbarupdate
}

;***** GAME MENU JOTI-IRC ******

dialog games {
	title "IRC games overview"
	size -1 -1 600 250
	icon 1, 1 1 150 150, $adiircdir\pix\pimpampet.bmp
	icon 2, 151 1 150 150, $adiircdir\pix\wakkerdam.bmp
	icon 3, 301 1 150 150, $adiircdir\pix\welpen.bmp
	icon 4, 451 1 150 150, $adiircdir\pix\uno.bmp
	icon 5, 601 1 150 150, $adiircdir\pix\trivia.bmp
	text "Pim Pam Pet, the oldfashioned dutch game with words, hosted by: Pimmetje!",6, 5 160 140 50
	text "The werewolves of Millers Hollow, the well known game!",7, 155 160 140 50
	text "The werewolves of Millers Hollow, a cub scouts jungle edition!",8, 305 160 140 50
	text "UNO, play the worldfamous cardgame here!",9, 455 160 140 50
	text "Trivia, test your knowledge in this Trivia quiz!",10, 605 160 140 50
	button "Play now!",11, 25 215 100 25, OK 
	button "Play now!",12, 175 215 100 25, OK 
	button "Play now!",13, 325 215 100 25, OK 
	button "Play now!",14, 475 215 100 25, OK 
	button "Play now!",15, 625 215 100 25, OK 
}

alias startgames {
	/dialog -m games games
}


on *:DIALOG:games:sclick:1: {
	/join #dutch-pimpampet
	/dialog -x games
}

on *:DIALOG:games:sclick:11: {
	/join #dutch-pimpampet
	/dialog -x games
}

on *:DIALOG:games:sclick:2: {
	/join #dutch-weerwolven
	/dialog -x games
}

on *:DIALOG:games:sclick:12: {
	/join #dutch-weerwolven
	/dialog -x games
}

on *:DIALOG:games:sclick:3: {
	/join #dutch-jungle
	/dialog -x games
}

on *:DIALOG:games:sclick:13: {
	/join #dutch-jungle
	/dialog -x games
}

on *:DIALOG:games:sclick:4: {
	/join #dutch-uno
	/dialog -x games
}

on *:DIALOG:games:sclick:14: {
	/join #dutch-uno
	/dialog -x games
}

;***** BADGES AND LOGGING PROFILES JOTI-IRC ******

menu nicklist,channel,query {
	Badges
	.Nice Chat: { 
	  if ($1 != $me) {
	    /inc %badgequota
	    if (%badgequota == 1) /timerQUOTA 1 3600 /set %badgequota 0
	    if (%badgequota < 6) /ctcp $1 badge.leukstechat 
	    if (%badgequota < 6) /ctcp Douwe badge.leukstechat $1 
	    if (%badgequota >= 6) /echo You are only allowed to give 5 badges in 1 hour! 
	  }
	}
	.New Friend: { 
	  if ($1 != $me) {
	    /inc %badgequota
	    if (%badgequota == 1) /timerQUOTA 1 3600 /set %badgequota 0
	    if (%badgequota < 6) /ctcp $1 badge.nieuwevriend 
	    if (%badgequota < 6) /ctcp Douwe badge.nieuwevriend $1 
	    if (%badgequota >= 6) /echo You are only allowed to give 5 badges in 1 hour!
	  }
	}
	.Best Troop: { 
	  if ($1 != $me) {
	    /inc %badgequota
	    if (%badgequota == 1) /timerQUOTA 1 3600 /set %badgequota 0
	    if (%badgequota < 6) /ctcp $1 badge.bestegroep 
	    if (%badgequota < 6) /ctcp Douwe badge.bestegroep $1 
	    if (%badgequota >= 6) /echo You are only allowed to give 5 badges in 1 hour!
	  }
	}
	Profiel
	.Registreer log: {
	  if (%profilelock == unlock) {
	    /ctcp $1 GET.PROFILE
	    /set %profilelock lock
	    /timerPROFILELOCK 1 90 profile.unlock
	    /inc %logcounter
	  }
	}
}

alias profile.unlock {
	/set %profilelock unlock
}



dialog leukstechat {
	title "Fun chat badge"
	size -1 -1 182 255
	icon 1, 1 1 180 180, $adiircdir\pix\leukstechat.jpg
	text "Congratulations! You have received a badge for most fun chat from:",2, 12 183 160 56
	text "",3, 41 211 180 28 
	button "Close",4, 41 225 100 25, OK 
}

ctcp *:badge.leukstechat:*: {
	/set %afzender $nick
	/dialog -m leukstechat leukstechat
	/did -a leukstechat 3 %afzender
	/ctcp Douwe recieved.badge.leukstechat %afzender
	/playsound badgerecieved.wav
}

on *:DIALOG:leukstechat:sclick:4: {
	/inc %aantal.badges.leukstechat  
	/dialog -x leukstechat 
	/unset %afzender
}

dialog nieuwevriend {
	title "New friend badge"
	size -1 -1 182 255
	icon 1, 1 1 180 180, $adiircdir\pix\nieuwevriend.jpg
	text "Congratilations! You have received a new friend badge from:",2, 8 183 170 56
	text "",3, 41 211 180 28 
	button "Close",4, 41 225 100 25, OK 
}

ctcp *:badge.nieuwevriend:*: {
	/set %afzender $nick
	/dialog -m nieuwevriend nieuwevriend
	/did -a nieuwevriend 3 %afzender
	/ctcp Douwe recieved.badge.leukstechat %afzender
	/playsound badgerecieved.wav
}

on *:DIALOG:nieuwevriend:sclick:4: {
	/inc %aantal.badges.nieuwevriend  
	/dialog -x nieuwevriend 
	/unset %afzender
}

dialog bestegroep {
	title "Best troop badge"
	size -1 -1 182 255
	icon 1, 1 1 180 180, $adiircdir\pix\bestegroep.jpg
	text "Congratulations! Yuo have received a best troop badge from:",2, 8 183 170 56
	text "",3, 41 211 180 28 
	button "Close",4, 41 225 100 25, OK 
}

ctcp *:badge.bestegroep:*: {
	/set %afzender $nick
	/dialog -m bestegroep bestegroep
	/did -a bestegroep 3 %afzender
	/ctcp Douwe recieved.badge.leukstechat %afzender
	/playsound badgerecieved.wav
}

on *:DIALOG:bestegroep:sclick:4: {
	/inc %aantal.badges.bestegroep  
	/dialog -x bestegroep 
	/unset %afzender
}

dialog badgeoverzicht {
	title "Badge overview"
	size -1 -1 302 150
	icon 1, 1 1 100 100, $adiircdir\pix\leukstechat.jpg
	icon 2, 101 1 100 100, $adiircdir\pix\nieuwevriend.jpg
	icon 3, 201 1 100 100, $adiircdir\pix\bestegroep.jpg
	text "count:",4, 1 101 100 25
	text "count:",5, 101 101 100 25
	text "count:",6, 202 101 100 25
	text "",7, 51 101 50 25
	text "",8, 151 101 50 25
	text "",9, 251 101 50 25
	button "Close",10, 101 126 100 25, OK 
}

alias badgeoverzicht {
	/dialog -m badgeoverzicht badgeoverzicht
	/did -a badgeoverzicht 7 %aantal.badges.leukstechat 
	/did -a badgeoverzicht 8 %aantal.badges.nieuwevriend 
	/did -a badgeoverzicht 9 %aantal.badges.bestegroep 
}

on *:DIALOG:badgeoverzicht:sclick:10: {
	/dialog -x badgeoverzicht
}

;***** OPERATORSRIPT JOTI-IRC ******

;F1 - Vrije waarschuwingen
alias f1 { if ($me isop $chan) && ($active ischan)  /say $$1 $+ , $$input(General warning.,e,warning) } 
alias sf1 { if ($me isop $chan) && ($active ischan)  /kick $chan $$snick(#,1)  $$?="What is the reason for your kick?" } 
alias cf1 { if ($me isop $chan) && ($active ischan)  /var %kickmsg = $?="What is the reason for your kickban?" | ban -u60 $$address($$snick(#,1),0) | kick $chan $$snick(#,1) %kickmsg } 

;F2 - Taalgebruik
alias f2 { if ($me isop $chan) && ($active ischan)  /say $$1 $+ , please mind your language, I would hate to kick somebody from this channel. } 
alias sf2 { if ($me isop $chan) && ($active ischan)  /kick $chan $$snick(#,1) Your language is undesirable. } 
alias cf2 { if ($me isop $chan) && ($active ischan)  /ban -u60 $$address($$snick(#,1),0)) 1 | kick $chan $$snick(#,1) Your language is undesirable. } 

;F3 - Foute nickname
alias f3 { if ($me isop $chan) && ($active ischan)  /say $$1 $+ , your nickname is undesirable and I would like to see it changed. You can change it by using the command /nick.  } 
alias sf3 { if ($me isop $chan) && ($active ischan)  /kick $chan $$snick(#,1) Your nickname is not allowed here. You can change it by using the command /nick. } 
alias cf3 { if ($me isop $chan) && ($active ischan)  /ban -u60 $$address($$snick(#,1),7) | kick $chan $$snick(#,1) Your nickname is not allowed here. You can change it by using the command /nick. } 

;F4 - Flooding
alias f4 { if ($me isop $chan) && ($active ischan)  /say $$1 $+ , please refrain from flooding, other chatters are bothered by it and it is not needed. } 
alias sf4 { if ($me isop $chan) && ($active ischan)  /kick $chan $$snick(#,1) Flooding is annoying and not needed. Unfortunatly for you it seems not possible to lessen your enthousiasm } 
alias cf4 { if ($me isop $chan) && ($active ischan)  /ban -u60 $$address($$snick(#,1),0)) | kick $chan $$snick(#,1) Flooding is annoying and not needed. Unfortunatly for you it seems not possible to lessen your enthousiasm  } 

;F5 - Capslock gebruik
alias f5 { if ($me isop $chan) && ($active ischan)  /say $$1 $+ , the use of upper case is seen as yelling in irc and is considered very unfriendly. Please stop sending messages in all caps! } 
alias sf5 { if ($me isop $chan) && ($active ischan)  /kick $chan $$snick(#,1) You keep sending everything in upper case, which is undesirable. } 
alias cf5 { if ($me isop $chan) && ($active ischan)  /ban -u60 $$address($$snick(#,1),0)) | kick $chan $$snick(#,1) You keep sending everything in upper case, which is undesirable. } 


;F6 - Privé gegevens (Algemeen en persoonlijk)
alias f6 { if ($me isop $chan) && ($active ischan)  /say It is better NOT to disclose privat information. This could have unpleasant consequences later. If you decide to do so, it is better to open a privat chat and send it there. } 
alias sf6 { if ($me isop $chan) && ($active ischan)  /say $$1 $+ , It is better NOT to disclose privat information. This could have unpleasant consequences later. } 


;F7 - Vrij in te vullen
alias sf7 { if ($me isop $chan) && ($active ischan)  /say Hi $chan, my name is $me and i am an Operator for ScoutLink. } 

;F8 - Kill en Gline
alias sF8 { if ($me isop $chan) && ($active ischan)  /msg %operator.chan /kill $$snick(#,1) $$?="What is your reason? Leave this blank to cancel the Kill command." }
alias cF8 { if ($me isop $chan) && ($active ischan)  /msg %operator.chan gline $$snick(#,1)  2m : $+ $$?="What is your reason? Leave this blank to cancel the g-line. Please refer to %operator.chan for longer g-lines" (Short ban: send an email for more information to joti@scoutlink.nl) } 


;F9 - OP's aan/uit
alias f9 { 
	if ($me isop $active) { 
		/mode $active -o $me 
		;/timerCONN3 1 2 /who $active
		/msg %operator.chan 4I am NOT an operator in $active anymore
	} else { 
		/chanserv op $active $me
		;/timerCONN3 1 2 /who $active
		/playsound channeloperator.wav
		/msg %operator.chan 4I am operator in $active!
	}
}

;F10 - Kleur, inviteonly, moderated
alias f10 { if (($me isop $chan) && ($active ischan)) { 
	if ($me isop $active) {
		mode # $iif(c isincs $chan(#).mode,-c,+c) } 
		if (c isincs $chan(#).mode) {
			/msg %operator.chan 4 $chan can NOT use color codes
		} else {
			/msg %operator.chan 4 $chan can use color codes
		}
	}
}

alias Sf10 { if (($me isop $chan) && ($active ischan)) {
	if ($me isop $active) {
		mode # $iif(i isincs $chan(#).mode,-i,+i) } 
		if (i isincs $chan(#).mode) {
			/msg %operator.chan 4 $chan is open
		} else {
			/msg %operator.chan 4 $chan is now invite only
		}
	}	
}

alias cf10 { if (($me isop $chan) && ($active ischan)) { 
	if ($me isop $active) {
		mode # $iif(m isincs $chan(#).mode,-m,+m) } 
		if (m isincs $chan(#).mode) {
			/msg %operator.chan 4 $chan is no longer moderated
		} else {
			/msg %operator.chan 4 $chan is now moderated
		}
	}	
}

;F11 - Reclame
alias f11 { { if ($me isop $chan) && ($active ischan)  /say 12 Scoutlink is opened the whole year! Do visit us after JOTI sometime! } }

alias f12 { if ($me isop $chan) /msg Pimmetje !punterbij $snick(#,1) }     
alias sf12 { if ($me isop $chan) /msg Pimmetje !puntvoorantwoord $snick(#,1) $cb }
alias cf12 { if ($me isop $chan) /msg Pimmetje !strafpunt $snick(#,1) }     


alias massvoice {
	mode $$chan +m
	var %x = $nick($1,0,r) | while (%x) { 
  	var %r = %r $nick($1,%x,r)
  	if ($numtok(%r,32) = $modespl) { mode $1 + $+ $str(v,$modespl) %r | unset %r } | dec %x
	}
	if (%r) { mode $1 + $+ $str(v,$numtok(%r,32)) %r }
}


alias massdevoice {
	mode $$chan -m
	var %x = $nick($1,0,v) | while (%x) { 
  	var %r = %r $nick($1,%x,v)
  	if ($numtok(%r,32) = $modespl) { mode $1 - $+ $str(v,$modespl) %r | unset %r } 
  	dec %x
	}
	if (%r) { mode $1 - $+ $str(v,$numtok(%r,32)) %r }
}

menu nicklist,channel {
	.Check user
	..WHOIS:/whois op $$snick(#,1)
	..PING:/ctcp $$snick(#,1) ping
	..VERSION:/ctcp $$snick(#,1) version
	..MAIL:/ctcp $$snick(#,1) mail
	..NUMBER:/ctcp $$snick(#,1) number
	..Op: { 
		;/chanserv op $active $me 
		;/msg %operator.chan 4I am now operator in $active  
		/chanserv op $active $snick(#,1)
		;/timerCONN3 1 2 /who $active
		/msg %operator.chan $snick(#,1) is now an operator in $chan(#) by $me
	}
	..Deop: { 
	 	;/mode $active -o $me 
	 	;/msg %operator.chan 4I am NO LONGER operator in $active
	 	/mode $active -o $snick(#,1)
	 	;/timerCONN3 1 2 /who $active
	 	/msg %operator.chan $snick(#,1) is NO LONGER operator in $chan(#) by $me
	}
} 

menu nicklist,channel {
	$iif($me isop #,.Channel settings)
	..No colors: { if ($me isop $chan)  /mode $$chan +c }
	..With colors: { if ($me isop $chan)  /mode $$chan -c }
	..Invite On: { if ($me isop $chan)  /mode $$chan +i }
	..Invite Off: { if ($me isop $chan)  /mode $$chan -i }
	..Moderated On: { if ($me isop $chan)  { 
	    /mode $$chan +m 
	  /msg %operator.chan 4channel $$chan is now MODERATED  } 
	}
	..Moderated Off: { if ($me isop $chan)  { 
	    /mode $$chan -m 
	  /msg %operator.chan 4channel $$chan is now NOT MODERATED } 
	}
	..Massvoice:  { if ($me isop $chan)  { 
	    /massvoice $$chan 
	  	/msg %operator.chan 4channel $$chan is now MASSVOICE and MODERATED 
	  }
	}
	..Massdevoice:  { if ($me isop $chan) {  
	    /massdevoice $$chan  
	  	/msg %operator.chan 4channel $$chan is now NOT MASSVOICE anymore
		}
	}
	..Voice: { if ($me isop $chan)  /chanserv voice $chan $$snick(#,1) }
	..Devoice: { if ($me isop $chan)  /chanserv devoice $chan $$snick(#,1) }
	-
	$iif($me isop #,.General warnings)
	..Language: { if ($me isop $chan)  /say Please mind your language, i would hate to kick people from this channel. }
	..Flooding: { if ($me isop $chan)  /say Please refrain from flooding or entering too much nonsense in a short time. If you are looking for attention, be original, not annoying!. }
	..Privat information: { if ($me isop $chan)  /say Please do not disclose personal information here. It could have unpleasant concequences later. If you do want to share privat information, please do so in a privat chat. }
	..CapsLock: { if ($me isop $chan)  /Say Only using upper case is considered yelling and very unfriendly. If you persist in doing this i have no choice but to remove you from this channel. }
	-
	$iif($me isop #,.Languages)
	..English: { if ($me isop $chan)  /say If you wish to chat in English, please /hop #English } 
	..Spanish: { if ($me isop $chan)  /say Por favor, si quieren hablar en espanol, se pone /hop #espanol }
	..French: { if ($me isop $chan)  /say Pour communiquer en français, voulez vous sil vous plaît taper /hop #francais pour utiliser le canal #francais . Merci! }
	..German: { if ($me isop $chan)  /say Wenn Sie möchte deutsch sprechen , bitte /hop #deutsch }
	..Portugese: { if ($me isop $chan)  /say Se você quer falar português, por favor digite /hop #portuguese }
	..Italian: { if ($me isop $chan)  /say por favore se vuoi parlare italiano, por favore /hop #italian }
	..Norish: { if ($me isop $chan)  /say Hvis du vil skrive pa norsk, vennligst skriv /hop #scandinavia }
	..Swedish: { if ($me isop $chan)  /say  Om du vill prata svenska, lämna $chan och anslut till #scandinavia }
	..Chinese: { if ($me isop $chan)  /say  Ruguo ni yao shuo zhongwen, qing ni likai $chan $+ , lanhou zai jinru #chinese }
	..Papiamento: { if ($me isop $chan)  /say Den e kanal aki no tin mag di papia Papiamentu, type /hop #papiamento }
	..Indonesian: { if ($me isop $chan)  /say Kalau mau dengan bahasa Indonesia, tipe /hop #indonesia }
	-
	$iif($me isop #,.Nickname warnings)  
	..Warn(reason): { if ($me isop $chan)  /say $$1 $+ , $$?="Reason for the warning" }
	..Language:  { if ($me isop $chan)  /say $$1 $+ , keep it fun for everybody, please mind your language! }
	..Flooding:  { if ($me isop $chan)  /say $$1 $+ , please refrain from flooding. You already have my attention now and others are bothered by it. }
	..Privat information:  { if ($me isop $chan)  /say $$1 $+ , do not disclose privat information, it can have unpleasant consequences later. }
	..CapsLock:  { if ($me isop $chan)  /say $$1 $+ , only using upper case is considered yelling and annoying. Please stop using only upper case! }
	..Nickname:  { if ($me isop $chan)  /say $$1 $+ , your nickname is not appropriate and i would like you to change it. You can do so by using the /nick command. }
	-
	$iif($me isop #,.Kick)
	..Kick (reason): { if ($me isop $chan)  /kick $chan $$snick(#,1)  $$?="Please enter the kick message?") }
	..Kick Language: { if ($me isop $chan)  /kick $chan $$snick(#,1)  Your use of language is unacceptable. } 
	..Kick Caps:if ($network == Scoutlink ) { /kick $chan $$snick(#,1)  Unfortunately you persist in using upper case. This is not accepted. } 
	..Kick Flood:if ($network == Scoutlink ) { /kick $chan $$snick(#,1)  Flooding and nonsense is annoying. Unfortunatly you don't seem to be able to keep your enthousiasm in check.  } 
	..Kick Nickname:if ($network == Scoutlink ) { /kick $chan $$snick(#,1)  This nickname is not acceptable. You can change it using the /nick command  }
	-
	$iif($me isop #,.Ban + Kick 60 seconds)
	..Ban (reason): { if ($me isop $chan)  ban -u60 $$address($$snick(#,1),0)) 1 | /kick $chan $$snick(#,1) $iif($$?="Please enter the kick+ban reason?", $!) }
	..Ban Language: { if ($me isop $chan)  ban -u60 $$address($$snick(#,1),0)) 1 | /kick $chan $$snick(#,1)  Your use of language is unacceptable. }  
	..Ban Caps: { if ($me isop $chan)  ban -u60 $$address($$snick(#,1),0)) | /kick $chan $$snick(#,1)  Unfortunately you persist in using upper case. This is not accepted. } 
	..Ban Flood: { if ($me isop $chan)  ban -u60 $$address($$snick(#,1),0)) | /kick $chan $$snick(#,1)  Flooding and nonsense is annoying. Unfortunatly you don't seem to be able to keep your enthousiasm in check.   } 
	..Ban Nickname: { if ($me isop $chan)  ban -u60 $$address($$snick(#,1),7)) | /kick $chan $$snick(#,1)  This nickname is not acceptable. You can change it using the /nick command }
	-
	$iif($me isop #,.ChanServ Kick)
	..Kick (reason): { /chanserv kick $chan $$snick(#,1) $$?="Please enter the kick reason?" }
	..Kick Language: { /chanserv kick $chan $$snick(#,1)  Your use of language is unacceptable. } 
	..Kick Caps: { /chanserv kick $chan $$snick(#,1)  Unfortunately you persist in using upper case. This is not accepted. } 
	..Kick Flood: {  /chanserv kick $chan $$snick(#,1)  Flooding is not accepted, unfortunately your enthousiasm is untameable.  } 
	..Kick Nickname: {  /chanserv kick $chan $$snick(#,1)  Your nickname is not acceptable, you can change it by typing /nick }
	-
	$iif($me isop #,.Kill)
	..(Reason): { if ($me isop $chan) && ($active ischan)  /msg %operator.chan /kill $$snick(#,1)  $$?="What is your reason? leave blank to cancel" }
	..Language: { if ($me isop $chan) && ($active ischan)  /msg %operator.chan /kill $$snick(#,1) Persistent undesirable language. }  
	..Caps: { if ($me isop $chan) && ($active ischan)  /msg %operator.chan /kill $$snick(#,1) Persistent use of upper case. }
	..Flood: { if ($me isop $chan) && ($active ischan)  /msg %operator.chan /kill $$snick(#,1) Persistent flooding. }
	..Nickname: { if ($me isop $chan) && ($active ischan)  /msg %operator.chan /kill $$snick(#,1) Undesirable nickname. }
	-
	$iif($me isop #,.G-lines)
	..(Reason)     : { if ($me isop $chan) && ($active ischan)  /msg %operator.chan gline $$snick(#,1)  2m : $+ $$?="Enter your g-line. Leave blank to cancel and confer with %operator.chan for longer g-lines." (Short ban, email: joti@scoutlink.nl) } 
	..Language	 	: { if ($me isop $chan) && ($active ischan)  /msg %operator.chan gline $$snick(#,1)  2m : $+ Persistent undesired language (Short ban for $$snick(#,1) $+ : email to joti@scoutlink.nl for more information) }
	..Caps        : { if ($me isop $chan) && ($active ischan)  /msg %operator.chan gline $$snick(#,1)  2m : $+ Persistent use of upper case. (Short ban for $$snick(#,1) $+ : email to joti@scoutlink.nl for more information) }
	..Flood       : { if ($me isop $chan) && ($active ischan)  /msg %operator.chan gline $$snick(#,1)  2m : $+ Persistent flooding. (Short ban for $$snick(#,1) $+ : email to joti@scoutlink.nl for more information) }
	..Nickname    : { if ($me isop $chan) && ($active ischan)  /msg %operator.chan gline $$snick(#,1)  2m : $+ Undesirable nickname. (Short ban for $$snick(#,1) $+ : email to joti@scoutlink.nl for more information) }
	-
	$iif($me isop #,.Nick Change)
	.Nickchange   : { if ($me isop $chan) && ($active ischan)  /msg %operator.chan Nickchange: /sanick $$snick(#,1) $$?="What is the new nickname? Leave blank to cancel" } 
	-
	$iif($me isop #,.Pimmetje)
	..join : { if ($me isop $chan) /msg Pimmetje  !join $active ppp Pimmetje | /timerPimmetje 1 5 /chanserv on $active Pimmetje  }   
	..part : { if ($me isop $chan) /msg Pimmetje !part $active }
	..Start PimPamPet : { if ($me isop $chan) /msg Pimmetje !startppp }            
	..Stop PimPamPet : { if ($me isop $chan) /msg Pimmetje !stopppp }               
	..Award one point : { if ($me isop $chan) /msg Pimmetje !punterbij $$snick(#,1) }     
	..Award one point(answer) : { if ($me isop $chan) /msg Pimmetje !puntvoorantwoord $$snick(#,1) $cb }
	..Penalty : { if ($me isop $chan) /msg Pimmetje !strafpunt $$snick(#,1) }          
	..Show HiScore : { if ($me isop $chan) /msg Pimmetje !hiscore }              
	..Add Admin : { if ($me isop $chan) /msg Pimmetje !addadmin $?="Nickname" }         
	..Remove Admin : { if ($me isop $chan) /msg Pimmetje !deladmin $?="Nickname" }      
	..Show all Admins : { if ($me isop $chan) /msg Pimmetje !showadmins }         
	..Show Status : { if ($me isop $chan) /msg Pimmetje !toonstatus }         
}

menu nicklist,channel,query,status {
	.-
	$iif($me isop #,.ChanServ Commands)
	..Getkey :  { if ($me isop $chan)  /chanserv getkey $$?="Fetch the key for what channel?") }
	..Unban :  { if ($me isop $chan)  /chanserv unban  $$?="Request unban from what channel?") }
	..-
	..Op: { 
		/chanserv op $active $me 
		/msg %operator.chan 4I am now operator in $active  
	}
	..Deop: { 
	 	/mode $active -o $me 
	 	/msg %operator.chan 4I am no longer operator in $active
	}
	..-
	..Voice :if ($me isop $chan)  { /chanserv voice $chan $snick(#,1) }
	..Devoice :if ($me isop $chan)  { /chanserv devoice $chan $snick(#,1) }
	..-
	..Info :if ($me isop $chan)  { /chanserv info $chan }
	..Invite :if ($me isop $chan)  { /chanserv invite $chan $$?="Who do you want to invite?" } 
}

menu channel {
	Channel options : /channel
}

;****** 60 seconden ban *******
alias timedban {
/tban $$1 60s $$2 
/kick $$1 $$2 60 SECONDEN BAN: $$3-
}

;***** WARNING POP-UPS JOTI-IRC ******

dialog glined {
	title "WARNING: G:LINED"
	size -1 -1 400 240
	icon 1, 1 1 400 188, $adiircdir\pix\glined1.jpg
	icon 2, 1 1 400 188, $adiircdir\pix\glined2.jpg
	button "close",3, 150 210 100 25, OK 
}

alias blinkgreen.glined {
	/timerGREEN -m 1 500 /blinkred.glined
	/did -h glined 2
	/did -v glined 1
}

alias blinkred.glined {
	/timerRED -m 1 500 /blinkgreen.glined
	/did -h glined 1
	/did -v glined 2
}

on *:DIALOG:glined:sclick:3:{
	/dialog -x glined
	/timerGREEN off
	/timerRED off
}

dialog killed {
	title "WARNING: KILLED"
	size -1 -1 400 240
	icon 1, 1 1 400 188, $adiircdir\pix\killed1.jpg
	icon 2, 1 1 400 188, $adiircdir\pix\killed2.jpg
	button "close",3, 150 210 100 25, OK 
}

alias blinkgreen.killed {
	/timerGREEN -m 1 500 /blinkred.killed
	/did -h killed 2
	/did -v killed 1
}

alias blinkred.killed {
	/timerRED -m 1 500 /blinkgreen.killed
	/did -h killed 1
	/did -v killed 2
}

on *:DIALOG:killed:sclick:3:{
	/dialog -x killed
	/timerGREEN off
	/timerRED off
}


on *:ERROR:*banned*: {
	/dialog -m glined glined
	/blinkgreen.glined
	/playsound glined.wav
}

on *:ERROR:*kill*:  {
	/dialog -m killed killed
	/blinkgreen.killed
	/playsound killed.wav
}

;***** BADWORDSCRIPT JOTI-IRC ******

alias loadbwlist {
  if ($hget(badwords)) { 
  	/hfree badwords
  }
  var %tmp.bwl = $adiircdir $+ Scripts\bwl.txt
  if (!$exists(%tmp.bwl) ) {
  	/checkupdates
  } else {
  	/hload -m badwords %tmp.bwl
  }
}

alias savebwlist {
  if ($hget(badwords)) {
  	var %tmp.bwl = $adiircdir $+ Scripts\bwl.txt
    hsave badwords %tmp.bwl
    hfree badwords
  }
}

on *:UNLOAD:{ 
	/savebwlist
}

on *:EXIT:{ 
	/savebwlist
}

on *:INPUT:*:{ 
	if (!$hget(badwords)) { 
	  	/loadbwlist
	}
	if ($left($1,1) != /) && (!$ctrlenter) {
	  var %x = 1
	  var %y = $numtok($1-,32)
	  var %temp = $1-
	  while (%y) {
	    var %a = $gettok($1-,%y,32)
	    if ($hfind(badwords,%a)) {
	      var %b $numtok($hget(badwords,%a),32) - 1
	      var %temp = $puttok(%temp,$hget(badwords,%a),%y,32)
	      inc %b
	    }
	    dec %y
	  }
	  msg $active %temp
	  halt
	}
}

;***** VERSION CHECK AND DOWNLOAD FILES JOTI-IRC ******
dialog getupdates {
	title "Updates found"
	option dbu
	size -1 -1 200 50
	text "There are updates for Jotiirc. Would you like to download and install them?",2,5 5 200 10
	button "Yes", 9, 50 35 34 10,ok
	button "No", 10, 125 35 34 10, cancel
}

dialog goreload {
	title "Updates finished"
	option dbu
	size -1 -1 200 50
	text "All updates are finished. Would you like to restart Jotiirc to activate the changes?",2,5 5 200 10
	button "Yes", 9, 50 35 34 10, "ok"
	button "No", 10, 125 35 34 10, "cancel"
}

on *:dialog:getupdates:sclick:9:{
	/runupdates
}

on *:dialog:getupdates:sclick:10: {
	if (%tmp.startup == 1) {
		/runstartup
	}
}

on *:dialog:goreload:sclick:9: {
	if (%tmp.ircupdate == 1) {
	 	if ($exists($adiircdir $+ upp.exe)) {
	 		/run $adiircdir $+ upp.exe
	 		/exit
	 	} else {
	 		/exit -nr
		}
	} else {
		/exit -nr
	}
}

on *:dialog:goreload:sclick:10: {
	if (%tmp.startup == 1) {
		/unset %tmp.startup
		/runstartup
	}
}

alias listversions {
	/set %tmp.oldversions $adiircdir $+ Scripts\versions.txt
	if ($hget(oldversions)) { /hfree oldversions }
	if ($exists(%tmp.oldversions)) {
		/hload -m oldversions %tmp.oldversions
		var %tmp.filecount = $hget(oldversions,0).item
		var %tmp.filenum = 1
		/echo -sg #======== local file versions
		
		while (%tmp.filenum <= %tmp.filecount) {
			var %tmp.filename = $hget(oldversions,%tmp.filenum).item
			var %tmp.version = $hget(oldversions,%tmp.filenum).data
			/echo -sg $+(%tmp.filename,: ,%tmp.version)
			inc %tmp.filenum
		}		
		/echo ADIIRC version: $version
		/echo dotnet version: $dotnet
		/echo detected os: $os
		/echo version: $osversion
		if ($check_wine > 0) {
			/echo wine detected!
			}
	} else {
		/echo -sg version file not found, no updates done so far
	}
	if ($hget(oldversions)) { /hfree oldversions }
}	

alias checkfileversions {
	/set %tmp.newversions $adiircdir $+ Scripts\newversions.txt
	/set %tmp.oldversions $adiircdir $+ Scripts\versions.txt
	/set %tmp.force $1
	
	if (%tmp.force != $null) {
		/.remove %tmp.oldversions
	}
	
	if (%setup.url.filebase != $null) {
		
 		if ((%tmp.force) || (%setup.joti.mode) == single || ( %setup.joti.mode == group && %mynickname == %setup.joti.localadmin) || (%tmp.startup == 1)) {
 			var %tmp.url.fileinfo %setup.url.filebase $+ /fileversions.txt
 			/echo -sg #==================== Checking file versions
 			/echo -sg version file is fetched from: %tmp.url.fileinfo
 			
 			/set %tmp.updatecount = 0
 			/download -o fileversions %tmp.url.fileinfo %tmp.newversions
   	}
  } else {
  	/echo -g File update impossible, no host found!
		if (%tmp.startup == 1) {
			/unset %tmp.startup
			/runstartup
		}			  	
  }
}

alias forceupdates {
	/checkfileversions 1
}

on *:DOWNLOAD:fileversions: {
	
	if (!$downloaderr) {
		if ($hget(newversions)) { /hfree newversions }
		if ($hget(oldversions)) { /hfree oldversions }
		if ($hget(downloadlist)) { /hfree downloadlist }
		if ($hget(saveversions)) { /hfree saveversions }
		if ($hget(errordownload)) { /hfree errordownload }
				
		if ($exists(%tmp.oldversions)) {
			/hload -m oldversions %tmp.oldversions
		} else {
			/hmake oldversions
		}
		/hload -m newversions %tmp.newversions
		/hmake downloadlist
		/hmake saveversions
		/hmake errordownload
		
		var %tmp.filecount = $hget(newversions,0).item
		var %tmp.filenum = 1
		
		while (%tmp.filenum <= %tmp.filecount) {
			var %tmp.filename = $hget(newversions,%tmp.filenum).item
			var %tmp.newver = $hget(newversions,%tmp.filenum).data
			var %tmp.oldver = $hget(oldversions,%tmp.filename)
			
			if (%tmp.filename == adiirc.exe) {
				%tmp.oldver = $version
			}
			
			if (%tmp.oldver != %tmp.newver) {
				var %tmp.tempname = %tmp.filename
				/hadd downloadlist %tmp.tempname %tmp.newver
				/hadd errordownload %tmp.tempname 0
				if (%tmp.oldver == $null) {
					/echo -sg %tmp.filename : version is unknonwn
				} else {
					/echo -sg %tmp.filename : old version %tmp.oldver new version %tmp.newver
				}
			} else {
				/hadd saveversions %tmp.filename %tmp.newver
			}
			inc %tmp.filenum
		}
		
		if ($hget(downloadlist,0).item > 0) {
			/dialog -m getupdates getupdates
		} else {
			/echo -sg Everything is up-to-date
			/finishdownload
			if (%tmp.startup == 1) {
				/unset %tmp.startup
				/runstartup
			}			
		}
			
	} else {
		/echo -sg 4 There was a problem checking the versions.
		if (%tmp.startup == 1) {
			/unset %tmp.startup
			/runstartup
		}					
	}
}

alias runupdates {
	var %tmp.filenum = 1
	while (%tmp.filenum <= $hget(downloadlist,0).item) {
		var %tmp.filename = $hget(downloadlist,%tmp.filenum).item
		var %tmp.newversion = $hget(downloadlist,%tmp.filenum).data
		
		/echo checking %tmp.filename
		
		var %tmp.fetchfile = %setup.url.filebase $+ / $+ %tmp.filename
		var %tmp.tempfile = $adiircdir $+ $hget(downloadlist,%tmp.filenum).item $+ .tmp
		
		if (%tmp.filename == adiirc.exe) {
			/echo Updating adiirc to %tmp.newversion
			%tmp.adiircbits = $osbits
			
			if ($check_wine > 0) {
				%tmp.adiircbits = 20
			}
			%tmp.fetchfile = %setup.url.filebase $+ /adiirc/ $+ %tmp.newversion $+ / $+ AdiIRC_ $+ %tmp.adiircbits $+ .exe
			%tmp.fetchfile = $replace(%tmp.fetchfile,\,/)
			var %tmp.tempfile = $adiircdir $+ adiirc.tmp
			/echo -sg downloading %tmp.fetchfile
			
		}
			
		%tmp.fetchfile = $replace(%tmp.fetchfile,\,/)
		/echo -sg downloading %tmp.fetchfile
		/download -o $hget(downloadlist,%tmp.filenum).item %tmp.fetchfile %tmp.tempfile
		inc %tmp.filenum

	}
}

on *:DOWNLOAD:*: {
	/echo downloaded $download
	;/hdel downloadlist $download
	if (!$downloaderr) {
		if ($download != 'fileversions') {
			var %tmp.tempfile = $download($download).file
			var %tmp.realfile $adiircdir $+ $download
			if ($download == adiirc.exe) {
				%tmp.realfile = upp.exe
				/set %tmp.ircupdate 1
				/echo updating ircclient
			}
			/echo -sg installing $download
			if ($exists(%tmp.realfile)) {
				/.remove %tmp.realfile
			}
			/.rename %tmp.tempfile %tmp.realfile
			/hadd errordownload $download 2
			/hadd saveversions $download $hget(newversions,$download)
		}
	} else {
		/echo -sg 4 $download was not found on the server!
		/hadd errordownload $download 1
		/hadd saveversions $download $hget(oldversions,$download)
	}
	
	var %x = 1
	var %finished = 0
	var %errorsfound = 0
	var %downloadleft = 0
	
	if ($hget(downloadlist,0).item > 0) {
		while (%x <= $hget(errordownload,0).item) {
			if ($hget(errordownload,%x).data == 1) {
				%errorsfound = 1
			}
			if ($hget(errordownload,%x).data == 0) {
				%downloadleft = 1;
			}
			inc %x
		}
	}
	
	if (%downloadleft == 0) {
		if (%errorsfound == 1) {
			/echo -sg 4 Alles geupdate maar er zijn problemen gevonden.
			/finishdownload
			/dialog -m goreload goreload
		} else {
			/echo -sg Alles is geupdate
			/finishdownload
			/dialog -m goreload goreload
		}
	}
}

alias finishdownload {
	if ($exists(%tmp.newversions)) { /.remove %tmp.newversions }
	if ($exists(%tmp.oldversions)) { /.remove %tmp.oldversions }
	/.hsave saveversions %tmp.oldversions
	/unset %tmp.newversions
	/unset %tmp.oldversions
	if ($hget(newversions)) { /hfree newversions }
	if ($hget(oldversions)) { /hfree oldversions }
	if ($hget(saveversions)) { /hfree saveversions }
	if ($hget(downloadlist)) { /hfree downloadlist }
	if ($hget(badwords)) { hfree badwords }
}

alias check_wine {
  if (!$isid) { return }
 
  var %1 = CheckOS_1
  var %2 = CheckOS_2
  var %3 = CheckOS_3
  var %4 = CheckOS_4
 
;  .comopen %1 MSScriptControl.ScriptControl
;  if (!$com(%1)) || ($comerr) { return 1 }
 
  .comopen %2 WScript.Shell
  if (!$com(%2)) || ($comerr) { return 2 }
 
  .comopen %3 MSXML2.SERVERXMLHTTP.6.0
  if (!$com(%3)) || ($comerr) { return 3 }
 
  .comopen %4 Adodb.Stream
  if (!$com(%4)) || ($comerr) { return 4 }
 
  if ($com(%1)) { .comclose $v1 }
  if ($com(%2)) { .comclose $v1 }
  if ($com(%3)) { .comclose $v1 }
  if ($com(%4)) { .comclose $v1 }
 
  return 0
 
  :error
  reseterror
 
  if ($com(%1)) { .comclose $v1 }
  if ($com(%2)) { .comclose $v1 }
  if ($com(%3)) { .comclose $v1 }
  if ($com(%4)) { .comclose $v1 }
 
  return 5
}

;***** RESET ALL VARIABLES JOTI-IRC ******

alias resetdefault {
	/set %setup.joti.mode setup
	/set %setup.joti.naam $null
	/set %setup.joti.email joti@scoutlink.nl
	/set %setup.joti.weburl https://www.facebook.com/JOTAJOTINL/
	/set %setup.joti.woonplaats $null
	/set %setup.joti.deelname JOTI
	/set %setup.joti.jid $null
	/set %setup.joti.call $null
	/set %setup.joti.qth $null
	/set %setup.joti.avatar $null
	/set %setup.joti.prefix $null
	/set %setup.joti.localadmin $null
	/set %setup.joti.clientid standalone
	/set %tmp.setupid clear
	
  /set %font small
  /set %randomtimer 0
  /set %connection disconnected
  /set %timedisplay on
  /set %sounds on
  /set %toolbaricons more
  /set %badgequota 0
  /set %logcounter 0 
  /set %localadminmode 0
  /set %profilelock unlock
  /set %arrwindow 1
  /set %aantal.badges.leukstechat 0
  /set %aantal.badges.nieuwevriend 0
  /set %aantal.badges.bestegroep 0
  /set %badgequota 0
  /set %listcounter 0
  /set %mynickname SL_%currentyear
  /set %blink 1  
  /set %chanfilter #english
  /set %afzender 
}

;***** HTML LOGS GENERATOR JOTI-IRC ******

ctcp *:get.profile:*: {
	/ctcp $nick profile.nickname %mynickname
	/ctcp $nick profile.name %setup.joti.naam
	/ctcp $nick profile.mail %setup.joti.email
	/ctcp $nick profile.web %setup.joti.weburl
	/ctcp $nick profile.place %setup.joti.woonplaats
	/ctcp $nick profile.admin %setup.joti.localadmin
	/ctcp $nick profile.avatar %setup.joti.avatar
	/ctcp $nick profile.number %setup.joti.jid
	/ctcp $nick profile.deelname %setup.joti.deelname
	/ctcp $nick profile.call %setup.joti.call
	/ctcp $nick profile.qth %setup.joti.qth
	/ctcp $nick profile.station %setup.joti.clientid
	/ctcp $nick profile.done
}

ctcp *:profile.nickname:*: /set %guest.joti.nickname $$2-
ctcp *:profile.name:*: /set %guest.joti.naam $$2-
ctcp *:profile.mail:*: /set %guest.joti.email $$2
ctcp *:profile.web:*: /set %guest.joti.weburl $$2
ctcp *:profile.place:*: /set %guest.joti.woonplaats $$2-
ctcp *:profile.admin:*: /set %guest.joti.localadmin $$2
ctcp *:profile.prefix:*: /set %guest.joti.predix $$2
ctcp *:profile.avatar:*: /set %guest.joti.avatar $$2
ctcp *:profile.number:*: /set %guest.joti.jid $$2
ctcp *:profile.deelname:*: /set %guest.joti.deelname $$2
ctcp *:profile.call:*: /set %guest.joti.call $$2
ctcp *:profile.qth:*: /set %guest.joti.qth $$2
ctcp *:profile.station:*: /set %guest.joti.clientid $$2-
ctcp *:profile.done:*: /generate.html

alias generate.html {
	if (%guest.joti.avatar == $null) {
		/set %guest.joti.avatar https://jotiirc.scoutlink.nl/default/defaultavatar.jpg
	}
	/set %guest.nickscoutinggroep $nick
	/set %guest.datumscoutinggroep $date(dd-mm-yyyy)
	/set %guest.tijdscoutinggroep $time(HH:nn) uur
	/set %guest.url $adiircdir\records\log $+ %logcounter $+ _ $+ %guest.joti.clientid $+ _ $+ %guest.datumscoutinggroep $+ .html 
	/set %guest.link log $+ %logcounter $+ _ $+ %guest.joti.clientid $+ _ $+ %guest.datumscoutinggroep $+ .html
	/set %guest.search https://www.google.com/maps/embed/v1/place?key=AIzaSyCwdL_3SnjNV5FYNjAQe8O_gljXve4oOnk&q= $+ $replace(%guest.joti.woonplaats ,$chr(32),$+(+))
	/write %guest.url <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
	/write %guest.url <html><head><meta name="keywords" content="JOTA-JOTI LJJO Scouting Nederland ScoutLink JOTI-IRC irc client"><meta name="description" content="JOTA-JOTI %currentyear logs"><meta name="robots" content="index, follow"><meta name="author" content="JOTI-IRC %currentyear"><meta name="generator"JOTI-IRC %currentyear">
	/write %guest.url <title>
	/write %guest.url $fulldate
	/write %guest.url </title><style type="text/css">
	/write %guest.url h1 {font-family: Arial, Helvetica, sans-serif; font-size: 40pt; font-weight: bold; color: #FFFFFF; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url h2 {font-family: Arial, Helvetica, sans-serif; font-size: 20pt; font-weight: bold; color: #F7AC05; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url h3 {font-family: Arial, Helvetica, sans-serif; font-size: 14pt; font-weight: normal; color: #FFFFFF; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: left;}
	/write %guest.url h4 {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; color: #F7AC05; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url h5 {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; color: #FFFFFF; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url hr {width: 95%; border-color: #F7AC05; height:2px;}
	/write %guest.url img.icon {height: 20px; width: 20px; margin-left: 0px; margin-right: 5px; margin-top: 1px; margin-bottom: 1px;}
	/write %guest.url img.text {width: 200px; margin-left: 5px; margin-right: 5px; margin-top: 5px; margin-bottom: 5px; border-width: 1px; border-style: solid; border-color: #F7AC05;}
	/write %guest.url a.menu:visited {background-color: #F7AC05;display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #E8E8E8; text-align: center; text-decoration: none; text-transform: lowercase;}
	/write %guest.url a.menu:link {background-color: #F7AC05; display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #E8E8E8; text-align: center; text-decoration: none; text-transform: lowercase;}
	/write %guest.url a.menu:active {background-color: #F7AC05; display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #E8E8E8; text-align: center; text-decoration: none; text-transform: lowercase;}
	/write %guest.url a.menu:hover {background-color: #FED272; display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #1C1C1C; text-align: center; text-decoration: none; text-transform: uppercase;}
	/write %guest.url </style></head><body bgcolor="#000000"><div align="center"><table width="650" border="0" bgcolor="#1B1D58"><tr><td colspan="2" width="650" height="50" align="center" valign="middle"><a name="top"></a><h1>JOTA-JOTI %currentyear</h1></td></tr><tr><td colspan="2" width="650" height="20" align="center" valign="middle"><h2>Log van 
	/write %guest.url $fulldate
	/write %guest.url </h2></td></tr><tr><td colspan="2" width="650" height="50" align="right" valign="middle">
	/write %guest.url <a class="menu" href="index.html" target="_parent">Overview</a>
	/write %guest.url <a class="menu" href="
	/write %guest.url %guest.joti.weburl
	/write %guest.url " target="_parent">Website</a>
	/write %guest.url <a class="menu" href="mailto:
	/write %guest.url %guest.joti.email
	/write %guest.url ?SUBJECT=JOTA-JOTI %currentyear">E-mail</a>
	/write %guest.url </td></tr>
	/write %guest.url <tr><td colspan="1" width="210" height="210" align="center" valign="middle">
	/write %guest.url <A href="
	/write %guest.url %guest.joti.avatar
	/write %guest.url " target="_blank">
	/write %guest.url <img src="
	/write %guest.url %guest.joti.avatar
	/write %guest.url " class="text"></a>
	/write %guest.url </td><td colspan="1" width="440" height="210"><h3>Chatted on IRC with: 
	/write %guest.url %guest.joti.nickname
	/write %guest.url <br>Op
	/write %guest.url %guest.datumscoutinggroep
	/write %guest.url om 
	/write %guest.url %guest.tijdscoutinggroep
	/write %guest.url <br>Naam:
	/write %guest.url %guest.joti.naam
	/write %guest.url <br>Deelname:
	/write %guest.url %guest.joti.deelname
	/write %guest.url <br>Deelnemersnummer:
	/write %guest.url %guest.joti.jid
	/write %guest.url <br>Call:
	/write %guest.url %guest.joti.call
	/write %guest.url <br>QTH locator:
	/write %guest.url %guest.joti.qth
	/write %guest.url <br></td></tr><tr><td colspan="2" width="650" height="10"></td></tr><tr><td colspan="2" width="650" height="350">
	/write %guest.url <center><iframe width="400" height="300" frameborder="0" style="border:0" src="
	/write %guest.url %guest.search
	/write %guest.url "></iframe></center></td></tr><tr><td colspan="2" width="650" height="10"><hr></hr></td></tr><td colspan="2" width="650" height="50"><center><a class="menu" href="#top" target="_parent">naar boven</a></center></td></tr><tr><td colspan="2" width="650" height="80"><h4>Copyright %currentyear ScoutLink</h4><h5>JOTA-JOTI %currentyear</h5></td></tr></table></div>/body></html>
	/write -il20 $adiircdir\records\index.html <a href=" %guest.link " target=_parent">Logregistration date:  $+ $date(dd-mm-yyyy) $+ _ $+ $time(HH:nn) $+ </a><br>
	/url %guest.url 
	/timerUNSET 1 5 unset.profile1
}

alias unset.profile1 {
	/unset %guest.joti.nickname
	/unset %guest.joti.naam
	/unset %guest.joti.email
	/unset %guest.joti.weburl
	/unset %guest.joti.woonplaats 
	/unset %guest.joti.localadmin
	/unset %guest.joti.predix
	/unset %guest.joti.avatar
	/unset %guest.joti.jid
	/unset %guest.joti.deelname
	/unset %guest.joti.call
	/unset %guest.joti.qth
}

alias addlog {
	/dialog -m addlog addlog
	/inc %logcounter
}

dialog addlog {
	title "Enter log entry"
	size -1 -1 400 525
	icon 1, 1 1 400 188, $adiircdir\pix\banner6A.jpg
	text "Pleas fill in the following information",2, 10 195 200 25
	text "Troop/Scout",3, 10 220 175 25
	edit "",4, 190 220 200 20, limit 120
	text "E-mail address",5, 10 245 175 25
	edit "",6, 190 245 200 20, limit 120
	text "Website",7, 10 270 175 25
	edit "",8, 190 270 200 20, limit 120
	text "City",9, 10 295 175 25
	edit "",10, 190 295 200 20
	text "via",11, 10 320 175 25
	combo 12,190 320 120 140,drop 
	text "call/name",13, 10 345 175 25
	edit "",14, 190 345 200 20
	text "QTH locator",15, 10 370 150 25
	edit "",16, 190 370 200 20
	text "Remarks",19, 10 395 150 25
	edit "",18, 10 420 380 45
	button "Enter",100, 100 470 100 25, OK
	button "Cancel" 101, 200 470 100 25 CANCEL
}

on *:DIALOG:addlog:init:0: { 
	did -a addlog 12 80m
	did -a addlog 12 2m
	did -a addlog 12 70m
	did -a addlog 12 ATV
	did -a addlog 12 Skype
	did -a addlog 12 Teamspeak
	did -a addlog 12 ScoutLink Minecraft
	did -a addlog 12 Facebook msg
	did -a addlog 12 Google hangout
	did -a addlog 12 JOTI-TV
	did -a addlog 12 IRL  
	did -a addlog 12 IRC
} 

On *:DIALOG:addlog:sclick:100: {
	/set %guest.joti.naam $did(addlog,4).text
	/set %guest.joti.email $did(addlog,6).text
	/set %guest.joti.weburl $did(addlog,8).text
	/set %guest.joti.woonplaats $did(addlog,10).text
	/set %guest.joti.via $did(addlog,14).text
	/set %guest.joti.call $did(addlog,14).text
	/set %guest.joti.qth $did(addlog,16).text
	/set %guest.opmerkingen $did(addlog,18).text
	/generate.html.2
}

On *:DIALOG:addlog:sclick:101: {
	/dialog -x addlog
}

alias generate.html.2 {
	if (%guest.joti.avatar == $null) {
		/set %guest.joti.avatar https://jotiirc.scoutlink.nl/default/defaultavatar.jpg
	}
	
	/set %guest.datumscoutinggroep $date(dd-mm-yyyy)
	/set %guest.tijdscoutinggroep $time(HH:nn) uur
	/set %guest.url $adiircdir\records\log $+ %logcounter $+ _ $+ %setup.joti.clientid $+ _ $+ %guest.datumscoutinggroep $+ .html
	/set %guest.link log $+ %logcounter $+ _ $+ %guest.joti.clientid $+ _ $+ %guest.datumscoutinggroep $+ .html
	/set %guest.search https://www.google.com/maps/embed/v1/place?key=AIzaSyCwdL_3SnjNV5FYNjAQe8O_gljXve4oOnk&q= $+ $replace(%guest.plaatsscoutinggroep ,$chr(32),$+(+))
	/write %guest.url <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
	/write %guest.url <html><head><meta name="keywords" content="JOTA-JOTI LJJO Scouting Nederland ScoutLink JOTI-IRC irc client"><meta name="description" content="JOTA-JOTI %currentyear logs"><meta name="robots" content="index, follow"><meta name="author" content="JOTI-IRC %currentyear"><meta name="generator"JOTI-IRC %currentyear">
	/write %guest.url <title>
	/write %guest.url $fulldate
	/write %guest.url </title><style type="text/css">
	/write %guest.url h1 {font-family: Arial, Helvetica, sans-serif; font-size: 40pt; font-weight: bold; color: #FFFFFF; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url h2 {font-family: Arial, Helvetica, sans-serif; font-size: 20pt; font-weight: bold; color: #F7AC05; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url h3 {font-family: Arial, Helvetica, sans-serif; font-size: 14pt; font-weight: normal; color: #FFFFFF; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: left;}
	/write %guest.url h4 {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; color: #F7AC05; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url h5 {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: normal; color: #FFFFFF; margin-left: 2px; margin-right: 2px; margin-top: 2px; margin-bottom: 2px; text-align: center;}
	/write %guest.url hr {width: 95%; border-color: #F7AC05; height:2px;}
	/write %guest.url img.icon {height: 20px; width: 20px; margin-left: 0px; margin-right: 5px; margin-top: 1px; margin-bottom: 1px;}
	/write %guest.url img.text {width: 200px; margin-left: 5px; margin-right: 5px; margin-top: 5px; margin-bottom: 5px; border-width: 1px; border-style: solid; border-color: #F7AC05;}
	/write %guest.url a.menu:visited {background-color: #F7AC05;display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #E8E8E8; text-align: center; text-decoration: none; text-transform: lowercase;}
	/write %guest.url a.menu:link {background-color: #F7AC05; display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #E8E8E8; text-align: center; text-decoration: none; text-transform: lowercase;}
	/write %guest.url a.menu:active {background-color: #F7AC05; display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #E8E8E8; text-align: center; text-decoration: none; text-transform: lowercase;}
	/write %guest.url a.menu:hover {background-color: #FED272; display: inline-block; width: 150px; height: 25px; font-family: arial, sans-serif; font-size: 12pt; margin-left: 0px; margin-right: 5px; margin-top: 0px; margin-bottom: 0px; font-weight: bold; color: #1C1C1C; text-align: center; text-decoration: none; text-transform: uppercase;}
	/write %guest.url </style></head><body bgcolor="#000000"><div align="center"><table width="650" border="0" bgcolor="#1B1D58"><tr><td colspan="2" width="650" height="50" align="center" valign="middle"><a name="top"></a><h1>JOTA-JOTI %currentyear</h1></td></tr><tr><td colspan="2" width="650" height="20" align="center" valign="middle"><h2>Log van 
	/write %guest.url $fulldate
	/write %guest.url </h2></td></tr><tr><td colspan="2" width="650" height="50" align="right" valign="middle">
	/write %guest.url <a class="menu" href="index.html" target="_parent">Overview</a>
	/write %guest.url <a class="menu" href="
	/write %guest.url %guest.joti.weburl
	/write %guest.url " target="_parent">Website</a>
	/write %guest.url <a class="menu" href="mailto:
	/write %guest.url %guest.joti.email
	/write %guest.url ?SUBJECT=JOTA-JOTI %currentyear">E-mail</a>
	/write %guest.url </td></tr>
	/write %guest.url <tr><td colspan="1" width="210" height="210" align="center" valign="middle">
	/write %guest.url <img src="$adiircdir\pix\logo2017.bmp" class="text">
	/write %guest.url </td><td colspan="1" width="440" height="210"><h3>using: 
	/write %guest.url %guest.joti.via
	/write %guest.url with: 
	/write %guest.url %guest.joti.call
	/write %guest.url <br>on
	/write %guest.url %guest.datumscoutinggroep
	/write %guest.url at
	/write %guest.url %guest.tijdscoutinggroep
	/write %guest.url <br>troop/Scout:
	/write %guest.url %guest.joti.nickname
	/write %guest.url <br>QTH locator:
	/write %guest.url %guest.joti.qth
	/write %guest.url <br>Remark
	/write %guest.url %guest.opmerkingen
	/write %guest.url <br></td></tr><tr><td colspan="2" width="650" height="10"></td></tr><tr><td colspan="2" width="650" height="350">
	/write %guest.url <center><iframe width="400" height="300" frameborder="0" style="border:0" src="
	/write %guest.url %guest.search
	/write %guest.url "></iframe></center></td></tr><tr><td colspan="2" width="650" height="10"><hr></hr></td></tr><td colspan="2" width="650" height="50"><center><a class="menu" href="#top" target="_parent">naar boven</a></center></td></tr><tr><td colspan="2" width="650" height="80"><h4>Copyright %currentyear ScoutLink</h4><h5>JOTA-JOTI %currentyear</h5></td></tr></table></div>/body></html>
	/write -il20 $adiircdir\records\index.html <a href=" %guest.link " target=_parent">Logregistration date:  $+ $date(dd-mm-yyyy) $+ _ $+ $time(HH:nn) $+ </a><br>
	/url %guest.url 
	/timerUNSET 1 5 unset.profile2
}

alias unset.profile2 {
	/unset %guest.joti.naam
	/unset %guest.joti.email
	/unset %guest.joti.weburl
	/unset %guest.joti.woonplaats
	/unset %guest.joti.via
	/unset %guest.joti.call
	/unset %guest.joti.qth
	/unset %guest.opmerkingen
}

***** NICKNAME REGISTRATION TOOL JOTI-IRC *****

alias registernick {
    /dialog -m nickregistration nickregistration
}

dialog nickregistration {
  title "Welcome to the setup for JOTI-IRC"
  size -1 -1 400 350
  icon 1, 1 1 400 188, $adiircdir\pix\bannernick.jpg
  text "Register your nickname",2, 10 195 375 25
  text "Password",3, 10 225 175 25
  edit "",4, 190 225 200 20
  text "E-mail address",5, 10 255 175 25
  edit "",6, 190 255 200 20
  button "REGISTER",100, 125 315 175 25 
}


On *:DIALOG:nickregistration:sclick:100:{
    /did -a nickregistration 3 %registerpass 
    /did -a nickregistration 5 %registeremail   
    /msg NickServ register %registerpass %registeremail
    /dialog -x nickregistration
    /unset %registerpass
    /unset %registeremail
    /toolbar -d registernick
}

