Luadch Googlebot 0.5

Post finished Hubside Scripts here, known supporting hubsofts for LUA scripting.

ADCH++ | DCWatch | LUADCH
Locked
Toast

Luadch Googlebot 0.5

Post by Toast » 17 Jan 2009, 15:24

Code: Select all

    --| googlebot.lua version 0.5    07-12-2005 |--
    --| API2 |--
    --| GoogleBot |--
    --| Author: ZeroSleep |--
    --| e-mail: more (dot) caffiene (at) gmail (dot) com |--
    --| |--
    --| Added: torrent search by ATAG |--
    --| Luadch version by ATAG  10.01.2009 |--

    local Config = {}
    ----------------- Setup Start ----------------
    Config.help = "ghelp"
    Config.botname = "Google"
    ----------------- Setup End ------------------

    local scriptname = "ldch_googlebot.lua"
    local utf_match = utf.match
    local hub_getbot = hub.getbot

    local function onGoogle( user, command, parameters )
       local filetype, searchstring = utf.match( parameters, "^(%S+)%s*(.*)$" )
       if searchstring then
          searchstring = searchstring:gsub("%s", "+")
       else
          return nil
       end
       if filetype == "torrent" then
          user:reply( "Search results:\r\n"..
          "Bitenova:\r\nhttp://bitenova.org/search/"..searchstring.."\r\n"..
          "Bittorrent\r\nhttp://www.bittorrent.com/search_result.html?search="..searchstring.."\r\n"..
          "Btjunkie:\r\nhttp://btjunkie.org/search?q="..searchstring.."\r\n"..
          "Bushtorrent:\r\nhttp://www.bushtorrent.com/torrents.php?search=&words="..searchstring.."\r\n"..
          "Demonoid:\r\nhttp://www.demonoid.com/files/?query="..searchstring.."\r\n"..
          "Downloadanime:\r\nhttp://downloadanime.org/?q="..searchstring.."\r\n"..
          "Isohunt:\r\nhttp://isohunt.com/torrents.php?ext=&op=and&ihq="..searchstring.."\r\n"..
          "Fenopy:\r\nhttp://fenopy.com/?keyword="..searchstring.."&select=0&order=0&sort=0&minsize=&maxsize=&search.x=49&search.y=29&search=Search\r\n"..
          "Meganova:\r\nhttp://www.meganova.org/search.php?search="..searchstring.."\r\n"..
          "Mininova:\r\nhttp://www.mininova.org/search/?search="..searchstring.."\r\n"..
          "Mybittorent:\r\nhttp://www.mybittorrent.com/?keywords="..searchstring.."&cat=&subcat=\r\n"..
          "Newtorrents:\r\nhttp://newtorrents.info/index.php?q="..searchstring.."\r\n"..
          "Snarfit:\r\nhttp://snarf-it.org/?show=search&query="..searchstring.."\r\n"..
          "Thepiratebay:\r\nhttp://thepiratebay.org/search.php?q="..searchstring.."\r\n"..
          "Torrentbox:\r\nhttp://torrentbox.com/torrents-search.php?search="..searchstring.."\r\n"..
          "Torrentspy:\r\nhttp://www.torrentspy.com/search?query="..searchstring.."&submit.x=0&submit.y=0\r\n"..
          "Torrentvalley:\r\nhttp://www.torrentvalley.com/search.php?search="..searchstring.."&x=46&y=12&act=1&cat=0&trss=1\r\n"..
          "Torrentz:\r\nhttp://www.torrentz.com/search?q="..searchstring.."&x=0&y=0\r\n"..
          "Google's result:\r\nhttp://www.google.com/search?hl=en&lr=&c2coff=1=0&q=filetype%3Atorrent+="..searchstring.."\r\n"..
          "\r\nIf none of the links give you good results, try a different search string :)",  hub_getbot( ), hub_getbot( ) )
       else
          user:reply( "Try these links:\r\n"..
          "If the first one does not give good results, try the others.\r\n"..
          "1.\r\nthttp://www.google.com/search?hl=en&q=intitle%3Aindex.of+%2B+%22"..filetype.."%22+%2B+%22"..searchstring.."%22+-htm+-html+-php+-asp&btnG=Google+Search\r\n"..
          "2.\r\nhttp://www.google.com/search?hl=en&q=%22index+of%22+%2B+intitle%3A"..filetype.."+%2B+%22"..searchstring.."%22+-htm+-html+-php+-asp&btnG=Google+Search\r\n"..
          "3.\r\nhttp://www.google.com/search?hl=en&lr=&q=inurl%3Aandromeda.php+%2B+%22"..filetype.."%22+%2B+%22"..searchstring.."%22&btnG=Search\r\n"..
          "4.\r\nhttp://www.google.com/search?hl=en&lr=&q=%22directory+listings+of%22+%2B+inurl%3A"..filetype.."+%2B+%22"..searchstring.."%22&btnG=Search\r\n"..
          "5. (usually this does not work with medial files, but otherwise it does)\r\n"..
          "http://www.google.com/search?hl=en&lr=&q=filetype%3A"..filetype.."+%2B+%22"..searchstring.."%22&btnG=Search\r\n"..
          "\r\nIf none of the links give you good results, try a different search string :)",  hub_getbot( ), hub_getbot( ) )
       end
       return PROCESSED
    end

    local function onGhelp( user )
       user:reply( "The following "..Config.botname.." commands are there for you:\r\n"..
          "\r\n\t+"..Config.help.." - Gives help\r\n"..
          "\t+google <filetype> <keyword> - This command generates 4 Google links for you.\r\n"..
          "\tE. g. if you search for mp3's from Megadeth, you have to enter something like this:\r\n"..
          "\t\t+google mp3 megadeth\r\n"..
          "\tIf you would like to use more keywords, they have to be separated by a + sign::\r\n"..
          "\t\t+google avi saw+3\r\n"..
          "\tLinks you get as result will point to AVIs that contain the words 'saw' and '3' in the filenames.", hub_getbot( ), hub_getbot( ) )
       return PROCESSED

    end

    hub.setlistener( "onStart", { },
        function( )
            local help = hub.import "cmd_help"
            if help then
                help.reg( "google", "[+!#]google <filetype> <keyword>", "gives some search link", 0 )    -- reg help
             help.reg( Config.help, "[+!#]"..Config.help, "googlebot help", 0 )    -- reg help
            end
            local ucmd = hub.import "etc_usercommands"    -- add usercommand
            if ucmd then
                ucmd.add( { "Google Search\\Search for files" }, "google", { "%[line:filetype]", "%[line:keyword]" }, { "CT1" }, 0 )
             ucmd.add( { "Google Search\\Help" }, Config.help, { }, { "CT1" }, 0 )
            end
            local hubcmd = hub.import "etc_hubcommands"    -- add hubcommand
            assert( hubcmd )
            assert( hubcmd.add( "google", onGoogle ) )
          assert( hubcmd.add( Config.help, onGhelp ) )
            return nil
        end
    )

    hub.debug( "** Loaded " .. scriptname .. ".lua **" )

Locked