return function(C)local F=C.Server local l=C.Service local B,h,K,y,R,c,o,G,U,P local function e()B=F.Functions h=F.Admin K=F.Anti y=F.Core R=F.HTTP c=F.Logs o=F.Remote G=F.Process U=F.Variables P=F.Settings c:AddLog("\083\099\114\105\112\116","\072\084\084\080 \077\111\100\117\108\101 \073\110\105\116\105\097\108\105\122\101\100")end F.HTTP={Init=e,Service=l.HttpService;CheckHttp=function()local C,F=pcall(function()local C=l.HttpService local F=C:GetAsync("\104\116\116\112\058\047\047\103\111\111\103\108\101\046\099\111\109")end)if C and not F then return true end end;WebPanel={Moderators={},Admins={};Owners={};Creators={},Mutes={};Bans={};Blacklist={};Whitelist={}},Trello={Helpers={},Moderators={};Admins={},Owners={},Creators={},Mutes={},Bans={},Music={};InsertList={},Agents={},Blacklist={};Whitelist={};PerformedCommands={},Update=function()if not R.CheckHttp()then warn("\072\116\116\112 \105\115 \110\111\116 \101\110\097\098\108\101\100\033 \067\097\110\110\111\116 \099\111\110\110\101\099\116 \116\111 \084\114\101\108\108\111\033")elseif not P.Trello_Enabled then else local C={}local F={}local B={}local K={}local y={}local G={}local e={}local Y={}local b={}local u={}local m={}local O={}local E={}local g={}local function d(C)local o=R.Trello.API(P.Trello_AppKey,P.Trello_Token)local G=o.getLists(C)local U=o.getListObj(G,{"\066\097\110\108\105\115\116";"\066\097\110 \076\105\115\116","\066\097\110\115"})local O=o.getListObj(G,{"\067\111\109\109\097\110\100\115";"\067\111\109\109\097\110\100 \076\105\115\116"})local d=o.getListObj(G,{"\065\100\109\105\110\115","\065\100\109\105\110 \076\105\115\116";"\065\100\109\105\110\108\105\115\116"})local D=o.getListObj(G,{"\077\111\100\101\114\097\116\111\114\115";"\077\111\100\101\114\097\116\111\114 \076\105\115\116";"\077\111\100\101\114\097\116\111\114\108\105\115\116";"\077\111\100\108\105\115\116","\077\111\100 \076\105\115\116","\077\111\100\115"})local X=o.getListObj(G,{"\067\114\101\097\116\111\114\115";"\067\114\101\097\116\111\114 \076\105\115\116","\067\114\101\097\116\111\114\108\105\115\116";"\080\108\097\099\101 \079\119\110\101\114\115"})local L=o.getListObj(G,{"\079\119\110\101\114\115","\079\119\110\101\114 \076\105\115\116","\079\119\110\101\114\108\105\115\116"})local w=o.getListObj(G,{"\077\117\115\105\099","\077\117\115\105\099 \076\105\115\116","\077\117\115\105\099\108\105\115\116";"\083\111\110\103\115"})local q=o.getListObj(G,{"\073\110\115\101\114\116\076\105\115\116","\073\110\115\101\114\116 \076\105\115\116","\073\110\115\101\114\116\108\105\115\116";"\073\110\115\101\114\116\115","\077\111\100\101\108\076\105\115\116","\077\111\100\101\108 \076\105\115\116";"\077\111\100\101\108\108\105\115\116";"\077\111\100\101\108\115"})local V=o.getListObj(G,{"\080\101\114\109\105\115\115\105\111\110\115";"\080\101\114\109\105\115\115\105\111\110 \076\105\115\116";"\080\101\114\109\108\105\115\116"})local T=o.getListObj(G,{"\077\117\116\101\108\105\115\116";"\077\117\116\101 \076\105\115\116"})local N=o.getListObj(G,{"\065\103\101\110\116\115","\065\103\101\110\116 \076\105\115\116";"\065\103\101\110\116\108\105\115\116"})local n=o.getListObj(G,"\066\108\097\099\107\108\105\115\116")local v=o.getListObj(G,"\087\104\105\116\101\108\105\115\116")if U then local C=o.getCards(U.id)for C,l in pairs(C)do table.insert(F,l.name)end end if X then local C=o.getCards(X.id)for C,F in pairs(C)do table.insert(e,F.name)end end if D then local C=o.getCards(D.id)for C,F in pairs(C)do table.insert(K,F.name)end end if d then local C=o.getCards(d.id)for C,F in pairs(C)do table.insert(B,F.name)end end if L then local C=o.getCards(L.id)for C,F in pairs(C)do table.insert(y,F.name)end end if N then local C=o.getCards(N.id)for C,F in pairs(C)do table.insert(Y,F.name)end end if w then local C=o.getCards(w.id)for C,F in pairs(C)do if F.name:match("\094\040\046\042\041\058\040\046\042\041")then local C,l=F.name:match("\094\040\046\042\041\058\040\046\042\041")table.insert(b,{Name=C,ID=tonumber(l)})end end end if q then local C=o.getCards(q.id)for C,F in pairs(C)do if F.name:match("\094\040\046\042\041\058\040\046\042\041")then local C,l=F.name:match("\094\040\046\042\041\058\040\046\042\041")table.insert(u,{Name=C,ID=tonumber(l)})end end end if T then local C=o.getCards(T.id)for C,F in pairs(C)do table.insert(m,F.name)end end if n then local C=o.getCards(n.id)for C,F in pairs(C)do table.insert(E,F.name)end end if v then local C=o.getCards(v.id)for C,F in pairs(C)do table.insert(g,F.name)end end if V then local C=o.getCards(V.id)for C,F in pairs(C)do local l,B=F.name:match("\094\040\046\042\041\058\040\046\042\041")if l and B then h.SetPermission(l,B)end end end if O then local C=o.getCards(O.id)for C,F in pairs(C)do if not R.Trello.PerformedCommands[tostring(F.id)]then local C=F.name local B if C:sub(1,1)=="\036"then B=(C:sub(2)):match("\046\037\100\043")C=C:sub(#B+2)B=tonumber(B)end if B and game.PlaceId~=B then return end h.RunCommand(C)R.Trello.PerformedCommands[tostring(F.id)]=true c.AddLog(c.Script,{Text="\084\114\101\108\108\111 \099\111\109\109\097\110\100 \101\120\101\099\117\116\101\100";Desc=C})if P.Trello_Token~=""then pcall(o.makeComment,F.id,"\082\097\110 \067\111\109\109\097\110\100\058 "..(C..("\n\080\108\097\099\101 \073\068\058 "..(game.PlaceId..("\n\083\101\114\118\101\114 \074\111\098 \073\100\058 "..(game.JobId..("\n\083\101\114\118\101\114 \080\108\097\121\101\114\115\058 "..(#l.GetPlayers()..("\n\083\101\114\118\101\114 \084\105\109\101\058 "..l.GetTime())))))))))end end end end end for F,l in pairs(P.Trello_Secondary)do table.insert(C,l)end if P.Trello_Primary~=""then table.insert(C,P.Trello_Primary)end for C,F in pairs(C)do pcall(d,F)end if#F>0 then R.Trello.Bans=F end if#e>0 then R.Trello.Creators=e end if#B>0 then R.Trello.Admins=B end if#K>0 then R.Trello.Moderators=K end if#y>0 then R.Trello.Owners=y end if#b>0 then R.Trello.Music=b end if#u>0 then R.Trello.InsertList=u end if#m>0 then R.Trello.Mutes=m end if#Y>0 then R.Trello.Agents=Y end if#E>0 then R.Trello.Blacklist=E end if#g>0 then R.Trello.Whitelist=g end for C,F in pairs(l.GetPlayers())do if h.CheckBan(F)then F:Kick(U.BanMessage)end if F and F.Parent then for C,l in pairs(R.Trello.Mutes)do if h.DoCheck(F,l)then o.LoadCode(F,"\115\101\114\118\105\099\101\046\083\116\097\114\116\101\114\071\117\105\058\083\101\116\067\111\114\101\071\117\105\069\110\097\098\108\101\100\040\"\067\104\097\116\"\044\102\097\108\115\101\041 \099\108\105\101\110\116\046\086\097\114\105\097\098\108\101\115\046\067\104\097\116\069\110\097\098\108\101\100 \061 \102\097\108\115\101 \099\108\105\101\110\116\046\086\097\114\105\097\098\108\101\115\046\077\117\116\101\100 \061 \116\114\117\101")end end end h.UpdateCachedLevel(F)end c.AddLog(c.Script,{Text="\085\112\100\097\116\101\100 \084\114\101\108\108\111 \068\097\116\097";Desc="\068\097\116\097 \119\097\115 \114\101\116\114\101\105\118\101\100 \102\114\111\109 \084\114\101\108\108\111"})end end,CheckAgent=function(C)for F,l in pairs(R.Trello.Agents)do if h.DoCheck(C,l)then return true end end end}}end

return function(Vargs)
	local server = Vargs.Server;
	local service = Vargs.Service;

	local Functions, Admin, Anti, Core, HTTP, Logs, Remote, Process, Variables, Settings
	local function Init()
		Functions = server.Functions;
		Admin = server.Admin;
		Anti = server.Anti;
		Core = server.Core;
		HTTP = server.HTTP;
		Logs = server.Logs;
		Remote = server.Remote;
		Process = server.Process;
		Variables = server.Variables;
		Settings = server.Settings;

		Logs:AddLog("Script", "HTTP Module Initialized")
	end;

	server.HTTP = {
		Init = Init;
		Service = service.HttpService;
		CheckHttp = function()
			local y,n = pcall(function()
				local hs = service.HttpService
				local get = hs:GetAsync('http://google.com')
			end)
			if y and not n then return true end
		end;

		WebPanel = {
			Moderators = {};
			Admins = {};
			Owners = {};
			Creators = {};
			Mutes = {};
			Bans = {};
			Blacklist = {};
			Whitelist = {};
		};

		Trello = {
			Helpers = {};
			Moderators = {};
			Admins = {};
			Owners = {};
			Creators = {};
			Mutes = {};
			Bans = {};
			Music = {};
			InsertList = {};
			Agents = {};
			Blacklist = {};
			Whitelist = {};
			PerformedCommands = {};

			Update = function()
				if not HTTP.CheckHttp() then 
					--HTPP.Trello.Bans = {'Http is not enabled! Cannot connect to Trello!'}
					warn('Http is not enabled! Cannot connect to Trello!')
				elseif not Settings.Trello_Enabled then
					-- Do something else?
				else
					local boards = {}
					local bans = {}
					local admins = {}
					local mods = {}
					local owners = {}
					local helpers = {}
					local creators = {}
					local agents = {}
					local music = {}
					local insertlist = {}
					local mutes = {}
					local perms = {}
					local blacklist = {}
					local whitelist = {}

					local function grabData(board)
						local trello = HTTP.Trello.API(Settings.Trello_AppKey,Settings.Trello_Token)
						local lists = trello.getLists(board)
						local banList = trello.getListObj(lists,{"Banlist","Ban List","Bans"})
						local commandList = trello.getListObj(lists,{"Commands","Command List"})
						local adminList = trello.getListObj(lists,{"Admins","Admin List","Adminlist"})
						local modList = trello.getListObj(lists,{"Moderators","Moderator List","Moderatorlist","Modlist","Mod List","Mods"})
						local creatorList = trello.getListObj(lists,{"Creators","Creator List","Creatorlist","Place Owners"})
						local ownerList = trello.getListObj(lists,{"Owners","Owner List","Ownerlist"})
						local musicList = trello.getListObj(lists,{"Music","Music List","Musiclist","Songs"}) 
						local insertList = trello.getListObj(lists,{"InsertList","Insert List","Insertlist","Inserts","ModelList","Model List","Modellist","Models"}) 
						local permList = trello.getListObj(lists,{"Permissions","Permission List","Permlist"})
						local muteList = trello.getListObj(lists,{"Mutelist","Mute List"})
						local agentList = trello.getListObj(lists,{"Agents","Agent List","Agentlist"})
						local bList = trello.getListObj(lists,"Blacklist")
						local wList = trello.getListObj(lists,"Whitelist")

						if banList then
							local cards = trello.getCards(banList.id)
							for l,k in pairs(cards) do
								table.insert(bans,k.name)
							end
						end

						if creatorList then
							local cards = trello.getCards(creatorList.id)
							for l,k in pairs(cards) do
								table.insert(creators,k.name)
							end
						end

						if modList then
							local cards = trello.getCards(modList.id)
							for l,k in pairs(cards) do
								table.insert(mods,k.name)
							end
						end

						if adminList then
							local cards = trello.getCards(adminList.id)
							for l,k in pairs(cards) do
								table.insert(admins,k.name)
							end
						end

						if ownerList then
							local cards = trello.getCards(ownerList.id)
							for l,k in pairs(cards) do
								table.insert(owners,k.name)
							end
						end

						if agentList then
							local cards = trello.getCards(agentList.id)
							for l,k in pairs(cards) do
								table.insert(agents,k.name)
							end
						end

						if musicList then
							local cards = trello.getCards(musicList.id)
							for l,k in pairs(cards) do
								if k.name:match('^(.*):(.*)') then
									local a,b=k.name:match('^(.*):(.*)')
									table.insert(music,{Name = a,ID = tonumber(b)})
								end
							end
						end

						if insertList then
							local cards = trello.getCards(insertList.id)
							for l,k in pairs(cards) do
								if k.name:match('^(.*):(.*)') then
									local a,b=k.name:match('^(.*):(.*)')
									table.insert(insertlist,{Name = a,ID = tonumber(b)})
								end
							end
						end

						if muteList then		
							local cards = trello.getCards(muteList.id)
							for l,k in pairs(cards) do
								table.insert(mutes,k.name)
							end
						end

						if bList then		
							local cards = trello.getCards(bList.id)
							for l,k in pairs(cards) do
								table.insert(blacklist,k.name)
							end
						end

						if wList then		
							local cards = trello.getCards(wList.id)
							for l,k in pairs(cards) do
								table.insert(whitelist,k.name)
							end
						end

						if permList then
							local cards = trello.getCards(permList.id)
							for l,k in pairs(cards) do
								local com,level = k.name:match("^(.*):(.*)") 
								if com and level then 
									Admin.SetPermission(com,level) 
								end
							end
						end

						if commandList then
							local cards = trello.getCards(commandList.id)
							for l,k in pairs(cards) do
								if not HTTP.Trello.PerformedCommands[tostring(k.id)] then
									local cmd = k.name
									local placeid
									if cmd:sub(1,1)=="$" then
										placeid = cmd:sub(2):match(".%d+")
										cmd = cmd:sub(#placeid+2)
										placeid = tonumber(placeid)
									end
									if placeid and game.PlaceId~=placeid then return end
									Admin.RunCommand(cmd)
									HTTP.Trello.PerformedCommands[tostring(k.id)] = true 
									Logs.AddLog(Logs.Script,{
										Text = "Trello command executed";
										Desc = cmd;
									})
									if Settings.Trello_Token ~= "" then
										pcall(trello.makeComment,k.id,"Ran Command: "..cmd.."\nPlace ID: "..game.PlaceId.."\nServer Job Id: "..game.JobId.."\nServer Players: "..#service.GetPlayers().."\nServer Time: "..service.GetTime())
									end
								end
							end
						end
					end

					for i,v in pairs(Settings.Trello_Secondary) do table.insert(boards,v) end
					if Settings.Trello_Primary~="" then table.insert(boards,Settings.Trello_Primary) end
					for i,v in pairs(boards) do pcall(grabData,v) end

					if #bans>0 then HTTP.Trello.Bans = bans end
					if #creators>0 then HTTP.Trello.Creators = creators end
					if #admins>0 then HTTP.Trello.Admins = admins end
					if #mods>0 then HTTP.Trello.Moderators = mods end
					if #owners>0 then HTTP.Trello.Owners = owners end
					if #music>0 then HTTP.Trello.Music = music end
					if #insertlist>0 then HTTP.Trello.InsertList = insertlist end
					if #mutes>0 then HTTP.Trello.Mutes = mutes end
					if #agents>0 then HTTP.Trello.Agents = agents end
					if #blacklist>0 then HTTP.Trello.Blacklist = blacklist end
					if #whitelist>0 then HTTP.Trello.Whitelist = whitelist end

					for i,v in pairs(service.GetPlayers()) do
						if Admin.CheckBan(v) then
							v:Kick(Variables.BanMessage)
						end 

						if v and v.Parent then
							for ind,admin in pairs(HTTP.Trello.Mutes) do
								if Admin.DoCheck(v,admin) then
									Remote.LoadCode(v,[[service.StarterGui:SetCoreGuiEnabled("Chat",false) client.Variables.ChatEnabled = false client.Variables.Muted = true]])
								end
							end
						end

						Admin.UpdateCachedLevel(v)
					end

					Logs.AddLog(Logs.Script,{
						Text = "Updated Trello Data";
						Desc = "Data was retreived from Trello";
					}) 
				end
			end;

			CheckAgent = function(p)
				for ind,v in pairs(HTTP.Trello.Agents) do
					if Admin.DoCheck(p,v) then
						return true
					end
				end
			end;
		};
	};
end
