### this encrypts the passwords and allows special strings to be sent too ;>

^on ^set "botlist *" {
  @ a.botlist = [$1-]}

^set botlist $G requesting ops on $0 from $1..

alias addbot {
  if ((pattern(#* $*) && [$2]) || (!pattern(#* $*) && [$1])) {
    ^local aa ${leftw(1 $filter(#* $*)) =~ [*!*@*] ? [$0] : [$0!] ## maskhost($_userhost($0))}
    ^local cc ${pattern(#* $*) ? leftw(1 $pattern(#* $*)) : C}
    if (after(! $aa)) {
      @ setitem(botlist $numitems(botlist) $aa $cc ${rightw(${#filter(#* $*)-2} $filter(#* $*)) ? kcrypt($strip(# $cc) $rightw(${#filter(#* $*)-1} $filter(#* $*))) : kcrypt($strip(# $cc) op $rightw(1 $filter(#* $*)))})
      ge added bot \"$aa\" to the botlist for $(cc).} else {
      ge \"$0\" is not currently on irc. try using the full hostmask.}} else {
    ausage addbot}}

alias unbot {
  if ([$0]) {
    fe ($reverse($getmatches(botlist $0* % *))) aa {
      ge removed "$word(0 $getitem(botlist $aa))\" from the botlist for $word(1 $getitem(botlist $aa)).
      @delitem(botlist $aa)}} else {
      ausage unbot}}

alias botlist {
  if (numitems(botlist)) {
    ^local aa
    for (@xx=0, xx < numitems(botlist), @xx++) {
      push aa $before(! $getitem(botlist $xx))}
    ^local bb $_ison($aa)
    echo $box.head()
    echo $box.echo_head($(c.hk)[$(cl)channel$(c.hk)..... $(cl)botmask$(c.hk)...................................... $(cl)status$(c.hk)....])
    for (@lb.c=0,lb.c<numitems(botlist),@lb.c++) {
      echo $box.echo($(c.hk)[$(c.hw)$numdots(12 $word(1 $getitem(botlist $lb.c))) $(c.lc)$numdots(45 $word(0 $getitem(botlist $lb.c))) $(c.hw)$numdots(10 ${match($before(! $getitem(botlist $lb.c)) $bb)?[online]:[offline]})]$(cl))}
    echo $box.footer()} else {
    ge the botlist is empty.}}

alias setpass {
  if ([$1-]) {
    ^local aa $matchitem(botlist $0*)
    if (aa>-1) {
      @setitem(botlist $aa $leftw(2 $getitem(botlist $aa)) ${[$2-]?kcrypt($strip(# $word(1 $getitem(botlist $aa))) $2-):kcrypt($strip(# $word(1 $getitem(botlist $aa))) op $1)})
      ge changed password of \"$word(0 $getitem(botlist $aa))\".} else {
      ge no bots were found matching \"$0\".}} else {
   ausage setpass}}

alias reqops {
  ^local dd ${ischannel($0)?[$0]:C}
  ^local bb
  ^local cc $ocuhost($dd)
  fe ($getmatches(botlist % $dd *)) aa {
    @ cc =~ [*$word(0 $getitem(botlist $aa))*] ? push(bb $before(! $getitem(botlist $aa))&$word(2 $getitem(botlist $aa))):}
  if (bb) {
    ^msg $before(& $word(0 $bb)) $kcrypt($strip(# $dd) $after(& $word(0 $bb)))
    echo $cparse("$a.botlist" $dd $before(& $word(0 $bb)))}}
alias savebot {
  savearray $a.botfile botlist ge loaded botlist created $strftime(%x)@$strftime(%X).
  ge the botlist has been saved in $a.botfile}
alias opbots {
  if (numitems(botlist)) {
    ge opping all bots on the botlist...
    for (@xx=0, xx < numitems(botlist), @xx++) {
      ^local aa $getitem(botlist $xx)
      if (ischanop($N $word(1 $aa))) {
        mode $word(1 $aa) +o $before(! $word(0 $aa))}}} else {
    ge the botlist is empty.}}

alias botsave savebot $*
alias rembot unbot $*
alias listbot botlist
#psy/sjk'97
