Irc !dupe function

Started by swizzles, August 29, 2012, 08:28:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

swizzles

Hi All

Again this was posted by Hajo1000:

"Posted 09 January 2007 - 09:41 PM
I used bonesxtr sitesearch script to build this one, so some credits to him.


you need mysqltcl for this:
http://www.xdobry.de/mysqltcl/

So once thats installed you need to drop the code provided below into your scripts folder in the eggdrop directory. This varies on each operating system and compile.

use: ".chanset #channel +dupesearch" for each channel you wish this script to be active.

All of the editing needs to be done is at the top.

##################################################
#                        Dupe Torrents v0.1                              #
#                       Created by Hajo1000                              #
#                        Based on bonesxtr                                #
#                                 09/01/07                                        #
##################################################


package require mysqltcl


###### Set Site address ###########################

set site_add ""


###### Setup Your database info here ##############

set sqlserver "localhost"
set dbuser "user"
set dbpassword "pass"
set name "dbname"
set portno "12345"


##### Set number of results in PM ################

set maxresults "5"






###### THAT'S IT #############









##################################################
#                       Connect to Database                              #
##################################################

set db_handle [mysqlconnect -host $sqlserver -port $portno -user $dbuser -password $dbpassword -db $name]


##################################################
#                 Bind channel commands                          #
##################################################

bind pub "-|-" !dupe dupe_torrent

##################################################
#          Set user defined flag for users                #
##################################################

setudef flag dupeSearch

##################################################
#                        DUPE PM TORRENTS                                  #
##################################################

proc dupe_torrent { nick host handle channel text} {
 
  global db_handle
  global maxresults
  global site_add

  if {![channel get $channel dupeSearch]} {
   return 0
  }
       
putquick "PRIVMSG $channel :\002SEACHING...\002"
         

          set sql "SELECT id, name, size, unix_timestamp(added), numfiles FROM torrents WHERE search_text LIKE '%$text%' ORDER BY added DESC LIMIT $maxresults"

          set result [mysqlsel $db_handle $sql -list]

        if {$result > 0} {
        putquick "PRIVMSG $channel :\002Sending last $maxresults Search Results in Query to $nick\002"
        for {set i 0} {$i < $maxresults} {incr i} {
                set record [lindex $result $i];
                set id [lindex $record 0];
                set name [lindex $record 1];
                set size [lindex $record 2];
                set added [lindex $record 3];
                set added [duration [expr [clock seconds] - $added]];
                set files [lindex $record 4];

                if {[expr $size / 1024] >= 1} {
                        set sized "[string range "[expr $size / 1024.0]" 0 [expr [string length "[expr $size / 1024]"]+ 2] ] KB"};

                if {[expr $size / 1048576] >= 1} {
                        set sized "[string range "[expr $size / 1048576.0]" 0 [expr [string length "[expr $size / 1048576]"]+ 2] ] MB"};

                if {[expr $size / 1073741824] >= 1} {
                        set sized "[string range "[expr $size / 1073741824.0]" 0 [expr [string length "[expr $size / 1073741824]"]+ 2] ] GB"};


                putquick "PRIVMSG $nick :\002( Torrent ) (\002 $name \002) (\002 $sized in $files Files \002) (\002 added $added ago \002) (\002 $site_add/details.php?id=$id \002)\002"
}

        } else {
                        putquick "PRIVMSG $channel :No matches : Please try again"
        }


  mysqlendquery $db_handle
}


putlog "TbSource !dupe by Hajo1000 Loaded!"



The outcome in the channel is this:

(21:34:48) (~Hajo1000) !dupe xvid
(21:34:49) (test) SEACHING...
(21:34:49) (test) Sending last 5 Search Results in Query to Hajo1000



and in Query:

(21:34:49) (test) ( Torrent ) ( DMC.World.Dj.Championship.Final.2006.DVDRip.XviD-CMS) ( 695.98 MB in 51 Files ) ( added 1 hour 10 minutes 28 seconds ago ) ( http://www.torrentpipeline.org/details.php?id=316 )
(21:34:49) (test) ( Torrent ) ( Kenny.2006.PROPER.DVDRip.XviD-aAF ) ( 726.55 MB in 56 Files ) ( added 3 hours 8 minutes 21 seconds ago ) ( http://SITEURL/details.php?id=6 )
(21:34:49) (test) ( Torrent ) ( Rome.S01E02.HDTV.XviD-LOKi ) ( 347.05 MB in 25 Files ) ( added 3 hours 55 minutes 18 seconds ago ) ( http://SITEURL/details.php?id=5 )
(21:34:50) (test) ( Torrent ) ( K PAX.2001.WS.DVDRip.XviD-AXIAL ) ( 1.38 GB in 105 Files ) ( added 4 hours 47 minutes 44 seconds ago ) ( http://SITEURL/details.php?id=4 )
(21:34:54) (test) ( Torrent ) ( Stargate.Atlantis.S03E17.HR.HDTV.AC3.2.0.XviD-NBS ) ( 710.83 MB in 52 Files ) ( added 4 hours 50 minutes 42 seconds ago ) ( http://SITEURL/details.php?id=3 )



i hope you like it :) "