Advertisement
Tocuto

#bolodefchoco - bot module

Jan 22nd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.24 KB | None | 0 0
  1. tribeModule["*\3Familia de Tocutoeltuco"] = function()
  2.     local json = (function()
  3.         local json = { _version = "0.1.1" }
  4.  
  5.         -------------------------------------------------------------------------------
  6.         -- Encode
  7.         -------------------------------------------------------------------------------
  8.  
  9.         local encode
  10.  
  11.         local escape_char_map = {
  12.           [ "\\" ] = "\\\\",
  13.           [ "\"" ] = "\\\"",
  14.           [ "\b" ] = "\\b",
  15.           [ "\f" ] = "\\f",
  16.           [ "\n" ] = "\\n",
  17.           [ "\r" ] = "\\r",
  18.           [ "\t" ] = "\\t",
  19.         }
  20.  
  21.         local escape_char_map_inv = { [ "\\/" ] = "/" }
  22.         for k, v in pairs(escape_char_map) do
  23.           escape_char_map_inv[v] = k
  24.         end
  25.  
  26.  
  27.         local function escape_char(c)
  28.           return escape_char_map[c] or string.format("\\u%04x", c:byte())
  29.         end
  30.  
  31.  
  32.         local function encode_nil(val)
  33.           return "null"
  34.         end
  35.  
  36.  
  37.         local function encode_table(val, stack)
  38.           local res = {}
  39.           stack = stack or {}
  40.  
  41.           -- Circular reference?
  42.           if stack[val] then error("circular reference") end
  43.  
  44.           stack[val] = true
  45.  
  46.           if val[1] ~= nil or next(val) == nil then
  47.             -- Treat as array -- check keys are valid and it is not sparse
  48.             local n = 0
  49.             for k in pairs(val) do
  50.               if type(k) ~= "number" then
  51.                 error("invalid table: mixed or invalid key types")
  52.               end
  53.               n = n + 1
  54.             end
  55.             if n ~= #val then
  56.               error("invalid table: sparse array")
  57.             end
  58.             -- Encode
  59.             for i, v in ipairs(val) do
  60.               table.insert(res, encode(v, stack))
  61.             end
  62.             stack[val] = nil
  63.             return "[" .. table.concat(res, ",") .. "]"
  64.  
  65.           else
  66.             -- Treat as an object
  67.             for k, v in pairs(val) do
  68.               if type(k) ~= "string" then
  69.                 error("invalid table: mixed or invalid key types")
  70.               end
  71.               table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
  72.             end
  73.             stack[val] = nil
  74.             return "{" .. table.concat(res, ",") .. "}"
  75.           end
  76.         end
  77.  
  78.  
  79.         local function encode_string(val)
  80.           return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
  81.         end
  82.  
  83.  
  84.         local function encode_number(val)
  85.           -- Check for NaN, -inf and inf
  86.           if val ~= val or val <= -math.huge or val >= math.huge then
  87.             error("unexpected number value '" .. tostring(val) .. "'")
  88.           end
  89.           return string.format("%.14g", val)
  90.         end
  91.  
  92.  
  93.         local type_func_map = {
  94.           [ "nil"     ] = encode_nil,
  95.           [ "table"   ] = encode_table,
  96.           [ "string"  ] = encode_string,
  97.           [ "number"  ] = encode_number,
  98.           [ "boolean" ] = tostring,
  99.         }
  100.  
  101.  
  102.         encode = function(val, stack)
  103.           local t = type(val)
  104.           local f = type_func_map[t]
  105.           if f then
  106.             return f(val, stack)
  107.           end
  108.           error("unexpected type '" .. t .. "'")
  109.         end
  110.  
  111.  
  112.         function json.encode(val)
  113.           return ( encode(val) )
  114.         end
  115.  
  116.  
  117.         -------------------------------------------------------------------------------
  118.         -- Decode
  119.         -------------------------------------------------------------------------------
  120.  
  121.         local parse
  122.  
  123.         local function create_set(...)
  124.           local res = {}
  125.           for i = 1, select("#", ...) do
  126.             res[ select(i, ...) ] = true
  127.           end
  128.           return res
  129.         end
  130.  
  131.         local space_chars   = create_set(" ", "\t", "\r", "\n")
  132.         local delim_chars   = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
  133.         local escape_chars  = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
  134.         local literals      = create_set("true", "false", "null")
  135.  
  136.         local literal_map = {
  137.           [ "true"  ] = true,
  138.           [ "false" ] = false,
  139.           [ "null"  ] = nil,
  140.         }
  141.  
  142.  
  143.         local function next_char(str, idx, set, negate)
  144.           for i = idx, #str do
  145.             if set[str:sub(i, i)] ~= negate then
  146.               return i
  147.             end
  148.           end
  149.           return #str + 1
  150.         end
  151.  
  152.  
  153.         local function decode_error(str, idx, msg)
  154.           local line_count = 1
  155.           local col_count = 1
  156.           for i = 1, idx - 1 do
  157.             col_count = col_count + 1
  158.             if str:sub(i, i) == "\n" then
  159.               line_count = line_count + 1
  160.               col_count = 1
  161.             end
  162.           end
  163.           error( string.format("%s at line %d col %d", msg, line_count, col_count) )
  164.         end
  165.  
  166.  
  167.         local function codepoint_to_utf8(n)
  168.           -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
  169.           local f = math.floor
  170.           if n <= 0x7f then
  171.             return string.char(n)
  172.           elseif n <= 0x7ff then
  173.             return string.char(f(n / 64) + 192, n % 64 + 128)
  174.           elseif n <= 0xffff then
  175.             return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
  176.           elseif n <= 0x10ffff then
  177.             return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
  178.                                f(n % 4096 / 64) + 128, n % 64 + 128)
  179.           end
  180.           error( string.format("invalid unicode codepoint '%x'", n) )
  181.         end
  182.  
  183.  
  184.         local function parse_unicode_escape(s)
  185.           local n1 = tonumber( s:sub(3, 6),  16 )
  186.           local n2 = tonumber( s:sub(9, 12), 16 )
  187.           -- Surrogate pair?
  188.           if n2 then
  189.             return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
  190.           else
  191.             return codepoint_to_utf8(n1)
  192.           end
  193.         end
  194.  
  195.  
  196.         local function parse_string(str, i)
  197.           local has_unicode_escape = false
  198.           local has_surrogate_escape = false
  199.           local has_escape = false
  200.           local last
  201.           for j = i + 1, #str do
  202.             local x = str:byte(j)
  203.  
  204.             if x < 32 then
  205.               decode_error(str, j, "control character in string")
  206.             end
  207.  
  208.             if last == 92 then -- "\\" (escape char)
  209.               if x == 117 then -- "u" (unicode escape sequence)
  210.                 local hex = str:sub(j + 1, j + 5)
  211.                 if not hex:find("%x%x%x%x") then
  212.                   decode_error(str, j, "invalid unicode escape in string")
  213.                 end
  214.                 if hex:find("^[dD][89aAbB]") then
  215.                   has_surrogate_escape = true
  216.                 else
  217.                   has_unicode_escape = true
  218.                 end
  219.               else
  220.                 local c = string.char(x)
  221.                 if not escape_chars[c] then
  222.                   decode_error(str, j, "invalid escape char '" .. c .. "' in string")
  223.                 end
  224.                 has_escape = true
  225.               end
  226.               last = nil
  227.  
  228.             elseif x == 34 then -- '"' (end of string)
  229.               local s = str:sub(i + 1, j - 1)
  230.               if has_surrogate_escape then
  231.                 s = s:gsub("\\u[dD][89aAbB]..\\u....", parse_unicode_escape)
  232.               end
  233.               if has_unicode_escape then
  234.                 s = s:gsub("\\u....", parse_unicode_escape)
  235.               end
  236.               if has_escape then
  237.                 s = s:gsub("\\.", escape_char_map_inv)
  238.               end
  239.               return s, j + 1
  240.  
  241.             else
  242.               last = x
  243.             end
  244.           end
  245.           decode_error(str, i, "expected closing quote for string")
  246.         end
  247.  
  248.  
  249.         local function parse_number(str, i)
  250.           local x = next_char(str, i, delim_chars)
  251.           local s = str:sub(i, x - 1)
  252.           local n = tonumber(s)
  253.           if not n then
  254.             decode_error(str, i, "invalid number '" .. s .. "'")
  255.           end
  256.           return n, x
  257.         end
  258.  
  259.  
  260.         local function parse_literal(str, i)
  261.           local x = next_char(str, i, delim_chars)
  262.           local word = str:sub(i, x - 1)
  263.           if not literals[word] then
  264.             decode_error(str, i, "invalid literal '" .. word .. "'")
  265.           end
  266.           return literal_map[word], x
  267.         end
  268.  
  269.  
  270.         local function parse_array(str, i)
  271.           local res = {}
  272.           local n = 1
  273.           i = i + 1
  274.           while 1 do
  275.             local x
  276.             i = next_char(str, i, space_chars, true)
  277.             -- Empty / end of array?
  278.             if str:sub(i, i) == "]" then
  279.               i = i + 1
  280.               break
  281.             end
  282.             -- Read token
  283.             x, i = parse(str, i)
  284.             res[n] = x
  285.             n = n + 1
  286.             -- Next token
  287.             i = next_char(str, i, space_chars, true)
  288.             local chr = str:sub(i, i)
  289.             i = i + 1
  290.             if chr == "]" then break end
  291.             if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
  292.           end
  293.           return res, i
  294.         end
  295.  
  296.  
  297.         local function parse_object(str, i)
  298.           local res = {}
  299.           i = i + 1
  300.           while 1 do
  301.             local key, val
  302.             i = next_char(str, i, space_chars, true)
  303.             -- Empty / end of object?
  304.             if str:sub(i, i) == "}" then
  305.               i = i + 1
  306.               break
  307.             end
  308.             -- Read key
  309.             if str:sub(i, i) ~= '"' then
  310.               decode_error(str, i, "expected string for key")
  311.             end
  312.             key, i = parse(str, i)
  313.             -- Read ':' delimiter
  314.             i = next_char(str, i, space_chars, true)
  315.             if str:sub(i, i) ~= ":" then
  316.               decode_error(str, i, "expected ':' after key")
  317.             end
  318.             i = next_char(str, i + 1, space_chars, true)
  319.             -- Read value
  320.             val, i = parse(str, i)
  321.             -- Set
  322.             res[key] = val
  323.             -- Next token
  324.             i = next_char(str, i, space_chars, true)
  325.             local chr = str:sub(i, i)
  326.             i = i + 1
  327.             if chr == "}" then break end
  328.             if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
  329.           end
  330.           return res, i
  331.         end
  332.  
  333.  
  334.         local char_func_map = {
  335.           [ '"' ] = parse_string,
  336.           [ "0" ] = parse_number,
  337.           [ "1" ] = parse_number,
  338.           [ "2" ] = parse_number,
  339.           [ "3" ] = parse_number,
  340.           [ "4" ] = parse_number,
  341.           [ "5" ] = parse_number,
  342.           [ "6" ] = parse_number,
  343.           [ "7" ] = parse_number,
  344.           [ "8" ] = parse_number,
  345.           [ "9" ] = parse_number,
  346.           [ "-" ] = parse_number,
  347.           [ "t" ] = parse_literal,
  348.           [ "f" ] = parse_literal,
  349.           [ "n" ] = parse_literal,
  350.           [ "[" ] = parse_array,
  351.           [ "{" ] = parse_object,
  352.         }
  353.  
  354.  
  355.         parse = function(str, idx)
  356.           local chr = str:sub(idx, idx)
  357.           local f = char_func_map[chr]
  358.           if f then
  359.             return f(str, idx)
  360.           end
  361.           decode_error(str, idx, "unexpected character '" .. chr .. "'")
  362.         end
  363.  
  364.  
  365.         function json.decode(str)
  366.           if type(str) ~= "string" then
  367.             error("expected argument of type string, got " .. type(str))
  368.           end
  369.           local res, idx = parse(str, next_char(str, 1, space_chars, true))
  370.           idx = next_char(str, idx, space_chars, true)
  371.           if idx <= #str then
  372.             decode_error(str, idx, "trailing garbage")
  373.           end
  374.           return res
  375.         end
  376.  
  377.  
  378.         return json
  379.     end)()
  380.    
  381.     local split_message_at = 600
  382.    
  383.     local function splitMessage(msg)
  384.         local messagesIndex = 0
  385.         local messages = {}
  386.        
  387.         for index = 1, #msg, split_message_at do
  388.             messagesIndex = messagesIndex + 1
  389.             messages[messagesIndex] = string.sub(msg, index, index + split_message_at - 1)
  390.         end
  391.        
  392.         return messages
  393.     end
  394.    
  395.     local function chatMessage(msgId, msg)
  396.         local messages
  397.         if #msg > split_message_at then
  398.             messages = splitMessage(msg)
  399.         else
  400.             messages = {msg}
  401.         end
  402.        
  403.         local messagesLength = #messages
  404.         for index = 1, messagesLength do
  405.             tfm.exec.chatMessage(msgId .. " " .. messagesLength .. " " .. messages[index])
  406.         end
  407.     end
  408.    
  409.     local eventLoopCount = 0
  410.     local staff_teams = {
  411.         ["translators"] = {
  412.             ["Abdeljalil6#0000"] = true,
  413.             ["Acer#0010"] = true,
  414.             ["Ae_86#5182"] = true,
  415.             ["Beachair#0000"] = true,
  416.             ["Bodykudo#0000"] = true,
  417.             ["Ctmce#0000"] = true,
  418.             ["Derpfacederp#0000"] = true,
  419.             ["Erennnnnnn#7651"] = true,
  420.             ["Faz_x#0010"] = true,
  421.             ["Flindix#0095"] = true,
  422.             ["Grabouilie#0000"] = true,
  423.             ["Grapeup#0020"] = true,
  424.             ["Jolkaebolka#0000"] = true,
  425.             ["Kanan#2167"] = true,
  426.             ["Kincslol#0000"] = true,
  427.             ["Leila#6251"] = true,
  428.             ["Linkaito#4129"] = true,
  429.             ["Lothcat#0000"] = true,
  430.             ["Majzer#3179"] = true,
  431.             ["Mikumaly#0000"] = true,
  432.             ["Millenios#7956"] = true,
  433.             ["Nicor22#0000"] = true,
  434.             ["Peanut_butter#0015"] = true,
  435.             ["Rkubi#0000"] = true,
  436.             ["Ryuuzaki#1216"] = true,
  437.             ["Sebafrancuz#0000"] = true,
  438.             ["Tocutoeltuco#0000"] = true,
  439.             ["Unidentified#8421"] = true,
  440.             ["Unlocker001#0000"] = true,
  441.             ["Usmiechnij_sie#9743"] = true,
  442.             ["Vajisco0#0000"] = true,
  443.             ["Wassimevicw#0000"] = true,
  444.             ["Wrfg#0000"] = true,
  445.             ["Yuba#2381"] = true,
  446.             ["Zimmer#9770"] = true,
  447.             ["Zutto#4451"] = true
  448.         },
  449.         ["fashion_squad"] = {
  450.             ["Alfiecakes#0000"] = true,
  451.             ["Bobbyxsoxer#0000"] = true,
  452.             ["Etyla#0015"] = true,
  453.             ["Eyeground#0000"] = true,
  454.             ["Iuliluca#0000"] = true,
  455.             ["Ikke#0015"] = true,
  456.             ["Katow#0020"] = true,
  457.             ["Kiddoru#0000"] = true,
  458.             ["Kingapysia#0000"] = true,
  459.             ["Kurt#0015"] = true,
  460.             ["Lou#3859"] = true,
  461.             ["Mlledebby#0015"] = true,
  462.             ["Papero#9240"] = true,
  463.             ["Perlchen#0000"] = true,
  464.             ["Roberta#0113"] = true,
  465.             ["Silvyna#0020"] = true,
  466.             ["Tini#8387"] = true,
  467.             ["Unlocker001#0000"] = true,
  468.             ["Venusise#0000"] = true
  469.         },
  470.         ["module_team"] = {
  471.             ["Athesdrake#0000"] = true,
  472.             ["Bodykudo#0000"] = true,
  473.             ["Bolodefchoco#0000"] = true,
  474.             ["Brenower#0000"] = true,
  475.             ["Drgenius#0000"] = true,
  476.             ["Esh#0095"] = true,
  477.             ["Frozenjord#0656"] = true,
  478.             ["Fofinhoppp#0000"] = true,
  479.             ["Gekkeiju#0000"] = true,
  480.             ["Haku#0807"] = true,
  481.             ["Heniyengui#0000"] = true,
  482.             ["Jordy#0010"] = true,
  483.             ["Laagaadoo#0000"] = true,
  484.             ["Makinit#0095"] = true,
  485.             ["Nettoork#0000"] = true,
  486.             ["Ninguem#0095"] = true,
  487.             ["Papero#9240"] = true,
  488.             ["Rkubi#0000"] = true,
  489.             ["Rufflesdqjo#0000"] = true,
  490.             ["Saintgio#0000"] = true,
  491.             ["Sebafrancuz#0000"] = true,
  492.             ["Sebaisseba#0020"] = true,
  493.             ["Shamousey#0015"] = true,
  494.             ["Sharpiepoops#0020"] = true,
  495.             ["Tat#0020"] = true,
  496.             ["Thanos#1306"] = true,
  497.             ["Thewav#0095"] = true,
  498.             ["Tortuegreen#0000"] = true,
  499.             ["Turkitutu#0000"] = true,
  500.             ["Unlocker001#0000"] = true,
  501.             ["Velspar#0000"] = true,
  502.             ["Warfenix#0095"] = true
  503.         },
  504.         ["funcorp"] = {
  505.             ["Bodykudo#0000"] = true,
  506.             ["Papero#9240"] = true,
  507.             ["Arcanacra#0010"] = true,
  508.             ["Jordy#0010"] = true,
  509.             ["Lezzly#0010"] = true,
  510.             ["Lummit#0010"] = true,
  511.             ["Miau#0010"] = true,
  512.             ["Mousey#0010"] = true,
  513.             ["Philae#0010"] = true,
  514.             ["Pop#0010"] = true,
  515.             ["Staszekowaty#0010"] = true,
  516.             ["Tarmac#0010"] = true,
  517.             ["Titivillus#0010"] = true,
  518.             ["Visne#0010"] = true,
  519.             ["Lightwood#0010"] = true,
  520.             ["Ikke#0015"] = true,
  521.             ["Mesmera#0015"] = true,
  522.             ["Milkycoffee#0015"] = true,
  523.             ["Bemmh#0020"] = true,
  524.             ["Grapeup#0020"] = true,
  525.             ["Sebaisseba#0020"] = true,
  526.             ["Charbz#3144"] = true
  527.         },
  528.         ["mapcrew"] = {
  529.             ["A_801#0015"] = true,
  530.             ["Bemmh#0020"] = true,
  531.             ["Goondad#0020"] = true,
  532.             ["Grapeup#0020"] = true,
  533.             ["Katow#0020"] = true,
  534.             ["Leetinsanity#0020"] = true,
  535.             ["Mapcrew#0020"] = true,
  536.             ["Mapcrewone#0020"] = true,
  537.             ["Mapcrewtwo#0020"] = true,
  538.             ["Sebaisseba#0020"] = true,
  539.             ["Sharpiepoops#0020"] = true,
  540.             ["Sherr#0020"] = true,
  541.             ["Uskil#0020"] = true,
  542.             ["Vividia#0015"] = true,
  543.             ["Mquk#0020"] = true,
  544.             ["Vvarriorw#0020"] = true,
  545.             ["Ikke#0015"] = true,
  546.             ["Kurt#0015"] = true,
  547.             ["Grimmaro#0020"] = true,
  548.             ["Reshman#0020"] = true,
  549.             ["Silvyna#0020"] = true,
  550.             ["Tat#0020"] = true
  551.         },
  552.         ["sentinel"] = {
  553.             ["A_801#0015"] = true,
  554.             ["Altercorp#0015"] = true,
  555.             ["Bog#0015"] = true,
  556.             ["Doraemons#0010"] = true,
  557.             ["Etyla#0015"] = true,
  558.             ["Obemice#0015"] = true,
  559.             ["Sentihu#0015"] = true,
  560.             ["Vividia#0015"] = true,
  561.             ["Winjid#0015"] = true,
  562.             ["Hollya#0015"] = true,
  563.             ["Mlledebby#0015"] = true,
  564.             ["Sentinonyme#0015"] = true,
  565.             ["Thallium#0015"] = true,
  566.             ["Centr#0015"] = true,
  567.             ["Jerry#0015"] = true,
  568.             ["Bortverde#0015"] = true,
  569.             ["Daisy#0015"] = true,
  570.             ["Daydream#0015"] = true,
  571.             ["Excasr#0010"] = true,
  572.             ["Grastfetry#0015"] = true,
  573.             ["Ikke#0015"] = true,
  574.             ["Kiwrimai#0015"] = true,
  575.             ["Kurt#0015"] = true,
  576.             ["Miau#0010"] = true,
  577.             ["Naiyme#0015"] = true,
  578.             ["Pandoraa#0015"] = true,
  579.             ["Ratacp#0015"] = true,
  580.             ["Xiezi#0010"] = true,
  581.             ["Sha#0010"] = true,
  582.             ["Visne#0010"] = true,
  583.             ["Amegake#0015"] = true,
  584.             ["Coska#0015"] = true,
  585.             ["Lament#0010"] = true,
  586.             ["Mesmera#0015"] = true,
  587.             ["Milkycoffee#0015"] = true,
  588.             ["Peanut_butter#0015"] = true,
  589.             ["Wooferx#0015"] = true,
  590.             ["Jordy#0010"] = true,
  591.             ["Chibi#0015"] = true,
  592.             ["Hotaru#0015"] = true,
  593.             ["Tarmac#0010"] = true,
  594.             ["Xiaojiemei#0015"] = true,
  595.             ["Archaeron#0010"] = true,
  596.             ["Mrslouzifer#0010"] = true,
  597.             ["Batt_mellamy#0015"] = true,
  598.             ["Calysis#0015"] = true,
  599.             ["Chiara#0010"] = true,
  600.             ["Dracoleaf#0010"] = true,
  601.             ["Gavin#0015"] = true,
  602.             ["Jacob#0010"] = true,
  603.             ["Katburger#0015"] = true,
  604.             ["Null#0010"] = true,
  605.             ["Rutabega#0015"] = true,
  606.             ["Shamousey#0015"] = true,
  607.             ["Vulli#0015"] = true,
  608.             ["Pitchou#0015"] = true,
  609.             ["Matekooo#0015"] = true,
  610.             ["Bembija#0010"] = true,
  611.             ["Layora#0010"] = true
  612.         },
  613.         ["moderation"] = {
  614.             ["Adami#0010"] = true,
  615.             ["Charissa#0010"] = true,
  616.             ["Darthmod#0010"] = true,
  617.             ["Djealvi#0010"] = true,
  618.             ["Doraemons#0010"] = true,
  619.             ["Eclipseclock#0010"] = true,
  620.             ["Faz_x#0010"] = true,
  621.             ["Frankenshtein#0010"] = true,
  622.             ["Jackgt20#0010"] = true,
  623.             ["Link#0010"] = true,
  624.             ["Meekoru#0010"] = true,
  625.             ["Mouseori#0010"] = true,
  626.             ["Mushi#0010"] = true,
  627.             ["Nattorei#0010"] = true,
  628.             ["Poomph#0010"] = true,
  629.             ["Pyjin#0010"] = true,
  630.             ["Sav#0010"] = true,
  631.             ["Sommersby#0010"] = true,
  632.             ["Tachiyukan#0010"] = true,
  633.             ["Teo#0010"] = true,
  634.             ["Titivillus#0010"] = true,
  635.             ["Tomatosin#0010"] = true,
  636.             ["Yosska#0010"] = true,
  637.             ["Chamsouris#0010"] = true,
  638.             ["Fiarb#0010"] = true,
  639.             ["Iceweasel#0010"] = true,
  640.             ["Miwakiko#0010"] = true,
  641.             ["Myulaw#0010"] = true,
  642.             ["Nuhy#0010"] = true,
  643.             ["Philae#0010"] = true,
  644.             ["Ihaya#0010"] = true,
  645.             ["Mishska#0010"] = true,
  646.             ["Balerion#0010"] = true,
  647.             ["Bijububu#0010"] = true,
  648.             ["Cosmo#0010"] = true,
  649.             ["Excasr#0010"] = true,
  650.             ["Iupi#0010"] = true,
  651.             ["Lucas#0010"] = true,
  652.             ["Lummit#0010"] = true,
  653.             ["Miau#0010"] = true,
  654.             ["Midnight#0010"] = true,
  655.             ["Morningstar#0010"] = true,
  656.             ["Pop#0010"] = true,
  657.             ["Jefitou#0010"] = true,
  658.             ["Lezzly#0010"] = true,
  659.             ["Lightwood#0010"] = true,
  660.             ["Makis#0010"] = true,
  661.             ["Piratearthur#0010"] = true,
  662.             ["Xiezi#0010"] = true,
  663.             ["Lexa#0010"] = true,
  664.             ["Sha#0010"] = true,
  665.             ["Visne#0010"] = true,
  666.             ["Mistle#0010"] = true,
  667.             ["Arcanacra#0010"] = true,
  668.             ["Lament#0010"] = true,
  669.             ["Meow#0010"] = true,
  670.             ["Migotka#0010"] = true,
  671.             ["Staszekowaty#0010"] = true,
  672.             ["Esoisdown#0010"] = true,
  673.             ["Flare#0010"] = true,
  674.             ["Jordy#0010"] = true,
  675.             ["Santa#0010"] = true,
  676.             ["Zoefke#0010"] = true,
  677.             ["Ceicu#0010"] = true,
  678.             ["Dandelion#0010"] = true,
  679.             ["Ildubbio#0010"] = true,
  680.             ["Tarmac#0010"] = true,
  681.             ["Archaeron#0010"] = true,
  682.             ["Mrslouzifer#0010"] = true,
  683.             ["Acer#0010"] = true,
  684.             ["Charlen#0010"] = true,
  685.             ["Chiara#0010"] = true,
  686.             ["Christine#0010"] = true,
  687.             ["Dracoleaf#0010"] = true,
  688.             ["Etoile#0010"] = true,
  689.             ["Exsilium#0010"] = true,
  690.             ["Faierey#0010"] = true,
  691.             ["Jacob#0010"] = true,
  692.             ["Jiro#0010"] = true,
  693.             ["Kim#0010"] = true,
  694.             ["Kloure#0010"] = true,
  695.             ["Mousey#0010"] = true,
  696.             ["Null#0010"] = true,
  697.             ["Plisette#0010"] = true,
  698.             ["Rachel#0010"] = true,
  699.             ["Sam#0010"] = true,
  700.             ["Secretive#0010"] = true,
  701.             ["Bembija#0010"] = true,
  702.             ["Layora#0010"] = true
  703.         },
  704.         ["admin"] = {
  705.             ["Azrou#0001"] = true,
  706.             ["Gimnir#0001"] = true,
  707.             ["Pxstardust#0001"] = true,
  708.             ["Stardev7#0001"] = true,
  709.             ["Streaxx#0001"] = true,
  710.             ["Melibellule#0001"] = true,
  711.             ["Pikashu#0001"] = true,
  712.             ["Tigrounette#0001"] = true
  713.         }
  714.     }
  715.     local online_players = {}
  716.     local player_requests = {}
  717.     local commands = {
  718.         ["get_team"] = function(args)
  719.             local result = {success = true, message = nil, members = {}}
  720.            
  721.             for member, isIn in next, staff_teams[args[3]] do
  722.                 if isIn then
  723.                     result.members[member] = online_players[member]
  724.                 end
  725.             end
  726.            
  727.             chatMessage(args[1], json.encode(result))
  728.         end,
  729.        
  730.         ["online"] = function(args)
  731.             local result = {success = true, message = nil, online = {}}
  732.            
  733.             local onlineIndex = 0
  734.             for member, isIn in next, staff_teams[args[3]] do
  735.                 if isIn then
  736.                     if online_players[member] then
  737.                         onlineIndex = onlineIndex + 1
  738.                         result.online[onlineIndex] = member
  739.                     end
  740.                 end
  741.             end
  742.            
  743.             chatMessage(args[1], json.encode(result))
  744.         end,
  745.        
  746.         ["get_user"] = function(args)
  747.             if not player_requests[args[3]] then
  748.                 player_requests[args[3]] = {{args[1]}, 0}
  749.             else
  750.                 player_requests[args[3]][1][#player_requests[args[3]][1]] = args[1]
  751.             end
  752.         end,
  753.        
  754.         ["team_add"] = function(args)
  755.             for index = 4, #args do
  756.                 staff_teams[args[3]][args[index]] = true
  757.             end
  758.            
  759.             chatMessage(args[1], '{"success":true,"message":null}')
  760.         end,
  761.        
  762.         ["team_remove"] = function(args)
  763.             for index = 4, #args do
  764.                 staff_teams[args[3]][args[index]] = nil
  765.             end
  766.            
  767.             chatMessage(args[1], '{"success":true,"message":null}')
  768.         end
  769.     }
  770.    
  771.     function eventPlayerDataLoaded(player)
  772.         online_players[player] = true
  773.     end
  774.    
  775.     function eventLoop()
  776.         local rem = {}
  777.        
  778.         for player, request in next, player_requests do
  779.             request[2] = request[2] + 1
  780.            
  781.             if request[2] == 2 then
  782.                 local result = {success = true, message = nil, roles = {}, isOnline = online_players[player] or false}
  783.            
  784.                 local rolesIndex = 0
  785.                 for teamName, teamData in next, staff_teams do
  786.                     if teamData[player] then
  787.                         rolesIndex = rolesIndex + 1
  788.                         result.roles[rolesIndex] = teamName
  789.                     end
  790.                 end
  791.                
  792.                 result = json.encode(result)
  793.                
  794.                 for index, msgId in next, request[1] do
  795.                     chatMessage(msgId, result)
  796.                 end
  797.                
  798.                 rem[player] = true
  799.             elseif request[2] == 1 then
  800.                 system.loadPlayerData(player)
  801.             end
  802.         end
  803.        
  804.         for player in next, rem do
  805.             player_requests[player] = nil
  806.         end
  807.        
  808.         eventLoopCount = eventLoopCount + 1
  809.        
  810.         if eventLoopCount == 20 then
  811.             eventLoopCount = 0
  812.             local onlinePlayersTable = {}
  813.            
  814.             for teamName, team in next, staff_teams do
  815.                 for member, isIn in next, team do
  816.                     if isIn then
  817.                         onlinePlayersTable[member] = false
  818.                     end
  819.                 end
  820.             end
  821.            
  822.             online_players = onlinePlayersTable
  823.             for member in next, online_players do
  824.                 system.loadPlayerData(member)
  825.             end
  826.         end
  827.     end
  828.    
  829.     function eventChatMessage(player, msg)
  830.         if player == "Tocutoeltuco#5730" then
  831.             local spl = string.split(msg, "%S+")
  832.            
  833.             commands[spl[2]](spl)
  834.         end
  835.     end
  836. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement