Advanced Clanbot
Posted by Ghost
Friday, March 19, 2004
Description: Made with the help of everyone in #script.

I do not take credit for this bot, even though I put a great deal of it together, but an even greater deal (doesnt make sense) came from everyone at #scroipt. Thats why its an open source project. Feel free to edit, etc. Any suggestions etc would still be greatly appreciated since I am still working on it :) .
Its made for the channel #tkoclan. Im to lazy to take that out.


On *:JOIN:#tkoclan:{
  .notice $nick [^K]15,1Welcome to [^K]7[^B][TKO][^B]. [^K]15Please type [^B][^K]4@Commands[^B] [^K]15for a list of my Commands or [^B][^K]4@About[^B][^K]15 for information about [^B][^K]7[TKO]
}
On *:TEXT:@Commands:#tkoclan:{
  if ($regex($loggedon($nick).access,^(leader|coleader)$) == 1) {
    .notice $nick [^K]15,1[^K]4Channel[^K]15 Commands Are:  [^K]4[^B]@Roster  [^B][^K]15[-r,-h,-m]  [^K]4[^B]@Site @Server @News @About @Broadcast
    .notice $nick [^K]15,1[^K]4Op[^K]15 Commands Are: [^K]4[^B]@NextMatch @ServerPass @OpNews *@Set [Command]*
    .notice $nick [^K]15,1[^K]4[^B]----@Set [^B][^K]15 can only be done through [^K]4[^B]PM[^K]15[^B]'imng the bot. For [^K]4help[^K]15, please [^K]4[^B]PM[^B][^K]15 the bot with [^B][^K]4@Set help  
  }
  else {
    .notice $nick [^K]15,1Channel Commands Are:  [^K]4[^B]@Roster  [^B][^K]15[-r,-h,-m]  [^K]4[^B]@Site @Server @News @About
  }
}
On *:TEXT:@News:#tkoclan:{
  .notice $nick [^K]15,1[^B][^K]7[TKO][^B][^K]15Clan News: %news
}
On *:TEXT:@roster *:#tkoclan:{
  if ($2 == -r) { .notice $nick  [^K]15,1[^K]7[^B][TKO]'s[^B] [^K]4Raven Shield [^K]15Roster: %roster.r }
  elseif ($2 == -h) { .notice $nick [^K]15,1[^K]7[^B][TKO]'s[^B] [^K]9Halo [^K]15Roster: %roster.h }
  elseif ($2 == -m) { .notice $nick [^K]15,1[^K]7[^B][TKO]'s[^B] [^K]12MMOG [^K]15Roster: %roster.m }
  else { .notice $nick [^K]15,1Please specify a switch command : [-r,-h,-m] }
}
On *:TEXT:@Site:#tkoclan:{
  .notice $nick [^K]15,1[TKO] site : %url
}
On *:TEXT:@Server:#tkoclan:{
  .notice $nick [^K]15,1[Servers]-[IP's]: %server.ip
}
On *:TEXT:@broadcast:#tkoclan: {
  if ($regex($loggedon($nick).access,^(leader|coleader)$) == 1) {
  .msg $chan [^K]15,1I am [TKO]Bot. Channel Commands Are:  [^K]4[^B]@Roster  [^B][^K]15[-r,-h,-m]  [^K]4[^B]@Site @Server @News @About @Broadcast  }
}
On *:TEXT:@About:#tkoclan: {
  .notice $nick %about
}
;Op Commands
On *:TEXT:@NextMatch:#tkoclan:{
  if ($regex($loggedon($nick).access,^(leader|coleader)$) == 1) {
    .notice $nick [^K]15,1Our next match is: %next.match
  }
}
on *:TEXT:@ServerPass:#tkoclan:{
  if ($regex($loggedon($nick).access,^(leader|coleader)$) == 1) {
    .notice $nick [^K]15,1Our Server Password is: %server.pass
  }
}
on *:TEXT:@Opnews:#tkoclan:{
  if ($regex($loggedon($nick).access,^(leader|coleader)$) == 1) {
    .notice $nick [^K]15,1The [^K]4Ops[^K]15 News is: %opnews
  }
}

On *:TEXT:@set *:?: {
  ;This will make the script run when ever someone PMs the Bot @Set and anything else
  ;You have to have the * in it, or else it will only respond to JUST @Set
  if ($regex($loggedon($nick).access,^(leader|coleader)$) == 1) {
    ;This will make the script only continue if they are an op in your channel
    if ($2 == $null) {
      .msg $nick [^K]15,1Error, you must input what to [^K]4[^B]Set[^B]. [^K]15For Help Type, [^B][^K]4@Set[^B] [^K]10Help
      halt
    }
    elseif ($2 == Help) {
      .notice $nick: [^K]15,1Commands for Setting the [^B][^K]4@Commands[^B][^K]15 are: [^B][^K]4@Set[^K]15 [Roster, Site, About, Server, News, Nextmatch, ServerPass, Opnews, Nick]
      .notice $nick: [^K]15,1Example: [^K]4[^B]@Set[^B] Site [^K]7www.tkolegacy.org
    }
    elseif ($2 == Roster) {
      if ($3 == -r) { set %roster.r $4- | .msg $nick [^K]15,1You have[^K]4 Set [^K]7[^B][TKO]'s[^B] [^K]4Raven Shield [^K]15Roster to: %roster.r }
      elseif ($3 == -h) { set %roster.h $4- | .msg $nick  [^K]15,1You have set [^B][^K]7[TKO]'s[^B] [^K]9Halo [^K]15Roster to: %roster.h }
      elseif ($3 == -m) { set %roster.m $4- | .msg $nick  [^K]15,1You have set [^B][^K]7[TKO]'s[^B] [^K]12MMOG [^K]15Roster to: %roster.m }
    }
    elseif ($2 == Site) {
      set %url $3-
      .msg $nick [^K]15,1You have Set the Site to: %url
    }
    elseif ($2 == About) {
      set %about $3-
      .msg $nick [^K]15,1You have Set About to: %about
    }
    elseif ($2 == Server) {
      set %server.ip $3-
      .msg $nick [^K]15,1You have Set the Sever ip to: %server.ip
    }
    elseif ($2 == News) {
      set %news $3-
      .msg $nick [^K]15,1You have Set News to: %news
    }
    elseif ($2 == Nextmatch) {
      set %next.match $3-
      .msg $nick [^K]15,1You have Set the Nextmatch to: %next.match
    }
    elseif ($2 == ServerPass) {
      set %server.pass $3-
      .msg $nick [^K]15,1You have Set the Server Password to: %server.pass
    }
    elseif ($2 == nick) {
      set %bot.nick $3-
      .msg $nick [^K]15,1You have Set the bots name to: %bot.nick
      .msg $nick [^K]15,1If the change does not the work, the name is in use.
      nick %bot.nick
    }
    elseif ($2 == opnews) {
      set %opnews $3-
      .msg $nick [^K]15,1You have Set The Op's Announcment to: %opnews
    }
    else {
      .msg $nick [^K]15,1Error, Please type [^B][^K]4@Set[^B] Help
      ;What this is doing is, if they got through all the error checking, but the @Set <command> is not reconized, it will tell them to do @Set Help
    }
  }
}
;THIS IS THE BOT LOG IN FEATURE
;KEET TRACK
;PLEASE
on *:exit: {
  var %i 1
  while (%i <= $hget(0)) {
    hsave -o $hget(%i) $+($mircdirdatabases\,$hget(%i),.dbu)
    inc %i
  }
}
on *:start: {
  var %i 1
  while (%i <= $findfile($mircdirdatabases\,*.dbu,0)) {
    hmake $nopath($remove($findfile($mircdirdatabases\,*.dbu,%i),.dbu)) 100
    hload $nopath($remove($findfile($mircdirdatabases\,*.dbu,%i),.dbu)) $nopath($findfile($mircdirdatabases\,*.dbu,%i))
    inc %i
  }
}
alias loggedon {
  if ($prop == account) return $hget(users,$address($1,2))
  elseif ($prop == access) return $hget($hget(users,$address($1,2)),access)
  else {
    if ($1 isnum) {
      return $hget(users,$1).item
    }
    else {
      return $iif($hfind(users,$address($1,2),0,w),$true,$false)
    }
  }
}
on *:text:register*:?: {
  if ($loggedon($nick) == $true) .notice $nick [^B]Error[^B]: You are already logged on.
  elseif (!$4) .notice $nick [^B]Error[^B]: Please /msg $me register account password email
  else {
    var %reg ^[_\.0-9a-zA-Z]+@([0-9a-zA-Z][0-9a-zA-Z]+\.)+[a-zA-Z]{2,3}$
    if ($regex($4,%reg) == 0) .notice $nick [^B]Error[^B]: Please enter a correct email.
    elseif ($hget($2)) .notice $nick [^B]Error[^B]: $2 is already an account.
    else {
      hmake $2 100
      hadd $2 Password $encode($3,m)
      hadd $2 Email $4
      hadd $2 Hostmask $mask($fulladdress,2)
      hadd $2 Ctime $ctime
      hadd $2 Nick $nick
      hadd $2 Access default
      hadd $2 hideemail 0
      hadd -m users $mask($fulladdress,2) $2
      .notice $nick Registration successful. You have automatically been logged on to account [^B] $+ $2 $+ [^B].
    }
  }
}
on *:text:auth*:?: {
  if ($loggedon($nick) == $true) .notice $nick [^B]Error[^B]: You are already logged on.
  elseif (!$3) .notice $nick [^B]Error[^B]: Please /msg $me auth account password
  else {
    if (!$hget($2)) .notice $nick [^B]Error[^B]: Unknown account. ( $+ $2 $+ )
    elseif ($3 != $decode($hget($2,Password),m)) .notice $nick [^B]Error[^B]: Incorrect password.
    else {
      if ($mask($fulladdress,2) != $hget($2,Hostmask)) hadd $2 Hostmask $mask($fulladdress,2)
      elseif ($nick != $hget($2,Nick)) hadd $2 Nick $nick
      hadd $2 Ctime $ctime
      hadd -m users $mask($fulladdress,2) $2
      .notice $nick Welcome back, $nick $+ .
    }
  }
}
on *:text:users:?: {
  .notice $nick Accounts on [^B] $+ $me $+ [^B]:
  var %i 1
  var %accounts 0
  while (%i <= $hget(0)) {
    if ($hget(%i) != users) && ($hget(%i) != clan) {
      .notice $nick $hget(%i) ( $+ $hget(%i,access) $+ )
      inc %accounts
    }
    inc %i
  }
  .notice $nick Totalling [^B] $+ %accounts $+ [^B] account(s).
}
on *:text:accountinfo*:?: {
  if (!$2) && ($loggedon($nick)) {
    .notice $nick Account Info for [^B] $+ $nick $+ [^B]:
    .notice $nick [^B]Account[^B]: $loggedon($nick).account
    .notice $nick [^B]Password[^B]: $decode($hget($loggedon($nick).account,Password),m)
    if ($hget($loggedon($nick).account,hideemail) == 0) {
      .notice $nick [^B]Email[^B]: $hget($loggedon($nick).account,Email)
    }
    .notice $nick [^B]Last Used Hostmask[^B]: $hget($loggedon($nick).account,Hostmask)
    .notice $nick [^B]Logged On For[^B]: $duration($calc($ctime - $hget($loggedon($nick).account,Ctime)))
    .notice $nick [^B]Infoline[^B]: $iif($hget($loggedon($nick).account,info),$($hget($loggedon($nick).account,info),2),(none))
  }
  elseif ($left($2,1) == $chr(42)) {
    if ($hget($right($2,-1))) {
      .notice $nick Account Info for [^B] $+ $right($2,-1) $+ [^B]:
      .notice $nick [^B]Account[^B]: $right($2,-1)
      if ($loggedon($nick).account == $right($2,-1)) {
        .notice $nick [^B]Password[^B]: $decode($hget($right($2,-1),password),m)
      }
      if ($hget($right($2,-1),hideemail) == 0) {
        .notice $nick [^B]Email[^B]: $hget($right($2,-1),email)
      }
      .notice $nick [^B]Last Used Hostmask[^B]: $hget($right($2,-1),hostmask)
      .notice $nick [^B]Last Seen On[^B]: $hget($right($2,-1),nick)
      .notice $nick [^B]Logged On For[^B]: $duration($calc($ctime - $hget($right($2,-1),ctime)))
      .notice $nick [^B]Infoline[^B]: $iif($hget($right($2,-1),info),$($hget($right($2,-1),info),2),(none))
    }
    elseif (!$hget($right($2,-1)) .notice $nick [^B]Error[^B]: Unknown account. ( $+ $right($2,-1) $+ )
  }
  else {
    if (!$loggedon($2)) .notice $nick [^B]Error[^B]: $2 is not logged on.
    elseif ($loggedon($2)) {
      .notice $nick Account Info for [^B] $+ $2 $+ [^B]:
      .notice $nick [^B]Account[^B]: $loggedon($2).account
      if ($loggedon($2).account,hideemail) == 0) {
        .notice $nick [^B]Email[^B]: $hget($loggedon($2).account,email)
      }
      .notice $nick [^B]Last Used Hostmask[^B]: $hget($loggedon($2).account,hostmask)
      .notice $nick [^B]Logged On For[^B]: $duration($calc($ctime - $hget($loggedon($2).account,ctime)))
      .notice $nick [^B]Infoline[^B]: $iif($hget($loggedon($2).account,info),$($hget($loggedon($2).account,info),2),(none))
    }
  }
}
on *:text:access*:?: {
  if (!$2) {
    if (!$loggedon($nick)) .notice $nick [^B]Error[^B]: Log in or specify a nickname/account to check.
    elseif ($loggedon($nick)) {
      .notice $nick $nick has the access level [^B] $+ $loggedon($nick).access $+ [^B].
    }
  }
  elseif ($2) {
    if ($left($2,1) == $chr(42)) {
      if ($hget($right($2,-1))) {
        .notice $nick $right($2,-1) has the access level [^B] $+ $loggedon($nick).access $+ [^B].
      }
      elseif (!$hget($right($2,-1))) .notice $nick [^B]Error[^B]: Account doesn't exist. ( $+ $right($2,-1) $+ )
    }
    else {
      if (!$loggedon($2)) .notice $nick [^B]Error[^B]: $2 is not logged on. Please use *account.
      elseif ($loggedon($2)) {
        .notice $nick $2 ( $+ $loggedon($2).account $+ ) has the access level [^B] $+ $loggedon($2).access $+ [^B].
      }
    }
  }
}
on *:text:-access*:#: {
  if (!$2) {
    if (!$loggedon($nick)) .notice $nick [^B]Error[^B]: Log in or specify a nickname/account to check.
    elseif ($loggedon($nick)) {
      .notice $nick $nick has the access level [^B] $+ $loggedon($nick).access $+ [^B].
    }
  }
  elseif ($2) {
    if ($left($2,1) == $chr(42)) {
      if ($hget($right($2,-1))) {
        .notice $nick $right($2,-1) has the access level [^B] $+ $loggedon($nick).access $+ [^B].
      }
      elseif (!$hget($right($2,-1))) .notice $nick [^B]Error[^B]: Account doesn't exist. ( $+ $right($2,-1) $+ )
    }
    else {
      if (!$loggedon($2)) .notice $nick [^B]Error[^B]: $2 is not logged on. Please use *account.
      elseif ($loggedon($2)) {
        .notice $nick $2 ( $+ $loggedon($2).account $+ ) has the access level [^B] $+ $loggedon($2).access $+ [^B].
      }
    }
  }
}
on *:text:clvl*:?: {
  if ($regex($loggedon($nick).access,(leader|coleader)) == 0) .notice $nick [^B]Error[^B]: You lack sufficient access to use that command.
  elseif (!$3) .notice $nick [^B]Error[^B]: Please use /msg $me clvl nick|*account newlevel
  elseif ($left($2,1) != $chr(42)) && (!$loggedon($2)) .notice $nick [^B]Error[^B]: $2 is not logged on. Please use *account.
  elseif (!$hget($iif($left($2,1) == $chr(42),$right($2,-1),$loggedon($2).account))) .notice $nick [^B]Error[^B]: Account $2 doesn't exist.
  else {
    if ($left($2,1) == $chr(42)) {
      if ($hget($right($2,-1),access) == $3) .notice $nick [^B]Error[^B]: $2 already has the access level [^B] $+ $3 $+ [^B].
      elseif ($hget($right($2,-1),access) != $3) {
        hadd $right($2,-1) access $3
        .notice $nick Change successful. $2 now has the access level [^B] $+ $3 $+ [^B].
      }
    }
    else {
      if (!$loggedon($2)) .notice $nick [^B]Error[^B]: $2 is not logged on. Please use *account.
      elseif ($loggedon($2)) {
        if ($hget($loggedon($2).account,access) == $3) .notice $nick [^B]Error[^B]: $2 already has the access level [^B] $+ $3 $+ [^B].
        else {
          hadd $loggedon($2).account access $3
          .notice $nick Change successful. $2 ( $+ $loggedon($2).account $+ ) now has the access level [^B] $+ $3 $+ [^B].
        }
      }
    }
  }
  }on *:text:uset*:?: {
    if (!$loggedon($nick)) .notice $nick [^B]Error[^B]: Please login before trying to access that command.
    else {
      if (!$2) {
        .notice $nick Possible [^B]user settings[^B]:
        .notice $nick /msg $me uset email <email@host.com> (Set your email)
        .notice $nick /msg $me uset password <password> (Set your password)
        .notice $nick /msg $me uset hideemail 1|0 (Hide your email from others (accountinfo) with 1, don't hide it with 0)
        .notice $nick /msg $me uset info <info> (Set your infoline(displayed in accountinfo))

      }
      elseif ($2) && ($3)  {
        if ($2 == hideemail) {
          if ($3 == $hget($loggedon($nick).account,hideemail)) .notice $nick The setting [^B]hide email[^B] is already set to $hget($loggedon($nick).account,hideemail) $+ .
          elseif ($regex($3,^[0-1]$) == 0) .notice $nick [^B]Error[^B]: Please use [^B]1[^B] or [^B]0[^B] as the setting. (eg. /msg $me uset email 1)
          else {
            hadd $loggedon($nick).account hideemail $3
            .notice $nick The user setting [^B]hide email[^B] is now set to: $3
          }
        }
        elseif ($2 == info) {
          if ($3- == $hget($loggedon($nick).account,info)) .notice $nick The setting [^B]infoline[^B] is already set to $hget($loggedon($nick).account,info)
          else {
            hadd $loggedon($nick).account info $3-
            .notice $nick The user setting [^B]infoline[^B] is now set to: $3-
          }
        }
        elseif ($2 == email) {
          var %reg ^[_\.0-9a-zA-Z]+@([0-9a-zA-Z][0-9a-zA-Z]+\.)+[a-zA-Z]{2,3}$
          if ($regex($3,%reg) == 0) .notice $nick [^B]Error[^B]: Please insert a correct email. (email@host)
          elseif ($3 == $hget($loggedon($nick).account,email)) .notice $nick The setting [^B]email[^B] is already set to $hget($loggedon($nick).account,email)
          else {
            hadd $loggedon($nick).account email $3
            .notice $nick The user setting [^B]email[^B] is now set to: $3
          }
        }
        elseif ($2 == password) {
          if  ($encode($3,m) == $hget($loggedon($nick).account,password)) .notice $nick [^B]Error[^B]: The user setting [^B]password[^B] is already set to $decode($hget($loggedon($nick).account,password),m) $+ .
          else {
            hadd $loggedon($nick).account password $encode($3,m)
            .notice $nick The user setting [^B]password[^B] is now set to: $3
          }
        }
      }
    }
  }
One Bug
Posted by Ghost
Friday, March 19, 2004 08:12pm PST
For me, slips log in system didnt load properly.
Hrmm
Posted by CrashB
Saturday, March 20, 2004 08:19am PST
this might be a little big to be a snippet, but I dunno, thats just me I suppose...
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world