PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: YASHOV on 27 February, 2005, 13:31:21

Title: Help with logon bot, please
Post by: YASHOV on 27 February, 2005, 13:31:21
Could someone please help me convert this script to lua 5???????


-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03

file_logon = "logon.txt"

function NewUserConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function OpConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function UserDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function OpDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..date("%d").."."..date("%m").."."..date("%y").." - "..date("%H")..":"..date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function MyInfoString(data)
s,e,description,speed,email,share = strfind(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
if speed~=nil then
speed = strsub(speed,1,strlen(speed)-1)
end
return description,speed,email,share
end

Title:
Post by: Pothead on 27 February, 2005, 13:54:52
all parts with ..dateneed replacing with ..os.date :)
Title:
Post by: YASHOV on 27 February, 2005, 14:12:48
Thank you, I did as you said, but there is nothing being written to logon.txt file

Also I am getting: logon_bot.lua:45: attempt to call global `strfind' (a nil value)

Now the script is changed to this:

Quote-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03

file_logon = "logon.txt"

function NewUserConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function OpConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function UserDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function OpDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." -  with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function MyInfoString(data)
s,e,description,speed,email,share = strfind(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
if speed~=nil then
speed = strsub(speed,1,strlen(speed)-1)
end
return description,speed,email,share
end

TIA
Title:
Post by: [NL]Pur on 27 February, 2005, 15:04:02
try


string.find
Title:
Post by: Dag on 27 February, 2005, 15:04:29
QuoteOriginally posted by YASHOV

Also I am getting: logon_bot.lua:45: attempt to call global `strfind' (a nil value)
All parts with
Quotestrfind
need replacing with -> string.find !!!

and all parts with
Quotestrsub
need replacing with -> string.sub !!!
 :D   :]   ;)
Title:
Post by: YASHOV on 27 February, 2005, 15:42:35
Thank you very , I made the changes as you said, but there is still nothing being written to logon.txt file

Also I am now getting: logon_bot.lua:47: attempt to call global `strlen' (a nil value)

Now the script is changed to this:

Quote-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03

file_logon = "logon.txt"

function NewUserConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function OpConnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("-->> "..user.sName..","..os.date("%d").."."..date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function UserDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function OpDisconnected(user)
description,speed,email,share=MyInfoString(user.sMyInfoString)
local share2 = share / (1024*1024*1024)
ip = user.sIP
appendto(file_logon)
write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
writeto()
end

function MyInfoString(data)
s,e,description,speed,email,share = string.find(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
if speed~=nil then
speed = string.sub(speed,1,strlen(speed)-1)
end
return description,speed,email,share
end



Thank you
Title:
Post by: [NL]Pur on 27 February, 2005, 16:05:12
this can use some optimization

-- A simple logon logger by piglja - 25/04/03
-- Updated and modifyed a bit by piglja - 28/04/03
-- A bug by piglja fixed by piglja;P - 28/04/03
-- An update that Ops are logged too and disconnect are logged by piglja - 28/04/03

file_logon = "logon.txt"

function NewUserConnected(user)
  description,speed,email,share=MyInfoString(user.sMyInfoString)
  local share2 = share / (1024*1024*1024)
  ip = user.sIP
  fileHandle = io.open(file_logon,"a+")
  fileHandle:write("-->> "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
  fileHandle:flush()
  fileHandle:close()
end

function OpConnected(user)
  description,speed,email,share=MyInfoString(user.sMyInfoString)
  local share2 = share / (1024*1024*1024)
  ip = user.sIP
  fileHandle = io.open(file_logon,"a+")
  fileHandle:write("-->> "..user.sName..","..os.date("%d").."."..date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
  fileHandle:flush()
  fileHandle:close()
end

function UserDisconnected(user)
  description,speed,email,share=MyInfoString(user.sMyInfoString)
  local share2 = share / (1024*1024*1024)
  ip = user.sIP
  fileHandle = io.open(file_logon,"a+")
  fileHandle:write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
  fileHandle:flush()
  fileHandle:close()
end

function OpDisconnected(user)
  description,speed,email,share=MyInfoString(user.sMyInfoString)
  local share2 = share / (1024*1024*1024)
  ip = user.sIP
  fileHandle = io.open(file_logon,"a+")
  fileHandle:write("<<-- "..user.sName..","..os.date("%d").."."..os.date("%m").."."..os.date("%y").." - "..os.date("%H")..":"..os.date("%M").." - with:"..speed.." IP "..ip..", e-mail "..email.." with "..share2.."Gb \r\n")
  fileHandle:flush()
  fileHandle:close()
end

function MyInfoString(data)
  s,e,description,speed,email,share = string.find(data, "$MyINFO $ALL ([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")
  if speed~=nil then
    speed = string.sub(speed,1,string.len(speed)-1)
  end
  return description,speed,email,share
end
 
Title:
Post by: nErBoS on 27 February, 2005, 16:05:25
Hi,

Check out plop 425 convertor there you all modifications that you have to make, or you can also check the LUA 5 manual that you can find in http://www.lua.org

Best regards, nErBoS