Clanbot ^-^
Posted by Technique
Wednesday, August 09, 2006
Description: Clanbot Version 1.0

This is a simple clanbot created in INI's and Hash Tables. The features are Add/Edit/Del cmds, Add/Del users and Login/Logout. I took it down to update pointless lines i forgot i had. So here is the update.

;;Clanbot Version 1.0
;;Created By Technique aka Tech^_^

alias addowner {
  if (!$1) {
    echo -a Syntax: /addowner name
    halt
  }
  else {
    writeini database2.ini Admins $address($1,2) Owner
    echo -a Success: $1 has been added.
  }
}

alias loggedin {
  if ($readini(database2.ini,Loggedin,$address($nick,2))) {
    return $true
  }
  else {
    return $false
  }
}

alias admins {
  if ($readini(database2.ini,Admins,$address($nick,2))) {
    return $true
  }
  else {
    return $false
  }
}

alias deleteskeet {
  if ($readini(database.ini,Loggedin,%temp) == $true) {
    remini database.ini Loggedin %temp
    unset %temp
    msg $nick Success: %x has been deleted from the userlist.
    unset %x
  }
  else {
    unset %temp
    msg $nick Success: %x has been deleted from the userlist.
    unset %x
    halt
  }
}

alias startup {
  if (!$hget(Settings,Trigger)) {
    hadd -m Settings Trigger -
    echo -a Trigger database created.
    timertrig 0 2200 hsave Settings Trigger -o
  }
  if (!$hget(Commands)) {
    hmake Commands 10
    echo -a Command database created.
    timercmds 0 1200 hsave Commands -o
  }
}

on *:START:{
  echo -a Clanbot Version 1.0 Created By Technique
  echo -a Type /startup to create the database's.
}

on *:QUIT:{
  hsave -o Settings Trigger
  hsave -o Commands
}

on *:TEXT:*:#chan:{
  if ($left($1,1) == $hget(Settings,Trigger)) {
    %com = $right($1,-1)
    if ($hget(Commands,%com)) {
      notice $nick $hget(Commands,%com)
      halt
    }
    if (!$hget(Commands,%com)) && (%com != addcmd) && (%com != delcmd) && (%com != editcmd) && (%com != settrigger) {
      notice $nick Error: Invalid Command.
      halt
    }
    if (%com == addcmd) {
      if ($nick isop $chan) {
        if ($admins($address($nick,2)) == $true) && ($loggedin($address($nick,2)) == $true) {
          if (!$3) {
            notice $nick Syntax: $1 [COMMAND] [VALUE]
            halt
          }
          if ($hget(Commands,$2)) || ($2 == addcmd) || ($2 == delcmd) || ($2 == editcmd) || ($2 == settrigger) {
            notice $nick Error: That command already exists.
            halt
          }
          else {
            hadd Commands $2-
            notice $nick Command successfully added.
          }
          halt
        }
        else {
          notice $nick Error: You are not an admin or you are not loggedin.
          halt
        }
      }
      else {
        notice $nick Error: You are not opped in $chan $+ .
        halt
      }
    }
    if (%com == delcmd) {
      if ($nick isop $chan) {
        if ($admins($address($nick,2)) == $true) && ($loggedin($address($nick,2)) == $true) {
          if (!$2) {
            notice $nick Syntax: $1 [COMMAND]
            halt
          }
          if (!$hget(Commands,$2)) {
            notice $nick Error: That command doesn't exist.
            halt
          }
          else {
            hdel Commands $2
            notice $nick Command successfully deleted.
          }
          halt
        }
        else {
          notice $nick Error: You are not an admin or you are not loggedin.
          halt
        }
      }
      else {
        notice $nick Error: You are not opped in $chan $+ .
        halt
      }
    }
    if (%com == editcmd) {
      if ($nick isop $chan) {
        if ($admins($address($nick,2)) == $true) && ($loggedin($address($nick,2)) == $true) {
          if (!$3) {
            notice $nick Syntax: $1 [COMMAND] [VALUE]
            halt
          }
          if ($2 == addcmd) || ($2 == delcmd) || ($2 == editcmd) || ($2 == settrigger) {
            notice $nick Error: That command can't be edited.
            halt
          }
          if (!$hget(Commands,$2)) {
            notice $nick Error: That command doesn't exist.
            halt
          }
          else {
            hadd -m Commands $2-
            notice $nick Command successfully edited.
          }
          halt
        }
        else {
          notice $nick Error: You are not an admin or you are not loggedin.
          halt
        }
      }
      else {
        notice $nick Error: You are not opped in $chan $+ .
        halt
      }
    }
    if (%com == settrigger) {
      if ($nick isop $chan) {
        if ($admins($address($nick,2)) == $true) && ($loggedin($address($nick,2)) == $true) {
          if (!$2) {
            notice $nick Syntax: $1 [NEW TRIGGER]
            halt
          }
          if ($len($2) > 1) {
            notice $nick Error: The trigger can only be one character.
            halt
          }
          else {
            hadd -m Settings Trigger $2
            notice $nick Success: Trigger successfully changed.
          }
          halt
        }
        else {
          notice $nick Error: You are not an admin or you are not loggedin.
          halt
        }
      }
      else {
        notice $nick Error: You are not opped in $chan $+ .
        halt
      }
    }
  }
}

on *:TEXT:*:?:{
  if ($nick isop #chan) {
    if ($1 == login) {
      if (!$readini(database2.ini,Admins,$address($nick,2))) {
        msg $nick Error: You are not on the userlist.
        halt
      }
      if ($readini(database2.ini,Loggedin,$address($nick,2)) == $true) {
        msg $nick Error: You are already loggedin.
        halt
      }
      else {
        writeini database2.ini Loggedin $address($nick,2) $true
        msg $nick Success: You have been loggedin.
      }
    }
    if ($1 == logout) {
      if (!$readini(database2.ini,Admins,$address($nick,2))) {
        msg $nick Error: You are not on the userlist.
        halt
      }
      if (!$readini(database2.ini,Loggedin,$address($nick,2))) {
        msg $nick Error: You are not loggedin.
        halt
      }
      else {
        remini database2.ini Loggedin $address($nick,2)
        msg $nick Success: You have been logged out.
      }
    }
    if ($1 == addadmin) {
      if ($admins($address($nick,2)) == $true) && ($loggedin($address($nick,2)) == $true) {
        if (!$2) {
          msg $nick Syntax: $1 [NAME]
          halt
        }
        if ($readini(database2.ini,Admins,$address($2,2))) {
          msg $nick Error: $2 is already on the userlist.
          halt
        }
        if ($2 !ison #chan) {
          msg $nick Error: $2 is not in #chan.
          msg $nick You can add $2 manualy by going to your mIRC Directory and opening the database2.ini file and add $2 $+ 's Hostmask under [Admins]
          halt
        }
        else {
          writeini database2.ini Admins $address($2,2) Admin
          msg $nick Success: $2 has been added to the userlist.
        }
      }
      else {
        msg $nick Error: You are not an admin or you are not loggedin.
        halt
      }
    }
    if ($1 == deladmin) {
      if ($admins($address($nick,2)) == $true) && ($loggedin($address($nick,2)) == $true) {
        if (!$2) {
          msg $nick Syntax: $1 [NAME]
          halt
        }
        if ($readini(database2.ini,Admins,$address($2,2)) == Owner) {
          msg $nick Error: $2 is an owner.
          halt
        }
        if (!$readini(database2.ini,Admins,$address($2,2))) {
          msg $nick Error: $2 is not on the userlist.
          halt
        }
        if ($2 !ison #chan) {
          msg $nick Error: $2 is not in #chan
          msg $nick You can add $2 manualy by going to your mIRC Directory and opening the database2.ini file and add $2 $+ 's Hostmask under [Admins]
          halt
        }
        else {
          remini database2.ini Admins $address($2,2)
          set %temp $address($2,2)
          set %x $2
          deleteskeet
        }
      }
      else {
        msg $nick Error: You are not an admin or you are not loggedin.
        halt
      }
    }
    if ($1 == mystatus) {
      if ($admins($address($nick,2)) == $true) {
        if ($loggedin($address($nick,2)) == $true) {
          msg $nick Status: Loggedin.
          halt
        }
        else {
          msg $nick Status: Logged out.
          halt
      }
      else {
        msg $nick You are not an admin.
      }
    }
  }
}


database2.ini
[Admins]

[Loggedin]


Add yourself to the userlist by typing "/addowner [NAME]" without the "" and [].
If i get around to it il make a verison 2 with more and better features. Make sure you change #chan to your CHANNEL. Enjoy

-Technique aka Tech^_^
.
Posted by Log1x
Monday, August 14, 2006 07:56am PDT
looks good, haven't tried it though ;-]
Well...
Posted by Rustynails
Monday, August 14, 2006 04:55pm PDT
Why on earth do you use halt after every command? Instead of multiple if's why don't you use elseif? Think about it.
Halt
Posted by Technique
Tuesday, August 15, 2006 10:43pm PDT
Why because I can. I got use to it and I dont feel like switching my style. I also forgot a bracket which i just edited.
multiple channels
Posted by stefoo
Tuesday, June 26, 2007 09:08pm PDT
can u make this bot work on multiple channels?
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world