Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.90 KB | None | 0 0
  1. === modified file plugins/Script/examples/access.lua
  2. --- plugins/Script/examples/access.lua  2011-02-16 21:33:10 +0000
  3. +++ plugins/Script/examples/access.lua  2011-02-18 15:48:17 +0000
  4. @@ -467,8 +467,8 @@
  5.     end
  6.  end
  7.  
  8. -local function make_user(cid, nick, password, level)
  9. -   local user = { cid = cid, nick = nick, password = password, level = level }
  10. +local function make_user(cid, nick, password, level, regby)
  11. +   local user = { cid = cid, nick = nick, password = password, level = level, regby = regby, regtime = os.time() }
  12.     return user
  13.  end
  14.  
  15. @@ -547,6 +547,7 @@
  16.         end
  17.  
  18.         user.nick = nick
  19. +       user.lasttime = os.time()
  20.         users.nicks[user.nick] = user
  21.         base.pcall(save_users)
  22.         return true, "Registration data updated (new nick)"
  23. @@ -563,16 +564,21 @@
  24.         end
  25.  
  26.         user.cid = cid
  27. +       user.lasttime = os.time()
  28.         users.cids[user.cid] = user
  29.         base.pcall(save_users)
  30.         return true, "Registration data updated (new CID)"
  31.     end
  32.  
  33. +   user.lasttime = os.time()
  34. +   users.cids[user.cid] = user
  35. +   base.pcall(save_users)
  36. +
  37.     return true
  38.  end
  39.  
  40. -function register_user(cid, nick, password, level)
  41. -   local user = make_user(cid, nick, password, level)
  42. +function register_user(cid, nick, password, level, regby)
  43. +   local user = make_user(cid, nick, password, level, regby)
  44.     if nick then
  45.         users.nicks[nick] = user
  46.     end
  47. @@ -883,6 +889,20 @@
  48.     return string.format("%d days, %d hours, %d minutes and %d seconds", t_d, t_h, t_m, t_s)
  49.  end
  50.  
  51. +function format_minutes(t)
  52. +   local t_d = math.floor(t / (60*60*24))
  53. +   local t_h = math.floor(t / (60*60)) % 24
  54. +   local t_m = math.floor(t / 60) % 60
  55. +
  56. +   return string.format("%d days, %d hours and %d minutes", t_d, t_h, t_m)
  57. +end
  58. +
  59. +function time_diff(t)
  60. +   local diff = os.difftime(os.time(), t)
  61. +   local time = format_minutes(diff)
  62. +   return time
  63. +end
  64. +
  65.  cut_str = function(str, max)
  66.     if #str > max - 3 then
  67.         return string.sub(str, 1, max - 3) .. "..."
  68. @@ -1244,20 +1265,30 @@
  69.             if v.level <= user.level then
  70.                 local fields = {}
  71.                 if v.nick then
  72. -                   table.insert(fields, "Nick: " .. v.nick)
  73. +                   table.insert(fields, "\tNick: " .. v.nick)
  74.                 end
  75.                 if v.cid then
  76. -                   table.insert(fields, "CID: " .. v.cid)
  77. +                   table.insert(fields, "\n\tCID: " .. v.cid)
  78.                 end
  79.                 if settings.passinlist.value ~=0 and v.level < user.level and v.password then
  80.                     table.insert(fields, "Pass: " .. v.password)
  81.                 end
  82. -               table.insert(list, table.concat(fields, "\t"))
  83. +               if v.regtime then
  84. +                   table.insert(fields, "\n\tWhen: " .. time_diff(v.regtime) .. " ago")
  85. +               end
  86. +               if v.lasttime then
  87. +                   table.insert(fields, "Last on: " .. time_diff(v.lasttime) .. " ago")
  88. +               end
  89. +               if v.regby then
  90. +                   table.insert(fields, "\n\tRegged By: " .. v.regby)
  91. +               end
  92. +
  93. +               table.insert(list, table.concat(fields, "\t\t"))
  94.             end
  95.         end
  96.         table.sort(list)
  97.  
  98. -       autil.reply(c, "Registered users with a level <= " .. user.level .. " (your level):\n" .. table.concat(list, "\n"))
  99. +       autil.reply(c, "Registered users with a level <= " .. user.level .. " (your level):\n\n" .. table.concat(list, "\n\n") .. "\n")
  100.     end,
  101.  
  102.     protected = function(c) return not get_user_c(c).is_default end,
  103. @@ -1291,7 +1322,7 @@
  104.             base.pcall(save_users)
  105.             autil.reply(c, "Your password has been changed to \"" .. parameters .. "\"")
  106.         elseif settings.allowreg.value ~= 0 then
  107. -           register_user(c:getCID():toBase32(), c:getField("NI"), parameters, 1)
  108. +           register_user(c:getCID():toBase32(), c:getField("NI"), parameters, 1, c:getField("NI"))
  109.             autil.reply(c, "You're now registered with the password \"" .. parameters .. "\"")
  110.         else
  111.             autil.reply(c, "You are not allowed to register by yourself; ask an operator to do it for you")
  112. @@ -1392,7 +1423,7 @@
  113.             return
  114.         end
  115.  
  116. -       register_user(cid, nick, password, level)
  117. +       register_user(cid, nick, password, level, c:getField("NI"))
  118.  
  119.         autil.reply(c, "\"" .. nick .. "\" has been registered")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement