hello ppl
i have this scripts but it don?t work in lua 5
can you convert it to me ?
--Requested by Woodster
--Made by nErBoS
Bot = "?Lusomundo??"
rules = "regras.txt"
function Main()
frmHub:RegBot(Bot)
end
function NewUserConnected(user, data)
Readtextfile(user, rules)
end
OpConnected = NewUserConnected
function Readtextfile(user, file)
local filecontents = ""
local handle = openfile(file, "r")
if (handle ~= nil) then
local line = read(handle)
while line do
filecontents = filecontents..line.."\r\n"
line = read(handle)
end
closefile(handle)
user:SendPM(Bot, filecontents)
end
end
this one to
--------------------------------------------------
-- --
-- This bot is designed to fix the --
-- "*** Your nick is taken" bug when a user is --
-- disconnected from the hub. --
-- --
-- For more details go to: --
-- [URL]http://students.dwc.edu/cbarber/nickbug.html --[/URL]
-- --
-- By RabidWombat --
--------------------------------------------------
BotName = "?Games??";
BotVersion = "v0.6";
BotAuthor = "Drugas";
NickMessage = "O seu nick ja esta em uso, Por favor mude para outro!"
Title = BotName.." "..BotVersion.." by: "..BotAuthor;
Message = "Se cais-te do hub, Por favor espera 1 minuto e volta a conectar-te.";
TriesArray = {};
TimeToWait = 20; -- in seconds
MaxTries = 3;
function Main()
frmHub:RegBot(BotName);
frmHub:EnableFullData(1);
frmHub:EnableSearchData(0);
SetTimer(1000);
StartTimer();
end
function OnTimer()
-- This is designed so old entries will be removed from the table
for UserName,TryTable in TriesArray do
if(TryTable[0] == nil or TryTable[1] == nil) then
TriesArray[UserName] = nil; -- set entry to be removed
return;
end
TryTable[1] = TryTable[1] - 1; -- decrement time count
if(TryTable[1] <= 0) then -- less than just in case
TryTable[1] = TimeToWait; -- reset time count for next decrement
TryTable[0] = TryTable[0] - 1; -- decrement try count
if(TryTable[0] <= 0) then -- less than just in case
TriesArray[UserName] = nil; -- set entry to be removed
end
end
end
end
function DataArrival(curUser, sData)
if curUser.sName == "" and strsub(sData, 1, 13) == "$ValidateNick" then
local s, e, name = strfind(sData, "$ValidateNick (%S+)");
name = strsub(name, 1, strlen(name) - 1);
if(GetItemByName(name)) then
if(TriesArray[name] and TriesArray[name][0]) then
TriesArray[name][0] = TriesArray[name][0] + 1; -- increment tries
if(TriesArray[name][0] > MaxTries) then
TriesArray[name][1] = TimeToWait; -- reset time count
return; -- do not send message
end
else
TriesArray[name] = {1, TimeToWait};
end
SendToNick(name, "testing this connection|"); -- Check for ghost
curUser:SendData("*** "..NickMessage); -- Do hubs job
curUser:SendData("*** "..Title); -- Inform new user
curUser:SendData("*** "..Message);
-- Disconnect user before $ValidateDenide is sent
-- Some clients do not reconnect automatically correctly when this message is sent
curUser:Disconnect();
return 1;
end
end
end
function OnNewUserConnected(curUser) -- Remove entry if user connects
if(TriesArray[curUser.sName]) then
TriesArray[curUser.sName] = nil;
end
end
function OnNewOpConnected(curUser) -- Remove entry if op connects
if(TriesArray[curUser.sName]) then
TriesArray[curUser.sName] = nil;
end
end
this:
botname = "?Games??"
minutes = 240 -- podem mudar aqui os minutos
file = "Pub.txt"
function Main()
SetTimer(minutes*60000)
StartTimer()
end
function OnTimer()
MessageToAll()
end
function MessageToAll()
local handle = openfile(file, "r")
if (handle ~= nil) then
local line = read(handle)
while line do
SendToAll(botname,line)
line = read(handle)
end
closefile(handle)
end
end
this to:
-- v0.3
-- por: Xico
-- Data: 30/08/2004
-- O ficheiro "IpRanges.dat" contem os IPs permitidos no formato (um registo pot linha):
-- Nome do ISP #10.10.10.0/24
-- Lista de IPs nacionais tirada de: [URL]http://www.ripe.net/ripencc/mem-services/general/allocs.html[/URL]
-- ?ltima compila??o: 30/06/2004 - 23:15:02
-- Tambem ? poss?vel utilizar a lista de IPs do eMule (Bowlfifsh)
-- Compilar lista a partir dos ficheiros:
-- "ipranges.txt"
-- "ipranges.Netcabo.txt"
-- "ipranges.Adsl.Telepac.Sapo.txt"
-- que podem ser encontrados na pasta "config" do eMule,
-- normalmente em "C:\Programas\eMule\config"
----------------------------------------------------
FilePath = "SoTugasAki/"
sIpList = FilePath.."IpRanges.dat"
BotName = "?FBI??"
iBotShareSize = 0.0 * 1024 *1024
sBoteMail = "Num Haaa"
sBotSpeed = "BOT"
sBotTAG = "GNR"
sBotDescr = "GNR por Drugas 2004"
sBotString = "$MyINFO $ALL "..BotName.." "..sBotDescr..""..sBotTAG.."$ $"..sBotSpeed..strchar( 1 ).."$"..sBoteMail.."$"..iBotShareSize.."$"
tRanges = {}
tISPs = {}
----------------------------------------------------------------------------------
--// Main
----------------------------------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
LoadSubnets()
end
----------------------------------------------------------------------------------
--// OpConnected
----------------------------------------------------------------------------------
function OpConnected(curUser)
curUser:SendData(sBotString )
end
----------------------------------------------------------------------------------
--// NewUserConnected
----------------------------------------------------------------------------------
function NewUserConnected(curUser)
curUser:SendData( sBotString )
local bPermitido, sISP = TestarIP(curUser.sIP)
if (bPermitido == 0) then
curUser:SendData(BotName,"Your IP isn't from Portugal.... Se est?s em Portugal por favor contacta: " ..sBoteMail)
curUser:Disconnect()
return 1
end
end
----------------------------------------------------------------------------------
--// LoadSubnets
----------------------------------------------------------------------------------
function LoadSubnets()
local sLinha
readfrom(sIpList)
repeat
sLinha = read("*l")
if (sLinha) then
local _,_,sISP,a,b,c,d,bits = strfind(sLinha, "(.*)#(%d*).(%d*).(%d*).(%d*)/(%d*)")
local nIniRange = GetIPLong(a,b,c,d)
local nFimRange = (nIniRange + (2^(32-bits)) - 1)
tRanges[nIniRange] = nFimRange
tISPs[nIniRange] = sISP
end
until (sLinha == nil)
readfrom()
end
----------------------------------------------------------------------------------
--// Passar o IP para valor n?merico
----------------------------------------------------------------------------------
function GetIPLong(a,b,c,d)
return ((a*256+b)*256+c)*256+d
end
----------------------------------------------------------------------------------
--// Testar o IP
-- / 1-IP permitido / 0-IP N?O permitido
----------------------------------------------------------------------------------
function TestarIP(sIP)
local _,_,a,b,c,d = strfind(sIP, "(%d*).(%d*).(%d*).(%d*)")
local nIpLong = GetIPLong(a,b,c,d)
local bPermite = 0
local sISP = "desconhecido"
for nInicio, nFim in tRanges do
if((nIpLong >= nInicio) and (nIpLong <= nFim)) then
bPermite = 1
sISP = tISPs[nInicio]
break
end
end
return bPermite, sISP
end
please helpme
best regards Loading
The same goes for these requests ;)
All of them have already been converted to Lua 5 except for the second one that isn't needed any longer with the new PtokaX.
Search for them and you'll find them.
Regards,
jiten