Advertisement
contr0l

!mostsearched - New Method - Uncommented

Dec 3rd, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 5.21 KB | None | 0 0
  1. on *:start: {
  2.   set %_mschan #elite-chat | set %_msb !mostsearched | set %_msdir $+($mircdir,mostsearched\) | set %_msitems $+(",%_msdir,msitems.txt,")
  3.   if !$exists(%_msdir) { mkdir %_msdir } | if !$exists(%_msitems) { write -c %_msitems }
  4.   .timermscopy 0 86400 _mscopy
  5.   .timermspurge 0 21600 _mspurge
  6. }
  7. on *:unload: {
  8.   var %_msanswer = $?="Would you like to delete your database and all backups? $crlf From %_msdir? $crlf Enter y or n. (yes or no)"
  9.   if %_msanswer == y || %_msanswer == yes { var %i $findfile(%_msdir,*.*,0,.remove $1-) | echo -a %_msb All Databases deleted. | .remove %_msdir }
  10. if %_msanswer == n || %_msanswer == no || !%_msanswer { noop }
  11.   unset %_ms*
  12. }
  13. alias whilefix { dll WhileFix.dll WhileFix . }
  14. alias ' { return $replace($1-,$chr(32),$chr(46)) }
  15. alias _mstotal { return $lines(%_msitems) }
  16. alias mst { msg %_mschan %_msb There are $+(,$bytes($_mstotal,b),) total searches Indexed. }
  17. alias _msimport { var %i $hget(ms,0).item | while %i { whilefix | write %_msitems $hget(ms,%i).data $hget(ms,%i).item | dec %i } }
  18. alias _mscopy { var %mscfn $+($remove(%_msitems,.txt,"),-BACKUP-,$asctime(mmddyy),-,$asctime(hhnntt),.txt) | copy -o %_msitems %mscfn | echo -a %_msb Backup made of the database. Name: $nopath(%mscfn) -Location: $+(,$nofile(%_msitems),) }
  19. alias _mspurge {
  20.   var %x $_mstotal, %c 0 | while %x {
  21.     whilefix
  22.     if $gettok($read(%_msitems,%x),1,32) <= 3 { write $+(-dl,%x) %_msitems }
  23.     dec %x | inc %c
  24.   }
  25.   if %c > 0 { msg %_mschan %_msb Database Purged of all entried with less than 5 searches. }
  26. }
  27. alias _mslist {
  28.   var %count = 1
  29.   if ($window(@Sort1,state)) { window -c @Sort1 } | if ($window(@Sort2,state)) { window -c @Sort2 }
  30.   window -h @Sort1 | window -h @Sort2
  31.   while (%count <= $_mstotal) { whilefix | aline @Sort1 $gettok($read(%_msitems,%count),2-,32) $gettok($read(%_msitems,%count),1,32) | inc %count }
  32.   filter -wwucte 2 32 @Sort1 @Sort2 *
  33.   var %x = 1, %v = 10 | while (%x <= %v) { whilefix | msg %_mschan $+(,%x,.,)  $gettok($line(@Sort2,%x),1,32) :: Searched: $gettok($line(@Sort2,%x),2,32) times. | inc %x }
  34.   window -c @Sort1 | window -c @Sort2
  35. }
  36. alias mss {
  37.   msg %_mschan %_msb :: Listing [Top 10] Most Searched Terms of the $+(,$bytes($_mstotal,b),) Indexed.
  38.   _mslist
  39.   msg %_mschan %_msb :: [EOF]
  40. }
  41.  
  42. on *:text:*:%_mschan:{
  43.   if !%msfld. [ $+ [ $nick ] ] {
  44.     set -u5 %msfld. [ $+ [ $nick ] ] 1
  45.     if $2- { var %msr = $'($2-) }
  46.     if (($1 == !s || $1 == !search)) && $2- {
  47.       if $read(%_msitems, w, $+(*,%msr,*)) {
  48.         var %msln $readn
  49.         var %msval $calc($gettok($ifmatch,1,32) + 1), %msval2 $gettok($ifmatch,2-,32)
  50.         write $+(-dl,%msln) %_msitems
  51.         write %_msitems %msval %msval2
  52.         halt
  53.       }
  54.       else write %_msitems 1 %msr
  55.     }
  56.     if $1 == !mostsearched  && !$2- {
  57.       if $_mstotal > 0 { mss | halt }
  58.       else msg %_mschan %_msb :: No Searches Indexed yet...
  59.     }
  60.     if $1 == !mostsearched && $2- {
  61.       ; Code for help
  62.       if $2 != merge && $2 == help {
  63.         msg # :: Sending %_msb :: Help Command Reference to $+(,$nick,) via pm.
  64.         msg $nick %_msb :: Help Command Reference
  65.         msg $nick :: If a user only types !mostsearched, then list top 10 most searched terms.
  66.         msg $nick :: If a user types !mostsearched release.name.here (periods required), it will show the number of searches that release has.
  67.         msg $nick :: If an op (@) or halfop (%) types !mostsearched merge release.name1.here release.name2.here  - it will merge the 2 values of the specified releases, then delete release.name1.here. You are merging the first into the second, then deleting the first.
  68.         msg $nick %_msb :: EOF
  69.         halt
  70.       }
  71.       if $2 && $2 != merge && $2 != help {
  72.         if $read(%_msitems, w, $+(*,$2-,*)) {
  73.           var %_msrdn $readn
  74.           msg # %_msb :: Number of searches for $+(,$2-,) is $iif($gettok($read(%_msitems,%_msrdn),1,32) > 0,$ifmatch,0) $+ .
  75.           halt
  76.         }
  77.         else msg # %_msb :: Error: $+(,$2-,) doesn't exist. | halt
  78.       }
  79.     }
  80.     if ($1 == !mostsearched) && ($2 == merge) && ($3) && ($4) {
  81.       if $nick isop # || $nick ishop # || $nick isvoice # {
  82.         if $chr(32) !iswm $3 && $chr(32) !iswm $4 {
  83.           if $read(%_msitems, w, $+(*,$'($3),*)) {
  84.             var %ms3ln $readn
  85.             if $read(%_msitems, w, $+(*,$'($4),*)) {
  86.               var %ms4ln $readn
  87.               var %mc $calc($gettok($read(%_msitems,%ms3ln),1,32) + $gettok($read(%_msitems,%ms4ln),1,32))
  88.               write $+(-dl,%ms3ln) %_msitems
  89.               write %_msitems %mc $'($4)
  90.               msg # %_msb :: Merge Successful! $+(,$3,) has been merged with $+(,$'($4),) and the new value is $+(,%mc,.) The first release specified, $+(,$3,) $+ , has been deleted.
  91.               halt
  92.             }
  93.             else msg # %_msb :: Error: Second Release specified, $+(,$4,) doesn't exist. Check your spelling.
  94.           }
  95.           else msg # %_msb :: Error: First Release specified, $+(,$3,) doesn't exist. Check your spelling.
  96.         }
  97.         else msg # %_msb :: Error: Release names indexed do not have spaces in the titles, use periods.
  98.       }
  99.     }
  100.   }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement