Bot Skeleton 1
Posted by HellRaz0r
Friday, July 20, 2007
Description: Bot Template.


on *:start:{
  set %bot-nick BotNick
  set %bot-server irc.address.com
  set %bot-network NetWork
  set %bot-master *!*@addr1 *!*@addr2
  set %bot-chan #chan
  set %bot-authserv user pass

  nick %bot-nick
  server %bot-server


  if (!%bot-trig) set %bot-trig @
  if (!%bot-skin) set %bot-skin 1

  if ($exists(binds.db)) {
    hmake binds
    hload binds binds.db
  }
}

on *:connect:{
  if ($network == %bot-network) {
    mode $me +x
    if (%bot-authserv) as auth $v1
    if (%bot-chan) join $v1
  }
}

on *:text:*:%bot-chan:{
  var %master = $iif($istok(%bot-master,$wildsite,32),1,0)
  var %isop = $iif($nick isop $chan,1,0), %isvoice = $iif($nick isvoice $chan,1,0)

  if (%bot-trig $+ * !iswm $1) halt
  tokenize 32 $right($1-,-1)

  if ($hget(Binds,$1-)) msg $chan $skin(%bot-skin,$1,$v1)

  elseif ($1 == Bind) && ((%isop) || (%master)) {
    if (!$3) {
      var %error = Invalid syntax, use like this: %bot-trig $+ Bind <Name> <Text>
      notice $nick $skin(%bot-skin,$1,%error)
    }
    else {
      hadd -m Binds $2 $3-
      hsave Binds binds.db
      notice $nick $skin(%bot-skin,$1,Successfully bound $qt($2) to $qt($3-))
    }
  }
  elseif ($1 == Unbind) && ((%isop) || (%master)) {
    if (!$2) {
      var %error = Invalid syntax, use like this: %bot-trig $+ Unbind <Name>
      notice $nick $skin(%bot-skin,$1,%error)
    }
    elseif (!$hget(binds,$2)) notice $nick $skin(%bot-skin,$1,That bind doesnt exist.)
    else {
      hdel -sw binds $2
      hsave Binds binds.db
      notice $nick $skin(%bot-skin,$1,Successfully unbound $qt($2))
    }
  }
  elseif ($1- == Binds) || ($1- == Commands) && ((%isop) || (%master)) {
    var %x = 1, %t = %bot-trig, %cmds = %t $+ Bind %t $+ Binds %t $+ Unbind - %t $+ Set <Trigger|Skin|Topic> - %t $+ Topic
    while ($hfind(binds,*,%x,w)) {
      var %bind = $v1, %binds = %binds $iif($1 == Commands,@ $+ %bind,%bind)
      inc %x
    }
    if (%binds) notice $nick $skin(%bot-skin,$1,$iif($1 == binds,%binds,%cmds - %binds))
    elseif ($1 == Commands) notice $nick $skin(%bot-skin,$1,%cmds)
    else notice $nick $skin(%bot-skin,$1,No binds exist.)
  }
  elseif ($1 == Set) && ((%isop) || (%master)) {
    if ($2 == Trigger) && (%master) {
      if (!$3)  {
        var %error = Invalid syntax, use like this %bot-trig $+ Set Trigger <Character>
        notice $nick $skin(%bot-skin,$1-2,%error)
      }
      elseif ($len($3) > 1) notice $nick $skin(%bot-skin,$1,You must use a single character for the trigger.)
      else {
        set %bot-trig $3
        notice $nick $skin(%bot-skin,$1-2,Successfully changed the trigger.)
      }
    }
    elseif ($2 == Skin) && (%master) {
      if ($3 !isnum 1-2) {
        var %error = Invalid syntax, use like this: %bot-trig $+ Set Skin < $+ $v2 $+ >
        notice $nick $skin(%bot-skin,$1-2,%error)
      }
      else {
        set %bot-skin $3
        notice $nick $skin(%bot-skin,$1-2,Successfully changed skin.)
      }
    }
    elseif ($2 == Topic) {
      if (!$3-) {
        var %error = Invalid syntax, use like this: %bot-trig $+ Set Topic [Section] <Text>
        notice $nick $skin(%bot-skin,$1-2,%error)
      }
      else {
        _topic $chan $3-
        notice $nick $skin(%bot-skin,$1-2,Successfully changed the topic.)
      }
    }
  }
  elseif ($1 == Topic) && (%isop) {
    echo -a Topic
    if (!$2-) {
      var %error = Invalid syntax, use like this: %bot-trig $+ Topic [Section] <Text>
      notice $nick $skin(%bot-skin,$1,%error)
    }
    else {
      _topic $chan $2-
      notice $nick $skin(%bot-skin,$1,Successfully changed the topic.)
    }
  }
  elseif ($1 == Help) {
    if ($2 == $null) notice $nick $skin(%bot-skin,$1,[^B]Help[^B]: %bot-trig $+ Help [Bind|Unbind|Binds|Set|Topic])
    elseif ($2- == Bind) notice $nick $skin(%bot-skin,$+($1,->,$2),Binds some text to a command. - Syntax: %bot-trig $+ Bind <Name> <text>)
    elseif ($2- == Unbind) notice $nick $skin(%bot-skin,$+($1,->,$2),Unbinds a command. - Syntax: %bot-trig $+ Unbind <Name>)
    elseif ($2- == Binds) notice $nick $skin(%bot-skin,$+($1,->,$2),Shows the list of binds. - Syntax: %bot-trig $+ Binds)
    elseif ($2- == Topic) notice $nick $skin(%bot-skin,$+($1,->,$2),Changes the specified Section or whole topic. - Syntax: %bot-trig $+ Topic [Section] <text>
    elseif ($2 == Set) {
      if ($3 == $null) notice $nick $skin(%bot-skin,$+($1,->,$2),Set: %bot-trig $+ Help Set [Trigger|Skin|Topic])
      elseif ($3- == Trigger) notice $nick $skin(%bot-skin,$+($1,->,$2,->,$3),Changes the bot command trigger. - Syntax: %bot-trig $+ Set Trigger <Character>)
      elseif ($3- == Skin) notice $nick $skin(%bot-skin,$+($1,->,$2,->,$3),Changes the bot skin. - Syntax: %bot-trig $+ Set Skin <1-2>)
      elseif ($3- == Topic) notice $nick $skin(%bot-skin,$+($1,->,$2,->,$3),Changes the specified Section or whole topic. - Syntax: %bot-trig $+ Set Topic [Section] <text>)
      else notice $nick $skin(%bot-skin,$+($1,->,$2,->,$3),Help topic not found.)
    }
    else notice $nick $skin(%bot-skin,$1,Help topic not found.)
  }
}
alias _topic {
  var %chan = $$1, %section = $$2, %text = $3-
  var %topic = $chan(%chan).topic, %exp = /\Q $+ %section $+ \E:(?=(.*?)[^\s]+:|(.+))/i
  if ($regex(%topic,%exp)) if ($regsubex(%topic,/( $+ %section $+ :)(.*?)((\S+:)|$)/i,\1 %text \3)) topic %chan $v1
  else topic %chan $2-
}
alias skin {
  if ($1 == 1) { return [^K]15,1[[^K]14,1«[^K]0,1»[^K]15,1 [^K]9 $+ $2 [^K]0,1«[^K]14,1»[^K]15,1]: [^K]4,1 $+ $3- $+ [^O] }
  elseif ($1 == 2) { return [^K]15,1[[^K]14,1«[^K]0,1»[^K]15,1 [^K]4 $+ $2 [^K]0,1«[^K]14,1»[^K]15,1]: [^K]9,1 $+ $3- $+ [^O] }
  else return $3-
}
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world