-- LUA google implementation for Verlihub using LuaSocket-2.0beta available from: http://www.tecgraf.puc-rio.br/~diego/luasocket/ -- Please note that this script was made for demonstration purposes only. -- When somebody preforms a google search, hub may slow down because script waits for answer from google. -- I try to make this script to use threads, so this problem will be solved... -- Beginers may find LuaSocket difficult to install, but it is not so hard. -- Download luasocket-2.0b.tar.gz -- Extract it to /usr/src/luasocket-2.0-beta/ -- Go to the dir: cd /usr/src/luasocket-2.0-beta/ -- Type: make -f makefile.Linux -- 2 files will be created: luasocket-2.0.so and mime-1.0.so -- Make a directory under your home's root directory called luasocket -- Make 2 symlinks by typing: -- ln -s /usr/src/luasocket-2.0-beta/luasocket-2.0.so /home/yourhome/luasocket/luasocket.dylib -- ln -s /usr/src/luasocket-2.0-beta/mime-1.0.so /home/yourhome/luasocket/mime.dylib -- Preform these copies by running: -- cp /usr/src/luasocket-2.0-beta/etc/* /home/yourhome/luasocket/ -- cp /usr/src/luasocket-2.0-beta/lua/* /home/yourhome/luasocket/ -- When finished, you should add 3 variables to your environment by invoking these commands: -- export LUA_INIT="@/home/yourhome/luasocket/lua.lua" -- export LUA_PATH="/home/yourhome/luasocket/?.lua;?.lua" -- export LUA_PATHLIB="/home/yourhome/luasocket/?.dylib;?.dylib" -- You can add these variables to the .bash_profile file, thus you don't have to type when needed. -- Good luck. -- Usage of script: type "??verlihub" into the main chat. You can use any words or sentences to search it with google. --- [ Global stuff ] --- require("lua") socket = require("socket") http = require("http") ltn12 = require("ltn12") content = {} botname = "LUABOT" server = "http://www.google.co.hu/" host = socket.dns.gethostname() --- [ End global stuff ] --- --- [ Functions ] --- function getbyhttp(u) local container = ltn12.sink.table(content) local r, c, h, s = http.request { url = u, sink = container } if c==200 then return 1 end end function VH_OnParsedMsgChat(nick, data) _, _, query = string.find(data, "^%?%?(.*)$") if query then query = string.gsub(query, "(%s+)", "+") url = server.."search?q="..query res = getbyhttp(url) if res then for i,v in content do for url in string.gfind(v, "