Author Topic: need to convert two fine scripts  (Read 2009 times)

0 Members and 1 Guest are viewing this topic.

Offline rolipoli

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-1
  • Transilvania-Erd?ly
need to convert two fine scripts
« on: 31 March, 2008, 13:58:50 »
Hello all!Can somebody convert this fine scripts?
Code: [Select]
--[[

RegLog 1.0f LUA 5.0/5.1

By American Idiot 04/01/06

Logs user registration/unregistration, by whom with date/time stamp.
**Note: Not to be used with other registration scripts/methods.
Scripted registration will not be logged. Not compatible with RoboCop

-Works in conjuction with Px reg/un reg commands
-Accepts commands in main or pm to bot
-Logs to external file
-Updates log at script start.
-User lookup by command
-Includes context menu [right click]
-Shows log size, number of entries and memory used

Changes from 1.0 by American Idiot 9/07/06
+Bugfix in RegUser entry Thanks cynicist8 for report
-No longer sends status message to all ops
+Added OnError function, set OpNick [line ~37]
-Dropped CheckVer function
+Extended LUA 5.1x support

Changes from 1.0b by American Idiot 9/07/06
+Added regby/regsince/regon commands Requested by cynicist8
+Fixed userlist commands, reply from bot
+Added option to always reply in PM     Requested by cynicist8


Changes from 1.0c by American Idiot 9/20/06
+Added show users by profile. Requested by cynicist8/swapy2006

Changes from 1.0d by American Idiot 10/09/06
+Case insenstive search. Requested by cynicist8

Changes from 1.0e by American Idiot 03/11/07
~Changed regby reply format Requested by Yahoo

]]

RlCfg = {
-- Name for bot pulled from hub or use "custom name"
Bot = frmHub:GetHubBotName() or "RegLog",
-- Bot description
Desc = "User Registration Log",
-- Bot email address
Mail = "user@domain.com",
-- Admins nick for status / error messages
OpNick = "American Idiot",
-- Always reply in PM ["yes"/"no"]
PmReply = "yes",
-- Registration data file
File = "RegLog.dat",
-- Context Menu Title
Menu = frmHub:GetHubName(),
--Context Submenu Title
SubMenu = "Registry Log",
--Set your profiles permissions here
--profile_idx, Commands/Menus enabled [0=no 1=yes], "Profile Name"
Profiles = {
[-1] = {0,"Unregistered User"},
[0] = {1,"Master"},
[1] = {1,"Operator"},
[2] = {0,"Vip"},
[3] = {0,"Registered User"},
},
RegUsers = {}
}

RlCmds = {
addreguser = function(user,data)
if user then
local date,time = os.date("%d/%m/%y"),os.date("%I:%M:%s ")..string.lower(os.date("%p"))
local op,opprf = user.sName,GetProfileName(user.iProfile)
local s,e,usr = string.find( data, "%b<>%s%p%w+%s(%S+)")
local s,e,pwd = string.find( data, "%b<>%s%p%w+%s%S+%s(%S+)")
local s,e,prf = string.find( data, "%b<>%s%p%w+%s%S+%s%S+%s(%S+)|$")
if usr and pwd and prf then
if not GetUserProfile(usr) then
if GetProfileIdx(prf) ~= -1 then
local tab = {usr,GetProfileName(GetProfileIdx(prf)),op,opprf,date,time,"Enabled"}
for i,v in ipairs(RlCfg.RegUsers) do
if v[1] == usr and v[7] == "Disabled" then
table.remove(RlCfg.RegUsers,i)
tab = {usr,GetProfileName(GetProfileIdx(prf)),op,opprf,date,time,"Reactivated"}
table.insert(RlCfg.RegUsers,tab)
Save_File(RlCfg.File,RlCfg.RegUsers,"RlCfg.RegUsers")
return prf.." "..usr.." was reactivated by "..
opprf.. " "..op..", log entry updated.",nil
end
end
table.insert(RlCfg.RegUsers,tab)
Save_File(RlCfg.File,RlCfg.RegUsers,"RlCfg.RegUsers")
return GetProfileName(GetProfileIdx(prf)).." "..usr.." added by "..
opprf.. " "..op..", log entry updated. Entries: "..
no(RlCfg.RegUsers)..".",nil
else
return prf.." is an invalid profile",nil
end
else
return usr.." is already registered",nil
end
else
return "Error!  Usage: !addreguser <nickname> <password> <profilename>",nil
end
else
return "Add A User To The Registry"," %[line:Name] %[line:Password] "..
"%[line:Profile Name]"," %[nick] %[line:Password] %[line:Profile Name]"
end
end,
delreguser = function(user,data)
if user then
local date,time = os.date("%m/%d/%y"),os.date("%I:%M:%s ")..string.lower(os.date("%p"))
local op,opprf = user.sName,GetProfileName(user.iProfile)
local s,e,usr = string.find( data, "%b<>%s%p%w+%s(%S+)|$")
if usr then
if GetUserProfile(usr) then
for i,v in ipairs(RlCfg.RegUsers) do
if v[1] == usr then
local prf = GetProfileName(GetUserProfile(usr)) or "Invalid"
local tab = {usr,prf,op,opprf,date,time,"Disabled"}
table.remove(RlCfg.RegUsers,i)
table.insert(RlCfg.RegUsers,tab)
Save_File(RlCfg.File,RlCfg.RegUsers,"RlCfg.RegUsers")
return prf.." "..usr.." was disabled by "..
opprf.. " "..op..", log entry updated. Entries: "..
no(RlCfg.RegUsers)..".",nil
end
end
else
return usr.." is not registered",nil
end
else
return "Error! Usage: !delreguser <nickname>",1
end
else
return "Remove A User From The Registry"," %[line:Name]"," %[nick]"
end
end,
rlfind = function(user,data)
if user then
local s,e,usr = string.find( data, "%b<>%s%p%w+%s(%S+)|$")
if usr then
for i,v in ipairs(RlCfg.RegUsers) do
if string.lower(v[1]) == string.lower(usr) then
local reply = "\r\n\r\n\tRegistry Log Results For *"..v[1]..
"*\r\n\t"..string.rep("?",100).."\r\n\t["..i.."] - Profile: "..
"*["..v[2].."]* Status: *"..v[7].."*  Set By: *"..v[4]..
string.char(160)..v[3].."* On: "..v[5].." "..v[6]..
"\r\n\r\n\t"..string.rep("?",100).."\r\n"
return reply,1
end
end
return "Sorry "..user.sName..", "..usr.." was not found in the registry log.",1
else
return "Error! Usage: !rlfind <nickname>",1
end
else
return "Find A Log Entry For User"," %[line:Name]"," %[nick]"
end
end,
showprof = function(user,data)
local profiles = table.concat(GetProfiles(),"/")
if user then
local s,e,profile = string.find( data, "%b<>%s%p%w+%s([%w%s]+)|$")
if profile then
if profile and GetProfileIdx(profile) ~= -1 then
local reply,cnt = "\r\n\r\n\tRegistry Log Results For: *"..profile..
"'s* Profile Number: ".."["..GetProfileIdx(profile).."]\r\n\t"..
string.rep("?",100).."\r\n".."\t # Nick:\t\t\tStatus\t\tSet By:\t\t\t\tOn:\r\n",0
for i,v in ipairs(RlCfg.RegUsers) do
if string.lower(v[2]) == string.lower(profile) then
cnt = cnt + 1
reply = reply.."\t"..string.format("[%-3.3s]",i)..
"   "..string.format("%-40.40s",v[1])..
"\t"..string.format("%-13.13s","*"..v[7].."*")..
"\t"..string.format("%-45.55s","*"..v[4]..
string.char(160)..v[3])..
"\t"..v[5].." "..v[6].."\r\n"
end
end
if cnt > 0 then
reply = reply.."\r\n\t"..string.rep("?",100).."\r\n\t[ "..cnt..
" ] Entries found for ( "..string.upper(profile).." )\r\n\r\n"
else
reply = " Sorry "..user.sName..", "..
"there are no entries for "..profile.."'s."
end
return reply,1
else
return "Error! "..profile.." is not a valid profile. "..
"Valid choices are: "..profiles..".",1
end
else
return "Error! Usage: !showprof <"..profiles..">",1
end
else
return "Show users by <Profile Name>"," %[line:"..profiles.."]"," %[line:"..profiles.."]"
end
end,
regby = function(user,data)
if user then
local s,e,usr = string.find( data, "%b<>%s%p%w+%s(%S+)|$")
if usr then
if GetUserProfile(usr) then
local cnt = 0
local t = GetProfilePermissions(GetUserProfile(usr))
if t.bAddRegUser == 1 and t.bDelRegUser == 1 then
local reply = "\r\n\r\n\tRegistry Log Entries By "..usr.."\r\n\r\n"
for i,v in ipairs(RlCfg.RegUsers) do
if string.lower(v[3]) == string.lower(usr) then
cnt = cnt + 1
reply = reply.."\t"..i..")  Nick: "..string.format("%-30.40s",v[1])..
" Date: "..v[5].." Time: "..v[6].."\r\n"
end
end
if cnt == 0 then
reply = reply..usr.."*\r\n\tThere are no entries by "..
usr.." in the registry log.\r\n\r\n"
else
reply = reply.."\r\n\tThere were a total of [ "..cnt..
" ] entries by "..usr.." found in the registry log.\r\n\r\n"
end
return reply,1
else
return "Sorry "..user.sName..", "..usr.." is not an "..
"permitted to register users.",1
end
else
return "Sorry "..user.sName..", "..usr.." is not a registered user.",1
end
else
return "Error! Usage: !regby <nickname>",1
end
else
return "List Registrations By <Operator>"," %[line:Op Nick]"," %[nick]"
end
end,
regsince = function(user,data)
if user then
local s,e,month,day,year = string.find( data, "%b<>%s%p%w+%s(%d+)%/(%d+)%/(%d+)|$")
if not month  then month = os.date("%m") end
if not day then day = os.date("%d") end
if not year then year = os.date("%y") end
if string.find(string.sub(year,1,2),"20") then
year = string.gsub(year,"20","")
end
local cnt,reply  = 0,"\r\n\r\n\tRegistry Log Results Since *"..
month.."/"..day.."/"..year.."*\r\n"..string.rep("?",115).."\r\n"..
"  #     Nick:\t\t\tProfile:\t\tStatus:\t\tSet By:\t\t\t\tTime/Date:\r\n"..
string.rep("?",115).."\r\n"
month,day,year,yr = tonumber(month),tonumber(day),tonumber(year),year
for i,v in ipairs(RlCfg.RegUsers) do
local s,e,m,d,y = string.find(v[5], "^(%d+)%/(%d+)%/(%d+)$")
if m and d and y then
m,d,y = tonumber(m),tonumber(d),tonumber(y)
if m >= month and d >= day and y >= year then
cnt = cnt + 1
reply = reply.." "..string.format("[%-3.3s]",i)..
"   "..string.format("%-35.45s",v[1])..
"\t"..string.format("%-20.25s","*"..v[2].."*")..
"\t"..string.format("%-13.13s","*"..v[7].."*")..
"\t"..string.format("%-45.55s","*"..v[4]..
string.char(160)..v[3].."*")..
"  "..v[5].." "..v[6].."\r\n"
end
end
end
if cnt == 0 then
reply  = "Sorry "..user.sName..", There were no entries found since *"..
month.."/"..day.."/"..year.."*",1
else
reply = reply..string.rep("?",115).."\r\n\r\n\tThere were a "..
"total of [ "..cnt.." ] entries since *"..month.."/"..day.."/"..yr.."*\r\n\r\n"
end
return reply,1
else
return "List Registration Since <MM/DD/YY>"," %[line:Month]/%[line:Day]/%[line:Year]",
" %[line:Month]/%[line:Day]/%[line:Year]"
end
end,
regon = function(user,data)
if user then
local s,e,month,day,year = string.find( data, "%b<>%s%p%w+%s(%d+)%/(%d+)%/(%d+)|$")
if not month  then month = os.date("%m") end
if not day then day = os.date("%d") end
if not year then year = os.date("%y") end
if string.find(string.sub(year,1,2),"20") then
year = string.gsub(year,"20","")
end
local cnt,reply  = 0,"\r\n\r\n\tRegistry Log Results From *"..
month.."/"..day.."/"..year.."*\r\n"..string.rep("?",115).."\r\n"..
"  #     Nick:\t\t\tProfile:\t\tStatus:\t\tSet By:\t\t\t\tTime/Date:\r\n"..
string.rep("?",115).."\r\n"
month,day,year,yr = tonumber(month),tonumber(day),tonumber(year),year
for i,v in ipairs(RlCfg.RegUsers) do
local s,e,m,d,y = string.find(v[5], "^(%d+)%/(%d+)%/(%d+)$")
if m and d and y then
m,d,y = tonumber(m),tonumber(d),tonumber(y)
if m == month and d == day and y == year then
cnt = cnt + 1
reply = reply.." "..string.format("[%-3.3s]",i)..
"   "..string.format("%-35.45s",v[1])..
"\t"..string.format("%-20.25s","*"..v[2].."*")..
"\t"..string.format("%-13.13s","*"..v[7].."*")..
"\t"..string.format("%-45.55s","*"..v[4]..
string.char(160)..v[3].."*")..
"  "..v[5].." "..v[6].."\r\n"
end
end
end
if cnt == 0 then
reply  = "Sorry "..user.sName..", There were no entries found on *"..
month.."/"..day.."/"..year.."*",1
else
reply = reply..string.rep("?",115).."\r\n\r\n\tThere were a "..
"total of [ "..cnt.." ] entries on *"..month.."/"..day.."/"..yr.."*\r\n\r\n"
end
return reply,1
else
return "List Registration Changes On <MM/DD/YY>"," %[line:Month]/%[line:Day]/%[line:Year]",
" %[line:Month]/%[line:Day]/%[line:Year]"
end
end,
rlhelp = function(user,data)
if user then
local reply = "\n\n\t\t Topic Command Help\n\t"..string.rep("?",35).."\n"
for i,v in pairs(RlCmds) do
local desc,args = RlCmds[i]()
reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\n"
end
return reply.."\n\t"..string.rep("?",35).."\n\n",1
else
return "Show Registry Log Help","",""
end
end,
}

Main = function()
gc,no,pat,mem = nil,table.getn,string.gfind,gcinfo()
if _VERSION == "Lua 5.1" then
gc,no,pat,mem = "collect",table.maxn,string.gmatch,collectgarbage("count")
end
mem = string.format("%-.2f Kb.",mem)
local reply = ""
local date,time = os.date("%m/%d/%y"),os.date("%I:%M:%s ")..string.lower(os.date("%p"))
local op,opprf = "RegLog","Script"
if RlCfg.Bot ~= frmHub:GetHubBotName() or not frmHub:GetHubBot() then
frmHub:RegBot(RlCfg.Bot, 1, RlCfg.Desc.." PtokaX ".._Version, RlCfg.Mail)
end
if loadfile(RlCfg.File) then
dofile(RlCfg.File)
local Users = {}
for a,b in ipairs(RlCfg.RegUsers) do
local tab = {b[1],b[2],b[3],b[4],b[5],b[6],b[7]}
if not GetUserProfile(b[1]) then
if b[7] ~= "Disabled" then
tab = {b[1],b[2],op,opprf,date,time,"Disabled"}
end
elseif b[2] ~= GetProfileName(GetUserProfile(b[1])) then
tab = {b[1],GetProfileName(GetUserProfile(b[1])),b[3],b[4],b[5],b[6],b[7]}
end
table.insert(Users,a,tab)
end
RlCfg.RegUsers = Users
Save_File(RlCfg.File,RlCfg.RegUsers,"RlCfg.RegUsers")
local FileSize = CheckFile(RlCfg.File)
reply = "Configuration file: "..RlCfg.File..", found and executed.  Filesize: "..FileSize..
",  Entries: "..no(RlCfg.RegUsers)..",  Memory Used: "..mem.." Kb."
else
RlCfg.RegUsers = {}
for i,v in ipairs(frmHub:GetRegisteredUsers()) do
local tab = {v.sNick,GetProfileName(v.iProfile),op,opprf,date,time,"Enabled"}
table.insert(RlCfg.RegUsers,tab)
end
Save_File(RlCfg.File,RlCfg.RegUsers,"RlCfg.RegUsers")
local FileSize = CheckFile(RlCfg.File)
if not FileSize then
reply = "Error! File: "..File.." not found."
else
reply = "Registry log created and saved to "..RlCfg.File..". Filesize: "..
FileSize..".  Memory Used: "..mem.." Kb. Entries: "..no(RlCfg.RegUsers)
end
end
OnError(reply)
end

OnError = function(msg)
SendToNick(RlCfg.OpNick,"<"..RlCfg.Bot.."> "..msg)
end

NewUserConnected = function(user)
if user.iProfile ~= -1 then
local Perm = GetProfilePermissions(user.iProfile)
if Perm.bAddRegUser == 1 and Perm.bDelRegUser == 1 then
DoRlCmds(user)
user:SendData(RlCfg.Bot,GetProfileName(user.iProfile).."'s user registry "..
"commands enabled. Right click hub tab for command menu.")
end
end
end
OpConnected = NewUserConnected

ChatArrival = function(user, data)
if RlCfg.Profiles[user.iProfile] and RlCfg.Profiles[user.iProfile][1] == 1 then
local s,e,to = string.find(data,"^$To:%s(%S+)%s+From:")
local s,e,cmd = string.find( data, "%b<>%s%p(%w+)")
if cmd then cmd = string.lower(cmd) end
if RlCmds[cmd] then
local s,c = RlCmds[cmd](user,data)
if to and to == RlCfg.Bot or RlCfg.PmReply == "yes" then
user:SendPM(RlCfg.Bot,s)
else
user:SendData(RlCfg.Bot,s)
end
return c
end
end
end
ToArrival = ChatArrival

DoRlCmds = function(user)
for i,v in pairs(RlCmds) do
local m,s = RlCfg.Menu,RlCfg.SubMenu
local c,n,p = "$UserCommand 1","$<%[mynick]>","&#124;"
local d,a1,a2 = RlCmds[i]()
user:SendData(c.." 1 "..m.."\\"..s.."\\"..d..n.." +"..i..a1..p)
user:SendData(c.." 2 "..m.."\\"..s.."\\"..d.."$$To: "..RlCfg.Bot..
" From: %[mynick] "..n.." "..frmHub:GetPrefixes()[1]..i..a2..p)
end
collectgarbage(gc)
end

CheckFile = function(File)
local f,e = io.open(File,"r")
if f then
local current = f:seek()
local size = f:seek("end")
f:seek("set", current)
f:close()
if size then
return FormatSize(size)
end
else
if e then
return e
end
end
end

function FormatSize(size)
local fs,unit,div,sz = "","",0,0
Range = {
[1] = {1099511627776,"GB",(1024^3)},
[2] = {1073741824,"MB",(1024^2)},
[3] = {1048576,"KB",1024},
[4] = {1024,"B ",1},
}
for a,b in ipairs(Range) do
while size < b[1] do
unit,div = b[2],b[3]
sz = string.format("%.2f", size / div)
fs = string.format("%"..(13-string.len(sz)).."s",sz)..string.format(" %-2s",unit)
break
end
end
return fs
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

Save_File = function(file,table,tablename)
local hFile = io.open (file , "wb")
Save_Serialize(table, tablename, hFile)
hFile:close()
collectgarbage(gc)
end
and
Code: [Select]
--[[

Main Message On Timer

By American Idiot 08/16/07

Requested by virusel2013

Sends contents of a text file to
select profiles in main chat on timer.

]]

-- Start Settings
local GetMsg = {
[-1] =1, -- Unregistered User
[0] = 1, -- Master
[1] = 1, -- Operator
[2] = 1, -- VIP
[3] = 1, -- Reg
[4] = 1, -- Moderator
[5] = 1, -- Netfounder
[6] = 1, -- Owner

}

local SendEvery = 90 --Time in Mins
local SendAtStart = "yes" --Send At Script Start?
local TextFile = "massmessage.txt" --File To Send
local Bot = "?Info?" --Name For Bot
-- End Settings

local Mins = 1000 * 60 * SendEvery
function Main()
SetTimer(Mins)
StartTimer()
if SendAtStart:lower() == "yes" then
OnTimer()
end
Thank You!!!
rolipoli
« Last Edit: 31 March, 2008, 14:06:15 by rolipoli »

PtokaX forum

need to convert two fine scripts
« on: 31 March, 2008, 13:58:50 »

Offline Daywalker?

  • Scripter
  • Member
  • ******
  • Posts: 45
  • Karma: +9/-9
Re: need to convert two fine scripts
« Reply #1 on: 31 March, 2008, 15:27:20 »
no offence but....

does anyone ever search the board for scripts???

LogBot by American Idiot
EventBot by American Idiot

that's what i remember if i remember correct anyway, maybe a little more advanced but for the same use.

Offline rolipoli

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-1
  • Transilvania-Erd?ly
Re: need to convert two fine scripts
« Reply #2 on: 31 March, 2008, 20:21:18 »
no offence but....

does anyone ever search the board for scripts???

LogBot by American Idiot
EventBot by American Idiot

that's what i remember if i remember correct anyway, maybe a little more advanced but for the same use.
Whith no offence... :) you have right but i know this scripts.I like to use the Mainmassage on Timer because use one text file witch contains a simple advertise whith our partner hubs and our hub website, like the "hubaddmessage lua" in the Robocop.
The Logbot not make a list per user profile like op, vip, regs, etc.and after a period of time the log file it's recreated:"Log file logs/Regs.log flushed and recreated for(my hubname)".That's the reasons for asking for the conversions.

Offline rolipoli

  • Junior Member
  • **
  • Posts: 19
  • Karma: +0/-1
  • Transilvania-Erd?ly
Re: need to convert two fine scripts
« Reply #3 on: 01 April, 2008, 11:55:38 »
Thank you !!! :)

PtokaX forum

Re: need to convert two fine scripts
« Reply #3 on: 01 April, 2008, 11:55:38 »