Xdcc Search Bot Script 2.8

By Yoinx on Dec 05, 2004

This is my xdcc search script. I have been working on it for quite some time for people to implement new features etc. If you have any suggestions for things that should be added, leave a not in the comments here. Also, if you notice any bugs let me know via the comments. You can also email me at the email address in the credits.

Directions:

You must create a file called searchbot.ini I'd place it into a subfolder, you'll need to place this script in the same directory.

Searchbot.ini :



[passwords]

owner=Ownerpass

admin=Adminpass

op=Oppass

[searchbot]

maxresults=5

enable=1

ignore=60

failed.searches=0

flood=5

indexchan=#chan1,#chan2

successful.searches=0

trigger=!search,@find

default=This is the Default Advertisement. Please have someone create a custom advertisement for your channel.

network=yournet

floodtime=60



The passwords ARE case-sensitive.




After you make this ini, load the script by pasting it in your remotes then going to File>Save as and saving it to the same directory as searchbot.ini. I would recommend not running the initialization commands until after you save it in the proper directory. Then just close and re-open mirc.



The bot is configured with the main configuration settings. Once it joins your channel you should Private message it with:

/msg botnick login Ownerpass

then

/msg botnick Help



read the help that it plays to you, play and enjoy.


Disclaimer: I do not approve of people using xdcc for illegal purposes. However since xdcc can be used for trading file that are not illegal. I'll post this.





This script as with all of mine is open to anyone for modifications. You dont have to ask, and I only ask that you include some sort of credit or a link back to this snippet.

;############################
;#
;# XDCC Searchbot Script
;#
;############################
;# To Do:
;# Low Priority: Add A Pm trigger to change new release trigger/time, request enable disable
;# Medium Priority: Update the help, change the method it displays its help with
;#############################
; Startup/Shutdown Events
;#############################
;#
;# Loads Settings, Makes required Directories to prevent errors.
;#
on *:start: {
  sb.startup
}
on *:unload: {
  sb.close
}
;#
;# Saves Settings and indexes
on *:exit: {
  sb.close
}
;#
;# Makes the bot join its channels. Starts timers to save indexes and check for old releases.
on *:connect: {
  if ( $network == $hget(searchbot.settings,network) ) && ( $hget(searchbot.settings,enable) == 1 ) {
    join $hget(searchbot.settings,indexchan)
    .timersearchbotsave 0 600 sb.saveindexes
  }
}
on me:*:Join:#: {
  if ($istok($hget(searchbot.settings,indexchan),$chan,44)) {
    $+(.,timer,check.releases.,$chan) 0 600 sb.checkreleasetimes $chan
    if ($hget(searchbot.settings,$+($chan,.adtime))) {
      if (!$hget(searchbot.settings,$+($chan,.advert))) && ($hget(searchbot.settings,default)) {
        $+(.,timer,$chan,.advert) 0 $hget(searchbot.settings,$+($chan,.adtime)) .msg $chan $hget(searchbot.settings,default)
      }
      elseif ($hget(searchbot.settings,$+($chan,.advert))) {
        $+(.,timer,$chan,.advert) 0 $hget(searchbot.settings,$+($chan,.adtime)) .msg $chan $hget(searchbot.settings,$+($chan,.advert))
      }
    }
  }
}
;#
;# Advertises version
;#
ctcp *:VERSION:*:/ctcpreply $nick VERSION Searchbot 2.8
;#
;# Enables you to turn the bot on.
menu channel {
  $iif($hget(searchbot.settings,enable) == 1, Turn Searchbot off, Turn Searchbot on):$iif($hget(searchbot.settings,enable) == 1, hadd searchbot.settings enable 0, hadd -m searchbot.settings enable 1)
}
;# Code to allow remote bot updates. Only allows searchbot.mrc , creates backups. Only Owners will have access to this.
;#
on *:filercvd:*: {
  if (!$hget(searchbot.sessions,$nick))  {
    .remove $+(",$filename,")
    .msg $nick You're send has been removed.
  }
  elseif ( $nopath($filename) == searchbot.mrc ) && ($hget(searchbot.sessions,$nick)) {
    .copy $+(",$scriptdir,searchbot.mrc,") $+(",$scriptdir,backup/,$asctime(mmm-dd-yyyy-HH-mm-ss),-searchbot.mrc,") 
    .copy -o $+(",$filename,") $+(",$scriptdir,searchbot.mrc,")
    .remove $+(",$filename,")
    .timer 1 1 .msg $nick Script Successfully Backed Up and Reloaded.
    .close -g $nick
    .reload -rs $+(",$scriptdir,searchbot.mrc,")
  }
}
;# Disables dcc ignore if an owner tries to send an update and itis ignored.
on *:getfail:*: {
  if ( $nopath($filename) == searchbot.mrc ) && ($hget(searchbot.sessions,$nick)) {
    .msg $nick Please resend the file. Ignore is now turned off.
  }
}
;#####################
; Searchbot Aliases
;#####################
;#
;# Startup/Shutdown Aliases
;# No Parameters are passed to any aliases in the Startup/Shutdown Aliases. Other Sections have examples with each alias.
;# 
;# Startup events
alias sb.startup {
  hfree -w searchbot.*
  hmake searchbot.settings
  if (!$isdir($+(",$scriptdirdata/,"))) mkdir $+(",$scriptdirdata/,")
  if ( $readini($+(",$scriptdir,searchbot.ini,"),n,Searchbot,enable) == $null ) {
    hadd -m searchbot.settings enable 1
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,enable) == 1 ) {
    hadd -m searchbot.settings enable 1
    server $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,server)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,requests.enable) ) {
    hadd searchbot.settings requests.enable $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,requests.enable)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,network) ) {
    hadd searchbot.settings network $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,network)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,trigger) ) {
    hadd searchbot.settings trigger $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,trigger)  
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,indexchan) ) {
    hadd searchbot.settings indexchan $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,indexchan)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,maxresults) ) {
    hadd searchbot.settings maxresults $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,maxresults)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,release.trigger) ) {
    hadd searchbot.settings release.trigger $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,release.trigger)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,release.time) ) {
    hadd searchbot.settings release.time $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,release.time)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,flood) ) {
    hadd searchbot.settings flood $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,flood)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,floodtime) ) {
    hadd searchbot.settings floodtime $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,floodtime)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,ignore) ) {
    hadd searchbot.settings ignore $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,ignore)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,failed.searches) ) {
    hadd searchbot.settings failed.searches $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,failed.searches)
  }
  if ( $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,successful.searches) ) {
    hadd searchbot.settings successful.searches $readini($+(",$scriptdirsearchbot.ini,"),n,Searchbot,successful.searches)
  }
  mkdir $+(",$scriptdir,update,")
  mkdir $+(",$scriptdir,backup,")
  if (!$hget(searchbot.settings,default)) {
    hadd -m searchbot.settings default This is the Default Advertisement. Please have someone create a custom advertisement for your channel.
  }
  sb.findhashes
}
;# Alias to save indexes stored in hash tables to hard drive.
alias sb.saveindexes {
  hsave -i searchbot.settings $+(",$scriptdir,searchbot.ini,") searchbot
  if ( !$isdir($+(",$scriptdir,data,")) ) mkdir $+(",$scriptdir,data,")
  var %x = 1
  while ( %x <= $hget(0) ) {
    if ( $gettok($hget(%x),1,46) == searchbot ) && ( $gettok($hget(%x),2,46) != settings ) && ( $gettok($hget(%x),2,46) != search ) && ( $gettok($hget(%x),2,46) != sessions ) && ( $gettok($hget(%x),2,46) != flood ) {
      .hsave -o $hget(%x) $+(",$scriptdir,data\,$mkfn($hget(%x)),.dat,")
    }
    inc %x
  }
}
;# Alias to find stored hash tables.
alias sb.findhashes {
  var %x = 1
  while ( %x <= $findfile($+(",$scriptdir,data/,"),*.dat,0) ) {
    .echo -q $findfile($+(",$scriptdir,data/,"),*.dat,%x,sb.makehashes $1-)
    inc %x
  }
}
;# Alias to make the hash tables and load any indexes that have been stored on the hard drive
alias sb.makehashes {
  if ( *#* iswm $nopath($1-)) {
    if ( $istok($hget(searchbot.settings,indexchan),$wildtok($nopath($1-),#*,1,46),44) ) {
      hmake $left($nopath($1-),-4)
      hload $left($nopath($1-),-4) $+(",$1-,")
    }
  }
  ;  if ( $gettok($left($nopath($1-),-4),2,46) == settings ) halt
  else {
    hmake $left($nopath($1-),-4)
    hload $left($nopath($1-),-4) $+(",$1-,")
  }
}
;# Alias to perfrom when closing the searchbot.
alias sb.close {
  sb.saveindexes
  if ($hget(searchbot.settings,enable) == 1)  writeini $+(",$scriptdirsearchbot.ini,") Searchbot enable $hget(searchbot.settings,enable)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot trigger $hget(searchbot.settings,trigger)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot indexchan $hget(searchbot.settings,indexchan)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot maxresults $hget(searchbot.settings,maxresults)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot releasetrig $hget(searchbot.settings,release.trigger)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot releasetime $hget(searchbot.settings,release.time)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot flood $hget(searchbot.settings,flood)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot floodtime $hget(searchbot.settings,floodtime)
  writeini $+(",$scriptdirsearchbot.ini,") Searchbot ignore $hget(searchbot.settings,ignore)
  unset %searchbot.*
}
;# Alias to check release times of things in the new releases hash table. Removes outdated items.
alias sb.checkreleasetimes {
  if ($hget($+(searchbot.,$1,.newreleases),0).item == 0) halt
  else {
    var %x = 1
    while ( %x <= $hget($+(searchbot.,$1,.newreleases),0).item) {
      if ($hget($+(searchbot.,$1,.newreleases),%x).item >= $calc($ctime - $hget(searchbot.settings,release.time))) {
        hdel $+(searchbot.,$1,.newreleases) $hget($+(searchbot.,$1,.newreleases),%x).item
      }
      inc %x
    }
  }
}
;###################
;# Searching Aliases
;###################
;# test alias
alias sb.search {
  if ( $remove($3-,*,?) == $null ) || ( $len($remove($3-,*,?)) < 2 ) {
    .msg $2 Please use a more specific search string.
    halt
  }
  else {
    hadd -m searchbot.search $+($2,.searchstring) $+(*,$replace($3-,$chr(32),$chr(42)),*)
    var %x = 1
    var %z = 1
    while ( %z <= $hget(0) ) {
      if ( searchbot.#* !iswm $hget(%z)) || ($hget(%z) == searchbot.search ) {
        inc %z
        continue
      }
      else {
        if ( $hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),0,w).data == 0 ) {
          inc %z
          continue
        }
        else {
          hinc searchbot.search $+($2,.allresults) $hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),0,w).data
          hinc searchbot.search $+($2,.chans)
          inc %z
        }
      }
    }
    var %x = 1
    var %z = 1
    while ( %z <= $hget(0) ) {
      if ( searchbot.#* !iswm $hget(%z)) || ($hget(%z) == searchbot.search ) {
        inc %z
        continue
      }
      else {
        if ( $hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),0,w).data == 0 ) {
          inc %z
          continue
        }
        else {
          while ( %x <= $hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),0,w).data ) {
            if ( $hget(searchbot.search,$+($2,.totalresults)) >= $hget(searchbot.settings,maxresults) ) {
              goto truncated
            } 
            hinc searchbot.search $+($2,.totalresults)
            if ( $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) ison $gettok($hget(%z),2,46) ) {
              hinc searchbot.search $+($2,.online)
              if ( $1 == all ) {
                .msg $2 - ONLINE - Channel: $gettok($hget(%z),2,46) Nick: $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) Ad: $hget(%z,$hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data)  -- Use: /ctcp $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) xdcc send $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,2,46)
              }
              if ( $1 == online ) {
                .msg $2 - ONLINE - Channel: $gettok($hget(%z),2,46) Nick: $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) Ad: $hget(%z,$hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data)  -- Use: /ctcp $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) xdcc send $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,2,46)
              }
            }
            else {
              hinc searchbot.search $+($2,.offline)
              if ( $1 == offline ) {
                .msg $2 - OFFLINE - Channel: $gettok($hget(%z),2,46) Nick: $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) Ad: $hget(%z,$hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data)  -- Use: /ctcp $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) xdcc send $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,2,46)
              }
              if ( $1 == all ) {
                .msg $2 - OFFLINE - Channel: $gettok($hget(%z),2,46) Nick: $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) Ad: $hget(%z,$hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data)  -- Use: /ctcp $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,1,46) xdcc send $gettok($hfind($hget(%z),$hget(searchbot.search,$+($2,.searchstring)),%x,w).data,2,46)
              }
            }
            inc %x
          }
        }
        inc %z
      }
    }
    goto end
    :truncated
    .msg $2 Your results have been restricted to the first $hget(searchbot.settings,maxresults) results.
    goto end
    :end
    if ( $hget(searchbot.search,$+($2,.totalresults)) == 0 ) || ( $hget(searchbot.search,$+($2,.totalresults)) == $null ) {
      .msg $2 Sorry No packs were found that matched $+(",$3-,")
      hinc searchbot.settings failed.searches
    }
    else {
      .msg $2 End of results. Total Packs: $iif($hget(searchbot.search,$+($2,.allresults)),$hget(searchbot.search,$+($2,.allresults)),0) Results: $iif($hget(searchbot.search,$+($2,.totalresults)),$hget(searchbot.search,$+($2,.totalresults)),0) Online: $iif($hget(searchbot.search,$+($2,.online)),$hget(searchbot.search,$+($2,.online)),0) Offline: $iif($hget(searchbot.search,$+($2,.offline)),$hget(searchbot.search,$+($2,.offline)),0) - On $hget(searchbot.search,$+($2,.chans)) Channel(s).
      hinc searchbot.settings successful.searches
    }
    hdel -w searchbot.search $+($2,*)
  }
}
;# Allows people to see what new releases are avaiable. Useage= sb.newreleases $nick
alias sb.newreleases {
  if ( $hget(NewReleases,0).item == 0 ) .msg $1 There are No New releases listed.
  else {
    .msg $1 There are currently $hget(NewReleases,0).item New Releases Listed.
    set $+(%,$1) 1
    while ( $($+(%,$1),2) <= $hget(NewReleases,0).item ) {
      .msg $1 New Release $($+(%,$1),2) : $hget(NewReleases,$($+(%,$1),2)).data
      inc $+(%,$1)
    }
  }
  unset set $+(%,$1)
}
;################
;# Pack Aliases
;################
;# Adds a pack. Useage= sb.addpack $chan $nick $strip($remove($wildtok($1-,*#*,1,32),$chr(91),$chr(93)),burc) $strip($1-,burc)
alias sb.addpack {
  hadd -m $+(searchbot.,$1) $+($2,.,$3) $4-
}
; Returns Total Packs Indexed on all channels. And Number of Channels Indexed. Useage= msg $nick $sb.countpacks
alias sb.countpacks {
  if (!$1) {
    var %x = 1
    var %numpacks = 0
    while ( %x <= $numtok($hget(searchbot.settings,indexchan),44)) {
      inc %numpacks $hget($+(searchbot.,$gettok($hget(searchbot.settings,indexchan),%x,44)),0).item
      inc %x
    }
    return %numpacks
  }
  elseif ($1) {
    if ($left($1,1) != $chr(35)) {
      return Error: You must specify a channel.
    }
    if (!$hget($+(Searchbot.,$1))) {
      return No Packs are currently indexed for $+(",$1,")
    }
    else {
      Return $hget($+(searchbot.,$1),0).item
    }
  }
}
;#################
;# Control Aliases
;#################
;# Disables the searchbot Remotely. No Paramaeters.
alias sb.disablesearchbot {
  hadd searchbot.settings enable 0 
  msg %searchbot.searchchan This Searchbot is now offline.
}
;# Enables the searchbot Remotely. No Parameters.
alias sb.enablesearchbot {
  hadd searchbot.settings enable 1 
  msg %searchbot.searchchan This searchbot is now online Indexing channel(s): $replace($hget(searchbot.settings,indexchan),$chr(44),$chr(32)) Trigger(s): $replace($hget(searchbot.settings,trigger),$chr(44),$chr(32)) 
}
;# Used to validae logins. Useage= msg $nick $sb.login($1,$nick)
alias sb.login {
  var %x = 1
  if ( $hget(searchbot.sessions,$2) ) {
    return You are already logged in with $+(",$hget(searchbot.sessions,$2),") - Please logout before logging in with a different access.
  }
  while ( %x <= $ini($+(",$scriptdir,searchbot.ini"),passwords,0) ) {
    if ( $1 === $readini($+(",$scriptdir,searchbot.ini"),passwords,$ini($+(",$scriptdir,searchbot.ini"),passwords,%x)) ) {
      hadd -mu1800 searchbot.sessions $2 $ini($+(",$scriptdir,searchbot.ini"),passwords,%x)
      return You now have $+(",$ini($+(",$scriptdir,searchbot.ini"),passwords,%x),") access. This bot will recognize you from your nick $+(",$2,") for the next 30 Minutes, or the bot is restarted.
    }
    inc %x
  }
  return Password Incorrect. You are not Logged in.
}
;# Used to log yourself out. Useage= msg $nick $sb.logout($nick)
alias sb.logout {
  if (!$hget(searchbot.sessions,$1)) {
    return Error: You are not currently Logged In.
  }
  else {
    hdel searchbot.sessions $1
    return You are now logged out. You must login again before you will have any bot control.
  }
}
;# Alias to change passwords. Useage msg $nick $sb.changepass(level,newpass)
alias sb.changepass {
  if ( $istok(op admin owner,$1,32) ) {
    writeini $+(",$scriptdir,searchbot.ini,") passwords $1 $2
    return You have changed the password for $+(",$1,") to $+(",$2,")
  }
  else {
    return Error: You must specify a level (op admin owner) and a password.
  }
}
;# Alias to get a password.
alias sb.getpass {
  if ( $istok(op admin owner,$1,32) ) {
    return The password for $+(",$1,") is $+(",$readini($+(",$scriptdir,searchbot.ini,"),passwords,$1),")
  }
  else {
    return Error: You must specify a level (op admin owner)
  }
}
;# alias to get a list of sessions.
alias sb.sessions {
  hsave -iu searchbot.sessions $+(",$scriptdir,sessions.tmp,") sessions
  var %x = 1 
  while ( %x <= $ini($+(",$scriptdir,sessions.tmp,"),sessions,0) ) {
    .msg $1 $+(",$ini($+(",$scriptdir,sessions.tmp,"),sessions,%x),") is logged in as $+(",$readini($+(",$scriptdir,sessions.tmp,"),sessions,$ini($+(",$scriptdir,sessions.tmp,"),sessions,%x)),")
    inc %x
  }
  .remove $+(",$scriptdir,sessions.tmp,")
  .msg $1 End of Sessions.
}
;# Alias to log another user out. Useage= msg $nick $sb.disconnect(*!ident@host)
alias sb.disconnect {
  if (!$hget(searchbot.sessions,$1)) {
    return Error: $+(",$1,") is not currently logged in.
  }
  else {
    .hdel searchbot.sessions $1
    return User $+(",$1,") has been disconnected.
  }
}
;# Returns true if someone is listed in a channel's index. Useage= msg $nick $sb.findserver(#channel,$nick)
alias sb.findserver {
  if ( !$hget($+(searchbot.,$1)) ) {
    return $1 does not currently have an index.
  }
  elseif ( $hfind($+(searchbot.,$1),$+($2,.*),0,w) < 1 ) {
    return $2 does not have any packets listed on $1
  }
  else {
    return $2 has $hfind($+(searchbot.,$1),$+($2,.*),0,w) packets listed on $1
  }
}
;# Used To delete nicks from an index. Useage= msg $nick $sb.delserver(#channel,$nick)
alias sb.delserver {
  if ( !$hget($+(searchbot.,$1)) ) {
    return $1 does not currently have an index.
  }
  elseif ( $hfind($+(searchbot.,$1),$+($2,.*),0,w) < 1 ) {
    return $2 does not have any packets listed on $1
  }
  else {
    hdel -w $+(searchbot.,$1) $+($2,.*)
    return $2 has been deleted from the index of $1
  }
}
;#############################
;# Channel Indexing Functions.
;#############################
;# Used to add a channel to index. Useage= msg $nick $sb.addchan(#channel)
alias sb.addchan {
  if ( $left($1,1) != $chr(35) ) {
    return Error: You must specify a channel.
  }
  if ($istok($hget(searchbot.settings,indexchan),$1,44)) {
    return Error: $+(",$1,") is currently being indexed.
  }
  else {
    hadd searchbot.settings indexchan $addtok($hget(searchbot.settings,indexchan),$1,44)
    join $1
    if (!hget($+(searchbot.,$1))) {
      hmake $+(searchbot.,$1) 50
    }
    if ( $exists($+(",$scriptdir,data/,searchbot.,$1,.dat,")) ) {
      hload $+(searchbot.,$1) $+(",$scriptdir,data/,searchbot.,$1,.dat,")
    }
    if ( $exists($+(",$scriptdir,data/,searchbot.,$1,newreleases.dat,")) ) {
      hmake $+(searchbot.,$1,.newreleases)
      hload $+(searchbot.,$1,.newreleases) $+(",$scriptdir,data/,searchbot.,$1,newreleases.dat,")
    }
    return $+(",$1,") has been added to the channels this bot is indexing.
  }
}
;# Used to delete an index channel. Useage= msg $nick $sb.delchan(#channel,$nick)
alias sb.delchan {
  if ( $left($1,1) != $chr(35) ) {
    return Error: You must specify a channel.
  }
  if (!$istok($hget(searchbot.settings,indexchan),$1,44)) {
    return Error: $+(",$1,") is not currently being indexed.
  }
  else {
    hadd searchbot.settings indexchan $remtok($hget(searchbot.settings,indexchan),$1,1,44)
    part $1 I am no longer indexing this channel at the request of $+(",$2,")
    if ($hget($+(searchbot.,$1))) {    
      hsave -o $+(searchbot.,$1) $+(",$scriptdir,data/,searchbot.,$1,.dat,")
      hfree $+(searchbot.,$1)
    }
    return $+(",$1,") has been deleted from my my index channels.
  }
}
;# Used to add a search trigger. Useage: msg $nick $sb.addtrig(trigger)
alias sb.addtrig {
  if ($istok($hget(searchbot.settings,trigger),$1,44)) {
    return Error: $+(",$1,") is already being used as a trigger
  }
  hadd searchbot.settings trigger $addtok($hget(searchbot.settings,trigger),$1,44)
  return $+(",$1,") successfully added. Current triggers: $hget(searchbot.settings,trigger)
}
;# Used to delete a search trigger. Useage: msg $nick $sb.deltrig(trigger)
alias sb.deltrig {
  if (!$istok($hget(searchbot.settings,trigger),$1,44)) {
    return Error: $+(",$1,") is not being used as a trigger
  }
  hadd searchbot.settings trigger $remtok($hget(searchbot.settings,trigger),$1,1,44)
  return $+(",$1,") successfully deleted. Current triggers: $hget(searchbot.settings,trigger)
}
;#########################
;# New Releases Functions.
;#########################
;# Used to add a New Release to a channel. Useage: /msg $nick $sb.addrelease(#channel,release)
alias sb.addrelease {
  if ($left($1,1) != $chr(35)) {
    return Error: You must specify a channel.
  }
  if (!$istok($hget(searchbot.settings,indexchan),$1,44)) {
    return Error: I am not currently indexing $+(",$1,")
  }
  if ($hget($+(searchbot.,$1,.newreleases),$2)) {
    return Error: $+(",$2,") is already listed as a new release on $+(",$1,")
  }
  else {
    hadd -m $+(searchbot.,$1,.newreleases) $ctime $2
    return $+(",$2,") successfully added as a new release for $+(",$1,") and will be automatically deleted $asctime($calc($ctime + %searchbot.releasetime),HH:mm:ss mmm dd yyyy)
  }
}
;# Used to list releases for a channel. Useage= /sb.listrelease $channel $nick
alias sb.listreleases {
  if ($left($1,1) != $chr(35)) {
    .msg $2 Error: You must specify a channel.
  }
  if ( $hget($+(searchbot.,$1,.newreleases),0).item == 0 ) || (!$hget($+(searchbot.,$1,.newreleases))) {
    .msg $2 No releases are listed for $+(",$1,")
  }
  else {
    var %x = 1 
    .msg $nick Listing New Releases for $+(",$1,")
    while (%x <= $hget($+(searchbot.,$1,.newreleases),0).item) {
      .msg $2 $+(",$hget($+(searchbot.,$1,.newreleases),%x).data,") to be deleted $+(",$asctime($calc($hget($+(searchbot.,$1,.newreleases),%x).item + %searchbot.releasetime),HH:mm:ss mmm dd yyyy),")
      inc %x
    }
    .msg $2 End Of Listing.
  }
}
;# Used to delete a release for a channel manually. Useage= /msg $nick $sb.delrelease(#channel,release text)
alias sb.delrelease {
  if ($left($1,1) != $chr(35)) {
    return Error: You must specify a channel.
  } 
  if ( $hget($+(searchbot.,$1,.newreleases),0).item == 0 ) || (!$hget($+(searchbot.,$1,.newreleases))) {
    return No releases are listed for $+(",$1,")
  }
  if (!$hfind($+(searchbot.,$1,.newreleases),$2,1).data) {
    return Error: $+(",$2,") is not in the release list for $+(",$1,")
  }
  else {
    hdel $+(searchbot.,$1,.newreleases) $hfind($+(searchbot.,$1,.newreleases),$2,1).data
    return $+(",$2,") successfully deleted from the listing for $+(",$1,")
  }
}
;# Used to list releases for a certain channel. sb.listreleases #channel nick
alias sb.listreleases {
  if ( $left($1,1) != $chr(35)) {
    return Error: You must specify a channel.
  }
  elseif (!$hget($+(searchbot.,$1,.newreleases))) {
    return There are currently no new releases listed for $+(",$1,")
  }
  else {
    hsave -i $hget($+(searchbot.,$1,.newreleases)) $+(",$scriptdir,$1,.newreleases.tmp") releases
    .play -treleases $2 $+(",$scriptdir,$1,.newreleases.tmp") 
  }
}
;#######################
;# Advertisement Aliases
;#######################
;# Used to find a channels advertisement. Uses defualt one if it cant find one. $sb.getadvert(#channel)
alias sb.getadvert {
  if ( $left($1,1) != $chr(35)) {
    return Error: You must specify a channel name.
  }
  if (!$hget(searchbot.settings)) {
    return Error: Settings Table not found.
  }
  if (!$hget(searchbot.settings,$+($1,.advert))) {
    if (!$hget(searchbot.settings,default.advert)) {
      return Error: No advertisment found for $+(",$1,") Default advert not found.
    }
    else {
      return Default advertisement of $+(",$hget(searchbot.settings,default.advert),") is being used for $+(",$1,")
    }
  }
  else {
    return Advertisement for $+(",$1,") is set to $+(",$hget(searchbot.settings,$+($1,.advert)),")
  }
}
;# Sets the advertisment for a specified channel or the defualt. $sb.setadvert(#channel,new ad)
alias sb.setadvert {
  if ($1 == default) {
    hadd -m searchbot.settings default.advert $2-
    return Default Advertisment successfully set to $+(",$2-,")
  }
  if ($left($1,1) != $chr(35)) {
    return Error: You must specify a channel.
  }
  else {
    hadd -m searchbot.settings $+($1,.advert) $2-
    return Advert for $+(",$1,") sucessfully set to $+(",$2,")
  }
}
;# Deletes an advert for a specified channel or defualt. $sb.deladvert(#channel)
alias sb.deladvert {
  if ($1 == default) {
    hdel searchbot.settings default.advert
    return Default Advertisment successfully deleted.
  }
  if ($left($1,1) != $chr(35)) {
    return Error: You must specify a channel.
  }
  else {
    hdel searchbot.settings $+($1,.advert)
    if ($timer($+($1,.advert))) {
      $+(.timer,$1,.advert) off
    }
    return Advert for $+(",$1,") sucessfully deleted and stopped.
  }
}
;# Formats the advertisment to replace substitution words. $sb.formatadvert(#channel)
alias sb.formatadvert {
  if ( $left($1,1) != $chr(35)) {
    return Error: You must specify a channel with this command.
  }
  if (!$hget(searchbot.settings,$+($1,.advert))) {
    if ($hget(searchbot.settings,default.advert)) {
      return $sb.subadvert($hget(searchbot.settings,default.advert))
    }
    else {
      return No advert set for $+(",$1,"). Default Advert not found.
    }
  }
  else {
    return $sb.subadvert($hget(searchbot.settings,$+($1,.advert)))
  }
}
;# Performs substitutions for advert. $sb.subadvert(advert)
alias sb.subadvert {
  return $replace($1-,[triggers],$+(",$replace($hget(searchbot.settings,trigger),$chr(44),$+($chr(32),or,$chr(32))),"),[indexchans],$+(",$hget(searchbot.settings,indexchan),")) 
}
;# Sets an advertisement time.
alias sb.setadtime {
  if ( $left($1,1) != $chr(35)) {
    return Error: You must specify a channel with this command.
  }
  if ($2 !isnum) {
    Return Error: You must specify a time in seconds. /msg $me setadtime #channel 300 - would make a 5 minute advert.
  }
  if (!$hget(searchbot.settings,default.advert)) && (!$hget(searchbot.settings,$+($1,.advert))) {
    return Error: You must either set a Default Advertisement or a Custom Channel Advertisement.
  }
  else {
    if ($me !ison $1) {
      return Error: I am not currently on $+(",$1,") so I cannot run an advertisement on that channel.
    }
    else {
      hadd searchbot.settings $+($1,.adtime) $2
      $+(.,timer,$1,.advert) 0 $hget(searchbot.settings,$+($1,.adtime)) .msg $1 $sb.formatadvert($1)
      return Ad Time for $+(",$1,") successfully set to $+(",$duration($2),")
    }
  }
}
;# Returns the adtime. /msg $nick $sb.getadtime(#channel)
alias sb.getadtime {
  if ($left($1,1) != $chr(35)) {
    return Error: You must specify a channel.
  }
  if (!$hget(searchbot.settings,$+($1,.adtime))) {
    return Error: There is no advert time set for $+(",$1,")
  }
  else {
    return Current Advert time for $+(",$1,") set to $+(",$duration($hget(searchbot.settings,$+($1,.adtime))),")
  }
}
;#################
;# Request Aliases
;#################
;# Alias to Add a request.
alias sb.addrequest {
  if ( $hfind(searchbot.requests,$1-).data) {
    return Error: You have already placed that request at $asctime($hfind(searchbot.requests,$1-).data)
  }
  hadd -m searchbot.requests $ctime $1-
  return Your request has been added on $+(-,$asctime,-)
}
;# Alias to list requests.
alias sb.listrequests {
  if (!$hget(searchbot.requests)) || ($hget(searchbot.requests,0).item == 0) {
    .msg $1 No requests are currently stored.
  }
  else {
    write -c $+(",$scriptdir,requests.txt,") Current Requests are:
    var %x = 1
    while (%x <= $hget(searchbot.requests,0).item) {
      write $+(",$scriptdir,requests.txt,") $+(#,%x) - $gettok($hget(searchbot.requests,%x).data,2-,32) - Requested By $gettok($hget(searchbot.requests,%x).data,1,32) on $asctime($hget(searchbot.requests,%x).item) 
      inc %x
    }
    write $+(",$scriptdir,requests.txt,") If you can fill any of these requests please do.
    .play $1 $+(",$scriptdir,requests.txt,")
  }
}
;# Alias to delete a request.
alias sb.delrequest {
  if (!$hget(searchbot.requests)) {
    return Error: No Requests are currently found on this bot.
  }
  elseif (!$hfind(searchbot.requests,$+(*,$1-),1,w).data) {
    return Error: $+(",$1-,") was not found in the requests.
  }
  else {
    hdel searchbot.requests $hfind(searchbot.requests,$+(*,$1-),1,w).data
    return $+(",$1,") Has successfully been deleted.
  }
}
;#################
;# Ignore Aliases
;#################
;# Alias to list ingored hosts
alias sb.listignored {
  if ( $ignore(0) == 0 ) {
    .msg $1 There are currently no ignores set.
  }
  else {
    write -c $+(",$scriptdir,ignore.txt,")
    var %x = 1
    while ( %x <= $ignore(0) ) {
      write $+(",$scriptdir,ignore.txt,") Nick: $gettok($ignore(%x),1,33) Type: $ignore(%x).type Unset in: $duration($ignore(%x).secs)
      inc %x
    }
    .play $1 $+(",$scriptdir,ignore.txt,")
  }
}
;# Alias to remove an ignore
alias sb.delignore {
  if (!$ignore($+($1,!*@*))) {
    return Error: That nick is not ignored.
  }
  else {
    ignore -r $+($1,!*@*)
    return $+(",$1,") Successfully unignored
  }
}
;################
;# Backup Aliases
;################
;# Alias to list all Backedup script files. Found in /backup
alias sb.listbackups {
  if ( $findfile($+(",$scriptdir,backup/,"),*.mrc,0) == 0 ) {
    .msg $1 No Backedup Scripts found.
  }
  else {
    var %x = 1
    .write -c $+(",$scriptdir,backups.txt,") Backed Up Searchbot Scripts.
    while ( %x <= $findfile($+(",$scriptdir,backup/,"),*.mrc,0) ) {
      .write $+(",$scriptdir,backups.txt,") $nopath($findfile($+(",$scriptdir,backup/,"),*.mrc,%x))
      inc %x
    }
    .write $+(",$scriptdir,backups.txt,") End of Backups
    .play $1 $+(",$scriptdir,backups.txt,")
  }
}
;# Alias to restore a backedup script.
alias sb.restorebackup {
  if ($findfile($+(",$scriptdir,backup/,"),$2-,1) == 0 ) {
    .msg $1 $+(",$2-,") Was not found in my backups.
  }
  else {
    .msg $1 Script Is being rerstored. It may take a few secoonds.
    .timerunloadsearchbot 1 2 unload -rs searchbot.mrc
    .timerbackupscript 1 2 .copy $+(",$scriptdir,searchbot.mrc,") $+(",$scriptdir,backup/,$asctime(mmm-dd-yyyy-HH-mm-ss),-searchbot.mrc,") 
    .timercopyscript 1 2 .copy -o $+(",$scriptdir,backup/,$2-,") $+(",$scriptdir,searchbot.mrc,")
    .timerreloadscript 1 2 load -rs $+(",$scriptdir,searchbot.mrc,")
    .timermsgnick 1 2 .msg $1 Script Restored and Reloaded
  }
}
;#################
;# Misc. Aliases
;#################
;# Checks if a new trigger is a command. When commands are added they must be added here as well to prevent search trigger conflicts.
alias sb.iscommand {
  if ($istok(Triggers online offline Login Logout Changepass Getpass Sessions Dissconnect Delnick Addchan Delchan Listreleases Delrelease Setadvert Getadvert Deladvert Setadtime Info Listchans Addtrig Deltrig Addrelease Seeadvert Getadtime Countpacks,$1,32)) {
    return true
  }
}
;# checks if anyone is using a file for a play. If they arent it deletes the file.
alias sb.playcheck {
  var %x = 1
  while ( %x <= $play(0)) {
    if ($play(%x).fname == $1- ) {
      return true
    }
    inc %x
  }
}
;# Alias to change flood settings.
alias sb.flood {
  if ($1 !isnum ) {
    return Error: You may only specify a number with this command.
  }
  else {
    if ($prop == flood) {
      hadd searchbot.settings flood $1
      return Amount of messages to trigger flood have been changed to $+(",$1,").
    }
    elseif ($prop == floodtime) {
      hadd searchbot.settings floodtime $1
      return The flood time has been changed to $+(",$1,").
    }
    elseif ($prop == ignoretime) {
      hadd searchbot.settings ignore $1
      return The ignore time for a user who floods the bot has been changed to $+(",$1,").
    }
  }
}
;# alias to change the max results setting
alias sb.maxresults {
  if ($1 !isnum ) {
    Return Current Max Results: $+(",$hget(searchbot.settings,maxresults),") Please specify a number with this command to change it.
  }
  elseif ( $1 == $hget(searchbot.settings,maxresults) ) {
    return Error: Your parameter matches the current setting.
  }
  else {
    hadd searchbot.settings maxresults $1
    return Max results set to $+(",$1,").
  }
}
;# Alias to total up searches
alias sb.searchcount {
  .msg $1 Failed Searches: $iif($hget(searchbot.settings,failed.searches),$hget(searchbot.settings,failed.searches),0)
  .msg $1 Successful Searches: $iif($hget(searchbot.settings,successful.searches),$hget(searchbot.settings,successful.searches),0)
  .msg $1 Total Searches: $calc( $iif($hget(searchbot.settings,failed.searches),$hget(searchbot.settings,failed.searches),0) + $iif($hget(searchbot.settings,successful.searches),$hget(searchbot.settings,successful.searches),0) )
}
;###################
;# On Text Events
;# #################
on *:text:*:?: {
  if ( $hget(searchbot.settings,enable) == 1 ) {
    ;# Anti-Flood Event.
    if (!$hget(searchbot.sessions,$nick)) {
      hinc $+(-,mu,$hget(searchbot.settings,floodtime)) searchbot.flood $nick
      if ($hget(searchbot.flood,$nick) >= $hget(searchbot.settings,flood) ) {
        .msg $nick You have activated my flood protect. You will be ignored for $+(",$duration($hget(searchbot.settings,ignore)),").
        .ignore $+(-,pcdinktu,$hget(searchbot.settings,ignore)) $nick
        .closemsg $nick
        hdel searchbot.flood $nick
        halt
      }
    }
    if ( $chr(124) isin $1- ) {
      .msg $nick Please do not include $+(",$chr(124),") in your messages.
      halt
    }
    if (help isin $1) {
      if (!$hget(searchbot.sessions,$nick)) {
        .play -tallusers $nick $+(",$scriptdir,searchbot.mrc,")
      }
      elseif ($hget(searchbot.sessions,$nick) == owner) {
        .play -tallusers $nick $+(",$scriptdir,searchbot.mrc,")
        .play -towner $nick $+(",$scriptdir,searchbot.mrc,")
        .play -tadmin $nick $+(",$scriptdir,searchbot.mrc,")
        .play -top $nick $+(",$scriptdir,searchbot.mrc,")
      }
      elseif ($hget(searchbot.sessions,$nick) == admin) {
        .play -tallusers $nick $+(",$scriptdir,searchbot.mrc,")
        .play -tadmin $nick $+(",$scriptdir,searchbot.mrc,")
        .play -top $nick $+(",$scriptdir,searchbot.mrc,")
      }
      elseif ($hget(searchbot.sessions,$nick) == op) {
        .play -tallusers $nick $+(",$scriptdir,searchbot.mrc,")
        .play -top $nick $+(",$scriptdir,searchbot.mrc,")
      }
      halt
    }
    ;# Lists Triggers
    if ( $1 == triggers ) {
      .msg $nick The Current Search triggers are $+(",$replace($hget(searchbot.settings,trigger),$chr(44),$+($chr(32),or,$chr(32))),") New Release Triggers - $+(",$replace(%searchbot.newrelease.triggers,$chr(44),$+($chr(32),or,$chr(32))),") followed by the channel you would like to see new releases for.
      halt
    }
    ;# Search Events.
    If ( $hget(searchbot.settings,enable) == 1 ) {
      ;# Searches all packs
      if ( $istok($hget(searchbot.settings,trigger),$1,44) ) {
        if ($2) {
          sb.search all $nick $2-
        }
        else {
          .msg $nick Please Specify A Search String.
        }
        closemsg $nick
        halt
      }
      ;# Searches offline packs
      elseif ( $1 == !offline ) {
        if ($2) {
          sb.search offline $nick $2-
        }
        else {
          .msg $nick Please Specify A Search String.
        }
        closemsg $nick
        halt
      }
      ;# Searches online packs
      elseif ( $1 == !online ) {
        if ($2) {
          sb.search online $nick $2-
        }
        else {
          .msg $nick Please Specify A Search String.
        }
        closemsg $nick
        halt
      }
    }
    ;# New release Listing.
    if ( $istok($hget(searchbot.settings,release.trigger),$1,44)) {
      if (!$2) {
        .msg $nick You must specify a channel to lookup releases for.
      }
      else {  
        sb.listreleases $2 $nick
      }
      halt
    }
    ;# Lets a user add a request.
    if ( $1 == !request ) && ( $hget(searchbot.settings,requests.enable) == 1 ) {
      if (!$2) {
        .msg $nick You must include text for a request.
      }
      else {
        .msg $nick $sb.addrequest($nick $2-)
      }
      halt
    }
    ;# Lists all requests.
    if ( $1 == !requests ) && ( $hget(searchbot.settings,requests.enable) == 1 ) {
      sb.listrequests $nick
      halt
    }
  }
  ;# Login Event.
  if ( $1 == login ) {
    if (!$2) {
      .msg $nick You MUST specify a password.
    }
    else {
      .msg $nick $sb.login($2,$nick)
    }
    halt
  }
  ;# Logout Event
  if ( $1 == logout ) {
    .msg $nick $sb.logout($nick)
    halt
  }
  ;# Stops access to all following commands if the person is not logged in.
  if (!$hget(searchbot.sessions,$nick)) && ( $hget(searchbot.settings,enable) == 1 ) {
    .msg $nick Error: You have either typed an unrecognized command or you must login before using any commands beyond the basic search functions. Please use /msg $me $gettok($hget(searchbot.settings,trigger),1,44) *search term*
    halt  
  }
  ;#Control Access
  ;# Checks if the user is logged in to get access to all following commands.
  if ( $hfind(searchbot.sessions,$nick) ) {
    ;# Checks if you are an owner. Limits Commands nested in this if to an owner.
    if ( $hget(searchbot.sessions,$nick) == owner ) {
      ;#
      ;# Owner
      :#
      ;# Change login passwords
      if ( $1 == changepass ) {
        if (!$2) || (!$3) {
          .msg $nick Useage: /msg $me changepass level (op admin owner) newpass
        }
        else {
          .msg $nick $sb.changepass($2,$3)
        }
      }
      ;# Get login passwords
      if ( $1 == getpass ) {
        if (!$2) {
          .msg $nick Useage: /msg $me getpass level (op admin owner)
        }
        else {
          .msg $nick $sb.getpass($2)
        }
      }
      ;# Lists all logged in sessions
      if ( $1 == sessions ) {
        sb.sessions $nick
      }
      ;# Disconnects a logged in session
      if ( $1 == disconnect ) {
        if (!$2) {
          .msg $nick Useage: /msg $me disconnect *!ident@host
        }
        else {
          .msg $nick $sb.disconnect($2)
        }
      }
      ;# Rehashes the startup events.
      if ( $1 == rehash ) {
        sb.startup
      }
      if ( $1 == listbackups ) {
        sb.listbackups $nick
      }
      if ( $1 == restorebackup ) {
        if (!$2) {
          .msg $nick Error: You must specify the filename to restore.
        }
        else {
          sb.restorebackup $nick $2-
        }
      }
      if ( $1 == flood ) {
        if (!$2) {
          .msg $nick You must specify a number for this command.
        }
        else {
          .msg $nick $sb.flood($2).flood
        }
      }
      if ( $1 == floodtime ) {
        if (!$2) {
          .msg $nick You must specify a number for this command.
        }
        else {
          .msg $nick $sb.flood($2).floodtime
        }
      }
      if ( $1 == ignoretime ) {
        if (!$2) {
          .msg $nick You must specify a number for this command.
        }
        else {
          .msg $nick $sb.flood($2).ignoretime
        }
      }
      if ( $1 == maxresults ) {
        ;   if (!$2) {
        ;    .msg $nick You must specify a number for this command.
        ; }
        ; else {
        .msg $nick $sb.maxresults($2)
        ;}
      }
    }
    ;# Checks if you are an owner or admin. Limits Commands nested in this if to an owner or admin.
    if ( $hget(searchbot.sessions,$nick) == admin ) || ( $hget(searchbot.sessions,$nick) == owner ) {
      ;#
      ;# Admin
      ;#
      ;#Deletes all of a nicks entries out of a channel's index.
      If ( $1 == delnick ) {
        if ( $left($2,1) != $chr(35) ) {
          .msg $nick You must specify a channel. Syntax: /msg $me delete #channel nick
        }
        elseif (!$3) {
          .msg $nick You must specify a nick. Syntax: /msg $me delete #channel nick
        }
        else {
          .msg $nick $sb.delserver($2,$3)
        }
      }
      ;# Adds an index channel
      if ( $1 == addchan ) {
        if (!$2) {
          .msg $nick You must specify a channel. Useage: /msg $me addchan #channel
        }
        else {
          .msg $nick $sb.addchan($2)
        }
      }
      ;# Deletes an index channel
      if ( $1 == delchan ) {
        if (!$2) {
          .msg $nick You must specify a channel. Useage: /msg $me delchan #channel
        }
        else {
          .msg $nick $sb.delchan($2,$nick)
        }
      }
      ;# Deletes a new release manually.
      if ( $1 == delrelease ) {
        if (!$2) || (!$3) {
          .msg $nick Error: You must specify a channel and a release name. Useage: /msg $me delrelease #channel releasetext
        }
        else {
          .msg $nick $sb.delrelease($2,$3-)
        }
      }
      ;# Lists all releases for a channel.
      if ( $1 == listreleases ) {
        if (!$2) {
          .msg $nick Error: You must specify a channel. Useage: /msg $me listreleases #channel
        }
        else {
          sb.listreleases $2 $nick
        }
      }
      ;# Sets an advertisement
      if ( $1 == setadvert ) {
        if (!$2) || (!$3) {
          .msg $nick Error. You must specify a channel or defualt and advertisement. Useage: /msg $me setadvert #channel/default new advertisement.
        }
        else {
          .msg $nick $sb.setadvert($2,$3-)
        }
      }
      ;# Deletes an advertisement
      if ( $1 == deladvert ) {
        if (!$2) {
          .msg $nick Error. You must specify a channel or default. Useage: /msg $me deladvert #channel
        }
        else {
          .msg $nick $sb.deladvert($2)
        }
      }
      ;# Get the advertisement for a channel without substitutions. [triggers] is replaced with the current triggers [indexchans] is replaced with the indexed channels.
      if ($1 == getadvert) {
        if (!$2) {
          .msg $nick You must specify a channel.
        }
        else {
          .msg $nick $sb.getadvert($2)
        }
      }
      ;# Sets the repeat time for an ad.
      if ( $1 == setadtime) {
        if (!$2) || (!$3) {
          .msg $nick Error. You must specify a channel and advertisement time. Useage: /msg $me setadvert #channel 300.
        }
        else {
          .msg $nick $sb.setadtime($2,$3)
        }
      }
    }
    ;# Checks if you are an owner, admin, or op. Limits Commands nested in this if to an owner, admin, or op.
    if ( $hget(searchbot.sessions,$nick) == op ) || ( $hget(searchbot.sessions,$nick) == admin ) || ( $hget(searchbot.sessions,$nick) == owner ) {
      ;#
      ;# Op
      ;#   
      ;#Searches for a nick in a channels index. Returns information about the nick.
      If ( $1 == info ) {
        if ( $left($2,1) != $chr(35) ) {
          .msg $nick You must specify a channel. Syntax: /msg $me info #channel nick
        }
        elseif (!$3) {
          .msg $nick You must specify a nick. Syntax: /msg $me info #channel nick
        }
        else {
          .msg $nick $sb.findserver($2,$3)
        }
      }
      ;# Lists the channels being indexed.
      if ( $1 == listchans ) {
        .msg $nick $replace($hget(searchbot.settings,indexchan),$chr(44),$chr(32))
      }
      ;# Adds a search trigger to be used to search all packs.
      if ( $1 == addtrig ) {
        if (!$2) {
          .msg $nick You must specify a trigger. Useage: /msg $me addtrig trigger
        }
        if ($sb.iscommand($2)) {
          .msg $nick Error: $+(",$2,") is in use by the bot as a command.
        }
        else {
          .msg $nick $sb.addtrig($2)
        }
      }
      ;# Deletes a search trigger to be used to search all packs.
      if ( $1 == deltrig ) {
        if (!$2) {
          .msg $nick You must specify a trigger. Useage: /msg $me deltrig trigger
        }
        else {
          .msg $nick $sb.deltrig($2)
        }
      }
      ;# Adds a new release for a channel.
      if ( $1 == addrelease ) {
        if (!$2) || (!$3) {
          .msg $nick You must specify a channel and a release. Useage: /msg $me addrelease #channel release
        }
        else {
          .msg $nick $sb.addrelease($2,$3-)
        }
      }
      ;# See the advert as it would be sent to the channel.
      if ( $1 == seeadvert ) {
        if (!$2) {
          .msg $nick You must specify a channel.
        }
        else {
          .msg $nick $sb.formatadvert($2)
        }
      }
      ;# See the set time for an advert to repeat
      if ($1 == getadtime) {
        if (!$2) {
          .msg $nick You must specify a channel.
        }
        else {
          .msg $nick $sb.getadtime($2)
        }
      }
      if ( $1 == countpacks ) {
        if (!$2) {
          .msg $nick $sb.countpacks
        }
        elseif ($2) {
          .msg $nick $sb.countpacks($2)
        }
      }
      ;# Deletes a request.
      if ( $1 == delrequest ) {
        if (!$2) {
          .msg $nick You must include the text of the request.
        }
        else {
          .msg $nick $sb.delrequest($2-)
        }
      }
      ;# Deletes An Ignore
      if ( $1 == delignore ) {
        if (!$2) {
          .msg $nick You must include a nick to unignore.
        }
        else {
          .msg $nick $sb.delignore($2)
        }
      }
      if ( $1 == listignores ) {
        sb.listignored $nick
      }
      if ( $1 == totalsearches ) {
        sb.searchcount $nick
      }
    }
  }
}
on *:text:*:#: {
  ;# Checks if the channel is being indexed.
  if ( $istok($hget(searchbot.settings,indexchan),$chan,44) ) {
    ;# Checks if the line is an actual xdcc ad. And that it is from a voice or higher.
    if ( $chr(35) isin $strip($1-,burc)) && ( to request !isin $1- ) && ( xdcc send !isin $1- ) && ($nick($chan,$nick,vho~&)) && ($remove($strip($1,burc),$chr(35),$chr(60),$chr(62),$chr(171),$chr(187)) isnum ) { 
      ;# Checks if the pack is #1
      if ( $+($chr(35),1,$chr(32)) isin $strip($1-,burc)) {
        ;# Checks if the channel's index is made.
        if ($hget($+(searchbot.,$chan))) {
          ;# Deletes all packs from a user when they list #1 to ensure old packs arent updated if they list fewer than before.
          hdel -w $+(searchbot.,$chan) $+($nick,.*)
          ;# Adds the new #1 pack.
          sb.addpack $chan $nick $strip($remove($wildtok($1-,*#*,1,32),$chr(91),$chr(93),$chr(171),$chr(187)),burc) $strip($1-,burc)
        }
      }
      else {
        ;# Adds all packs after #1 for a user.
        sb.addpack $chan $nick $strip($remove($wildtok($1-,*#*,1,32),$chr(91),$chr(93),$chr(171),$chr(187)),burc) $strip($1-,burc)
      }
    }
  }
}
;################
;# Play event
;################
on *:playend: {
  if ($filename != $scriptdirsearchbot.mrc ) {
    if (!$sb.playcheck($filename)) {
      .remove $+(",$filename,")
    }
  }
}
;###############
;# Help Sections
;###############
[allusers]
You can send any of these commands to me in Private Message.
All Users can access these commands without logging in.
To get a list of Triggers: Triggers - These search both online and offline packs.
To search online packs only: !online  *search*string*
To search offline packs only: !offline  *search*string*
To login: Login Password (passwords are case sensitive.) To Logout: Logout
[owner]
Only Owners can access this section. May Also access Admin and Op Commands.
Changepass level newpass - Levels are Owner Admin and Op - Passwords will be case sensitive.
Getpass Level - Levels are Owner Admin and Op - Passwords will be case sensitive.
Sessions - Lists all currently logged in hosts.
Dissconnect Host - Disconnects a user that is logged in. Copy the host from the 'Sessions' Listing.
[admin]
Only Admins and Higher may access this section. May also access Op commands.
Delnick #channel Nick - Deletes all packs listed by a nick on the specified Channel
Addchan #channel - Adds a channel to be indexed.
Delchan #channel - Deletes a channel from being indexed.
Listreleases #channel - Lists all releases for the specified channel
Delrelease #channel Release text - Deletes a release from a channel's list manually. Copy and paste the text from the release listing.
Setadvert #channel Advertisement text - Sets a channel's custom advertisement. You may also set a defualt ad for a channels that do not use a custom advert but enable a running advert with Setadtime. [triggers] will substitute to "@find !search" etc. [indexchans] will substitute to "#indexchannel1,#indexchannel2" etc.
Getadvert #channel - Returns the advert text for a channel (or default) without substitutions.
Deladvert #channel - Will delete a channel's advert. You can also specify default.
Setadtime #channel 300 - Sets a repeat time for a channels advertisment. Time is in seconds. You MUST issue this command after setting either a default ad, or a custom ad. Your ad will not run without this setting.
[op]
Only Ops and Higher may access this section. 
Info #channel Nick - Tells you how many packs a nick has listed on the channel.
Listchans - Lists the channels the bot is indexing.
Addtrig Trigger - Adds a new trigger to search all packets.
Deltrig Trigger - Deletes an existing trigger that searches all packets.
Addrelease #channel Release Text - Adds a New Release for a channel. Will be automatically deleted. Delete date will be specified after using the command.
Seeadvert #channel - Shows you the advertisement for a channel (may use Default instead of a channel to see the defualt ad).
Getadtime #channel - Shows you the repeat time for a channel's ad.
Countpacks - Shows you the number of packs indexed on all channels. --- Countpacks #channel will Show the number of packs on that channel.
------- IMPORTANT - Do not add any triggers that match any given command. This will cause conflicts. I will address this issue later. ---------

Comments

Sign in to comment.
ovelayer   -  Feb 22, 2013

sure wish an awsome coder would take the time to update this script.
this script still works on current mirc versions and is currently the best xdcc searchbot script i can find
it does lack the ability to show the gets and date added for the packs it shows which is one feature i would like to see
also all commands must be sent via msg which is kinda lame needs a public channel trigger (which i have done)
i just cant figure out how to make it add gets and date pack was added
and i am sure the script needs updating for better execution on newest versions of mirc
i know its 1300 lines of code but
if a scripter could take the time to update this script I and I am sure alot of people would greatly appreciate it and you..
thanks

 Respond  
ryu.dragonryder   -  Aug 04, 2010

and yes they ARE in the exact same directory D:\Search no spacers no nothing for an excuse as to why it is not working

 Respond  
ryu.dragonryder   -  Aug 04, 2010

searchbot.ini searchbot.mrc

Per Your own instructions they have been named exactly the same thing and i do not get any erros using your updated thing other than the password issue and i do not EVER get any results for anyone ever

[PASSWORD ISSUE]
[3:02pm] login CreepyDragon
[3:02pm] Password Incorrect. You are not Logged in.
[3:03pm] login CreepyDragon
[3:03pm] Password Incorrect. You are not Logged in.
[3:05pm] login CreepyDragon
[3:05pm] Password Incorrect. You are not Logged in.
[3:05pm] login CreepyDragon
[3:05pm] Password Incorrect. You are not Logged in.
[3:09pm] login CreepyDragon
[3:10pm] Password Incorrect. You are not Logged in.

[SEARCH RESULTS]
[3:09pm] <@Ryu> !search Nirvana
[3:16pm] <@Ryu> !search Angeles
[3:16pm] <@Ryu> !search Tuck
[3:17pm] <@Ryu> !search Smallville

i have done ALL the updates you showed above with the changes you said about the channel results and get no responses no errors fo any kind at all.

the bot runs on mirc 6.35 & i also tested on mirc v7.1 with the exact same issues and 0 errors

now i do not claim to be a great scripter, and i have looked and can not find why it keeps telling me " Password Incorrect. You are not Logged in."

and it does NOT matter if i put the ini in remotes or aliases - i get teh exact same results no matter what i do.

PLEASE HELP

 Respond  
yelow79   -  Jun 28, 2010

Okay, I see others have had this issue. I can not get the bot to auto join the channels and I get a wrong pass error when I try to login for the first time. I copy and pasted the searchbot.ini and created that file, and in the same directory I I created searchbot.mrc with all of the snippit info. Is there something I am missing? Thanks in advance

 Respond  
CraigW   -  May 11, 2009

i'm quite happy to take over this project

 Respond  
jayice   -  Mar 09, 2009

hi, can anyone help me with getting this to respond to !search as a channel command rather than /msg user !search ?
also is it possible to display any findings in channel??
many thx in advance

 Respond  
Fuzion   -  Sep 04, 2008

wow

 Respond  
ShAmPi   -  Jun 25, 2008

It\'d be awesome if it auto requested every time a download is finished from that paticular bot.
So you don\'t have to wait to finish the first download and manually type in the next download command.
Know what I mean?

 Respond  
loshi   -  Aug 12, 2007

Hey Guys. I think this problem has been mentioned earlier.
The channel I use the searchbot in has a dot in its name (i.e. #search.channel).
The bot works just fine. Only the Online/Offline statements he throws out are wrong. The bot always sais all xdcc bots are offline because he is searching in #search instead of #search.channel.

Can anybody please tell me how to solve that problem? Would be great. THX!

 Respond  
Yoinx   -  May 02, 2007

sorry pal, that wouldnt be possible. I designed it to delete the old list for a user when they started listing again. So, each time someone listed, it would be the latest.

However, if you look at the help for ops, it tells you how to add new releases. You will however have to add two items to your searchbot.ini
under
[searchbot]
release.trigger=!releases
release.time=86400

86400 being the number of seconds in 24hours.

Then once logged in as with op access or above you should be able to use the addrelease command. and all users should be able to use !realeases #channel to see that channel\'s releases.... If I remember right. there\'s a lot of stuff that i had added to this script before I stopped working on it. and that stuff never got documented.

 Respond  
TrajicKaos   -  Apr 21, 2007

Ok i got it to work great but what about a !latest
/server irc.z0r.org
/join #MovieHouse

 Respond  
wickedclown   -  Mar 22, 2007

I keep getting this error..

  • /hinc: insufficient parameters (line 837, searchbot.mrc)
 Respond  
TrajicKaos   -  Mar 22, 2007

Hey Yoinx

I was hoping you were still willing to help people with your script i am having trouble running it i get an error on line 837 and i was wondering. i can get it to read the commands from the channel when it was working. and i was wondering if you had a !latest commend
please contact me back or join my channel
/server irc.101-freedom.net
/j #MovieHouse

 Respond  
Codine   -  Feb 22, 2007

I think it would be nice to have commands to turn the search bot on/off ect.. and be able to set hostmask\'s ect, so i can use it on my pc at work.. would be a good idea i think`s :) nice script tho, thanks m8 :)

 Respond  
Trion   -  Sep 04, 2006

well you not going to believe it.. i got it to work in channel.
only problem i now have is that im not able to login or even the commands !triggers !help doesnt work.

Still find this a bloody good script.

Thanx m8

 Respond  
darkcloud_be   -  Aug 27, 2006

Hey, first a thank you note to the maker of this script.
Scipt works indeed, it acutaly search when people use the !search in my chan. But i\'m stil having difficulties with login in on to the bot. It keep saying password incorrect. I tryed as much combinations as i can think of. Perhaps someone else how\'s using this script and perhaps now a solution to this login problem ?
thx in advance.

 Respond  
Trion   -  Aug 08, 2006

hello,

I still cant find a way to get this snippet to work in the channel.
Sorry to see that Yoinx lost interrest in this script.
i replaced the ontext part, still nothing.
Can somebody else had a clue how i can get it to work ?

All help would be great.

 Respond  
rvukma   -  Jul 26, 2006

Hy.What must i change in the script that i will only do !search \"release name\" not /msg the nick of the search bot.The script work very good and nice to use.Good job Yoinx.

 Respond  
Trion   -  Jul 18, 2006

oeps. wrong button :)

it didn`t work.
I hope that somebody is willing tohelp howto get the search commands to work just in the channel and not a s a PM message.
Thanx very much
BTW its a bloody good programming m8

 Respond  
Trion   -  Jul 18, 2006

never min my last request.
I got it to work.
I hoped that the update was for the command in the channel.
But it di`n

 Respond  
Trion   -  Jul 16, 2006

hi, i wonder if anyone could help me.
for some reason i cant get this snippet to work proper.
when i login to it and ask countpacks then the counter gives me all packs in the channel.
When i ask to search or find anything it tells me:
Your results have been restricted to the first results.
Sorry No packs were found that matched \"the text i was looking for\".

i set the results to 5.
hope anyone would give me some help with this.

 Respond  
Rodents   -  Jul 09, 2006

Hi, i have downloaded script, everything works just fine, except i tried to replace that on text deal, and it\'s not working in channel still. Would greatly appreciate any help you can give me <3

 Respond  
Noyerknot   -  May 31, 2006

I\'ve asked for help in the forum, I\'ve written an e-mail to yoinx asking for help, I\'ve gone to the channel on undernet asking for help (Is anyone EVER monitoring that channel or do you all just idle there to make it look like there\'s someone there?). No help to be found anywhere. Just where can I get help with making this particular snippet work?? I keep getting a message that I\'m using an incorret password when I try logging on for the first time even though I use the one I put into the configuration file and I\'m careful about how I type it.

 Respond  
Yoinx   -  Mar 05, 2006

if you change your current on text event in this to:

on :text::#: {
;# Checks if the channel is being indexed.
if ( $istok($hget(searchbot.settings,indexchan),$chan,44) ) {
;# Checks if the line is an actual xdcc ad. And that it is from a voice or higher.
if ( $chr(35) isin $strip($1-,burc)) && ( to request !isin $1- ) && ( xdcc send !isin $1- ) && ($nick($chan,$nick,vho~&)) && ($remove($strip($1,burc),$chr(35),$chr(60),$chr(62),$chr(171),$chr(187)) isnum ) {
;# Checks if the pack is #1
if ( $+($chr(35),1,$chr(32)) isin $strip($1-,burc)) {
;# Checks if the channel\'s index is made.
if ($hget($+(searchbot.,$chan))) {
;# Deletes all packs from a user when they list #1 to ensure old packs arent updated if they list fewer than before.
hdel -w $+(searchbot.,$chan) $+($nick,.)
;# Adds the new #1 pack.
sb.addpack $chan $nick $strip($remove($wildtok($1-,
#,1,32),$chr(91),$chr(93),$chr(171),$chr(187)),burc) $strip($1-,burc)
}
}
else {
;# Adds all packs after #1 for a user.
sb.addpack $chan $nick $strip($remove($wildtok($1-,
#*,1,32),$chr(91),$chr(93),$chr(171),$chr(187)),burc) $strip($1-,burc)
}
}
}
;List the search channels seperated by spaces, as shown
if ($istok(#channel1 #channel2 #channel3,$chan,32)) {
;# Search Events.
If ( $hget(searchbot.settings,enable) == 1 ) {
;# Searches all packs
if ( $istok($hget(searchbot.settings,trigger),$1,44) ) {
if ($2) {
sb.search all $nick $2-
}
else {
.notice $nick Please Specify A Search String.
}
halt
}
;# Searches offline packs
elseif ( $1 == !offline ) {
if ($2) {
sb.search offline $nick $2-
}
else {
.notice $nick Please Specify A Search String.
}
halt
}
;# Searches online packs
elseif ( $1 == !online ) {
if ($2) {
sb.search online $nick $2-
}
else {
.notice $nick Please Specify A Search String.
}
halt
}
}
}
}

it should accept the search commands in the channels after the commented line.

to get the results in notices, just go through the sb.search alias, and change all instances of .msg to .notice

 Respond  
mrmoe   -  Mar 05, 2006

great botscript, i managed to change everything to my liking, but cant figure out how to make it so that you dont have to msg bot !search and can just do it in channel, anyone figure out h0w yet?

 Respond  
ovelayer   -  Feb 16, 2006

Yoinx:
yeah kazuma, I just gave up, you cant please everyone... and I got tired of \"can you change this, can you change that\"
...
pussy
lmfao

 Respond  
nimcdow   -  Feb 02, 2006

Nevermind I figured it out... I just changed line 1245 to:
if ( $chr(35) isin $strip($1-,burc)) && ( to request !isin $1- ) && ( xdcc send !isin $1- ) && ($nick($chan,$nick,vho~&)) && ($remove($strip($1,burc),$chr(35),$chr(60),$chr(62),$chr(91),$chr(93),$chr(171),$chr(187)) isnum ) {

and it worked just fine. =)

 Respond  
nimcdow   -  Feb 02, 2006

Nice script. But doesn\'t seem to work with Kiri. I see that Yoinx doesn\'t feel like working on it anymore, but if anyone else decides to modify the \'on TEXT\' to make it index bots using Kiri please post the change or PM me on IRC: s3rv-w4r3z.org #ServWarez-Chat Thx in advance

 Respond  
`Kazuma   -  Jan 31, 2006

I know what you\'re talking about, lol.

 Respond  
Yoinx   -  Jan 31, 2006

yeah kazuma, I just gave up, you cant please everyone... and I got tired of \"can you change this, can you change that\"

 Respond  
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.