Advertisement
Terrah

betatimer

Apr 22nd, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. --This script is now dead
  2.  
  3. local next = 0;
  4. local last = "";
  5.  
  6. local function Save(invited,next)
  7.  
  8.     local tbl = {};
  9.     tbl.name = invited;
  10.     tbl.next = next;
  11.  
  12.     MOD.SetVar("betatimer",JSONEncode(tbl));
  13. end
  14.  
  15. local function CheckAndGet()
  16.  
  17.     MOD.Timer("betatimer",1,CheckAndGet);
  18.  
  19.     local t = os.time();
  20.  
  21.     if t > next then
  22.  
  23.         local raw,code = MOD.HTTPGet("https://www.pathofexile.com/scripts/beta-invite-query.php?mode=next");
  24.  
  25.         if code==200 then
  26.  
  27.             local data = JSONDecode(raw);
  28.             local p1 = data.p1;
  29.             local next_s = p1.next_s;
  30.             local invited = p1.last.name;
  31.  
  32.             if invited == last then
  33.                 return;
  34.             end
  35.  
  36.             print(invited.." has been invited to the closed beta!");
  37.  
  38.             last = invited;
  39.  
  40.             next = t+next_s+1;
  41.  
  42.             Save(invited,t+next_s);
  43.  
  44.         else
  45.             next = t+30;
  46.         end
  47.     end
  48. end
  49.  
  50. --[[local raw = MOD.GetVar("betatimer","#pathofexile");
  51.  
  52. if raw == nil then
  53.     MOD.Timer("betatimer",1,CheckAndGet);
  54. else
  55.     local data = JSONDecode(raw);
  56.     last = data.name;
  57.     next = data.next;
  58.     MOD.Timer("betatimer",1,CheckAndGet);
  59. end
  60.  
  61. return function(msg,usr,chan)
  62.  
  63.     if last==nil or last=="" then
  64.         return;
  65.     end
  66.  
  67.     local coming = next-os.time();
  68.  
  69.     if coming <= 0 then
  70.         coming = "Any moment now!";
  71.     else
  72.         coming = MOD.SecondToSpan(coming);
  73.     end
  74.  
  75.     print("Last invite: "..last.." next invite: " .. coming);
  76. end]]
  77.  
  78. MOD.DelVar("betatimer");
  79.  
  80. return nil;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement