Установка Verlihub с поддержкой Lua
Устанавливаем из портов net-p2p/verlihub и net-p2p/verlihub-plugins-luascript.
Ложим скрипты в каталог /usr/local/etc/verlihub/scripts.
В DC используем следующие команды:
!luaload /usr/local/etc/verlihub/scripts/file.lua
!luaunload /usr/local/etc/verlihub/scripts/file.lua
!luareload /usr/local/etc/verlihub/scripts/file.lua
Мой первый бот:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | aRange = { ["127.0.0.1-127.0.0.255"] = 1, ["10.128.0.1-10.128.255.254"] = 1, ["10.129.0.1-10.129.255.254"] = 1, ["10.130.0.1-10.130.255.254"] = 1, ["192.168.0.1-192.168.255.254"] = 1, ["213.79.108.1-213.79.111.254"] = 1, ["172.16.127.1-172.16.127.255"] = 1, } --function VH_OnParsedMsgChat(nick, data) function VH_OnUserLogin(nick) -- if (string.find(data,"^/me%s")) then res, myinfo = VH:GetMyINFO(nick) _, _, sharess = string.find(myinfo,"(%d+)$$") -- _, _, action = string.find(data,"^/me%s+(.+)") _, ip = VH:GetUserIP(nick) local Allow,Range = Func.CheckIP(GetIP(nick)) local res,class = VH:GetUserClass(nick) --if (Allow == 0) and (res and class <= 2) --VH:SendDataToUser("$To: sNick From: $<"..sBotName.."> nForbidden. Your IP: "..ip.." is not inside LocalNetwork |", sNick) shares = sharess / 1024 / 1024 / 1024; _, _, share = string.find(shares,"^(%d*)") if (class < 3) then if (tonumber(sharess) < 53687091200 ) then if (Allow == 0) then -- VH:SendDataToAll("** "..nick.." disconnect wrong user, nothing share|",5,10); VH:SendDataToUser("$To: Case From: Verlihub $<VerliHub> user: "..nick..", akado ("..ip.."), low share ("..share.."), disconnect|", "Case") else -- VH:SendDataToAll("** "..nick.." share something normal user|",5,10); VH:SendDataToUser("$To: Case From: Verlihub $<VerliHub> user: "..nick..", zelcom ("..ip.."), low share ("..share.."), alive|", "Case") end else -- VH:SendDataToAll("** "..nick.." welcome aboard, normal share user|",5,10); if (Allow == 0) then VH:SendDataToUser("$To: Case From: Verlihub $<VerliHub> user: "..nick..", akado ("..ip.."), normal share ("..share.."), alive|", "Case") else VH:SendDataToUser("$To: Case From: Verlihub $<VerliHub> user: "..nick..", zelcom ("..ip.."), normal share ("..share.."), alive|", "Case") end end else VH:SendDataToUser("$To: Case From: Verlihub $<VerliHub> user: "..nick..", operator, alive|", "Case") -- VH:SendDataToAll("** "..nick.." welcome aboard, operator|",5,10); end -- end return 1 end Func = {} Func.ComIP = function(curIP) local _,_,a,b,c,d = string.find(curIP, "(%d+).(%d+).(%d+).(%d+)") return a*16777216 + b*65536 + c*256 + d end Func.CheckIP = function(curIP) local _,_,a,b,c,d = string.find(curIP, "(%d*).(%d*).(%d*).(%d*)") if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then local UserIP = Func.ComIP(curIP) if UserIP then for Range, Table in pairs(aRange) do local _,_,R1,R2 = string.find(Range, "(%S+)-(%S+)") Range1 = Func.ComIP(R1) Range2 = Func.ComIP(R2) if UserIP >= Range1 and UserIP <= Range2 then return 1,Range end end end end return 0 end function GetIP(sNick) res, ip = VH:GetUserIP(sNick) return ip end |
