Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === modified file plugins/Script/examples/access.lua
- --- plugins/Script/examples/access.lua 2011-02-16 21:33:10 +0000
- +++ plugins/Script/examples/access.lua 2011-02-18 15:48:17 +0000
- @@ -467,8 +467,8 @@
- end
- end
- -local function make_user(cid, nick, password, level)
- - local user = { cid = cid, nick = nick, password = password, level = level }
- +local function make_user(cid, nick, password, level, regby)
- + local user = { cid = cid, nick = nick, password = password, level = level, regby = regby, regtime = os.time() }
- return user
- end
- @@ -547,6 +547,7 @@
- end
- user.nick = nick
- + user.lasttime = os.time()
- users.nicks[user.nick] = user
- base.pcall(save_users)
- return true, "Registration data updated (new nick)"
- @@ -563,16 +564,21 @@
- end
- user.cid = cid
- + user.lasttime = os.time()
- users.cids[user.cid] = user
- base.pcall(save_users)
- return true, "Registration data updated (new CID)"
- end
- + user.lasttime = os.time()
- + users.cids[user.cid] = user
- + base.pcall(save_users)
- +
- return true
- end
- -function register_user(cid, nick, password, level)
- - local user = make_user(cid, nick, password, level)
- +function register_user(cid, nick, password, level, regby)
- + local user = make_user(cid, nick, password, level, regby)
- if nick then
- users.nicks[nick] = user
- end
- @@ -883,6 +889,20 @@
- return string.format("%d days, %d hours, %d minutes and %d seconds", t_d, t_h, t_m, t_s)
- end
- +function format_minutes(t)
- + local t_d = math.floor(t / (60*60*24))
- + local t_h = math.floor(t / (60*60)) % 24
- + local t_m = math.floor(t / 60) % 60
- +
- + return string.format("%d days, %d hours and %d minutes", t_d, t_h, t_m)
- +end
- +
- +function time_diff(t)
- + local diff = os.difftime(os.time(), t)
- + local time = format_minutes(diff)
- + return time
- +end
- +
- cut_str = function(str, max)
- if #str > max - 3 then
- return string.sub(str, 1, max - 3) .. "..."
- @@ -1244,20 +1265,30 @@
- if v.level <= user.level then
- local fields = {}
- if v.nick then
- - table.insert(fields, "Nick: " .. v.nick)
- + table.insert(fields, "\tNick: " .. v.nick)
- end
- if v.cid then
- - table.insert(fields, "CID: " .. v.cid)
- + table.insert(fields, "\n\tCID: " .. v.cid)
- end
- if settings.passinlist.value ~=0 and v.level < user.level and v.password then
- table.insert(fields, "Pass: " .. v.password)
- end
- - table.insert(list, table.concat(fields, "\t"))
- + if v.regtime then
- + table.insert(fields, "\n\tWhen: " .. time_diff(v.regtime) .. " ago")
- + end
- + if v.lasttime then
- + table.insert(fields, "Last on: " .. time_diff(v.lasttime) .. " ago")
- + end
- + if v.regby then
- + table.insert(fields, "\n\tRegged By: " .. v.regby)
- + end
- +
- + table.insert(list, table.concat(fields, "\t\t"))
- end
- end
- table.sort(list)
- - autil.reply(c, "Registered users with a level <= " .. user.level .. " (your level):\n" .. table.concat(list, "\n"))
- + autil.reply(c, "Registered users with a level <= " .. user.level .. " (your level):\n\n" .. table.concat(list, "\n\n") .. "\n")
- end,
- protected = function(c) return not get_user_c(c).is_default end,
- @@ -1291,7 +1322,7 @@
- base.pcall(save_users)
- autil.reply(c, "Your password has been changed to \"" .. parameters .. "\"")
- elseif settings.allowreg.value ~= 0 then
- - register_user(c:getCID():toBase32(), c:getField("NI"), parameters, 1)
- + register_user(c:getCID():toBase32(), c:getField("NI"), parameters, 1, c:getField("NI"))
- autil.reply(c, "You're now registered with the password \"" .. parameters .. "\"")
- else
- autil.reply(c, "You are not allowed to register by yourself; ask an operator to do it for you")
- @@ -1392,7 +1423,7 @@
- return
- end
- - register_user(cid, nick, password, level)
- + register_user(cid, nick, password, level, c:getField("NI"))
- autil.reply(c, "\"" .. nick .. "\" has been registered")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement