;@@@
;@@@ DreamBot IRC Bot 5.4
;@@@ File description: visual bot setup
;@@@ Design & coding: DreamBot development team
;@@@ (C) Copyright 2004-2006 DreamBot development team. All rights reserved. 
;@@@

menu menubar {
  Accounts manager: { .dialog -ma accounts accounts }
  &Configuration...: { bs }
  Punishments...: { punish }
  Usermodes: { dialog -ma umode umode }
  &Log Viewer: { LogViewer }
  Channel mirroring: { _setup }
  &Remove owner: { _remowner }
  Bot banlist: { _banview }
  Bad words list: { bw_dialog }
  Spam filter: { ad_dialog }
  Rules: { call_rules_diag }
  Chanstats
  .Clear statistics:clearstats
  .$iif(%stats_module == on,Disable stats): { set %stats_module off }
  .$iif(%stats_module == off,Enable stats): { set %stats_module on }
  Google Search: { google_search }
  &Game setup
  .Trivia and Scramble { dialog -m trivsc trivsc }
  .Other { dialog -m games games }
  &Windows
  .Clear status: { clear -s }
  .Clear current: { clear }
  .Clear all: { clearall }
  -
  &DreamBot online
  .Forums: { run http://dreambot.eurion.com/index.php }
  .Portal: { run http://dreambot.eurion.com }
  ;  .E-mail: { run mailto:MrZipen@gmail.com?Subject=From DreamBot User }
  DreamBot files
  .Readme document: { _owner }
  .FAQ: { _faq }
  -
  &F commands: { _amenu }
  &Help: { f1 }
  &About DreamBot...: { about }

}
;alias google_Search { _google }
alias umodes { dialog -ma umode umode }


;@@@ Usermodes @@@
;dialog-

dialog umode {
  title "Usermodes"
  option dbu
  size -1 -1 135 73
  icon "img/set.ico", 0
  box "Bot usermodes", 1, 5 1 125 50
  button "Ok", 2, 30 55 35 12
  button "Cancel", 3, 70 55 35 12, cancel
  text "After connecting, the bot will set these modes on itself. Enter them bellow:", 4, 10 10 115 15
  edit "", 5, 10 32 115 10
}
on *:dialog:umode:init:0: {
  if %umodes == $null { did -ra umode 5 +x | halt }
  did -ra umode 5 %umodes
}
on *:dialog:umode:sclick:2: {
  if $did(umode,5).text == $null { _error Please specify the usermodes! | halt }
  set %umodes $did(umode,5).text
  dialog -c umode
}
on *:connect: {
  if %umodes != $null { mode $me %umodes }
}

;@@@ Punishments @@@
alias punish { dialog -ma punish punish }
dialog punish {
  title "Punishments"
  size -1 -1 300 230
  icon "img/set.ico" 0
  text "    This tool allows you to select the actions which the bot will perform on users who brake the rules. You can select one option from bellow. You can specify the default kick reason for mass kicks. In this reason you can include the &&url&& parameter, to include the channel's URL.", 1, 5 5 290 80
  radio "warn user, kick and ban user", 2, 50 80 160 20
  radio "warn user, kick user", 3, 50 100 160 20
  radio "kick ban user", 4, 50 120 160 20
  text "Enter default kick reason:", 7, 50 140 170 15
  edit "", 8, 50 160 200 20, autohs
  button "Ok", 5, 50 195 100 25
  button "Cancel", 6, 150 195 100 25, cancel
}
on *:dialog:punish:init:0: {
  if %kb.method == $null { set %kb.method 1 }
  if %kb.method == 1 { did -c punish 2 }
  if %kb.method == 2 { did -c punish 3 }
  if %kb.method == 3 { did -c punish 4 }
  if %kb.reason !== $null { did -ra punish 8 %kb.reason }
}
on *:dialog:punish:sclick:5: {
  if $did(punish,2).state == 1 { set %kb.method 1 }
  if $did(punish,3).state == 1 { set %kb.method 2 }
  if $did(punish,4).state == 1 { set %kb.method 3 }
  if $did(punish,8).text !== $null { set %kb.reason $did(punish,8).text }
  dialog -c punish
}
;@@@ end punishments @@@


;@@@ Begin 'About' box @@@
alias about { dialog -ma about about }
alias add_chan {
  set %sc $did(setup,154).text
  if ($readini(ini\channels.ini,%sc,Exist) == Yes) { dialog -om error error | did -a error 1 Channel %sc already exists in my database. | halt }
  if ($readini(ini\channels.ini,%sc,Exist) == $null) { 
    if ($numtok(%sc,32) > 1) { dialog -om error error | did -a error 1 A channel name can't contain spaces. | halt }
    if (%sc == $chr(40) $+ none $+ $chr(41)) { halt }
    if ($left(%sc,1) !== $chr(35)) { dialog -om error error | did -a error 1 A channel name must begin with $chr(35) $+ . Example: #AllNightCafe. | halt }
    did -e setup 159,160,161,162,163,164,165,167,169,171,172,173,166,168,170,157,158,174,180,181
    did -a setup 155 %sc
    write ini\clines.txt %sc
    writeini -n ini\channels.ini %sc Exist Yes
    save_chan
    if ($readini(ini\channels.ini, %sc, Flood) == On) { did -c setup 159 } 
    if ($readini(ini\channels.ini, %sc, Protect) == On) { did -c setup 160 }
    if ($readini(ini\channels.ini, %sc, Color) == On) { did -c setup 161 }
    if ($readini(ini\channels.ini, %sc, Repeat) == On) { did -c setup 162 }
    if ($readini(ini\channels.ini, %sc, Notice) == On) { did -c setup 163 }
    if ($readini(ini\channels.ini, %sc, Bitchmode) == On) { did -c setup 164 }
    if ($readini(ini\channels.ini, %sc, SModes) !== Off) { 
      if ($readini(ini\channels.ini, %sc, SModes) == $null) { halt }
      if ($readini(ini\channels.ini, %sc, SModes) !== $null) { did -c setup 165 | did -ra setup 166 $readini(ini\channels.ini, %sc, SModes) }
    }
    if ($readini(ini\channels.ini, %sc, Greet) == On) { 
      if ($read(ini\grlines.txt, s, %sc) !== $null) { did -c setup 167 | did -ra setup 168 $read(ini\grlines.txt, s, %sc) }
    }
    if ($readini(ini\channels.ini, %sc, Greet) == Off) {
      if ($read(ini\grlines.txt, s, %sc) !== $null) { did -ra setup 168 $read(ini\grlines.txt, s, %sc) }
    }
    if ($readini(ini\channels.ini, %sc, STopic) == On) { 
      if ($read(ini\tlines.txt, s, %sc) !== $null) { did -c setup 169 | did -a setup 170 $read(ini\tlines.txt, s, %sc) }
    }
    if ($readini(ini\channels.ini, %sc, HelpMode) == On) { did -c setup 171 }
    if ($readini(ini\channels.ini, %sc, AutoVoice) == On) { did -c setup 172 }
    if ($readini(ini\channels.ini, %sc, Swear) == On) { did -c setup 173 }
    if ($readini(ini\channels.ini, %sc, Adv) == On) { did -c setup 174 }
    if ($readini(ini\channels.ini, %sc, FloatLim) == On) { did -c setup 180 }
    if ($readini(ini\channels.ini, %sc, CTCP) == On) { did -c setup 181 }

  }
}
alias rem_chan {
  if ($did(setup,154).text == $chr(40) $+ none $+ $chr(41)) { dialog -om error error | did -a error 1 You can't remove this entry, as it isn't a channel. This is just to keep the list active. | halt }
  if ($did(setup,154).text !== $null) {
    set %sc $did(setup,154).text
    did -d setup 155 $did(setup,155).sel
    .write -ds $+ %sc ini\clines.txt
    .write -ds $+ %sc ini\grlines.txt
    .remini ini\channels.ini %sc
  }
}
alias ws { .writeini -n ini\channels.ini $1- }
alias save_chan {
  if ($did(setup,154).text == $chr(40) $+ none $+ $chr(41)) { dialog -om error error | did -a error 1 You can't save anything for this entry, as it isn't a channel. This is just to keep the list active. | halt }
  set %sc $did(setup,154).text
  if ($did(setup,159).state == 1) { .ws %sc Flood on }
  if ($did(setup,159).state == 0) { .ws %sc Flood off }
  if ($did(setup,160).state == 1) { .ws %sc Protect on }
  if ($did(setup,160).state == 0) { .ws %sc Protect off }
  if ($did(setup,161).state == 1) { .ws %sc Color on }
  if ($did(setup,161).state == 0) { .ws %sc Color off }
  if ($did(setup,162).state == 1) { .ws %sc Repeat on }
  if ($did(setup,162).state == 0) { .ws %sc Repeat off }
  if ($did(setup,163).state == 1) { .ws %sc Notice on }
  if ($did(setup,163).state == 0) { .ws %sc Notice off }
  if ($did(setup,164).state == 1) { .ws %sc Bitchmode on }
  if ($did(setup,164).state == 0) { .ws %sc Bitchmode off }
  if (($did(setup,165).state == 1) && ($did(setup,166).text !== $null))  { .ws %sc SModes $did(setup,166).text }
  if ($did(setup,165).state == 0) { .ws %sc SModes Off }
  if (($did(setup,167).state == 1) && ($did(setup,168).text !== $null)) { .ws %sc Greet On | .write -ds $+ %sc ini\grlines.txt | .write ini\grlines.txt %sc $did(setup,168).text }
  if ($did(setup,167).state == 0) { .ws %sc Greet Off }
  if (($did(setup,169).state == 1) && ($did(setup,170).text !== $null)) { .ws %sc STopic On | .write -ds $+ %sc ini\tlines.txt | .write ini\tlines.txt %sc $did(setup,170).text }
  if ($did(setup,169).state == 0) { .ws %sc STopic Off }
  if ($did(setup,171).state == 1) { .ws %sc HelpMode On }
  if ($did(setup,171).state == 0) { .ws %sc HelpMode Off }
  if ($did(setup,172).state == 1) { .ws %sc AutoVoice On }
  if ($did(setup,172).state == 0) { .ws %sc AutoVoice Off }
  if ($did(setup,173).state == 1) { .ws %sc Swear On }
  if ($did(setup,173).state == 0) { .ws %sc Swear Off }
  if ($did(Setup,174).state == 1) { .ws %sc Adv On }
  if ($did(Setup,174).state == 0) { .ws %sc Adv Off }
  if ($did(Setup,180).state == 1) { .ws %sc FloatLim On }
  if ($did(Setup,180).state == 0) { .ws %sc FloatLim Off }
  if ($did(Setup,181).state == 1) { .ws %sc CTCP On }
  if ($did(Setup,181).state == 0) { .ws %sc CTCP Off }
}
alias add_net {
  set %sn $did(setup,204).text
  if ($readini(ini\networks.ini,%sn,Exist) == Yes) { dialog -om error error | did -a error 1 Network %sn already exists in my database. | halt }
  if ($readini(ini\networks.ini,%sn,Exist) == $null) { 
    if ($numtok(%sn,32) > 1) { dialog -om error error | did -a error 1 A network name can't contain spaces. | halt }
    if (%sn == $chr(40) $+ none $+ $chr(41)) { halt }
    did -e setup 207,208,210,211,213,214,215,216,218,220,250,253,255,257,261,262
    did -a setup 205 %sn
    write ini\nlines.txt %sn
    writeini -n ini\networks.ini %sn Exist Yes
    writeini -n ini\networks.ini %sn Method 0

  }
}
alias rem_net {
  if ($did(setup,204).text == $chr(40) $+ none $+ $chr(41)) { dialog -om error error | did -a error 1 You can't remove this entry, as it isn't a network. This is just to keep the list active. | halt }
  if ($did(setup,204).text !== $null) {
    set %sn $did(setup,204).text
    did -d setup 205 $did(setup,205).sel
    .write -ds $+ %sn ini\nlines.txt
    .remini ini\networks.ini %sn
  }
}
alias wn { .writeini -n ini\networks.ini $1- }
alias _error { dialog -om error error | did -a error 1 $1- }
alias save_net {
  if ($did(setup,204).text == $chr(40) $+ none $+ $chr(41)) { dialog -om error error | did -a error 1 You can't save anything for this entry, as it isn't a network. This is just to keep the list active. | halt }
  set %sn $did(setup,204).text
  if ($did(setup,261).state == 1) { wn %sn Reop On }
  if ($did(setup,261).state == 0) { wn %sn Reop Off }
  if ($did(setup,262).state == 1) { wn %sn GainOps On }
  if ($did(Setup,262).state == 0) { wn %sn GainOps Off }
  if ($did(Setup,210).state == 1) {
    wn %sn Method NickServ
    if ($did(setup,213).state == 1) { wn %sn NSMethod 1 }
    if ($did(Setup,214).state == 1) { wn %sn NSMethod 2 }
    if ($did(setup,215).state == 1) { 
      if ($did(setup,216).text == $null) { dialog -om error error | did -a error 1 Please specify a method to auth with NickServ. | wn %sn NSMethod 1 }
    }
    if ($did(Setup,218).text == $null) { _error You must specify a nickname. | halt }
    if ($did(setup,220).text == $null) { _error You must specify a password. | halt }
    wn %sn NickName $did(setup,218).text
    wn %sn NPass $did(setup,220).text
  }
  if ($did(Setup,250).state == 1) { 
    wn %sn Method GNU
    if ($did(setup,253).text == $null) { dialog -om error error | did -a error 1 You must specify an username. | halt }
    if ($did(Setup,255).text == $null) { dialog -om error error | did -a error 1 You must specify a password for the username. | halt }
    if ($did(Setup,257).text == $null) { dialog -om error error | did -a error 1 You must specify a login method. Example: /msg x@channels. $+ %sn $+ .org | halt }
    wn %sn Username $did(setup,253).text
    wn %sn UPass $did(Setup,255).text
    wn %sn GNUmethod $did(Setup,257).text
  }
}

dialog about {
  title "About DreamBot..."
  icon "img/set.ico", 0
  size -1 -1 250 260
  text "DreamBot IRC Bot Deluxe", 1, 5 5 138 15
  text "by DreamBot development team", 2, 5 22 138 35
  text "Version: 5.4", 4, 5 60 138 15
  text "I wish to thank the following people for their help:", 7, 5 120 240 15
  edit "", 14, 5 135 240 73, multi read return vsbar
  text "_______________________________________", 12, 7 208 240 15
  button "Close", 13, 75 230 100 25, ok

  link "http://dreambot.eurion.com", 6, 5 73 138 15
  ;  text "Includes features written by Brax. Thanks!", 10, 7 88 135 30
  icon 3, 145 5 101 101, "img/dblogo3.bmp", 1
}
on *:dialog:about:init:0: {
  ;did -m about 14
  did -a about 14 -Garp (DALnet,UnderNet) - provided domain, webhosting and help for the website;
  did -a about 14  $crlf $+ -Brax (DALnet, UnderNet) - this person helped me a lot. He created: trivia game, timebomb, seen, log viewer, other. Also he is full of ideas and helped me locate and fix bugs. Thanks a million!
  did -a about 14 $crlf $+ -tonyp (UnderNet) - wrote the Google Search script, provided suggestions and helped a lot in channel and forums.
  did -a about 14 $crlf $+ -Mitko (UnderNet) - keeps his bot (dealing) 24/7 on the channel for protection, logs, etc.
  did -a about 14 $crlf $+ -|AmDeAtH (UnderNet) - had a lot of suggestions for this bot (channel mirroring, protections).
  did -a about 14 $crlf $+ -JustJason (DALnet, UnderNet) - keeps a bot (InVisions) on my channel, a bot that I often use to help users. Lots of thanks to you as well!
  did -a about 14 $crlf $+ ...and to all of you DreamBot users out there that make me keep this project alive and updated!
}
on *:dialog:about:sclick:5: { run http://dreambot.eurion.com }
on *:dialog:about:sclick:6: { run mailto:MrZipen@gmail.com?Subject=DreamBot IRC bot - Contact }
;@@@ End 'About' box @@@


;@@@ DreamBot IRC Bot account manager 5.4 @@@
;@@@ begin @@@
dialog accounts {
  icon "img/set.ico", 0
  title "DreamBot IRC Bot v5.4 Accounts"
  size -1 -1 300 190
  text "This is the accounts management tool which you can use to view or remove certain bot operators." 1, 5 1 295 30
  list 2, 5 35 200 145, vsbar
  button "View" 3, 215 35 75 25
  button "Remove" 4, 215 65 75 25
  button "Close" 5, 215 160 75 25, ok
  text "" 6, 5 160 200 30
}
on 1:dialog:accounts:sclick:3: { 
  dialog -ma view view 
  //set %l.op $did(accounts,2).seltext
  did -am view 3  %l.op
  did -am view 5 $readini(ini\oper.ini, %l.op, Level)
  if ($readini(ini\oper.ini, %l.op, Hostmask) == $null) { did -am view 7 Host not available. }
  if ($readini(ini\oper.ini, %l.op, Hostmask) !== $null) { did -am view 7 $readini(ini\oper.ini, %l.op, Hostmask) }
  if ($readini(ini\oper.ini, %l.op, Password) == $null) { did -am view 9 No password set by user. }
  if ($readini(ini\oper.ini, %l.op, Password) !== $null) { did -am view 9 $readini(ini\oper.ini, %l.op, Password) }

}
dialog view {
  title "View DreamBot account"
  size -1 -1 250 180
  icon "img/set.ico", 0
  text "Bellow are the username, level, hostmask and password of the selected operator." 1, 5 1 245 30
  text "Username:" 2, 5 35 50 20
  edit "" 3, 60 35 175 20, autohs
  text "Level:" 4, 5 65 50 20
  edit "" 5, 60 65 175 20, autohs
  text "Hostmask:" 6, 5 95 50 20
  edit "" 7, 60 95 175 20, autohs
  text "Password:" 8, 5 125 50 20
  edit "" 9, 60 125 175 20, autohs
  button "OK" 10, 80 150 85 25, ok
}
on *:dialog:accounts:init:*: {
  if ($exists(ini\oplines.txt) == $false) { halt }
  :init
  //set %total.ops $lines(ini\oplines.txt)
  //set %counter 1
  :begin
  if (%counter <= %total.ops) { did -ack accounts 2 $read(ini\oplines.txt,%counter) | inc %counter 1 | goto begin }
  else { unset %total.ops | unset %counter }
}
on *:dialog:accounts:sclick:4: {
  if ($readini(ini\oper.ini, $did(accounts,2).seltext, Level) == Owner) { dialog -om error error | did -a error 1 You can't remove the bot owner using this dialog box. To remove the owner of the bot, you must use the 'Remove owner' tool in the 'DreamBot 5.4' menu. | halt } 
  else {
    .ruser $readini(ini\oper.ini, $did(accounts,2).seltext, Hostmask)
    .remini ini\oper.ini $did(accounts,2).seltext
    .write -ds $+ $did(accounts,2).seltext ini\oplines.txt
    did -d accounts 2 $did(accounts,2).sel
  }
}
;@@@ end accounts @@@

alias _wg {
  .writeini -n ini\Globals.ini $1-
}
alias _info { dialog -om info info | did -ra info 1 $1- }
alias _save {
  if ($did(Setup,34).state == 1) { 
    if ($did(Setup,16).text == $null) { _error Please enter a server for the bot to connect to. Example: irc.undernet.org. | halt }
    if ($did(Setup,18).text == $null) { _error Please enter a port for the server. Example: 6667. | halt }
    if ($did(Setup,22).text == $null) { _error Please enter the bot's primary nickname. Example: ShoeBox. | halt }
    _wg Config Auto On
    _wg Config Server $did(Setup,16)
    _wg Config SrvPort $did(Setup,18)
    _wg Config NickName $did(Setup,22)
    if ($did(Setup,24).text !== $null) { _wg Config Channels $did(Setup,24) }
  }
  if ($did(Setup,34).state == 0) { _wg Config Auto Off }
  if ($did(Setup,44).text == 0) { _error You must enter a command identifyer for the bot. Example: ! or you can click on Default to use the default character. | halt }
  set %c $did(Setup,44).text
  if (($did(Setup,53).state == 1) && ($did(Setup,54).text == $null)) { _error If you enabled the %c $+ idle command, you must also type a message for it. | halt }
  _wg HelpMode Idle On
  .write -ds $+ IdleMsg ini\mlines.txt | .write ini\mlines.txt IdleMsg $did(Setup,54).text
  if ($did(Setup,53).state == 0) { _wg HelpMode Idle Off }
  if ($did(Setup,56).state == 0) { _wg HelpMode AModerated Off }
  if ($did(Setup,56).state == 1) { _wg HelpMode AModerated On }
  if ($did(Setup,67).state == 1) {
    if ($did(Setup,64).text == $null) { _error Please enter flood protection time limit. | halt }
    set %flood.channel.time $did(Setup,64).text
    if ($did(Setup,66).text == $null) { _error Please enter flood protection line limit. | halt }
    set %flood.channel.lines $did(Setup,66).text
    _wg Protections Flood On
  }
  if ($did(Setup,67).state == 0) {
    _wg Protections Flood Off
  }
  if ($did(Setup,70).text == $null) { _error Please enter event flood protection time limit. | halt }
  set %events.time $did(Setup,70).text
  if ($did(Setup,72).text == $null) { _error Please enter event flood protection line limit. | halt }
  set %events.lines $did(Setup,72).text
  if ($did(Setup,75).state == 1) { _wg Protections Color On }
  if ($did(Setup,75).state == 0) { _wg Protections Color Off }
  if ($did(Setup,77).state == 1) { _wg Protections Repeat On }
  if ($did(Setup,77).state == 0) { _wg Protections Repeat Off }
  if ($did(Setup,79).state == 1) { _wg Protections Notice On }
  if ($did(Setup,79).state == 0) { _wg Protections Notice Off }
  if ($did(Setup,81).state == 1) { .enable #kick }
  if ($did(Setup,81).state == 0) { .disable #kick }
  if ($did(Setup,83).state == 1) { .enable #ban }
  if ($did(Setup,83).state == 0) { .disable #ban }
  if ($did(Setup,85).state == 1) { _wg Protections CTCP On }
  if ($did(Setup,85).state == 0) { _wg Protections CTCP Off }
  if ($did(Setup,98).state == 1) {
    if ($did(Setup,93).text == $null) { _error Please enter the self flood protection msg limit. | halt }
    set %flood.self.num $did(Setup,93).text
    if ($did(Setup,95).text == $null) { _error Please enter the self flood protection time limit. | halt }
    set %flood.self.time $did(Setup,95).text
    if ($did(Setup,97).text == $null) { _error Please enter the self flood protection ignore time. | halt }
    set %flood.self.ignore $did(Setup,97).text
    _wg Protections SFlood On
  }
  if ($did(Setup,98).state == 0) { _wg Protections SFlood Off }

  if ($did(Setup,106).state == 1) {
    if ($did(Setup,101).text == $null) { _error Please enter the self notice protection msg limit. | halt }
    set %notice.self.num $did(Setup,101).text
    if ($did(Setup,103).text == $null) { _error Please enter the self notice protection time limit. | halt }
    set %notice.self.time $did(Setup,103).text
    if ($did(Setup,105).text == $null) { _error Please enter the self notice protection ignore time. | halt }
    set %notice.self.ignore $did(Setup,105).text
    _wg Protections SNotice On
  }
  if ($did(Setup,106).state == 0) { _wg Protections SNotice Off }

  if ($did(Setup,114).state == 1) {
    if ($did(Setup,109).text == $null) { _error Please enter the self CTCP protection CTCPs limit. | halt }
    set %CTCP.self.num $did(Setup,109).text
    if ($did(Setup,111).text == $null) { _error Please enter the self CTCP protection time limit. | halt }
    set %CTCP.self.time $did(Setup,111).text
    if ($did(Setup,113).text == $null) { _error Please enter the self CTCP protection ignore time. | halt }
    set %CTCP.self.ignore $did(Setup,111).text
    _wg Protections SCTCP On
  }
  if ($did(Setup,114).state == 0) { _wg Protections SCTCP Off }

  if ($did(Setup,122).state == 1) {
    if ($did(Setup,117).text == $null) { _error Please enter the self invite protection invites limit. | halt }
    set %invite.self.num $did(Setup,117).text
    if ($did(Setup,119).text == $null) { _error Please enter the self invite protection time limit. | halt }
    set %invite.self.time $did(Setup,119).text
    if ($did(Setup,121).text == $null) { _error Please enter the self invite protection ignore time. | halt }
    set %invite.self.ignore $did(Setup,121).text
    _wg Protections SInvite On
  }
  if ($did(Setup,122).state == 0) { _wg Protections SInvite Off }
  if ($did(Setup,127).state == 1) { .enable #seen }
  if ($did(Setup,127).state == 0) { .disable #seen }
  if ($did(Setup,130).state == 1) { .enable #bt }
  if ($did(Setup,130).state == 0) { .disable #bt }
  if ($did(Setup,132).state == 1) { _wg Features Say On }
  if ($did(Setup,132).state == 0) { _wg Features Say Off }
  if ($did(Setup,134).state == 1) { _wg Features PgMode On }
  if ($did(Setup,134).state == 0) { _wg Features PgMode Off }
  if ($did(Setup,138).state == 1) {
    if ($did(Setup,137).text == $null) { _error Please enter a maximum number of links. | halt }
    _wg Features LinkMax $did(Setup,137).text
    _wg Features Links On
  }
  if ($did(Setup,138).state == 0) { _wg Features Links Off }
  if ($did(Setup,149).state == 1) {
    if ($did(Setup,142).text == $null) { _error Please enter the float max. | halt }
    if ($did(Setup,144).text == $null) { _error Please etner the float margin. | halt }
    if ($did(Setup,146).text == $null) { _error Please etner the float grace. | halt }
    if ($did(Setup,148).text == $null) { _error Please etner the float period. | halt }
    _wg Features Floatlim On
    set %max.float $did(Setup,142).text
    set %margin.float $did(Setup,144).text
    set %grace.float $did(Setup,146).text
    set %period.float $did(Setup,148).text
  }
  if ($did(Setup,149).state == 0) { _wg Features Floatlim Off }
  if ($did(Setup,176).state == 1) { .enable #aop }
  if ($did(Setup,176).state == 0) { .disable #aop }
  if ($did(Setup,233).state == 1) { .enable #defmode }
  if ($did(Setup,233).state == 0) { .disable #defmode }
  if ($did(Setup,178).state == 1) { set %aidle on }
  if ($did(Setup,178).state == 0) { set %aidle off }
  if ($did(Setup,231).state == 1) { _wg Config Cycle On }
  if ($did(Setup,231).state == 0) { _wg Config Cycle Off }
  if ($1 == exit) { dialog -c setup | _info Settings are saved. }
  if ($1 == apply) { _info Settings are saved. }
}

; @@@ Bot setup dialog @@@
dialog setup {
  size -1 -1 550 500
  title "DreamBot IRC Bot Setup"
  icon "img/set.ico", 0
  tab "General", 2, 5 5 540 460
  box "Connection", 40, 10 30 250 150, tab 2
  text "Server:", 15, 15 47 100 15, tab 2
  edit "", 16, 80 45 170 20, tab 2, autohs
  text "Port:", 17, 15 72 100 15, tab 2 
  edit "", 18, 80 70 170 20, tab 2, limit 5
  text "Nickname:", 21, 15 97 100 15, tab 2
  edit "", 22, 80 95 170 20, tab 2, autohs, limit 30
  text "Channels:", 23, 15 122 100 15, tab 2
  edit "", 24, 80 120 170 20, tab 2, autohs
  check "Enable autoconnect", 34, 15 147 125 15, tab 2
  box "Command identifier", 41, 275 30 250 150, tab 2
  text "    Here you can set the command identifier for the bot. The command identifier is the character that is used when you give a command to the bot in a channel. For example, if the command identifier is '`', a channel command might look like this: `op The2ndBot.", 42, 280 43 243 90, tab 2
  text "Current command identifier:", 43, 280 130 150 15, tab 2
  edit "", 44, 430 127 30 20, limit 1, center, tab 2
  button "Default", 45, 280 148 80 25, tab 2
  box "Helpmode", 46, 10 190 250 160, tab 2
  ;@@@ Spare IDs: 47 - 52 @@@
  check "Enable .idle command", 53, 15 205 125 15, tab 2
  edit "", 54, 90 225 150 70, tab 2, hsbar, autohs, multi
  text "Idle message:", 55, 15 227 70 15, tab 2
  check "Always keep help channels +m", 56, 15 300 175 15, tab 2
  box "Link to us", 240, 275 190 250 160, tab 2
  text "    If you like DreamBot and if you wish to help to make it more popular, we would appreciate if you include the DreamBot logo in your website. The logo bellow can be found at http://dreambot.eurion.com/img/dblogo.gif.", 241, 280 205 240 80, tab 2
  icon 242, 350 260 100 100, "img/dblogo.bmp", 1, tab 2
  text "Active help:", 36, 10 365 60 30, tab 2
  edit "", 37, 10 380 530 70, tab 2, multi, vsbar
  ; @@@ The protection tab @@@
  tab "Protection", 3
  box "Channel protections", 61, 10 30 530 150, tab 3
  box "Flood", 62, 15 45 85 80, tab 3
  text "Time:", 63, 20 63 30 15, tab 3
  edit "", 64, 55 60 30 20, tab 3, limit 3
  text "Lines:", 65, 20 82 30 15, tab 3
  edit "", 66, 55 80 30 20, tab 3
  check "Enabled", 67, 20 105 75 15, tab 3
  box "Events", 68, 105 45 85 80, tab 3
  text "Time:", 69, 110 63 30 15, tab 3
  edit "", 70, 150 60 30 20, tab 3, limit 3
  text "Events:", 71, 110 82 45 15, tab 3
  edit "", 72, 150 80 30 20, tab 3
  ;check "Enabled", 73, 110 105 75 15, tab 3
  box "Color", 74, 195 45 85 80, tab 3
  check "Enabled", 75, 200 63 75 15, tab 3
  box "Repeat", 76, 285 45 85 80, tab 3
  check "Enabled", 77, 290 63 75 15, tab 3
  box "Notice", 78, 375 45 85 80, tab 3
  check "Enabled", 79, 380 63 75 15, tab 3
  box "CTCP", 84, 465 45 73 80, tab 3
  check "Enabled", 85, 470 63 65 15, tab 3
  box "Kick", 80, 15 130 85 45, tab 3
  check "Enabled", 81, 20 150 75 15, tab 3
  box "Ban", 82, 105 130 85 45, tab 3
  check "Enabled", 83, 110 150 75 15, tab 3
  box "Security level", 86, 195 130 340 45, tab 3
  button "Low", 87, 200 145 100 28, tab 3
  button "Medium", 88, 305 145 100 28, tab 3
  button "High", 89, 410 145 100 28, tab 3
  ;*
  box "Self protection", 90, 10 190 530 150, tab 3
  box "Msg flood", 91, 15 205 105 100, tab 3
  text "Msgs:", 92, 20 222 30 15, tab 3
  edit "", 93, 80 220 30 20, tab 3, limit 3
  text "Time:", 94, 20 242 30 15, tab 3
  edit "", 95, 80 240 30 20, tab 3, limit 3
  text "Ignore time:", 96, 20 262 80 15, tab 3
  edit "", 97, 80 260 30 20, tab 3, limit 3
  check "Enabled", 98, 20 285 75 15, tab 3
  box "Notice flood", 99, 125 205 105 100, tab 3
  text "Notices:", 100, 130 222 50 15, tab 3
  edit "", 101, 190 220 30 20, tab 3, limit 3
  text "Time:", 102, 130 242 50 15, tab 3
  edit "", 103, 190 240 30 20, tab 3, limit 3
  text "Ignore time:", 104, 130 262 80 15, tab 3
  edit "", 105, 190 260 30 20, tab 3, limit 3
  check "Enabled", 106, 130 285 75 15, tab 3
  box "CTCP flood", 107,  235 205 105 100, tab 3
  text "CTCPs:", 108, 240 222 50 15, tab 3
  edit "", 109, 300 220 30 20, tab 3, limit 3
  text "Time:", 110, 240 242 50 15, tab 3
  edit "", 111, 300 240 30 20, tab 3, limit 3
  text "Ignore time:", 112, 240 262 80 15, tab 3
  edit "", 113, 300 260 30 20, tab 3, limit 3
  check "Enabled", 114, 240 285 75 15, tab 3
  box "Invite flood", 115, 345 205 105 100, tab 3
  text "Invites:", 116, 350 222 50 15, tab 3
  edit "", 117, 410 220 30 20, tab 3, limit 3
  text "Time:", 118, 350 242 50 15, tab 3
  edit "", 119, 410 240 30 20, tab 3, limit 3
  text "Ignore time:", 120, 350 262 80 15, tab 3
  edit "", 121, 410 260 30 20, tab 3, limit 3
  check "Enabled", 122, 350 285 75 15, tab 3
  button "Enable all", 123, 460 210 70 30, tab 3
  button "Disable all", 124, 460 245 70 30, tab 3
  button "Default", 125, 460 280 70 30, tab 3
  text "Active help:", 47, 10 365 60 30, tab 3
  edit "", 48, 10 380 530 70, tab 3, multi, vsbar
  ; @@@ The extra tab @@@
  tab "Extra", 25
  box "Seen module", 126, 15 30 90 70, tab 25
  check "Enabled", 127, 20 45 75 15, tab 25
  button "Erase data", 128, 20 65 80 25, tab 25
  box "Bot talk", 129, 110 30 90 70, tab 25
  check "Enabled", 130, 115 45 75 15, tab 25
  box "Say module", 131, 205 30 90 70, tab 25
  check "Enabled", 132, 210 45 75 15, tab 25
  box "Ping mode", 133, 300 30 90 70, tab 25
  check "Enabled", 134, 305 45 75 15, tab 25
  box "Links module", 135, 395 30 140 70, tab 25
  text "Max links:", 136, 400 47 80 15, tab 25
  edit "", 137, 480 45 50 20, tab 25, limit 4
  check "Enabled", 138, 400 65 70 15, tab 25
  button "Clear", 139, 470 75 60 20, tab 25
  box "Channel floatlim", 140, 15 110 200 120, tab 25
  text "Float max:", 141, 20 127 75 15, tab 25
  edit "", 142, 105 125 50 20, limit 4, tab 25
  text "Float margin:", 143, 20 147 75 15, tab 25
  edit "", 144, 105 145 50 20, limit 4, tab 25
  text "Float grace:", 145, 20 167 75 15, tab 25
  edit "", 146, 105 165 50 20, tab 25, limit 4
  text "Float period:", 147, 20 187 75 15, tab 25
  edit "", 148, 105 185 50 20, tab 25, limit 3
  check "Enabled", 149, 20 210 75 15, tab 25
  button "Low", 150, 160 125 50 25, tab 25
  button "Medium", 151, 160 155 50 25, tab 25
  button "High", 152, 160 185 50 25, tab 25
  box "Auto op", 175, 220 110 90 70, tab 25
  check "Enabled", 176, 225 125 75 15, tab 25
  box "Anti idle", 177, 315 110 90 70, tab 25
  check "Enabled", 178, 320 125 75 15, tab 25
  box "Gain ops", 230, 410 110 90 70, tab 25
  check "Enabled", 231, 415 125 75 15, tab 25
  box "Define", 232, 220 180 90 50, tab 25
  check "Enabled", 233, 225 195 75 15, tab 25
  text "Active help:", 49, 10 365 60 30, tab 25
  edit "", 50, 10 380 530 70, tab 25, multi, vsbar

  ; @@@ The channels tab @@@
  button "Save settings", 4, 95 465 110 30
  button "Cancel", 5, 210 465 110 30, cancel
  button "Apply", 38, 325 465 110 30
  tab "Channels", 35
  box "Channel settings", 153, 15 30 515 320, tab 35
  edit "", 154, 20 50 150 20, tab 35, autohs
  list 155, 20 70 150 100, tab 35, hsbar
  button "Add", 156, 175 70 50 25, tab 35
  button "Remove", 157, 175 100 50 25, tab 35
  button "Save", 158, 175 130 50 25, tab 35
  check "Enable flood protection", 159, 250 50 175 15, tab 35
  check "Lock down on multiple floods", 160, 250 70 175 15, tab 35
  check "Enable color protection", 161, 250 90 175 15, tab 35
  check "Enable repeat protection", 162, 250 110 175 15, tab 35
  check "Enable notice protection", 163, 250 130 175 15, tab 35
  check "Don't allow users to op others", 164, 250 150 175 15, tab 35
  check "Keep these channel modes:", 165, 250 172 170 15, tab 35
  edit "", 166, 420 170 105 20, tab 35
  check "Greet users with this message:", 167, 20 192 170 15, tab 35
  edit "", 168, 190 190 335 20, tab 35, autohs
  check "Keep this topic:", 169, 20 212 170 15, tab 35
  edit "", 170, 190 212 335 20, tab 35, autohs 
  check "This is a help channel", 171, 20 230 170 15, tab 35
  check "Voice users on join", 172, 20 250 170 15, tab 35
  check "Enable swear protection", 173, 20 270 170 15, tab 35
  check "Ban on advertisements", 174, 20 290 170 15, tab 35
  check "Adjust channel +l mode", 180, 20 310 170 15, tab 35
  check "Enable CTCP protection", 181, 20 330 170 15, tab 35
  text "Active help:", 51, 10 365 60 30, tab 35
  edit "", 52, 10 380 530 70, tab 35, multi, vsbar
  ; @@@ Services tab @@@
  tab "Services", 200
  box "Network services settings", 203, 15 30 515 300, tab 200
  edit "", 204, 20 50 150 20, tab 200
  list 205, 20 70 150 100, tab 200, hsbar
  button "Add", 206, 175 70 50 25, tab 200
  button "Remove", 207, 175 100 50 25, tab 200
  button "Save", 208, 175 130 50 25, tab 200
  ; text "Login using:", 209, 230 50 60 15, tab 200
  radio "NickServ (on DALnet, smaller networks)", 210, 20 175 205 15, tab 200 
  box "NickServ options:", 211, 20 195 225 125, tab 200
  text "Contact Nickserv by:", 212, 25 210 100 15, tab 200
  radio "/nickserv", 213, 25 230 80 15, tab 200, group
  radio "/msg nickserv", 214, 25 250 80 15, tab 200
  radio "other:", 215, 25 270 80 15, tab 200
  edit "", 216, 25 290 205 20, tab 200, autohs
  text "Nickname:", 217, 150 210 60 15, tab 200
  edit "", 218, 150 225 80 20, tab 200, autohs
  text "Password:", 219, 150 245 60 15, tab 200
  edit "", 220, 150 265 80 20, tab 200, autohs, password
  radio "GNU World (on Undernet, other)", 250, 270 175 200 15, tab 200, group
  box "GNU World options:", 251, 270 195 250 125, tab 200
  text "Username:", 252, 275 217 80 15, tab 200
  edit "", 253, 360 215 120 20, tab 200, autohs 
  text "Password:", 254, 275 237 80 15, tab 200
  edit "", 255, 360 235 120 20, tab 200, autohs, password
  text "Contact service using:", 256, 275 260 120 15, tab 200 
  edit "", 257, 275 275 205 20, tab 200, autohs
  text "(ex: /msg X@channels.undernet.org)", 258, 275 295 190 15, tab 200
  box "Services options:", 260, 230 50 290 120, tab 200
  check "Gain ops via services if deoped", 261, 235 70 260 15, tab 200
  check "Always ask services for op when joining a channel", 262, 235 90 260 15, tab 200

  text "Active help:", 201, 10 365 60 30, tab 200
  edit "", 202, 10 380 530 70, tab 200, multi, vsbar
}
alias bs { dialog -ma setup setup }
;@@@ end bot setup dialog @@@

;@@@ begin active help @@@
on *:dialog:setup:mouse:*: { .timer -om 1 500 MainHelp $mouse.x $mouse.y }
alias MainHelp {
  if $dialog(setup).title != $null {
    var %tab = $dialog(setup).tab
    if %tab == 2 {
      if $1 > 80 && $1 < 250 { 
        if $2 > 45 && $2 < 65 { did -ra setup 37 Here you can enter the server that the bot will connect to. Make sure you enter a server from the same network as yours! Example: irc.undernet.org | halt }
        elseif $2 > 70 && $2 < 90 { did -ra setup 37 Here you can specify the port of the server. The most common port for this is 6667, but if you were told to use other port, type it there. | halt }
        elseif $2 > 95 && $2 < 115 { did -ra setup 37 Enter here the nickname that the bot will use while on IRC. If this nickname is already in use, a random number will be added to it. | halt }
        elseif $2 > 120 && $2 < 140 { did -ra setup 37 Enter here the channels that the bot will join when it connects to the IRC server. You can also specify keys. Example: #channel1,#channel2 key1,key2. | halt }
        elseif $2 > 147 && $2 < 162 { did -ra setup 37 Enable or disable the autoconnect mode. If it's enabled, the bot will connect to the specified IRC server when started. | halt }
      }
      if $1 > 275 && $1 < 525 { 
        if $2 > 30 && $2 < 180 { did -ra setup 37 Here you can specify the command identifier for the bot (command character). To avoid confusion with other bots, choose an unique one. Example: if the command identifier is "`", a command would look like this: `voice guest. | halt }
      }
      if $1 > 10 && $1 < 245 {
        if $2 > 205 && $2 < 220 { did -ra setup 37 Check this option to enable the .idle command. This is useful if you wish to warn the user about idleling in a help channel befor warning him. You can also enter a idle message in the box bellow. | halt }        
        elseif $2 > 300 && $2 < 315 { did -ra setup 37 Check this to always maintain the help channels +m. | halt }
        ;elseif $2 > 320 && $2 < 335 { did -ra setup 37 Check this to maintain a help topic for help channels. | halt }
      }
    }
    if %tab == 3 {
      if $1 > 15 && $1 < 100 {
        if $2 > 45 && $2 < 125 { did -ra setup 48 You can specify here the amount of lines and the time that will trigger the flood protection. This setting is available for any channel that has the channel_flood turned on. Example: Time: 3 Lines: 1 will ban users that write 3 lines/1 second. | halt }
      }
      if $1 > 105 && $1 < 190 { 
        if $2 > 45 && $2 < 125 { did -ra setup 48 Here you can specify the number of channel events before bot locks the channel (modes +mi & +r, if available). The bot keeps the channel locked for 1 minute. Eample: Time: 5 Events: 8. | halt }
      }
      if $1 > 195 && $1 < 285 {
        if $2 > 45 && $2 < 125 { did -ra setup 48 Enable or disable the color protection. The bot first warns the user to stop using colors and if he continues, it bans him. | halt }
      }
      if $1 > 285 && $1 < 370 {
        if $2 > 45 && $2 < 125 { did -ra setup 48 Enable or disable the repeat protection. The bot first warns the user to stop repeating and if he continues, it bans him. | halt }
      }
      if $1 > 375 && $1 < 460 {
        if $2 > 45 && $2 < 125 { did -ra setup 48 Enable or disable the channel notice protection. The bot first warns the user to stop noticing the channel and if he continues, it bans him. | halt }
      }
      if $1 > 465 && $1 < 538 {
        if $2 > 45 && $2 < 125 { did -ra setup 48 Enable or disable the channel CTCP protection. The bot first warns the user to stop using CTCPs on the channel and if he continues, it bans him. | halt }
      }
      if $1 > 15 && $1 < 100 {
        if $2 > 130 && $2 < 175 { did -ra setup 48 Enable or disable the kick protection. If a bot user is kicked by a non-bot user or by a lower level bot user, the bot kick-bans him. | halt }
      }
      if $1 > 105 && $1 < 190 {
        if $2 > 130 && $2 < 175 { did -ra setup 48 Enable or disable the ban protection. If some ban match the bot or bot users, the bot removes them. | halt }
      }
      if $1 > 195 && $1 < 325 {
        if $2 > 130 && $2 < 175 { did -ra setup 48 Select the bot's security level for channels. You may see changes in the time frames & lines, depending on which level you select: Low, Medium, High. | halt }
      }
      if $1 > 15 && $1 < 120 {
        if $2 > 205 && $2 < 305 { did -ra setup 48 Here you can enable and set or disable the bot msg self protection. You can specify the maximum number or private messages in a number of seconds and the ignore time. | halt }
      }
      if $1 > 125 && $1 < 230 {
        if $2 > 205 && $2 < 305 { did -ra setup 48 Here you can enable and set or disable the bot notice self protection. You can specify the maximum number of notices in a number of seconds and the ignore time. | halt }
      }
      if $1 > 235 && $1 < 340 { 
        if $2 > 205 && $2 < 305 { did -ra setup 48 Here you can enable and set or disable the bot CTCP self protection. You can specify the maximum number of notices in a number of seconds and the ignore time. | halt }
      }
      if $1 > 345 && $1 < 450 { 
        if $2 > 205 && $2 < 305 { did -ra setup 48 Here you can enable and set or disable the bot invite self protection. You can specify the maximum number of notices in a number of seconds and the ignore time. | halt }
      }
      if $1 > 460 && $1 < 530 {
        if $2 > 210 && $1 < 240 { did -ra setup 48 Click this button to enable all self protections. | halt }
        elseif $2 > 245 && $2 < 275 { did -ra setup 48 Click this button to disable all self protections. | halt }
        elseif $2 > 280 && $2 < 310 { did -ra setup 48 Click this button to return to the default settings. | halt }
      }
    }
    if %tab == 25 {
      if $1 > 15 && $1 < 105 { 
        if $2 > 30 && $2 < 100 { did -ra setup 50 Enable or disable the Seen module. Please note that the bot will keep track of users on all its channels. If you wish to erase all the seen data, click on Erase data. | halt }
      }
      if $1 > 110 && $1 < 200 {
        if $2 > 30 && $2 < 100 { did -ra setup 50 Enable or disable the bot talk mode. If enabled, the bot will respond to certain text said in a channel. | halt }
      }
      if $1 > 205 && $1 < 295 { 
        if $2 > 30 && $2 < 100 { did -ra setup 50 Enable or disable the bot say module. If enabled, bot operators can speak trough the bot using %c $+ say <text> or /msg botnick say <#channel> <text>. | halt }
      }
      if $1 > 300 && $1 < 390 { 
        if $2 > 30 && $2 < 100 { did -ra setup 50 Enable or disable the bot ping mode. If enabled, users can check their ping reply with the bot using %c $+ ping. | halt }
      }
      if $1 > 395 && $1 < 535 { 
        if $2 > 30 && $2 < 100 { did -ra setup 50 Enable or disable the bot links module. This is a feature that allows bot users to add/remove/change/view links via the bot. You can enter the maximum links number that the bot will store (default is 50). | halt }
      }
      if $1 > 15 && $1 < 200 {
        if $2 > 110 && $2 < 230 { did -ra setup 50 Enable, disable or change the floatlim settings. Floatlim is a convenient bot feature that adjusts the +l mode of a channel depending on the number of users on it. This is usefull to prevent mass joining. FLOATMAX - the highest number after wich the bot will stop adjusting +l. FLOATMARGIN - the number that the floatlim will be increased by. FLOATGRACE - if the difference between the +l and the number of users is lower than this number, the floatlim won't be modified. FLOATPERIOD - the period between adjustments of +l. | halt }
      }
      if $1 > 220 && $1 < 310 {
        if $2 > 110 && $2 < 180 { did -ra setup 50 Enable or disable the Auto Op feature. If enabled, bot user that join a channel will be automaticly oped by the bot. | halt }
      }
      if $1 > 220 && $1 < 310 {
        if $2 > 180 && $2 < 240 { did -ra setup 50 Enable or disable the Define Mode. Define can store words and their definitions and you can retrieve them at any time. | halt }
      }
      if $1 > 315 && $1 < 405 {
        if $2 > 110 && $2 < 180 { did -ra setup 50 Enable or disable the Anti Idle feature. This feature prevents the bot from getting disconnected due ping timeouts. | halt }
      }
      if $1 > 410 && $1 < 500 {
        if $2 > 110 && $2 < 180 { did -ra setup 50 Enables the gain ops feature. Having this enabled, the bot will try to cycle the channel when it figures out it's alone and opless. NOTE: This may get annoying on networks with ChanServ, especially if the bot doesn't have access. | halt }
      }
    }
    if %tab == 35 {
      if $1 > 20 && $1 < 170 {
        if $2 > 50 && $2 < 70 { did -ra setup 52 Here you can enter channels that you wish to add to the bot's list. | halt }
        elseif $2 > 70 && $2 < 170 { did -ra setup 52 This is the list of channels that the bot manage. You can add/edit/remove channels by using the buttons nearby. IMPORTANT: you must select a channel before changing any settings, and you MUST click SAVE after you're done setting that channel. | halt }
      }
      if $1 > 175  && $1 < 225 { 
        if $2 > 70 && $2 < 95 { did -ra setup 52 Click this button to add a channel. | halt }
        elseif $2 > 100 && $2 < 125 { did -ra setup 52 Click this button to remove the selected channel. | halt }
        elseif $2 > 130 && $2 < 155 { did -ra setup 52 Click this button to save the settings for the selected channel. IMPORTANT: be sure to click this before you select another channel. | halt }
      }
      if $1 > 250 && $1 < 425 {
        if $2 > 50 && $2 < 65 { did -ra setup 52 Check this box to enable the channel flood protection for the selected channel. | halt }
        elseif $2 > 70 && $2 < 85 { did -ra setup 52 Check this box to enable the channel event flood protection. The bot will lock the channel if the limit is exceeded. | halt }
        elseif $2 > 90 && $2 < 105 { did -ra setup 52 Check this box to enable the channel color protection. The bot will first warn the user to stop using colors and if he continues, it will ban him. | halt }
        elseif $2 > 110 && $2 < 125 { did -ra setup 52 Check this box to enable the channel repeat protection. | halt }
        elseif $2 > 130 && $2 < 145 { did -ra setup 52 Check this box to enable the channel notice protection. The bot will first warn the user to stop using notices and if he continues, it will ban him. | halt }
        elseif $2 > 150 && $2 < 160 { did -ra setup 52 This feature won't allow non-bot users to op non-bot users (also known as bitchmode). | halt }
        elseif $2 > 172 && $2 < 187 { did -ra setup 52 If you want the bot too keep certain channels modes always on, check this box and enter the modes. | halt }
      }
      if $1 > 20 && $1 < 190 {
        if $2 > 192 && $2 < 207 { did -ra setup 52 If you want users to be greeted when joining this channel, enter a greet message in the box. NOTE: 1) the bot sends the greet notice via /notice. 2) on a mass join, the bot may become targeted. | halt }
        elseif $2 > 212 && $2 < 227 { did -ra setup 52 If you want the bot to keep a specific topic on the channel, check this box and enter the desired topic in the box. | halt }
        elseif $2 > 230 && $2 < 245 { did -ra setup 52 If you check this box, your channel will be a help channel and you can then help users via the %c $+ next command. NOTE: help channel specific settings may apply to your channel, if enabled. For more info on this new module read the documentation that came with the bot. | halt }
        elseif $2 > 250 && $2 < 265 { did -ra setup 52 You can have all the users that join this channel voiced by checking this dialog. NOTE: after joining, there is a delay between modes, so the bot can voice more users at the same time. | halt }
        elseif $2 > 270 && $2 < 285 { did -ra setup 52 Check this option to make the bot ban users if they swear on the channel. Of course, the bot will first warn them. | halt }
        elseif $2 > 290 && $2 < 305 { did -ra setup 52 Check this option to make the bot ban users if they advertise on the channel. This includes: web sites and channels. | halt }
        elseif $2 > 310 && $2 < 335 { did -ra setup 52 Check this option to make the bot auto adjust the +l mode of the channel. Please note that this module has been reviewed and it's better now. | halt }
        elseif $2 > 330 && $2 < 355 { did -ra setup 52 Check this option to enable the channel CTCP protection. If the bot detects a channel CTCP, it will warn the user, then ban him. | halt }
      }
    }
    if %tab == 200 {
      if $1 > 20 && $1 < 170 {
        if $2 > 50 && $2 < 70 { did -ra setup 202 Here you can enter networks that you wish to add to the bot's list. | halt }
        elseif $2 > 70 && $2 < 170 { did -ra setup 202 This is the list of networks that the bot manage. You can add/edit/remove networks by using the buttons nearby. IMPORTANT: you must select a network before changing any settings, and you MUST click SAVE after you're done setting that network. | halt }
      }
      if $1 > 175  && $1 < 225 { 
        if $2 > 70 && $2 < 95 { did -ra setup 202 Click this button to add a network. | halt }
        elseif $2 > 100 && $2 < 125 { did -ra setup 202 Click this button to remove the selected network. | halt }
        elseif $2 > 130 && $2 < 155 { did -ra setup 202 Click this button to save the settings for the selected network. IMPORTANT: be sure to click this before you select another network. | halt }
      }
      if $1 > 235 && $1 < 495 {
        if $2 > 70 && $2 < 85 { did -ra setup 202 Enable this to let the bot automaticly gain ops via services (Chanserv, X) if deoped. | halt }
        elseif $2 > 90 && $2 < 105 { did -ra setup 202 When this is enabled, the bot will always ask services for ops when joining a channel. | halt }
      }
      if $1 > 20 && $1 < 225 { 
        if $2 > 175 && $2 < 320 { did -ra setup 202 If your network supports Chanserv and Nickserv, pick this option and then set the nickname, password and the way that the bot will use to identify to nickserv. You can specify via /nickserv, via /msg nickserv or via other command that you may supply in the box (example: /msg nickserv@services.mynet.com). NOTE: Passwords are stored as plain text, they are not encrypted. | halt }
      }
      if $1 > 270 && $1 < 470 {
        if $2 > 175 && $2 < 320 { did -ra setup 202 If your network works with GNUworld (like Undernet and other networks) you can let the bot login by supplying the username and password for it. You must also supply the service name for logging in (example: /msg X@channels.undernet.org). | halt }
      }
    }
  }
}
;@@@ end active help @@@

;@@@ start dialog scripting @@@
on *:dialog:setup:init:0: {  
  ;@@@ General tab scripting @@@
  db_progressb Reading general settings...
  if (($readini(ini\Globals.ini, Config, Auto) == $null) || ($readini(ini\globals.ini, Config, Auto) == Off)) { 
    did -m setup 16  
    did -m setup 18
    did -m setup 22
    did -m setup 24 
  }
  if ($readini(ini\globals.ini, Config, Server) == $null) { did -a setup 16 irc.undernet.org }
  if ($readini(ini\globals.ini, Config, Server) !== $null) { did -a setup 16 $readini(ini\globals.ini, Config, Server) }
  if ($readini(ini\globals.ini, Config, SrvPort) == $null) { did -a setup 18 6667 }
  if ($readini(ini\globals.ini, Config, SrvPort) !== $null) { did -a setup 18 $readini(ini\globals.ini, Config, SrvPort) }
  if ($readini(ini\globals.ini, Config, Nickname) == $null) { did -a setup 22 MyNick $+ $rand(1,1000) }
  if ($readini(ini\globals.ini, Config, Nickname) !== $null) { did -a setup 22 $readini(ini\globals.ini, Config, Nickname) }
  if ($readini(ini\globals.ini, Config, Channels) == $null) { did -a setup 24 #AllNightCafe }
  if ($readini(ini\globals.ini, Config, Channels) !== $null) { did -a setup 24 $readini(ini\globals.ini, Config, Channels) }
  if ($readini(ini\globals.ini, Config, Auto) == On) {
    did -n setup 16
    did -n setup 18
    did -n setup 22
    did -n setup 24
    did -c setup 34
  }
  if (%c == $null) { did -a setup 44 ! }
  if (%c !== $null) { did -a setup 44 %c }
  if (($readini(ini\globals.ini, Helpmode, Idle) == $null) || ($readini(ini\globals.ini, Helpmode, Idle) == Off)) { 
    did -u setup 53 
    did -m setup 54 
    if ($read(ini\mlines.txt, s, IdleMsg) == $null) { did -a setup 54 This is a help channel. You are not allowed to idle in it. Please part now or you will be banned. }
    if ($read(ini\mlines.txt, s, IdleMsg) !== $null) { did -a setup 54 $read(ini\mlines.txt, s, IdleMsg) }
  }
  if ($readini(ini\globals.ini, Helpmode, Idle) == On) {
    did -c setup 53
    did -n setup 54
    if ($read(ini\mlines.txt, s, IdleMsg) == $null) { did -a setup 54 This is a help channel. You are not allowed to idle in it. Please part now or you will be banned. }
    if ($read(ini\mlines.txt, s, IdleMsg) !== $null) { did -a setup 54 $read(ini\mlines.txt, s, IdleMsg) }
  }
  if (($readini(ini\globals.ini, Helpmode, AModerated) == $null) || ($readini(ini\globals.ini, Helpmode, AModerated) == Off)) { did -u setup 56 }
  if ($readini(ini\globals.ini, Helpmode, AModerated) == On) { did -c setup 56 }
  ;if (($readini(ini\globals.ini, Helpmode, ATopic) == $null) || ($readini(ini\globals.ini, Helpmode, ATopic) == Off)) { did -u setup 57 }
  ;if ($readini(ini\globals.ini, Helpmode, ATopic) == On) { did -c setup 57 }
  db_pb 20
  ;@@@ Protection tab scripting @@@
  db_progressb Configuring protections...
  if ($readini(ini\globals.ini, Protections, Flood) == On) {
    did -c setup 67
    did -n setup 64
    did -n setup 66
    if (%flood.channel.time !== $null) { did -a setup 64 %flood.channel.time }
    if (%flood.channel.time == $null) { did -a setup 64 3 | set %flood.channel.time 3 }
    if (%flood.channel.lines !== $null) { did -a setup 66 %flood.channel.lines }
    if (%flood.channel.lines == $null) { did -a setup 66 5 | set %flood.channel.lines 5 }
  }
  if (($readini(ini\globals.ini, Protections, Flood) == Off) || ($readini(ini\globals.ini, Protections, Flood) == $null)) {
    did -u setup 67
    did -m setup 64
    did -m setup 66
    if (%flood.channel.time !== $null) { did -a setup 64 %flood.channel.time }
    if (%flood.channel.time == $null) { did -a setup 64 3 | set %flood.channel.time 3 }
    if (%flood.channel.lines !== $null) { did -a setup 66 %flood.channel.lines }
    if (%flood.channel.lines == $null) { did -a setup 66 5 | set %flood.channel.lines 5 }
  }
  if (%events.time !== $null) { did -a setup 70 %events.time }
  if (%events.time == $null) { did -a setup 70 3 | set %events.time 3 }
  if (%events.lines !== $null) { did -a setup 72 %events.lines }
  if (%events.lines == $null) { did -a setup 72 6 | set %events.lines 6 }
  if (($readini(ini\globals.ini, Protections, Color) == $null) || ($readini(ini\globals.ini, Protections, Color) == Off)) { did -u setup 75 }
  if ($readini(ini\globals.ini, Protections, Color) == On) { did -c setup 75 }
  if (($readini(ini\globals.ini, Protections, Repeat) == $null) || ($readini(ini\globals.ini, Protections, Repeat) == Off)) { did -u setup 77 }
  if ($readini(ini\globals.ini, Protections, Repeat) == On) { did -c setup 77 }
  if (($readini(ini\globals.ini, Protections, Notice) == $null) || ($readini(ini\globals.ini, Protections, Notice) == Off)) { did -u setup 79 }
  if ($readini(ini\globals.ini, Protections, Notice) == On) { did -c setup 79 }
  if (($readini(ini\globals.ini, Protections, CTCP) == $null) || ($readini(ini\globals.ini, Protections, CTCP) == Off)) { did -u setup 85 }
  if ($readini(ini\globals.ini, Protections, CTCP) == On) { did -c setup 85 }
  if ($group(#kick) == On) { did -c setup 81 }
  if ($group(#ban) == On) { did -c setup 83 }
  ;@*@*@ Self protection scripting

  if ($readini(ini\globals.ini, Protections, SFlood) == On) {
    did -c setup 98
    did -n setup 93
    did -n setup 95
    did -n setup 97
    if (%flood.self.num !== $null) { did -a setup 93 %flood.self.num }
    if (%flood.self.num == $null) { did -a setup 93 5 | set %flood.self.num 5 }
    if (%flood.self.time !== $null) { did -a setup 95 %flood.self.time }
    if (%flood.self.time == $null) { did -a setup 95 3 | set %flood.self.time 3 }
    if (%flood.self.ignore !== $null) { did -a setup 97 %flood.self.ignore }
    if (%flood.self.ignore == $null) { did -a setup 97 60 | set %flood.self.ignore 60 }
  }
  if (($readini(ini\globals.ini, Protections, SFlood) == Off) || ($readini(ini\globals.ini, Protections, SFlood) == $null)) {
    did -u setup 98
    did -m setup 93
    did -m setup 95
    did -m setup 97
    if (%flood.self.num !== $null) { did -a setup 93 %flood.self.num }
    if (%flood.self.num == $null) { did -a setup 93 5 | set %flood.self.num 5 }
    if (%flood.self.time !== $null) { did -a setup 95 %flood.self.time }
    if (%flood.self.time == $null) { did -a setup 95 3 | set %flood.self.time 3 }
    if (%flood.self.ignore !== $null) { did -a setup 97 %flood.self.ignore }
    if (%flood.self.ignore == $null) { did -a setup 97 60 | set %flood.self.ignore 60 }
  }
  if ($readini(ini\globals.ini, Protections, SNotice) == On) {
    did -c setup 106
    did -n setup 101
    did -n setup 103
    did -n setup 105
    if (%notice.self.num !== $null) { did -a setup 101 %notice.self.num }
    if (%notice.self.num == $null) { did -a setup 101 5 | set %notice.self.num 5 }
    if (%notice.self.time !== $null) { did -a setup 103 %notice.self.time }
    if (%notice.self.time == $null) { did -a setup 103 3 | set %notice.self.time 3 }
    if (%notice.self.ignore !== $null) { did -a setup 105 %notice.self.ignore }
    if (%notice.self.ignore == $null) { did -a setup 105 60 | set %notice.self.ignore 60 }
  }
  if (($readini(ini\globals.ini, Protections, SNotice) == Off) || ($readini(ini\globals.ini, Protections, SNotice) == $null)) {
    did -u setup 106
    did -m setup 101
    did -m setup 103
    did -m setup 105
    if (%notice.self.num !== $null) { did -a setup 101 %notice.self.num }
    if (%notice.self.num == $null) { did -a setup 101 5 | set %notice.self.num 5 }
    if (%notice.self.time !== $null) { did -a setup 103 %notice.self.time }
    if (%notice.self.time == $null) { did -a setup 103 3 | set %notice.self.time 3 }
    if (%notice.self.ignore !== $null) { did -a setup 105 %notice.self.ignore }
    if (%notice.self.ignore == $null) { did -a setup 105 60 | set %notice.self.ignore 60 }
  }
  if ($readini(ini\globals.ini, Protections, SCTCP) == On) {
    did -c setup 114
    did -n setup 109
    did -n setup 111
    did -n setup 113
    if (%CTCP.self.num !== $null) { did -a setup 109 %CTCP.self.num }
    if (%CTCP.self.num == $null) { did -a setup 109 5 | set %CTCP.self.num 5 }
    if (%CTCP.self.time !== $null) { did -a setup 111 %CTCP.self.time }
    if (%CTCP.self.time == $null) { did -a setup 111 3 | set %CTCP.self.time 3 }
    if (%CTCP.self.ignore !== $null) { did -a setup 113 %CTCP.self.ignore }
    if (%CTCP.self.ignore == $null) { did -a setup 113 60 | set %CTCP.self.ignore 60 }
  }
  if (($readini(ini\globals.ini, Protections, SCTCP) == Off) || ($readini(ini\globals.ini, Protections, SCTCP) == $null)) {
    did -u setup 114
    did -m setup 109
    did -m setup 111
    did -m setup 113
    if (%CTCP.self.num !== $null) { did -a setup 109 %CTCP.self.num }
    if (%CTCP.self.num == $null) { did -a setup 109 5 | set %CTCP.self.num 5 }
    if (%CTCP.self.time !== $null) { did -a setup 111 %CTCP.self.time }
    if (%CTCP.self.time == $null) { did -a setup 111 3 | set %CTCP.self.time 3 }
    if (%CTCP.self.ignore !== $null) { did -a setup 113 %CTCP.self.ignore }
    if (%CTCP.self.ignore == $null) { did -a setup 113 60 | set %CTCP.self.ignore 60 }
  }
  if ($readini(ini\globals.ini, Protections, SInvite) == On) {
    did -c setup 122
    did -n setup 117
    did -n setup 119
    did -n setup 121
    if (%Invite.self.num !== $null) { did -a setup 117 %Invite.self.num }
    if (%Invite.self.num == $null) { did -a setup 117 5 | set %Invite.self.num 5 }
    if (%Invite.self.time !== $null) { did -a setup 119 %Invite.self.time }
    if (%Invite.self.time == $null) { did -a setup 119 3 | set %Invite.self.time 3 }
    if (%Invite.self.ignore !== $null) { did -a setup 121 %Invite.self.ignore }
    if (%Invite.self.ignore == $null) { did -a setup 121 60 | set %Invite.self.ignore 60 }
  }
  if (($readini(ini\globals.ini, Protections, SInvite) == Off) || ($readini(ini\globals.ini, Protections, SInvite) == $null)) {
    did -u setup 122
    did -m setup 117
    did -m setup 119
    did -m setup 121
    if (%Invite.self.num !== $null) { did -a setup 117 %Invite.self.num }
    if (%Invite.self.num == $null) { did -a setup 117 5 | set %Invite.self.num 5 }
    if (%Invite.self.time !== $null) { did -a setup 119 %Invite.self.time }
    if (%Invite.self.time == $null) { did -a setup 119 3 | set %Invite.self.time 3 }
    if (%Invite.self.ignore !== $null) { did -a setup 121 %Invite.self.ignore }
    if (%Invite.self.ignore == $null) { did -a setup 121 60 | set %Invite.self.ignore 60 }
  }
  db_pb 40
  ;@@@ Extra tab scripting @@@
  db_progressb Loading extra settings...
  if ($group(#seen) == On) { did -c setup 127 }
  if ($group(#bt) == On) { did -c setup 130 }
  if ($readini(ini\globals.ini, Features, Say) == On) { did -c setup 132 }
  if ($readini(ini\globals.ini, Features, PgMode) == On) { did -c setup 134 }
  if ($readini(ini\globals.ini, Features, Links) == On) { did -c setup 138 | did -n setup 137 | if ($readini(ini\globals.ini, Features, LinkMax) == $null) { did -a setup 137 50 } | if ($readini(ini\globals.ini, Features, LinkMax) !== $null) { did -a setup 137 $readini(ini\globals.ini, Features, LinkMax) } }
  if (($readini(ini\globals.ini, Features, Links) == Off) || ($readini(ini\globals.ini, Features, Links) == $null)) { did -ma setup 137 50 }
  if (%max.float !== $null) { did -a setup 142 %max.float }
  if (%max.float == $null) { did -a setup 142 9999 | set %max.float 9999 }
  if (%margin.float !== $null) { did -a setup 144 %margin.float }
  if (%margin.float == $null) { did -a setup 144 5 | set %margin.float 5 }
  if (%grace.float !== $null) { did -a setup 146 %grace.float }
  if (%grace.float == $null) { did -a setup 146 2 | set %grace.float 2 }
  if (%period.float !== $null) { did -a setup 148 %period.float }
  if (%period.float == $null) { did -a setup 148 20 | set %period.float 20 }
  if ($readini(ini\globals.ini, Features, Floatlim) == On) {
    did -c setup 149
    did -n setup 142
    did -n setup 144
    did -n setup 146
    did -n setup 148
  }
  if (($readini(ini\globals.ini, Features, Floatlim) == Off) || ($readini(ini\globals.ini, Features, Floatlim) == $null)) {
    did -u setup 149
    did -m setup 142
    did -m setup 144
    did -m setup 146
    did -m setup 148
    did -b setup 150,151,152
  }
  if ($group(#aop) == on) { did -c setup 176 }
  if ($group(#defmode) == on) { did -c setup 233 }

  if (%aidle == on) { did -c setup 178 }
  if ($readini(ini\globals.ini, Config, Cycle) == On) { did -c setup 231 }
  db_pb 55
  ;@@@ Channels tab scripting @@@
  db_progressb Loading channels...
  did -ack setup 155 (none)
  if ($exists(ini\clines.txt) == $false) { halt }
  :init
  //set %total.chans $lines(ini\clines.txt)
  //set %c.counter 1
  :begin
  if (%c.counter <= %total.chans) { did -ack setup 155 $read(ini\clines.txt,%c.counter) | inc %c.counter 1 | goto begin }
  else { unset %total.chans | unset %c.counter }
  if ($did(setup,155).lines <= 1) { 
    did -b setup 159,160,161,162,163,164,165,167,169,171,172,173,166,168,170,157,158,180,174,181
  }
  if ($did(setup,155).lines > 1) {
    set %sc $did(setup,155).seltext
    did -e setup 157,158
    did -ra setup 154 %sc
    if ($readini(ini\channels.ini, %sc, Flood) == On) { did -c setup 159 } 
    if ($readini(ini\channels.ini, %sc, Protect) == On) { did -c setup 160 }
    if ($readini(ini\channels.ini, %sc, Color) == On) { did -c setup 161 }
    if ($readini(ini\channels.ini, %sc, Repeat) == On) { did -c setup 162 }
    if ($readini(ini\channels.ini, %sc, Notice) == On) { did -c setup 163 }
    if ($readini(ini\channels.ini, %sc, Bitchmode) == On) { did -c setup 164 }
    if ($readini(ini\channels.ini, %sc, SModes) !== Off) { 
      if ($readini(ini\channels.ini, %sc, SModes) == $null) { halt }
      if ($readini(ini\channels.ini, %sc, SModes) !== $null) { did -c setup 165 | did -a setup 166 $readini(ini\channels.ini, %sc, SModes) }
    }
    if ($readini(ini\channels.ini, %sc, Greet) == On) { 
      if ($read(ini\grlines.txt, s, %sc) !== $null) { did -c setup 167 | did -a setup 168 $read(ini\grlines.txt, s, %sc) }
    }
    if ($readini(ini\channels.ini, %sc, Greet) == Off) {
      if ($read(ini\grlines.txt, s, %sc) !== $null) { did -a setup 168 $read(ini\grlines.txt, s, %sc) }
    }
    if ($readini(ini\channels.ini, %sc, STopic) == On) { 
      if ($read(ini\tlines.txt, s, %sc) !== $null) { did -c setup 169 | did -a setup 170 $read(ini\tlines.txt, s, %sc) }
    }
    if ($readini(ini\channels.ini, %sc, STopic) == Off) { 
      if ($read(ini\tlines.txt, s, %sc) !== $null) { did -ra setup 170 $read(ini\tlines.txt, s, %sc) }
    }

    if ($readini(ini\channels.ini, %sc, HelpMode) == On) { did -c setup 171 }
    if ($readini(ini\channels.ini, %sc, AutoVoice) == On) { did -c setup 172 }
    if ($readini(ini\channels.ini, %sc, Swear) == On) { did -c setup 173 }
    if ($readini(ini\channels.ini, %sc, Adv) == On) { did -c setup 174 }
    if ($readini(ini\channels.ini, %sc, FloatLim) == On) { did -c setup 180 }
    if ($readini(ini\channels.ini, %sc, CTCP) == On) { did -c setup 181 }
  }
  db_pb 70
  ;@@@ Services tab scripting
  db_progressb Loading networks...
  did -ack setup 205 (none)
  if ($exists(ini\nlines.txt) == $false) { halt }
  :Ninit
  //set %total.nets $lines(ini\nlines.txt)
  //set %n.counter 1
  :Nbegin
  if (%n.counter <= %total.nets) { did -ack setup 205 $read(ini\nlines.txt,%n.counter) | inc %n.counter 1 | goto nbegin }
  else { unset %total.nets | unset %n.counter }
  if ($did(setup,205).lines < 2) { 
    did -b setup 207,208,210,211,213,214,215,216,218,220,250,253,255,257,261,262
  }
  if ($did(setup,205).lines >= 1) {
    set %sn $did(setup,205).seltext
    did -e setup 207,208
    did -ra setup 204 %sn
    if ($readini(ini\networks.ini, %sn, Method) == 0) { goto _loaded }
    if ($readini(ini\networks.ini, %sn, Method) == NickServ) { 
      did -c setup 210
      did -u setup 250
      did -b setup 253,255,257
      did -ra setup 253,255,257
      set %ns.method $readini(ini\networks.ini, %sn, NSMethod)
      if (%ns.method == 1) { did -c setup 213 | did -u setup 214,215 | did -b setup 216 }
      if (%ns.method == 2) { did -c setup 214 | did -u setup 213,215 | did -b setup 216 }
      if (%ns.method == 3) { did -c setup 215 | did -u setup 213,214 | did -re setup 216 | did -ra setup 216 $readini(ini\networks.ini, %sn, NS3) }
      did -ra setup 218 $readini(ini\networks.ini, %sn, Nickname)
      did -ra setup 220 $readini(ini\networks.ini, %sn, NPass)
      if ($readini(ini\networks.ini, %sn, Reop) == On) { did -c setup 261 }
      if ($readini(ini\networks.ini, %sn, GainOps) == On) { did -c setup 262 }
    }
    if ($readini(ini\networks.ini,%sn, Method) == GNU) { 
      did -c setup 250
      did -u setup 210
      did -b setup 213,214,215,216,218,220
      did -ra setup 216,218,220
      did -ra setup 253 $readini(ini\networks.ini, %sn, Username)
      did -ra setup 255 $readini(ini\networks.ini, %sn, UPass)
      did -ra setup 257 $readini(ini\networks.ini, %sn, GNUmethod)
      if ($readini(ini\networks.ini, %sn, Reop) == On) { did -c setup 261 }
      if ($readini(ini\networks.ini, %sn, GainOps) == On) { did -c setup 262 }
      if ($readini(ini\networks.ini, %sn, Reop) != On) { did -u setup 261 }
      if ($readini(ini\networks.ini, %sn, GainOps) != On) { did -u setup 262 }

    }
  }
  :_loaded
  db_pb 100
  .timer -m 1 500 dialog -c db_progressb
}
on *:dialog:setup:sclick:34: {
  if ($did(setup,34).state == 1) { 
    did -n setup 16,18,22,24
  }
  if ($did(setup,34).state == 0) { 
    did -m setup 16,18,22,24
  }
}
on *:dialog:setup:sclick:45: { did -ra setup 44 ! }
on *:dialog:setup:sclick:53: {
  if ($did(setup,53).state == 1) { did -n setup 54 }
  if ($did(setup,53).state == 0) { did -m setup 54 }
}
on *:dialog:setup:sclick:67: {
  if ($did(setup,67).state == 1) { did -n setup 64,66 }
  if ($did(setup,67).state == 0) { did -m setup 64,66 }
}
on *:dialog:setup:sclick:87: {
  did -c setup 67
  did -nra setup 64 3
  did -nra setup 66 8
  did -nra setup 70 4
  did -nra setup 72 6
  did -u setup 77,79,85
  did -c setup 81,83
}
on *:dialog:setup:sclick:88: {
  did -c setup 67
  did -nra setup 64 4
  did -nra setup 66 5
  did -nra setup 70 5
  did -nra setup 72 6
  did -u setup 79,85
  did -c setup 81,83,77
}
on *:dialog:setup:sclick:89: {
  did -c setup 67
  did -nra setup 64 3
  did -nra setup 66 5
  did -nra setup 70 3
  did -nra setup 72 6
  did -c setup 81,83,77,79,85
}
on *:dialog:setup:sclick:98: {
  if ($did(setup,98).state == 1) { did -n setup 93,95,97 }
  if ($did(setup,98).state == 0) { did -m setup 93,95,97 }
}
on *:dialog:setup:sclick:106: {
  if ($did(setup,106).state == 1) { did -n setup 101,103,105 }
  if ($did(setup,106).state == 0) { did -m setup 101,103,105 }
}
on *:dialog:setup:sclick:114: {
  if ($did(setup,114).state == 1) { did -n setup 109,111,113 }
  if ($did(setup,114).state == 0) { did -m setup 109,111,113 }
}
on *:dialog:setup:sclick:122: {
  if ($did(setup,122).state == 1) { did -n setup 117,119,121 }
  if ($did(setup,122).state == 0) { did -m setup 117,119,121 }
}
on *:dialog:setup:sclick:123: {
  did -n setup 93,95,97,101,103,105,109,111,113,117,119,121
  did -c setup 98,106,114,122
  did -ra setup 93 5
  did -ra setup 95 3
  did -ra setup 97 60
  did -ra setup 101 5
  did -ra setup 103 3
  did -ra setup 105 60
  did -ra setup 109 5
  did -ra setup 111 3
  did -ra setup 113 60
  did -ra setup 117 5
  did -ra setup 119 3
  did -ra setup 121 60
}
on *:dialog:setup:sclick:124: {
  did -m setup 93,95,97,101,103,105,109,111,113,117,119,121
  did -u setup 98,106,114,122
}
on *:dialog:setup:sclick:125: {
  did -ra setup 93 5
  did -ra setup 95 3
  did -ra setup 97 60
  did -ra setup 101 5
  did -ra setup 103 3
  did -ra setup 105 60
  did -ra setup 109 5
  did -ra setup 111 3
  did -ra setup 113 60
  did -ra setup 117 5
  did -ra setup 119 3
  did -ra setup 121 60
}
dialog error {
  size -1 -1 250 100
  icon "img/err.ico", 0
  title "DreamBot IRC Bot Error"
  text "", 1, 5 5 240 70
  button "Ok", 2, 75 72 100 25, ok
}
dialog info {
  size -1 -1 250 80
  icon "img/info1.ico", 0
  title "DreamBot IRC Bot 5.4"
  text "", 1, 5 5 240 70
  button "Ok", 2, 75 50 100 25, ok
}
on *:dialog:setup:sclick:128: {
  dialog -oma info info
  if ($exists(ini\seen.ini) == $true) { .write -c ini\seen.ini }
  did -a info 1 Erased all seen data.
}
on *:dialog:setup:sclick:138: {
  if ($did(setup,138).state == 1) { did -n setup 137 }
  if ($did(setup,138).state == 0) { did -m setup 137 }
}
on *:dialog:setup:sclick:139: {
  if ($exists(txt\links.txt) == $true) { .write -c txt\links.txt | dialog -amo info info | did -a info 1 Cleared all the links in the file $mircdir $+ txt\links.txt $+ . }
}
on *:dialog:setup:sclick:149: {
  if ($did(setup,149).state == 1) {
    did -e setup 150,151,152
    did -n setup 142,144,146,148
  }
  if ($did(setup,149).state == 0) {
    did -b setup 150,151,152
    did -m setup 142,144,146,148
  }
}
on *:dialog:setup:sclick:150: {
  did -ra setup 142 3000
  did -ra setup 144 10
  did -ra setup 146 3
  did -ra setup 148 25
}
on *:dialog:setup:sclick:151: {
  did -ra setup 142 2000
  did -ra setup 144 5
  did -ra setup 146 2
  did -ra setup 148 20
}
on *:dialog:setup:sclick:152: {
  did -ra setup 142 1000
  did -ra setup 144 3
  did -ra setup 146 1
  did -ra setup 148 15
}
on *:dialog:setup:sclick:155: {
  if (%sc == $did(setup,155).seltext) { halt }
  did -u setup 159,160,162,163,164,165,167,169,171,172,173,174,161,180,181
  did -r setup 166,168,170
  set %sc $did(setup,155).seltext
  if (%sc == $chr(40) $+ none $+ $chr(41)) { did -b setup 159,160,161,162,163,164,165,167,169,171,172,173,166,168,170,157,158,174,180,181 | did -ra setup 154 (none) | halt }
  if (%sc !== $chr(40) $+ none $+ $chr(41)) { did -e setup 159,160,161,162,163,164,165,167,169,171,172,173,166,168,170,157,158,174,180,181 }
  did -e setup 157,158
  did -ra setup 154 %sc
  if ($readini(ini\channels.ini, %sc, Flood) == On) { did -c setup 159 } 
  if ($readini(ini\channels.ini, %sc, Protect) == On) { did -c setup 160 }
  if ($readini(ini\channels.ini, %sc, Color) == On) { did -c setup 161 }
  if ($readini(ini\channels.ini, %sc, Repeat) == On) { did -c setup 162 }
  if ($readini(ini\channels.ini, %sc, Notice) == On) { did -c setup 163 }
  if ($readini(ini\channels.ini, %sc, Bitchmode) == On) { did -c setup 164 }
  if ($readini(ini\channels.ini, %sc, SModes) !== Off) { 
    if ($readini(ini\channels.ini, %sc, SModes) == $null) { halt }
    if ($readini(ini\channels.ini, %sc, SModes) !== $null) { did -c setup 165 | did -ra setup 166 $readini(ini\channels.ini, %sc, SModes) }
  }
  if ($readini(ini\channels.ini, %sc, Greet) == On) { 
    if ($read(ini\grlines.txt, s, %sc) !== $null) { did -c setup 167 | did -ra setup 168 $read(ini\grlines.txt, s, %sc) }
  }
  if ($readini(ini\channels.ini, %sc, Greet) == Off) {
    if ($read(ini\grlines.txt, s, %sc) !== $null) { did -ra setup 168 $read(ini\grlines.txt, s, %sc) }
  }
  if ($readini(ini\channels.ini, %sc, STopic) == On) { 
    if ($read(ini\tlines.txt, s, %sc) !== $null) { did -c setup 169 | did -a setup 170 $read(ini\tlines.txt, s, %sc) }
  }
  if ($readini(ini\channels.ini, %sc, STopic) == Off) { 
    if ($read(ini\tlines.txt, s, %sc) !== $null) { did -ra setup 170 $read(ini\tlines.txt, s, %sc) }
  }

  if ($readini(ini\channels.ini, %sc, HelpMode) == On) { did -c setup 171 }
  if ($readini(ini\channels.ini, %sc, AutoVoice) == On) { did -c setup 172 }
  if ($readini(ini\channels.ini, %sc, Swear) == On) { did -c setup 173 }
  if ($readini(ini\channels.ini, %sc, Adv) == On) { did -c setup 174 }
  if ($readini(ini\channels.ini, %sc, FloatLim) == On) { did -c setup 180 }
  if ($readini(ini\channels.ini, %sc, CTCP) == On) { did -c setup 181 }

}
on *:dialog:setup:sclick:156: {
  if ($exists(ini\clines.txt) == $false) { halt }
  if ($did(setup,154).text == $null) { halt }
  if ($did(setup,154).text !== $null) { add_chan }
}
on *:dialog:setup:sclick:157: {
  if ($exists(ini\clines.txt) == $false) { halt }
  if ($did(setup,154).text == $null) { halt }
  if ($did(setup,154).text !== $null) { rem_chan }
}
on *:dialog:setup:sclick:158: {
  if ($exists(ini\clines.txt) == $false) { halt }
  if ($did(setup,154).text == $null) { halt }
  if ($did(setup,154).text !== $null) { save_chan }
}

on *:dialog:setup:sclick:206: {
  if ($exists(ini\nlines.txt) == $false) { halt }
  if ($did(setup,204).text == $null) { halt }
  if ($did(setup,204).text !== $null) { add_net }
}
on *:dialog:setup:sclick:207: {
  if ($exists(ini\nlines.txt) == $false) { halt }
  if ($did(setup,204).text == $null) { halt }
  if ($did(setup,204).text !== $null) { rem_net }
}
on *:dialog:setup:sclick:208: {
  if ($exists(ini\nlines.txt) == $false) { halt }
  if ($did(setup,204).text == $null) { halt }
  if ($did(setup,204).text !== $null) { save_net }
}
alias _none {
  did -b setup 207,208,210,211,213,214,215,216,218,220,250,253,255,257,261,262
  did -ra setup 216,218,220,253,255,257
  did -u setup 210,213,214,215,250,261,262
}
alias _half1 {
  did -ra setup 216,218,220
  did -u setup 213,214,215
}
alias _half2 {
  did -ra setup 253,255,257
}
on *:dialog:setup:sclick:205: {
  set %sn $did(setup,205).seltext
  if (%sn == $chr(40) $+ none $+ $chr(41)) { _none | halt }
  if (%sn !== $chr(40) $+ none $+ $chr(41)) { did -e setup 207,208,210,211,213,214,215,216,218,220,250,253,255,257,261,262 }
  did -e setup 207,208
  did -ra setup 204 %sn
  if ($readini(ini\networks.ini, %sn, Method) == 0) { halt }
  if ($readini(ini\networks.ini, %sn, Method) == NickServ) { 
    did -c setup 210
    did -u setup 250
    did -b setup 253,255,257
    did -ra setup 253,255,257
    _half2
    set %ns.method $readini(ini\networks.ini, %sn, NSMethod)
    if (%ns.method == 1) { did -c setup 213 | did -u setup 214,215 | did -b setup 216 }
    if (%ns.method == 2) { did -c setup 214 | did -u setup 213,215 | did -b setup 216 }
    if (%ns.method == 3) { did -c setup 215 | did -u setup 213,214 | did -re setup 216 | did -ra setup 216 $readini(ini\networks.ini, %sn, NS3) }
    did -ra setup 218 $readini(ini\networks.ini, %sn, Nickname)
    did -ra setup 220 $readini(ini\networks.ini, %sn, NPass)
    if ($readini(ini\networks.ini, %sn, Reop) == On) { did -c setup 261 }
    if ($readini(ini\networks.ini, %sn, GainOps) == On) { did -c setup 262 }
    if ($readini(ini\networks.ini, %sn, Reop) != On) { did -u setup 261 }
    if ($readini(ini\networks.ini, %sn, GainOps) != On) { did -u setup 262 }


  }
  if ($readini(ini\networks.ini,%sn, Method) == GNU) { 
    did -c setup 250
    did -u setup 210
    did -b setup 213,214,215,216,218,220
    did -ra setup 216,218,220
    _half1
    did -ra setup 253 $readini(ini\networks.ini, %sn, Username)
    did -ra setup 255 $readini(ini\networks.ini, %sn, UPass)
    did -ra setup 257 $readini(ini\networks.ini, %sn, GNUmethod)
    if ($readini(ini\networks.ini, %sn, Reop) == On) { did -c setup 261 }
    if ($readini(ini\networks.ini, %sn, GainOps) == On) { did -c setup 262 }
  }
}
on *:dialog:setup:sclick:215: {
  did -u setup 213,214
  did -era setup 216 /msg nickserv@services. $+ %sn $+ .org
}
on *:dialog:setup:sclick:210: {
  did -c setup 210
  did -u setup 250
  did -b setup 253,255,257
  did -e setup 213,214,215,216,218,220
  _half2
}
on *:dialog:setup:sclick:250: {
  did -u setup 210
  did -c setup 250
  did -e setup 253,255,257
  did -b setup 213,214,215,216,218,220
  _half1
}
on *:dialog:setup:sclick:215: {
  if ($did(setup,215).state == 1) { did -e setup 216 }
}
on *:dialog:setup:sclick:213: {  did -b setup 216 }
on *:dialog:setup:sclick:214: {  did -b setup 216 }
on *:dialog:setup:sclick:242: { run http://dreambot.eurion.com }
on *:dialog:setup:sclick:4: { _save exit }
on *:dialog:setup:sclick:38: { _save apply }
on *:dialog:*:sclick:*: { .splay $mircdir $+ img\click.wav }





;u
