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


alias rep {
  var %repchan = #dreambot
  var %rep = off
  if %rep == on { 
    msg %repchan $1-
  }
}
on *:join:#: { 
  var %ban.file = ini\bans\ $+ $sWin($chan) $+ .ban
  var %check.ban 0
  var %user.addr $address($nick,5)
  ;msg $chan %user.addr %ban.file %check.ban
  :checkban
  inc %check.ban
  if $read(%ban.file,%check.ban) == $null { halt }
  ;msg $chan $read(%ban.file,%check.ban)
  if $read(%ban.file,%check.ban) iswm %user.addr { _enforce $chan $read(%ban.file,%check.ban) }
  goto checkban
}
alias _live.kb {
  var %ban.file = ini\bans\ $+ $sWin($1) $+ .ban
  var %check.ban 0
  :checkban
  inc %check.ban
  if $read(%ban.file,%check.ban) == $null { halt }
  _enforce $1 $read(%ban.file,%check.ban) 
  goto checkban
}
on *:op:#: {
  if $opnick == $me {
    _main $chan
    var %ban.file = ini\bans\ $+ $sWin($chan) $+ .ban
    var %check.ban 0
    :checkban
    inc %check.ban
    if $read(%ban.file,%check.ban) == $null { halt }
    _enforce $chan $read(%ban.file,%check.ban) 
    goto checkban
  }
}
alias dbver {
  if ($1 == num) { return 5.4 }
  if ($1 == text) { return DreamBot IRC Bot v5.4 }
  if ($1 == site) { return http://dreambot.eurion.com }
}
alias remnick { 
  if ($1 == $null) { echo -s $cl /remnick: no nickname supplied | halt }
  if ($2 == $null) { echo -s $cl /remnick: no channel supplied | halt }
  unset  %p.* [ $+ [ $2 ] ] [ $+ [ $1 ] ]
}
on 1:part:#: { remnick $nick $chan }
on 1:op:#: { remnick $opnick $chan }
on 1:kick:#: { remnick $knick $chan }
alias cl { return 2*12*11* }
alias fl {
  return 4 $+ $str($chr(160),10) $+ *
}
alias db_title { titlebar DreamBot IRC Bot v5.4 - http://dreambot.eurion.com }
alias f6 { _amenu }
alias f1 { run dbhelp.htm }
alias f2 { bs }
alias f3 { .dialog -ma accounts accounts }
alias f4 { logviewer }
alias f5 { _connect force }
alias f7 { .dialog -ma about about }
alias _amenu {
  echo -s $cl $_sp
  echo -s $cl DreamBot F Commands:
  echo -s $fl F1 - display DreamBot Help
  echo -s $fl F2 - configuration
  echo -s $fl F3 - accounts manager
  echo -s $fl F4 - log viewer
  echo -s $fl F5 - connect to server
  echo -s $fl F6 - display these commands again
  echo -s $fl F7 - about DreamBot
  echo -s $fl F8 - ban list
  echo -s $cl $_sp
}
; Protection check identifier
; Usage: $_protect(<protection,#channel>)
; Retruns: $true or $false

alias _protect {
  set %_p $1
  set %_ch $2
  if $1 !== swear && $1 !== adv {
    if $readini(ini\globals.ini, Protections, $1) == Off || $readini(ini\globals.ini, Protections, $1) == $null { return $false }
  }
  if $readini(ini\channels.ini, %_ch, %_p) == Off || $readini(ini\channels.ini, %_ch, %_p) == $null { return $false }
  else { return $true }
}

; Warning alias
; Usage: /_warn <#channel> <nick> <type>
; Types: color, repeat, ctcp, swear, ad
; Returns: nothing.

alias _warn {

  ; Build warning
  if $3 == color { set %warning Please do not use colors/bolds/underlines/reverses while in this channel. }
  if $3 == repeat { set %warning Please do not repeat while in this channel. }
  if $3 == ctcp { set %warning Please do not use CTCPs while in this channel. }
  if $3 == swear { set %warning Please do not swear while in this channel. }
  if $3 == ad { set %warning Please do not advertise while in this channel. }
  if $3 == notice { set %warning Please do not use notices while in this channel. }

  ; warn user and lock up
  .timerUk $+ $1 1 10 set %evtrig [ $+ [ $1 ] ] no
  if ((%evtrig [ $+ [ $1 ] ] == no) || (%evtrig [ $+ [ $1 ] ] == $null)) { 
    .msg $1 -> $2 : %warning
    set %evtrig [ $+ [ $1 ] ] yes
  }
}
