SRU

XDCC (SRU EDiT)

SRU
May 6th, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 52.11 KB | None | 0 0
  1. ;############################
  2. ;#
  3. ;# XDCC SearchBOT Script - Original downloaded from: http://www.hawkee.com/snippet/608/
  4. ;#
  5. ;############################
  6. ;# To Do:
  7. ;# Low Priority: Add A Pm trigger to change new release trigger/time, request enable disable
  8. ;# Medium Priority: Update the help, change the method it displays its help with
  9. ;#############################
  10. ; Startup/Shutdown Events
  11. ;#############################
  12. ;#
  13. ;# Loads Settings, Makes required Directories to prevent errors.
  14. ;#
  15. on *:start: { sb.startup }
  16. on *:unload: { sb.close }
  17. ;#
  18. ;# Saves Settings and indexes
  19. on *:exit: { sb.close }
  20. ;#
  21. ;# Makes the bot join its channels. Starts timers to save indexes and check for old releases.
  22. on *:connect: { if ($network == $hget(SearchBOT.settings,network)) && ($hget(SearchBOT.settings,enable) == 1) { join $hget(SearchBOT.settings,indexchan) | .timerSearchBOTsave 0 600 sb.saveindexes } }
  23. on me:*:JOiN:#: {
  24.   if ($istok($hget(SearchBOT.settings,indexchan),$chan,44)) { $+(.,timer,check.releases.,$chan) 0 600 sb.checkreleasetimes $chan
  25.     if ($hget(SearchBOT.settings,$+($chan,.adtime))) {
  26.       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) }
  27.       elseif ($hget(SearchBOT.settings,$+($chan,.advert))) { $+(.,timer,$chan,.advert) 0 $hget(SearchBOT.settings,$+($chan,.adtime)) .msg $chan $hget(SearchBOT.settings,$+($chan,.advert)) }
  28.     }
  29.   }
  30. }
  31. ;#
  32. ;# Advertises version
  33. ;#
  34. ;ctcp *:VERSION:*:/ctcpreply $nick VERSION SearchBOT 2.8
  35. ;#
  36. ;# Enables you to turn the bot on.
  37. 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) }
  38. ;# Code to allow remote bot updates. Only allows SearchBOT.mrc , creates backups. Only Owners will have access to this.
  39. ;#
  40. on *:FileRCVD:*: {
  41.   if (!$hget(SearchBOT.sessions,$nick))  { .remove $+(",$filename,") | .msg $nick You're send has been removed. }
  42.   elseif ( $nopath($filename) == SearchBOT.mrc ) && ($hget(SearchBOT.sessions,$nick)) {
  43.     .copy $+(",$scriptdir,SearchBOT.mrc,") $+(",$scriptdir,backup/,$asctime(mmm-dd-yyyy-HH-mm-ss),-SearchBOT.mrc,")
  44.     .copy -o $+(",$filename,") $+(",$scriptdir,SearchBOT.mrc,")
  45.     .remove $+(",$filename,")
  46.     .timer 1 1 .msg $nick Script Successfully Backed Up and Reloaded.
  47.     .close -g $nick
  48.     .reload -rs $+(",$scriptdir,SearchBOT.mrc,")
  49.   }
  50. }
  51. ;# Disables dcc ignore if an owner tries to send an update and itis ignored.
  52. on *:GetFAiL:*: { if ( $nopath($filename) == SearchBOT.mrc ) && ($hget(SearchBOT.sessions,$nick)) { .msg $nick Please resend the file. Ignore is now turned off. } }
  53. ;#####################
  54. ; SearchBOT Aliases
  55. ;#####################
  56. ;#
  57. ;# Startup/Shutdown Aliases
  58. ;# No Parameters are passed to any aliases in the Startup/Shutdown Aliases. Other Sections have examples with each alias.
  59. ;#
  60. ;# Startup events
  61. alias sb.startup {
  62.   hfree -w SearchBOT.*
  63.   hmake SearchBOT.settings
  64.   if (!$isdir($+(",$scriptdirdata/,"))) mkdir $+(",$scriptdirdata/,")
  65.   if ($readini($+(",$scriptdir,SearchBOT.ini,"),n,SearchBOT,enable) == $null) { hadd -m SearchBOT.settings enable 1 }
  66.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,enable) == 1) { hadd -m SearchBOT.settings enable 1
  67.   server $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,server) }
  68.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,requests.enable)) {
  69.   hadd SearchBOT.settings requests.enable $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,requests.enable) }
  70.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,network)) {
  71.   hadd SearchBOT.settings network $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,network) }
  72.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,trigger)) {
  73.   hadd SearchBOT.settings trigger $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,trigger) }
  74.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,indexchan)) {
  75.   hadd SearchBOT.settings indexchan $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,indexchan) }
  76.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,maxresults)) {
  77.   hadd SearchBOT.settings maxresults $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,maxresults) }
  78.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,release.trigger)) {
  79.   hadd SearchBOT.settings release.trigger $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,release.trigger) }
  80.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,release.time)) {
  81.     hadd SearchBOT.settings release.time $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,release.time)
  82.   }
  83.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,flood)) {
  84.   hadd SearchBOT.settings flood $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,flood) }
  85.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,floodtime)) {
  86.   hadd SearchBOT.settings floodtime $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,floodtime) }
  87.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,ignore)) {
  88.   hadd SearchBOT.settings ignore $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,ignore) }
  89.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,failed.searches)) {
  90.   hadd SearchBOT.settings failed.searches $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,failed.searches) }
  91.   if ($readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,successful.searches)) {
  92.   hadd SearchBOT.settings successful.searches $readini($+(",$scriptdirSearchBOT.ini,"),n,SearchBOT,successful.searches) }
  93.   mkdir $+(",$scriptdir,update,") | mkdir $+(",$scriptdir,backup,")
  94.   if (!$hget(SearchBOT.settings,default)) {
  95.   hadd -m SearchBOT.settings default This is the Default Advertisement. Please have someone create a custom advertisement for your channel. }
  96.   sb.findhashes
  97. }
  98. ;# Alias to save indexes stored in hash tables to hard drive.
  99. alias sb.saveindexes { hsave -i SearchBOT.settings $+(",$scriptdir,SearchBOT.ini,") SearchBOT
  100.   if (!$isdir($+(",$scriptdir,data,"))) mkdir $+(",$scriptdir,data,")
  101.   var %x = 1
  102.   while ( %x <= $hget(0) ) {
  103.     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 ) {
  104.       .hsave -o $hget(%x) $+(",$scriptdir,data\,$mkfn($hget(%x)),.dat,")
  105.     }
  106.     inc %x
  107.   }
  108. }
  109. ;# Alias to find stored hash tables.
  110. alias sb.findhashes { var %x = 1
  111.   while ( %x <= $findfile($+(",$scriptdir,data/,"),*.dat,0) ) {
  112.     .echo -q $findfile($+(",$scriptdir,data/,"),*.dat,%x,sb.makehashes $1-)
  113.     inc %x
  114.   }
  115. }
  116. ;# Alias to make the hash tables and load any indexes that have been stored on the hard drive
  117. alias sb.makehashes {
  118.   if (*#* iswm $nopath($1-)) {
  119.     if ($istok($hget(SearchBOT.settings,indexchan),$wildtok($nopath($1-),#*,1,46),44)) {
  120.       hmake $left($nopath($1-),-4)
  121.       hload $left($nopath($1-),-4) $+(",$1-,")
  122.     }
  123.   }
  124.   ;  if ( $gettok($left($nopath($1-),-4),2,46) == settings ) halt
  125.   else {
  126.     hmake $left($nopath($1-),-4)
  127.     hload $left($nopath($1-),-4) $+(",$1-,")
  128.   }
  129. }
  130. ;# Alias to perfrom when closing the SearchBOT.
  131. alias sb.close {
  132.   sb.saveindexes
  133.   if ($hget(SearchBOT.settings,enable) == 1)  writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT enable $hget(SearchBOT.settings,enable)
  134.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT trigger $hget(SearchBOT.settings,trigger)
  135.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT indexchan $hget(SearchBOT.settings,indexchan)
  136.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT maxresults $hget(SearchBOT.settings,maxresults)
  137.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT releasetrig $hget(SearchBOT.settings,release.trigger)
  138.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT releasetime $hget(SearchBOT.settings,release.time)
  139.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT flood $hget(SearchBOT.settings,flood)
  140.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT floodtime $hget(SearchBOT.settings,floodtime)
  141.   writeini $+(",$scriptdirSearchBOT.ini,") SearchBOT ignore $hget(SearchBOT.settings,ignore)
  142.   unset %SearchBOT.*
  143. }
  144. ;# Alias to check release times of things in the new releases hash table. Removes outdated items.
  145. alias sb.checkreleasetimes {
  146.   if ($hget($+(SearchBOT.,$1,.newreleases),0).item == 0) halt
  147.   else { var %x = 1
  148.     while ( %x <= $hget($+(SearchBOT.,$1,.newreleases),0).item) {
  149.       if ($hget($+(SearchBOT.,$1,.newreleases),%x).item >= $calc($ctime - $hget(SearchBOT.settings,release.time))) {
  150.         hdel $+(SearchBOT.,$1,.newreleases) $hget($+(SearchBOT.,$1,.newreleases),%x).item
  151.       }
  152.       inc %x
  153.     }
  154.   }
  155. }
  156. ;###################
  157. ;# Searching Aliases
  158. ;###################
  159. ;# test alias
  160. alias sb.search {
  161.   if ($remove($3-,*,?) == $null) || ($len($remove($3-,*,?)) < 2) {
  162.     .msg $2 Please use a more specific search string.
  163.     halt
  164.   }
  165.   else { hadd -m SearchBOT.search $+($2,.searchstring) $+(*,$replace($3-,$chr(32),$chr(42)),*)
  166.     var %x = 1, %z = 1
  167.     while (%z <= $hget(0)) {
  168.       if (SearchBOT.#* !iswm $hget(%z)) || ($hget(%z) == SearchBOT.search) { inc %z | continue }
  169.       else {
  170.         if ($hfind($hget(%z),$hget(SearchBOT.search,$+($2,.searchstring)),0,w).data == 0) { inc %z | continue }
  171.         else {
  172.           hinc SearchBOT.search $+($2,.allresults) $hfind($hget(%z),$hget(SearchBOT.search,$+($2,.searchstring)),0,w).data
  173.           hinc SearchBOT.search $+($2,.chans)
  174.           inc %z
  175.         }
  176.       }
  177.     }
  178.     var %x = 1, %z = 1
  179.     while (%z <= $hget(0)) {
  180.       if (SearchBOT.#* !iswm $hget(%z)) || ($hget(%z) == SearchBOT.search) { inc %z | continue }
  181.       else {
  182.         if ($hfind($hget(%z),$hget(SearchBOT.search,$+($2,.searchstring)),0,w).data == 0) { inc %z | continue }
  183.         else {
  184.           while (%x <= $hfind($hget(%z),$hget(SearchBOT.search,$+($2,.searchstring)),0,w).data) {
  185.             if ($hget(SearchBOT.search,$+($2,.totalresults)) >= $hget(SearchBOT.settings,maxresults)) { goto truncated }
  186.             hinc SearchBOT.search $+($2,.totalresults)
  187.             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)
  188.               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) }
  189.               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) }
  190.             }
  191.             else { hinc SearchBOT.search $+($2,.offline)
  192.               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) }
  193.               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) }
  194.             }
  195.             inc %x
  196.           }
  197.         }
  198.         inc %z
  199.       }
  200.     }
  201.     goto end
  202.     :truncated
  203.     .msg $2 Your results have been restricted to the first $hget(SearchBOT.settings,maxresults) results.
  204.     goto end
  205.     :end
  206.     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 }
  207.     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 }
  208.     hdel -w SearchBOT.search $+($2,*)
  209.   }
  210. }
  211. ;# Allows people to see what new releases are avaiable. Useage= sb.newreleases $nick
  212. alias sb.newreleases {
  213.   if ($hget(NewReleases,0).item == 0) .msg $1 There are No New releases listed.
  214.   else {
  215.     .msg $1 There are currently $hget(NewReleases,0).item New Releases Listed.
  216.     set $+(%,$1) 1
  217.     while ( $($+(%,$1),2) <= $hget(NewReleases,0).item ) {
  218.       .msg $1 New Release $($+(%,$1),2) : $hget(NewReleases,$($+(%,$1),2)).data
  219.       inc $+(%,$1)
  220.     }
  221.   }
  222.   unset set $+(%,$1)
  223. }
  224. ;################
  225. ;# Pack Aliases
  226. ;################
  227. ;# Adds a pack. Useage= sb.addpack $chan $nick $strip($remove($wildtok($1-,*#*,1,32),$chr(91),$chr(93)),burc) $strip($1-,burc)
  228. alias sb.addpack {
  229.   echo -st [9Working]-[9Added] $+(3,$1,) 4@ $+(07,$2,.,$3,) $+(15,$4-,)
  230.   hadd -m $+(SearchBOT.,$1) $+($2,.,$3) $4-
  231. }
  232. ; Returns Total Packs Indexed on all channels. And Number of Channels Indexed. Useage= msg $nick $sb.countpacks
  233. alias sb.countpacks {
  234.   if (!$1) { var %x = 1, %numpacks = 0
  235.     while ( %x <= $numtok($hget(SearchBOT.settings,indexchan),44)) {
  236.       inc %numpacks $hget($+(SearchBOT.,$gettok($hget(SearchBOT.settings,indexchan),%x,44)),0).item
  237.       inc %x
  238.     }
  239.     return %numpacks
  240.   }
  241.   elseif ($1) {
  242.     if ($left($1,1) != $chr(35)) { return Error: You must specify a channel. }
  243.     if (!$hget($+(SearchBOT.,$1))) { return No Packs are currently indexed for $+(",$1,") }
  244.     else { Return $hget($+(SearchBOT.,$1),0).item }
  245.   }
  246. }
  247. ;#################
  248. ;# Control Aliases
  249. ;#################
  250. ;# Disables the SearchBOT Remotely. No Paramaeters.
  251. alias sb.disableSearchBOT {
  252.   hadd SearchBOT.settings enable 0
  253.   msg %SearchBOT.searchchan This SearchBOT is now offline.
  254. }
  255. ;# Enables the SearchBOT Remotely. No Parameters.
  256. alias sb.enableSearchBOT {
  257.   hadd SearchBOT.settings enable 1
  258.   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))
  259. }
  260. ;# Used to validae logins. Useage= msg $nick $sb.login($1,$nick)
  261. alias sb.login { var %x = 1
  262.   if ( $hget(SearchBOT.sessions,$2) ) {
  263.     return You are already logged in with $+(",$hget(SearchBOT.sessions,$2),") - Please logout before logging in with a different access.
  264.   }
  265.   while ( %x <= $ini($+(",$scriptdir,SearchBOT.ini"),passwords,0) ) {
  266.     if ( $1 === $readini($+(",$scriptdir,SearchBOT.ini"),passwords,$ini($+(",$scriptdir,SearchBOT.ini"),passwords,%x)) ) {
  267.       hadd -mu1800 SearchBOT.sessions $2 $ini($+(",$scriptdir,SearchBOT.ini"),passwords,%x)
  268.       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.
  269.     }
  270.     inc %x
  271.   }
  272.   return Password Incorrect. You are not Logged in.
  273. }
  274. ;# Used to log yourself out. Useage= msg $nick $sb.logout($nick)
  275. alias sb.logout {
  276.   if (!$hget(SearchBOT.sessions,$1)) { return Error: You are not currently Logged In. }
  277.   else {
  278.     hdel SearchBOT.sessions $1
  279.     return You are now logged out. You must login again before you will have any bot control.
  280.   }
  281. }
  282. ;# Alias to change passwords. Useage msg $nick $sb.changepass(level,newpass)
  283. alias sb.changepass {
  284.   if ( $istok(op admin owner,$1,32) ) {
  285.     writeini $+(",$scriptdir,SearchBOT.ini,") passwords $1 $2
  286.     return You have changed the password for $+(",$1,") to $+(",$2,")
  287.   }
  288.   else { return Error: You must specify a level (op admin owner) and a password. }
  289. }
  290. ;# Alias to get a password.
  291. alias sb.getpass {
  292.   if ( $istok(op admin owner,$1,32) ) { return The password for $+(",$1,") is $+(",$readini($+(",$scriptdir,SearchBOT.ini,"),passwords,$1),") }
  293.   else { return Error: You must specify a level (op admin owner) }
  294. }
  295. ;# alias to get a list of sessions.
  296. alias sb.sessions {
  297.   hsave -iu SearchBOT.sessions $+(",$scriptdir,sessions.tmp,") sessions
  298.   var %x = 1
  299.   while ( %x <= $ini($+(",$scriptdir,sessions.tmp,"),sessions,0) ) {
  300.     .msg $1 $+(",$ini($+(",$scriptdir,sessions.tmp,"),sessions,%x),") is logged in as $+(",$readini($+(",$scriptdir,sessions.tmp,"),sessions,$ini($+(",$scriptdir,sessions.tmp,"),sessions,%x)),")
  301.     inc %x
  302.   }
  303.   .remove $+(",$scriptdir,sessions.tmp,")
  304.   .msg $1 End of Sessions.
  305. }
  306. ;# Alias to log another user out. Useage= msg $nick $sb.disconnect(*!ident@host)
  307. alias sb.disconnect {
  308.   if (!$hget(SearchBOT.sessions,$1)) { return Error: $+(",$1,") is not currently logged in. }
  309.   else {
  310.     .hdel SearchBOT.sessions $1
  311.     return User $+(",$1,") has been disconnected.
  312.   }
  313. }
  314. ;# Returns true if someone is listed in a channel's index. Useage= msg $nick $sb.findserver(#channel,$nick)
  315. alias sb.findserver {
  316.   if ( !$hget($+(SearchBOT.,$1)) ) { return $1 does not currently have an index. }
  317.   elseif ( $hfind($+(SearchBOT.,$1),$+($2,.*),0,w) < 1 ) { return $2 does not have any packets listed on $1 }
  318.   else { return $2 has $hfind($+(SearchBOT.,$1),$+($2,.*),0,w) packets listed on $1 }
  319. }
  320. ;# Used To delete nicks from an index. Useage= msg $nick $sb.delserver(#channel,$nick)
  321. alias sb.delserver {
  322.   if ( !$hget($+(SearchBOT.,$1)) ) { return $1 does not currently have an index. }
  323.   elseif ( $hfind($+(SearchBOT.,$1),$+($2,.*),0,w) < 1 ) { return $2 does not have any packets listed on $1 }
  324.   else {
  325.     hdel -w $+(SearchBOT.,$1) $+($2,.*)
  326.     return $2 has been deleted from the index of $1
  327.   }
  328. }
  329. ;#############################
  330. ;# Channel Indexing Functions.
  331. ;#############################
  332. ;# Used to add a channel to index. Useage= msg $nick $sb.addchan(#channel)
  333. alias sb.addchan {
  334.   if ( $left($1,1) != $chr(35) ) { return Error: You must specify a channel. }
  335.   if ($istok($hget(SearchBOT.settings,indexchan),$1,44)) { return Error: $+(",$1,") is currently being indexed. }
  336.   else {
  337.     hadd SearchBOT.settings indexchan $addtok($hget(SearchBOT.settings,indexchan),$1,44)
  338.     join $1
  339.     if (!hget($+(SearchBOT.,$1))) { hmake $+(SearchBOT.,$1) 50 }
  340.     if ( $exists($+(",$scriptdir,data/,SearchBOT.,$1,.dat,")) ) { hload $+(SearchBOT.,$1) $+(",$scriptdir,data/,SearchBOT.,$1,.dat,") }
  341.     if ( $exists($+(",$scriptdir,data/,SearchBOT.,$1,newreleases.dat,")) ) {
  342.       hmake $+(SearchBOT.,$1,.newreleases)
  343.       hload $+(SearchBOT.,$1,.newreleases) $+(",$scriptdir,data/,SearchBOT.,$1,newreleases.dat,")
  344.     }
  345.     return $+(",$1,") has been added to the channels this bot is indexing.
  346.   }
  347. }
  348. ;# Used to delete an index channel. Useage= msg $nick $sb.delchan(#channel,$nick)
  349. alias sb.delchan {
  350.   if ( $left($1,1) != $chr(35) ) { return Error: You must specify a channel. }
  351.   if (!$istok($hget(SearchBOT.settings,indexchan),$1,44)) { return Error: $+(",$1,") is not currently being indexed. }
  352.   else {
  353.     hadd SearchBOT.settings indexchan $remtok($hget(SearchBOT.settings,indexchan),$1,1,44)
  354.     part $1 I am no longer indexing this channel at the request of $+(",$2,")
  355.     if ($hget($+(SearchBOT.,$1))) {    
  356.       hsave -o $+(SearchBOT.,$1) $+(",$scriptdir,data/,SearchBOT.,$1,.dat,")
  357.       hfree $+(SearchBOT.,$1)
  358.     }
  359.     return $+(",$1,") has been deleted from my my index channels.
  360.   }
  361. }
  362. ;# Used to add a search trigger. Useage: msg $nick $sb.addtrig(trigger)
  363. alias sb.addtrig {
  364.   if ($istok($hget(SearchBOT.settings,trigger),$1,44)) { return Error: $+(",$1,") is already being used as a trigger }
  365.   hadd SearchBOT.settings trigger $addtok($hget(SearchBOT.settings,trigger),$1,44)
  366.   return $+(",$1,") successfully added. Current triggers: $hget(SearchBOT.settings,trigger)
  367. }
  368. ;# Used to delete a search trigger. Useage: msg $nick $sb.deltrig(trigger)
  369. alias sb.deltrig {
  370.   if (!$istok($hget(SearchBOT.settings,trigger),$1,44)) { return Error: $+(",$1,") is not being used as a trigger }
  371.   hadd SearchBOT.settings trigger $remtok($hget(SearchBOT.settings,trigger),$1,1,44)
  372.   return $+(",$1,") successfully deleted. Current triggers: $hget(SearchBOT.settings,trigger)
  373. }
  374. ;#########################
  375. ;# New Releases Functions.
  376. ;#########################
  377. ;# Used to add a New Release to a channel. Useage: /msg $nick $sb.addrelease(#channel,release)
  378. alias sb.addrelease {
  379.   if ($left($1,1) != $chr(35)) { return Error: You must specify a channel. }
  380.   if (!$istok($hget(SearchBOT.settings,indexchan),$1,44)) { return Error: I am not currently indexing $+(",$1,") }
  381.   if ($hget($+(SearchBOT.,$1,.newreleases),$2)) { return Error: $+(",$2,") is already listed as a new release on $+(",$1,") }
  382.   else {
  383.     hadd -m $+(SearchBOT.,$1,.newreleases) $ctime $2
  384.     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)
  385.   }
  386. }
  387. ;# Used to list releases for a channel. Useage= /sb.listrelease $channel $nick
  388. alias sb.listreleases {
  389.   if ($left($1,1) != $chr(35)) { .msg $2 Error: You must specify a channel. }
  390.   if ( $hget($+(SearchBOT.,$1,.newreleases),0).item == 0 ) || (!$hget($+(SearchBOT.,$1,.newreleases))) { .msg $2 No releases are listed for $+(",$1,") }
  391.   else { var %x = 1
  392.     .msg $nick Listing New Releases for $+(",$1,")
  393.     while (%x <= $hget($+(SearchBOT.,$1,.newreleases),0).item) {
  394.       .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),")
  395.       inc %x
  396.     }
  397.     .msg $2 End Of Listing.
  398.   }
  399. }
  400. ;# Used to delete a release for a channel manually. Useage= /msg $nick $sb.delrelease(#channel,release text)
  401. alias sb.delrelease {
  402.   if ($left($1,1) != $chr(35)) { return Error: You must specify a channel. }
  403.   if ( $hget($+(SearchBOT.,$1,.newreleases),0).item == 0 ) || (!$hget($+(SearchBOT.,$1,.newreleases))) { return No releases are listed for $+(",$1,") }
  404.   if (!$hfind($+(SearchBOT.,$1,.newreleases),$2,1).data) { return Error: $+(",$2,") is not in the release list for $+(",$1,") }
  405.   else {
  406.     hdel $+(SearchBOT.,$1,.newreleases) $hfind($+(SearchBOT.,$1,.newreleases),$2,1).data
  407.     return $+(",$2,") successfully deleted from the listing for $+(",$1,")
  408.   }
  409. }
  410. ;# Used to list releases for a certain channel. sb.listreleases #channel nick
  411. alias sb.listreleases {
  412.   if ( $left($1,1) != $chr(35)) { return Error: You must specify a channel. }
  413.   elseif (!$hget($+(SearchBOT.,$1,.newreleases))) { return There are currently no new releases listed for $+(",$1,") }
  414.   else {
  415.     hsave -i $hget($+(SearchBOT.,$1,.newreleases)) $+(",$scriptdir,$1,.newreleases.tmp") releases
  416.     .play -treleases $2 $+(",$scriptdir,$1,.newreleases.tmp")
  417.   }
  418. }
  419. ;#######################
  420. ;# Advertisement Aliases
  421. ;#######################
  422. ;# Used to find a channels advertisement. Uses defualt one if it cant find one. $sb.getadvert(#channel)
  423. alias sb.getadvert {
  424.   if ( $left($1,1) != $chr(35)) { return Error: You must specify a channel name. }
  425.   if (!$hget(SearchBOT.settings)) { return Error: Settings Table not found. }
  426.   if (!$hget(SearchBOT.settings,$+($1,.advert))) {
  427.     if (!$hget(SearchBOT.settings,default.advert)) { return Error: No advertisment found for $+(",$1,") Default advert not found. }
  428.     else { return Default advertisement of $+(",$hget(SearchBOT.settings,default.advert),") is being used for $+(",$1,") }
  429.   }
  430.   else { return Advertisement for $+(",$1,") is set to $+(",$hget(SearchBOT.settings,$+($1,.advert)),") }
  431. }
  432. ;# Sets the advertisment for a specified channel or the defualt. $sb.setadvert(#channel,new ad)
  433. alias sb.setadvert {
  434.   if ($1 == default) {
  435.     hadd -m SearchBOT.settings default.advert $2-
  436.     return Default Advertisment successfully set to $+(",$2-,")
  437.   }
  438.   if ($left($1,1) != $chr(35)) { return Error: You must specify a channel. }
  439.   else {
  440.     hadd -m SearchBOT.settings $+($1,.advert) $2-
  441.     return Advert for $+(",$1,") sucessfully set to $+(",$2,")
  442.   }
  443. }
  444. ;# Deletes an advert for a specified channel or defualt. $sb.deladvert(#channel)
  445. alias sb.deladvert {
  446.   if ($1 == default) {
  447.     hdel SearchBOT.settings default.advert
  448.     return Default Advertisment successfully deleted.
  449.   }
  450.   if ($left($1,1) != $chr(35)) { return Error: You must specify a channel. }
  451.   else {
  452.     hdel SearchBOT.settings $+($1,.advert)
  453.     if ($timer($+($1,.advert))) { $+(.timer,$1,.advert) off }
  454.     return Advert for $+(",$1,") sucessfully deleted and stopped.
  455.   }
  456. }
  457. ;# Formats the advertisment to replace substitution words. $sb.formatadvert(#channel)
  458. alias sb.formatadvert {
  459.   if ( $left($1,1) != $chr(35)) { return Error: You must specify a channel with this command. }
  460.   if (!$hget(SearchBOT.settings,$+($1,.advert))) {
  461.     if ($hget(SearchBOT.settings,default.advert)) { return $sb.subadvert($hget(SearchBOT.settings,default.advert)) }
  462.     else { return No advert set for $+(",$1,"). Default Advert not found. }
  463.   }
  464.   else { return $sb.subadvert($hget(SearchBOT.settings,$+($1,.advert))) }
  465. }
  466. ;# Performs substitutions for advert. $sb.subadvert(advert)
  467. alias sb.subadvert { return $replace($1-,[triggers],$+(",$replace($hget(SearchBOT.settings,trigger),$chr(44),$+($chr(32),or,$chr(32))),"),[indexchans],$+(",$hget(SearchBOT.settings,indexchan),")) }
  468. ;# Sets an advertisement time.
  469. alias sb.setadtime {
  470.   if ( $left($1,1) != $chr(35)) { return Error: You must specify a channel with this command. }
  471.   if ($2 !isnum) { Return Error: You must specify a time in seconds. /msg $me setadtime #channel 300 - would make a 5 minute advert. }
  472.   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. }
  473.   else {
  474.     if ($me !ison $1) { return Error: I am not currently on $+(",$1,") so I cannot run an advertisement on that channel. }
  475.     else {
  476.       hadd SearchBOT.settings $+($1,.adtime) $2
  477.       $+(.,timer,$1,.advert) 0 $hget(SearchBOT.settings,$+($1,.adtime)) .msg $1 $sb.formatadvert($1)
  478.       return Ad Time for $+(",$1,") successfully set to $+(",$duration($2),")
  479.     }
  480.   }
  481. }
  482. ;# Returns the adtime. /msg $nick $sb.getadtime(#channel)
  483. alias sb.getadtime {
  484.   if ($left($1,1) != $chr(35)) { return Error: You must specify a channel. }
  485.   if (!$hget(SearchBOT.settings,$+($1,.adtime))) { return Error: There is no advert time set for $+(",$1,") }
  486.   else { return Current Advert time for $+(",$1,") set to $+(",$duration($hget(SearchBOT.settings,$+($1,.adtime))),") }
  487. }
  488. ;#################
  489. ;# Request Aliases
  490. ;#################
  491. ;# Alias to Add a request.
  492. alias sb.addrequest {
  493.   if ( $hfind(SearchBOT.requests,$1-).data) { return Error: You have already placed that request at $asctime($hfind(SearchBOT.requests,$1-).data) }
  494.   hadd -m SearchBOT.requests $ctime $1-
  495.   return Your request has been added on $+(-,$asctime,-)
  496. }
  497. ;# Alias to list requests.
  498. alias sb.listrequests {
  499.   if (!$hget(SearchBOT.requests)) || ($hget(SearchBOT.requests,0).item == 0) { .msg $1 No requests are currently stored. }
  500.   else {
  501.     write -c $+(",$scriptdir,requests.txt,") Current Requests are:
  502.     var %x = 1
  503.     while (%x <= $hget(SearchBOT.requests,0).item) {
  504.       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)
  505.       inc %x
  506.     }
  507.     write $+(",$scriptdir,requests.txt,") If you can fill any of these requests please do.
  508.     .play $1 $+(",$scriptdir,requests.txt,")
  509.   }
  510. }
  511. ;# Alias to delete a request.
  512. alias sb.delrequest {
  513.   if (!$hget(SearchBOT.requests)) { return Error: No Requests are currently found on this bot. }
  514.   elseif (!$hfind(SearchBOT.requests,$+(*,$1-),1,w).data) { return Error: $+(",$1-,") was not found in the requests. }
  515.   else {
  516.     hdel SearchBOT.requests $hfind(SearchBOT.requests,$+(*,$1-),1,w).data
  517.     return $+(",$1,") Has successfully been deleted.
  518.   }
  519. }
  520. ;#################
  521. ;# Ignore Aliases
  522. ;#################
  523. ;# Alias to list ingored hosts
  524. alias sb.listignored {
  525.   if ( $ignore(0) == 0 ) { .msg $1 There are currently no ignores set. }
  526.   else {
  527.     write -c $+(",$scriptdir,ignore.txt,")
  528.     var %x = 1
  529.     while ( %x <= $ignore(0) ) {
  530.       write $+(",$scriptdir,ignore.txt,") Nick: $gettok($ignore(%x),1,33) Type: $ignore(%x).type Unset in: $duration($ignore(%x).secs)
  531.       inc %x
  532.     }
  533.     .play $1 $+(",$scriptdir,ignore.txt,")
  534.   }
  535. }
  536. ;# Alias to remove an ignore
  537. alias sb.delignore {
  538.   if (!$ignore($+($1,!*@*))) { return Error: That nick is not ignored. }
  539.   else {
  540.     ignore -r $+($1,!*@*)
  541.     return $+(",$1,") Successfully unignored
  542.   }
  543. }
  544. ;################
  545. ;# Backup Aliases
  546. ;################
  547. ;# Alias to list all Backedup script files. Found in /backup
  548. alias sb.listbackups {
  549.   if ( $findfile($+(",$scriptdir,backup/,"),*.mrc,0) == 0 ) { .msg $1 No Backedup Scripts found. }
  550.   else { var %x = 1
  551.     .write -c $+(",$scriptdir,backups.txt,") Backed Up SearchBOT Scripts.
  552.     while ( %x <= $findfile($+(",$scriptdir,backup/,"),*.mrc,0) ) {
  553.       .write $+(",$scriptdir,backups.txt,") $nopath($findfile($+(",$scriptdir,backup/,"),*.mrc,%x))
  554.       inc %x
  555.     }
  556.     .write $+(",$scriptdir,backups.txt,") End of Backups
  557.     .play $1 $+(",$scriptdir,backups.txt,")
  558.   }
  559. }
  560. ;# Alias to restore a backedup script.
  561. alias sb.restorebackup {
  562.   if ($findfile($+(",$scriptdir,backup/,"),$2-,1) == 0 ) { .msg $1 $+(",$2-,") Was not found in my backups. }
  563.   else {
  564.     .msg $1 Script Is being rerstored. It may take a few secoonds.
  565.     .timerunloadSearchBOT 1 2 unload -rs SearchBOT.mrc
  566.     .timerbackupscript 1 2 .copy $+(",$scriptdir,SearchBOT.mrc,") $+(",$scriptdir,backup/,$asctime(mmm-dd-yyyy-HH-mm-ss),-SearchBOT.mrc,")
  567.     .timercopyscript 1 2 .copy -o $+(",$scriptdir,backup/,$2-,") $+(",$scriptdir,SearchBOT.mrc,")
  568.     .timerreloadscript 1 2 load -rs $+(",$scriptdir,SearchBOT.mrc,")
  569.     .timermsgnick 1 2 .msg $1 Script Restored and Reloaded
  570.   }
  571. }
  572. ;#################
  573. ;# Misc. Aliases
  574. ;#################
  575. ;# Checks if a new trigger is a command. When commands are added they must be added here as well to prevent search trigger conflicts.
  576. 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 } }
  577. ;# checks if anyone is using a file for a play. If they arent it deletes the file.
  578. alias sb.playcheck { var %x = 1
  579.   while ( %x <= $play(0)) { if ($play(%x).fname == $1- ) { return true } | inc %x }
  580. }
  581. ;# Alias to change flood settings.
  582. alias sb.flood {
  583.   if ($1 !isnum ) { return Error: You may only specify a number with this command. }
  584.   else {
  585.     if ($prop == flood) {
  586.       hadd SearchBOT.settings flood $1
  587.       return Amount of messages to trigger flood have been changed to $+(",$1,").
  588.     }
  589.     elseif ($prop == floodtime) {
  590.       hadd SearchBOT.settings floodtime $1
  591.       return The flood time has been changed to $+(",$1,").
  592.     }
  593.     elseif ($prop == ignoretime) {
  594.       hadd SearchBOT.settings ignore $1
  595.       return The ignore time for a user who floods the bot has been changed to $+(",$1,").
  596.     }
  597.   }
  598. }
  599. ;# alias to change the max results setting
  600. alias sb.maxresults {
  601.   if ($1 !isnum ) { Return Current Max Results: $+(",$hget(SearchBOT.settings,maxresults),") Please specify a number with this command to change it. }
  602.   elseif ( $1 == $hget(SearchBOT.settings,maxresults) ) { return Error: Your parameter matches the current setting. }
  603.   else {
  604.     hadd SearchBOT.settings maxresults $1
  605.     return Max results set to $+(",$1,").
  606.   }
  607. }
  608. ;# Alias to total up searches
  609. alias sb.searchcount {
  610.   .msg $1 Failed Searches: $iif($hget(SearchBOT.settings,failed.searches),$hget(SearchBOT.settings,failed.searches),0)
  611.   .msg $1 Successful Searches: $iif($hget(SearchBOT.settings,successful.searches),$hget(SearchBOT.settings,successful.searches),0)
  612.   .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) )
  613. }
  614. ;###################
  615. ;# On Text Events
  616. ;# #################
  617. on *:text:*:?: {
  618.   if ($hget(SearchBOT.settings,enable) == 1) { .closemsg $nick
  619.     ;# Anti-Flood Event.
  620.     if (!$hget(SearchBOT.sessions,$nick)) { hinc $+(-,mu,$hget(SearchBOT.settings,floodtime)) SearchBOT.flood $nick
  621.       if ($hget(SearchBOT.flood,$nick) >= $hget(SearchBOT.settings,flood)) { .ignore $+(-,pcdinktu,$hget(SearchBOT.settings,ignore)) $nick | .closemsg $nick | hdel SearchBOT.flood $nick
  622.         .msg $nick You have activated flood protect... and will be actively ignored for $+(07,$duration($hget(SearchBOT.settings,ignore)),...) enjoy ;)
  623.         halt
  624.       }
  625.     }
  626.     if ($chr(124) isin $1-) { .msg $nick Please do not include $+(",$chr(124),") in your messages. | halt }
  627.     ;*** /msg $me HELP
  628.     elseif (help isin $1) {
  629.       if (!$hget(SearchBOT.sessions,$nick)) { .play -tallusers $nick $+(",$scriptdir,SearchBOT.mrc,") }
  630.       elseif ($hget(SearchBOT.sessions,$nick) == owner) {
  631.         .play -tallusers $nick $+(",$scriptdir,SearchBOT.mrc,")
  632.         .play -towner $nick $+(",$scriptdir,SearchBOT.mrc,")
  633.         .play -tadmin $nick $+(",$scriptdir,SearchBOT.mrc,")
  634.         .play -top $nick $+(",$scriptdir,SearchBOT.mrc,")
  635.       }
  636.       elseif ($hget(SearchBOT.sessions,$nick) == admin) {
  637.         .play -tallusers $nick $+(",$scriptdir,SearchBOT.mrc,")
  638.         .play -tadmin $nick $+(",$scriptdir,SearchBOT.mrc,")
  639.         .play -top $nick $+(",$scriptdir,SearchBOT.mrc,")
  640.       }
  641.       elseif ($hget(SearchBOT.sessions,$nick) == op) {
  642.         .play -tallusers $nick $+(",$scriptdir,SearchBOT.mrc,")
  643.         .play -top $nick $+(",$scriptdir,SearchBOT.mrc,")
  644.       }
  645.       halt
  646.     }
  647.     ;*** Lists Triggers
  648.     elseif ($1 == triggers) {
  649.       .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.
  650.       halt
  651.     }
  652.     ;*** Search Events.
  653.     elseif ($hget(SearchBOT.settings,enable) == 1) {
  654.       ;*** Searches all packs
  655.       if ($istok($hget(SearchBOT.settings,trigger),$1,44)) {
  656.         if ($2) { sb.search all $nick $2- }
  657.         else { .msg $nick Please Specify A Search String. }
  658.         halt
  659.       }
  660.       ;*** Searches offline packs
  661.       elseif (offline isin $1) {
  662.         if ($2) { sb.search offline $nick $2- }
  663.         else { .msg $nick Please Specify A Search String. }
  664.         halt
  665.       }
  666.       ;*** Searches online packs
  667.       elseif (online isin $1) {
  668.         if ($2) { sb.search online $nick $2- }
  669.         else { .msg $nick Please Specify A Search String. }
  670.         halt
  671.       }
  672.     }
  673.     ;*** New release Listing.
  674.     elseif ($istok($hget(SearchBOT.settings,release.trigger),$1,44)) {
  675.       if (!$2) { .msg $nick You must specify a channel to lookup releases for. }
  676.       else { sb.listreleases $2 $nick }
  677.       halt
  678.     }
  679.     ;*** Lets a user add a request.
  680.     elseif ($1 == !request) && ($hget(SearchBOT.settings,requests.enable) == 1) {
  681.       if (!$2) { .msg $nick You must include text for a request. }
  682.       else { .msg $nick $sb.addrequest($nick $2-) }
  683.       halt
  684.     }
  685.     ;*** Lists all requests.
  686.     elseif ($1 == !requests) && ($hget(SearchBOT.settings,requests.enable) == 1) { sb.listrequests $nick | halt }
  687.   }
  688.   ;*** Login Event.
  689.   if ($1 == login) {
  690.     if (!$2) { .msg $nick You MUST specify a password. }
  691.     else { .msg $nick $sb.login($2,$nick) }
  692.     halt
  693.   }
  694.   ;*** Logout Event
  695.   elseif ($1 == logout) { .msg $nick $sb.logout($nick) | halt }
  696.   ;*** Stops access to all following commands if the person is not logged in.
  697.   elseif (!$hget(SearchBOT.sessions,$nick)) && ($hget(SearchBOT.settings,enable) == 1) {
  698.     .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*
  699.     halt  
  700.   }
  701.   ;*** Control Access
  702.   ;* Checks if the user is logged in to get access to all following commands.
  703.   elseif ($hfind(SearchBOT.sessions,$nick)) {
  704.     ;*** Owner section - Checks if you are an owner. Limits Commands nested in this if to an owner.
  705.     if ($hget(SearchBOT.sessions,$nick) == owner) {
  706.       ;*** Change login passwords
  707.       elseif ($1 == changepass) {
  708.         if (!$2) || (!$3) { .msg $nick Useage: /msg $me changepass level (op admin owner) newpass }
  709.         else { .msg $nick $sb.changepass($2,$3) }
  710.       }
  711.       ;*** Get login passwords
  712.       elseif ($1 == getpass) {
  713.         if (!$2) { .msg $nick Useage: /msg $me getpass level (op admin owner) }
  714.         else { .msg $nick $sb.getpass($2) }
  715.       }
  716.       ;*** Lists all logged in sessions
  717.       elseif ($1 == sessions) { sb.sessions $nick }
  718.       ;# Disconnects a logged in session
  719.       elseif ($1 == disconnect) {
  720.         if (!$2) { .msg $nick Useage: /msg $me disconnect *!ident@host }
  721.         else { .msg $nick $sb.disconnect($2) }
  722.       }
  723.       ;# Rehashes the startup events.
  724.       elseif ($1 == rehash) { sb.startup }
  725.       elseif ($1 == listbackups) { sb.listbackups $nick }
  726.       elseif ($1 == restorebackup) {
  727.         if (!$2) { .msg $nick Error: You must specify the filename to restore. }
  728.         else { sb.restorebackup $nick $2- }
  729.       }
  730.       elseif ($1 == flood) {
  731.         if (!$2) { .msg $nick You must specify a number for this command. }
  732.         else { .msg $nick $sb.flood($2).flood }
  733.       }
  734.       elseif ($1 == floodtime) {
  735.         if (!$2) { .msg $nick You must specify a number for this command. }
  736.         else { .msg $nick $sb.flood($2).floodtime }
  737.       }
  738.       elseif ($1 == ignoretime) {
  739.         if (!$2) { .msg $nick You must specify a number for this command. }
  740.         else { .msg $nick $sb.flood($2).ignoretime }
  741.       }
  742.       elseif ($1 == maxresults) {
  743.         if (!$2) || ($2 !isnum) { .msg $nick You must specify a number for this command. }
  744.         else { .msg $nick $sb.maxresults($2) }
  745.       }
  746.     }
  747.     ;*** Admin Section - Checks if you are an owner or admin. Limits Commands nested in this if to an owner or admin.
  748.     if ($hget(SearchBOT.sessions,$nick) == admin) || ($hget(SearchBOT.sessions,$nick) == owner) {
  749.       ;*** Deletes all of a nicks entries out of a channel's index.
  750.       if ($1 == delnick) {
  751.         if ($left($2,1) != $chr(35)) { .msg $nick You must specify a channel. Syntax: /msg $me delete #channel nick }
  752.         elseif (!$3) { .msg $nick You must specify a nick. Syntax: /msg $me delete #channel nick }
  753.         else { .msg $nick $sb.delserver($2,$3) }
  754.       }
  755.       ;*** Adds an index channel
  756.       elseif ($1 == addchan) {
  757.         if (!$2) { .msg $nick You must specify a channel. Useage: /msg $me addchan #channel }
  758.         else { .msg $nick $sb.addchan($2) }
  759.       }
  760.       ;*** Deletes an index channel
  761.       elseif ($1 == delchan) {
  762.         if (!$2) { .msg $nick You must specify a channel. Useage: /msg $me delchan #channel }
  763.         else { .msg $nick $sb.delchan($2,$nick) }
  764.       }
  765.       ;*** Deletes a new release manually.
  766.       elseif ($1 == delrelease) {
  767.         if (!$2) || (!$3) { .msg $nick Error: You must specify a channel and a release name. Useage: /msg $me delrelease #channel releasetext }
  768.         else { .msg $nick $sb.delrelease($2,$3-) }
  769.       }
  770.       ;*** Lists all releases for a channel.
  771.       elseif ($1 == listreleases) {
  772.         if (!$2) { .msg $nick Error: You must specify a channel. Useage: /msg $me listreleases #channel }
  773.         else { sb.listreleases $2 $nick }
  774.       }
  775.       ;*** Sets an advertisement
  776.       elseif ($1 == setadvert) {
  777.         if (!$2) || (!$3) { .msg $nick Error. You must specify a channel or defualt and advertisement. Useage: /msg $me setadvert #channel/default new advertisement. }
  778.         else { .msg $nick $sb.setadvert($2,$3-) }
  779.       }
  780.       ;*** Deletes an advertisement
  781.       elseif ($1 == deladvert) {
  782.         if (!$2) { .msg $nick Error. You must specify a channel or default. Useage: /msg $me deladvert #channel }
  783.         else { .msg $nick $sb.deladvert($2) }
  784.       }
  785.       ;*** Get the advertisement for a channel without substitutions. [triggers] is replaced with the current triggers [indexchans] is replaced with the indexed channels.
  786.       elseif ($1 == getadvert) {
  787.         if (!$2) { .msg $nick You must specify a channel. }
  788.         else { .msg $nick $sb.getadvert($2) }
  789.       }
  790.       ;*** Sets the repeat time for an ad.
  791.       elseif ($1 == setadtime) {
  792.         if (!$2) || (!$3) { .msg $nick Error. You must specify a channel and advertisement time. Useage: /msg $me setadvert #channel 300. }
  793.         else { .msg $nick $sb.setadtime($2,$3) }
  794.       }
  795.     }
  796.     ;*** Operator Commands - Checks if you are an owner, admin, or op. Limits Commands nested in this if to an owner, admin, or op.
  797.     if ( $hget(SearchBOT.sessions,$nick) == op ) || ( $hget(SearchBOT.sessions,$nick) == admin ) || ( $hget(SearchBOT.sessions,$nick) == owner ) {
  798.       ;*** Searches for a nick in a channels index. Returns information about the nick.
  799.       if ($1 == info) {
  800.         if ($left($2,1) != $chr(35)) { .msg $nick You must specify a channel. Syntax: /msg $me info #channel nick }
  801.         elseif (!$3) { .msg $nick You must specify a nick. Syntax: /msg $me info #channel nick }
  802.         else { .msg $nick $sb.findserver($2,$3) }
  803.       }
  804.       ;*** Lists the channels being indexed.
  805.       elseif ($1 == listchans) { .msg $nick $iif($replace($hget(SearchBOT.settings,indexchan),$chr(44),$chr(32)) != $null,$v1,No channles added yet) }
  806.       ;*** Adds a search trigger to be used to search all packs.
  807.       elseif ($1 == addtrig) {
  808.         if (!$2) { .msg $nick You must specify a trigger. Useage: /msg $me addtrig trigger }
  809.         elseif ($sb.iscommand($2)) { .msg $nick Error: $+(",$2,") is in use by the bot as a command. }
  810.         else { .msg $nick $sb.addtrig($2) }
  811.       }
  812.       ;*** Deletes a search trigger to be used to search all packs.
  813.       elseif ($1 == deltrig) {
  814.         if (!$2) { .msg $nick You must specify a trigger. Useage: /msg $me deltrig trigger }
  815.         else { .msg $nick $sb.deltrig($2) }
  816.       }
  817.       ;*** Adds a new release for a channel.
  818.       elseif ($1 == addrelease) {
  819.         if (!$2) || (!$3) { .msg $nick You must specify a channel and a release. Useage: /msg $me addrelease #channel release }
  820.         else { .msg $nick $sb.addrelease($2,$3-) }
  821.       }
  822.       ;*** See the advert as it would be sent to the channel.
  823.       elseif ($1 == seeadvert) {
  824.         if (!$2) { .msg $nick You must specify a channel. }
  825.         else { .msg $nick $sb.formatadvert($2) }
  826.       }
  827.       ;*** See the set time for an advert to repeat
  828.       elseif ($1 == getadtime) {
  829.         if (!$2) { .msg $nick You must specify a channel. }
  830.         else { .msg $nick $sb.getadtime($2) }
  831.       }
  832.       ;*** Count packs
  833.       elseif ($1 == countpacks) {
  834.         if (!$2) { .msg $nick $sb.countpacks }
  835.         elseif ($2) { .msg $nick $sb.countpacks($2) }
  836.       }
  837.       ;*** Deletes a request.
  838.       elseif ($1 == delrequest) {
  839.         if (!$2) { .msg $nick You must include the text of the request. }
  840.         else { .msg $nick $sb.delrequest($2-) }
  841.       }
  842.       ;*** Deletes An Ignore
  843.       elseif ($1 == delignore) {
  844.         if (!$2) { .msg $nick You must include a nick to unignore. }
  845.         else { .msg $nick $sb.delignore($2) }
  846.       }
  847.       ;*** List the ignore list
  848.       elseif ($1 == listignores) { sb.listignored $nick }
  849.       ;*** List total searches
  850.       elseif ($1 == totalsearches) { sb.searchcount $nick }
  851.     }
  852.   }
  853. }
  854. on *:TEXT:*:#: {
  855.   ;*** Checks if the channel is being indexed.
  856.   if ( $istok($hget(SearchBOT.settings,indexchan),$chan,44) ) { tokenize 32 $strip($1-)
  857.     ;*** Checks if the line is an actual XDCC ad (And that it is from a voice or higher)
  858.     if ($chr(35) isin $strip($1-)) && (to request !isin $1-) && (xdcc send !isin $1-) && ($nick($chan,$nick,vho~&)) && ($remove($strip($1),$chr(35),$chr(60),$chr(62),$chr(171),$chr(187)) isnum) {
  859.       ;*** #Number ****************************************************************************************************************************************
  860.       set -u1 %Pack.# $strip($remove($wildtok($1-,*#*,1,32),$chr(91),$chr(93),$chr(171),$chr(187)))
  861.       ;*** GETs *******************************************************************************************************************************************
  862.       set -u1 %Pack.GETs $remove($iif(x isin $2,$2,$iif(x isin $3,$3,$4)),x)
  863.       ;*** SiZE *******************************************************************************************************************************************
  864.       set -u1 %Pack.SiZE $remove($iif($chr(93) isin $3,$3,$iif($chr(93) isin $4,$4,$5)),$chr(91),$chr(93))
  865.       ;*** Title / Name ***********************************************************************************************************************************
  866.       set -u1 %Pack.RLS $replace($iif($chr(93) isin $3,$4-,$iif($chr(93) isin $4,$5-,$6-)),$chr(32),$chr(42))
  867.       ;****************************************************************************************************************************************************
  868.       if (MB isin %Pack.SiZE) || ($right(%Pack.SiZE,1) == M) { set -u1 %Pack.SiZE $+($remove(%Pack.SiZE,M,B),14MB) }
  869.       elseif (GB isin %Pack.SiZE) || ($right(%Pack.SiZE,1) == G) { set -u1 %Pack.SiZE $+($remove(%Pack.SiZE,G,B),14GB) }
  870.       elseif (TB isin %Pack.SiZE) || ($right(%Pack.SiZE,1) == T) { set -u1 %Pack.SiZE $+($remove(%Pack.SiZE,M,B),14TB) }
  871.       ;****************************************************************************************************************************************************
  872.       ;echo 4 -st %Pack.# %Pack.GETs %Pack.SiZE %Pack.RLS
  873.       ;****************************************************************************************************************************************************
  874.       ;*** Checks if the pack is #1 (And if the channel's index is made) - Deletes all packs from a user when they list #1 to ensure old packs arent updated if they list fewer than before.
  875.       if ($+($chr(35),1,$chr(32)) isin $strip($1-)) && ($hget($+(SearchBOT.,$chan))) { hdel -w $+(SearchBOT.,$chan) $+($nick,.*) }
  876.       ;*** Checks to see if the channel's index is made
  877.       elseif (!$hget($+(SearchBOT.,$chan))) { halt }
  878.       ;*** Adds all packs after #1 for a user.
  879.       sb.addpack $chan $nick %Pack.# $1-
  880.       ;****************************************************************************************************************************************************
  881.       hadd -m $+(Packs.,$nick) %Pack.# %Pack.# %Pack.RLS %Pack.SiZE %Pack.GETs $ctime $network $chan $+($server,:,$port)
  882.       ;****************************************************************************************************************************************************
  883.       ;*** New Release
  884.       $iif($hget(Packs,$+($nick,$chr(255),%Pack.#)) != %Pack.RLS,set -u1 %Pack.NEW RLS) | $iif(!$hget(Packs,$+($nick,$chr(255),%Pack.#)),unset %Pack.NEW)
  885.       ;****************************************************************************************************************************************************
  886.       hadd -mu19000 Packs $+($nick,$chr(255),%Pack.#) %RLS
  887.       hadd -mu19000 Gets $+($nick,$chr(255),%Pack.#) $+(%Pack.GETs,$chr(255),%Pack.RLS)
  888.       hadd -mu19000 Files %Pack.RLS $+($nick,$chr(255),%Pack.#)
  889.       $iif(!$hget(Chan,$chan),hadd -mu19000 Chan $chan)
  890.       ;****************************************************************************************************************************************************
  891.       ;if ($readini(Files.ini,Files,%RLS) != 1) { writeini -n $+(Latest.ini) Files %RLS 1 | write $+(Latest.txt) $ctime $chan %RLS }
  892.       unset %Pack.*
  893.     }
  894.   }
  895. }
  896. ;################
  897. ;# Play event
  898. ;################
  899. on *:playend: { if ($filename != $scriptdirSearchBOT.mrc) { if (!$sb.playcheck($filename)) { .remove $+(",$filename,") } } }
  900. ;###############
  901. ;# Help Sections
  902. ;###############
  903. [allusers]
  904. You can send any of these commands to Me in Private Message (4NOTE: All Users can access these commands without logging in) 4->
  905. 3Online *search*string* - To search online online packs
  906. 3Offline *search*string* - To search online offline packs
  907. 3Triggers - To get a list of triggers (These search both online and offline packs)
  908. 3Login Password - To login and 3Logout - To logout (4NOTE: Passwords are case sensitive)
  909. [owner]
  910. Owner Section - Only Owners can access this section
  911. 3Changepass level newpass - Levels are Owner Admin and Op (4NOTE: Passwords are case sensitive)
  912. 3Getpass Level - Levels are Owner Admin and Op (4NOTE: Passwords are case sensitive)
  913. 3Sessions - Lists all currently logged in hosts.
  914. 3Dissconnect Host - Disconnects a user that is logged in. (4NOTE: You can copy/paste the host from the 3Sessions Listing)
  915. [admin]
  916. Asmin Section - Only Admins and Owners can access this section
  917. 3Delnick #Channel Nick - Deletes all packs listed by a nick on the specified Channel
  918. 3Addchan #Channel - Adds a channel to be indexed.
  919. 3Delchan #Channel - Deletes a channel from being indexed.
  920. 3ListReleases #Channel - Lists all releases for the specified channel
  921. 3DelRelease #Channel Release text - Deletes a release from a channel's list manually. Copy and paste the text from the release listing.
  922. 3SetAdvert #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 !XS" etc. [indexchans] will substitute to "#indexchannel1,#indexchannel2" etc.
  923. 3GetAdvert #Channel - Returns the advert text for a channel (or default) without substitutions.
  924. 3DelAdvert #Channel - Will delete a channel's advert. You can also specify default.
  925. 3SetAdTime #Channel 300 - Sets a repeat time for a channels advertisment (4NOTE: Time is in seconds) You MUST issue this command after setting either a default ad, or a custom ad (4NOTE: Your ad will not run without this setting)
  926. [op]
  927. Operator Section - Only Ops and Above can access this section.
  928. 3Info #Channel Nick - Tells you how many packs a nick has listed on the channel.
  929. 3ListChans - Lists the channels the bot is indexing.
  930. 3AddTrig Trigger - Adds a new trigger to search all packets.
  931. 3DelTrig Trigger - Deletes an existing trigger that searches all packets.
  932. 3AddRelease #Channel Release Text - Adds a New Release for a channel. Will be automatically deleted. Delete date will be specified after using the command.
  933. 3SeeAdvert #Channel - Shows you the advertisement for a channel (may use Default instead of a channel to see the defualt ad).
  934. 3GetAdTime #Channel - Shows you the repeat time for a channel's ad.
  935. 3Countpacks - Shows you the number of packs indexed on all channels where 3Countpacks #Channel - Will show the number of packs on that channel
  936. 4------- IMPORTANT 15- 14Do not add any triggers that match any given command. This will cause conflicts. I will address this issue later. 4---------
Advertisement
Add Comment
Please, Sign In to add comment