Bot alias bind system

By Bobbtyisdead on Jan 09, 2010

This was a system I put together on the concept of single on text and allow binds, a system system which allowed people to construct a script more modularly.

You can:
Set commands to run on any command trigger (check spam count?)
Set commands to run only on command match (increase spam count?)

Bind commands into the system just by making an alias.

The script already has an output handler, and will vary its reply method based on how its triggered.

output type 'chan' will notice the user on . or ! and message the chan on @.
output type 'forcechan' will message the chan on all binds.
output type 'notice' will always notice the user on all binds.
output type 'error' sends a message to a admin channel. (You will probably want to replace #kh in both places in the script)
output type 'halt' will return and do nothing. (Useful when you don't want to use the output handler)

Example:
alias botcmd_rawr {
return chan LIKE RAWR!
}

^ this above will listen for !rawr or .rawr events and reply in notice, or on @rawr it will send the message to the channel

on $*:TEXT:/^[!.@].+/Si:#kh: {
var %cmd = $right($1,-1)

; If you want to modify or run some checks for each command do so here
; This could be a good place to add some spam checks

  var %cmd = botcmd_ $+ %cmd
  if ($isalias(%cmd)) {

; This would be a good place to put commands you only want to run on matching commands.

    var %output = $eval($ $+ %cmd $+ ( $+ $!1- $+ ),2) 
    output $1 %output
  }
  return
  :error
  if (*no such identifier*botcmd* !iswm  $error) {
    logerror $error
  }
  reseterror
}

alias logerror {
  msg #kh Script Error: $1-
}

alias output {
  if ($2 == error) {
    msg #kh Script Warning: $3-
  }
  elseif ($2 == halt) {
    return
  }
  elseif (($left($1,1) == !) || ($left($1,1) == .)) {
    if ($2 == forcechan) {
      msg $chan $3-
    }
    else {
      notice $nick $3-
    }
  }
  else {
    if (($2 == chan) || ($2 == forcechan)) {
      msg $chan $3-
    } 
    else {
      notice $nick $3-
    }
  }
}

;This is the syntax for adding commands
alias botcmd_rawr {
  return chan LIKE RAWR!
}

alias botcmd_error {
  errortest
}

Comments

Sign in to comment.
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.