Bot variables manager

By Kyousoukyoku on Oct 21, 2007

In code documentation.

/*
Documentation;
Snippet;Variables manager bot version
Author;Kyou./XN.
Release;Oct;21;07
*******************************************
Initially got this idea from a snippet request on the forums. Just edited the submission a whole lot more. This snippet allows you to add variables, remove variables, view variables, and edit variables in your bot's variables data base. Please note that if you do not type in % with the variables name, it will include it automatically. This applies to each command throughout the snippet.
Syntax:
For adding variables, !addvariable <variable name> <variable data>.  For removing variables, !remvariable <variable name>. For editing variables, !editvariable <variable name> <variable data>. For displaying variables, !displayvariable <variable name>. To set the owner for the script, /setowner <nick>.

Ripping is fobidden, don't try it.

- Kyousoukyoku/XteNsion
*/

on *:TEXT:!addvariable *:#:{ 
  if ($nick = %owner && $3-) {
    if (!$var($2)) {  
      set $iif($left($2,1) = %,$2,$+(%,$2)) $3-
    }
    elseif ($var($2)) { .notice $nick Variable $2 exists. }
  }
  elseif ($nick != %owner) { .notice $nick You are not my owner. }
  elseif (!$3-) { .notice $nick Invalid syntax, correct: !addvariable (var name) (var data) }
}

on *:TEXT:!remvariable *:#:{ 
  if ($nick = %owner && $var($2)) { 
    unset $iif($left($2,1) = %,$2,$+(%,$2)) 
    .timer 1 2 notice $nick Variable $2 unset. 
  }
  elseif ($nick != %owner) { .notice $nick You are not my owner. }
  elseif (!$2) { .notice $nick You have not specified a variable. } 
  elseif (!$var($2)) { .notice $nick Variable $gt($2) does not exist in database. }
}

on *:TEXT:!displayvariable *:#:{ 
  if ($nick = %owner && $2) { 
    if ($var($2)) { 
      .notice $nick Data for $iif($left($2,1) != %,$+(%,$2),$2) is $($iif($left($2,1) != %,$+(%,$2),$2),2) 
    }
    elseif (!$var($2)) { .notice $nick Variable $2 does not exist! }
  }
  elseif ($nick != %owner) { .notice $nick You are not my owner. }
  elseif (!$2) { .notice $nick Incorrect syntax, correct: !displayvariable (var name) }
} 

on *:TEXT:!editvariable *:#:{
  if ($nick = %owner && $3-) { 
    if ($var($2)) { 
      set $iif($left($2,1) = %,$2,$+(%,$2)) $3-
      .notice $nick New data for variable $2 is now $3- $+ .
    }
    elseif (!$var($2)) { .notice $nick Variable $2 does not exist. }
  }
  elseif ($nick != %owner) { .notice $nick You are not my owner. }
  elseif (!$3-) { .notice $nick Incorrect syntax, correct: !editvariable (var name) (data) }
}

alias setowner { if ($1) {  set %owner $1 } }

Comments

Sign in to comment.
gooshie   -  Oct 07, 2010
alias setowner auser owner $$1
on $owner:TEXT:/^!(add|rem|display|edit)variable( .+)?/iS:#:{
  tokenize 32 $regml(1) $regml(2)
  if $1 = add {
    if $3 {
      if $var($2) { .notice $nick Variable $2 exists. }
      else { set $iif($left($2,1) = %,$2,$+(%,$2)) $3- }
    }
    else { .notice $nick Invalid syntax, correct: !addvariable (var name) (var data) }
  }
  if $1 = rem { 
    if !$2 { .notice $nick You have not specified a variable. } 
    elseif $var($2) { 
      unset $iif($left($2,1) = %,$2,$+(%,$2)) 
      .timer 1 2 notice $nick Variable $2 unset. 
    }
    else { .notice $nick Variable $qt($2) does not exist in database. }
  }
  if $1 = display { 
    if $2 { 
      if $var($2) { 
        .notice $nick Data for $iif($left($2,1) = %,$2,$+(%,$2)) is $($iif($left($2,1) = %,$2,$+(%,$2)),2) 
      }
      else { .notice $nick Variable $2 does not exist! }
    }
    else { .notice $nick Incorrect syntax, correct: !displayvariable (var name) }
  } 
  if $1 = edit {
    if $3 { 
      if $var($2) { 
        set $iif($left($2,1) = %,$2,$+(%,$2)) $3-
        .notice $nick New data for variable $2 is now $3- $+ .
      }
      else { .notice $nick Variable $2 does not exist. }
    }
    else { .notice $nick Incorrect syntax, correct: !editvariable (var name) (data) }
  }
}
______________________________________________________________________________________________________________
 Respond  
Massivity   -  Oct 07, 2010

Simply Awesome
thanks for this scrippt

but i've got a little question is it possible to make a !backupvariables command so as it creates an backupvar.ini and saves all the vars?

 Respond  
Kyousoukyoku   -  Oct 21, 2007

Thanks Zsadist. Updating it now.

 Respond  
Zsadist   -  Oct 21, 2007

But other than that it is well done

 Respond  
Zsadist   -  Oct 21, 2007

First off, not to critisize, but, for the on :text: You need to make it on :text:!addvariable *: instead, because then someone can just easily !addvariabledkhjdfd and it would still work :(

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.