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

on 500:text:*defmode*:#: {
  if $1 == %c $+ defmode {
    if $2 == $null { .msg $nick Command incomplete. Syntax: %c $+ defmode <on|off> | halt }
    if $2 == on { .enable #defmode | .msg $nick The bot definition mode is now enabled. To define a word type %c $+ define <word>. To add a word, use %c $+ defadd <word> <description>. To remove a word, use %c $+ defrem <word>. | halt }
    if $2 == off { .disable #defmode | .msg $nick The bot definition mode is now disabled. | halt }
    else { .msg $nick $cl Error: Invalid parameters. Available options: ON/OFF. | halt }
  }
}
on 500:text:defmode*:?: {
  if $2 == $null { .msg $nick Command incomplete. Syntax: /msg $me defmode <on|off> | halt }
  if $2 == on { .enable #defmode | .msg $nick The bot definition mode is now enabled. To define a word type %c $+ define <word>. To add a word, use %c $+ defadd <word> <description>. To remove a word, use %c $+ defrem <word>. | halt }
  if $2 == off { .disable #defmode | .msg $nick The bot definition mode is now disabled. | halt }
  else { .msg $nick $cl Error: Invalid parameters. Available options: ON/OFF. | halt }
}

#defmode on
on *:Text:*define*:#: {
  if $1 == %c $+ define {
    ;if $nick !isop $chan && $level($address($nick,2)) !> 99 { halt }
    if $2 == $null { .msg $nick Command incomplete. Syntax: %c $+ define <word> | halt }
    if $exists(txt\botdef.txt) == $false { msg $chan Database does not exist. | halt }
    if $read(txt\botdef.txt,s,$2) == $null { msg $chan Sorry $nick $+ , but I can't find  $+ $2 $+ . | halt }
    msg $chan  $+ $2 $+ : $read(txt\botdef.txt,s,$2)
  }
}
on *:Text:$( $+ $me $+ *tell * about * $+ ):#: {
  ;if $nick !isop $chan && $level($address($nick,2)) !> 99 { halt }
  if $2 == $null { .msg $nick Command incomplete. Syntax: %c $+ define <word> | halt }
  if $exists(txt\botdef.txt) == $false { msg $chan Database does not exist. | halt }
  if $read(txt\botdef.txt,s,$5) == $null { msg $chan Sorry $nick $+ , but I can't find  $+ $5 $+ . | halt }
  if $3 == me && me !ison $chan {   msg $chan [ $nick ]  $+ $5 $+ : $read(txt\botdef.txt,s,$5) | halt }
  msg $chan [ $3 ]  $+ $5 $+ : $read(txt\botdef.txt,s,$5)
}

on *:Text:*defadd*:#: {
  if $1 == %c $+ defadd {
    if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
    if $2 == $null { .msg $nick Command incomplete. Syntax: %c $+ defadd <word> <description> | halt }
    if $read(txt\botdef.txt,s,$2) !== $null { msg $chan  $+ $2 $+  already exists in my database. | halt }
    .write txt\botdef.txt $2 $relay_replace($3-)
    msg $chan  $+ $2 $+  stored succesfully.
  }
}
on *:Text:$( $+ $me $+ *add*):#: {
  if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
  if $3- == $null { .msg $chan well... add what? | halt }
  if $read(txt\botdef.txt,s,$3) !== $null { msg $chan  $+ $3 $+  already exists in my database. | halt }
  .write txt\botdef.txt $3 $relay_replace($4-) 
  msg $chan  $+ $3 $+  stored succesfully.
}
on *:Text:$( $+ $me $+ *remember*):#: {
  if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
  if $3- == $null { .msg $chan well... remember what? | halt }
  if $read(txt\botdef.txt,s,$3) !== $null { msg $chan  $+ $3 $+  already exists in my database. | halt }
  .write txt\botdef.txt $3  $relay_replace($4-)
  msg $chan  $+ $3 $+  stored succesfully.
}
on *:Text:$( $+ $me $+ *store*):#: {
  if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
  if $3- == $null { .msg $chan well... store what? | halt }
  if $read(txt\botdef.txt,s,$3) !== $null { msg $chan  $+ $3 $+  already exists in my database. | halt }
  .write txt\botdef.txt $3 $relay_replace($4-)
  msg $chan  $+ $3 $+  stored succesfully.
}
on *:Text:*defrem*:#: {
  if $1 == %c $+ defrem {
    if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
    if $2 == $null { .msg $nick Command incomplete. Syntax: %c $+ defrem <word> | halt }
    if $read(txt\botdef.txt,s,$2) == $null { msg $chan  $+ $2 $+  does not exist in my database. | halt }
    .write -ds $+ $2 txt\botdef.txt
    msg $chan  $+ $2 $+  was removed from database.
  }
}
on *:Text:$( $+ $me $+ *forget*):#: {
  if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
  if $3 == $null { .msg $chan eh... what to forget? | halt }
  if $read(txt\botdef.txt,s,$3) == $null { msg $chan  $+ $2 $+  does not exist in my database. | halt }
  .write -ds $+ $3 txt\botdef.txt
  msg $chan  $+ $3 $+  was removed from database.
}
on *:Text:$( $+ $me $+ *delete*):#: {
  if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
  if $3 == $null { .msg $chan eh... what to delete? | halt }
  if $read(txt\botdef.txt,s,$3) == $null { msg $chan  $+ $2 $+  does not exist in my database. | halt }
  .write -ds $+ $3 txt\botdef.txt
  msg $chan  $+ $3 $+  was removed from database.
}
on *:Text:$( $+ $me $+ *remove*):#: {
  if $nick !isop $chan && $level($address($nick,2)) == 1 { halt }
  if $3 == $null { .msg $chan eh... what to remove? | halt }
  if $read(txt\botdef.txt,s,$3) == $null { msg $chan  $+ $2 $+  does not exist in my database. | halt }
  .write -ds $+ $3 txt\botdef.txt
  msg $chan  $+ $3 $+  was removed from database.
}
#defmode end
