Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bc=select(1,...)or""
- local cc={["main.lua"]="local db;db=dofile(\"fix.lua\").require;local _c\
- _c=db(\"http\").AsyncHTTPQueue;local ac;ac=table.sort;local bc,cc=term.getSize()local dc=db(\"json\")local _d=_c()\
- local ad\
- local bd=Application(1,1,bc,cc):set({terminatable=true,colour=colours.white,backgroundColour=colours.grey})bd:importFromTML(\"markup/master.tml\")\
- local cd={servers={},server=\"\",channel=\"\",lastMessages={},channels={},channelsOpen=false}\
- local dd={masterTheme=Theme.fromFile(\"masterTheme\",\"styles/master.theme\"),pages=bd:query(\"PageContainer\").result[1],serverSelector=bd:query(\"Dropdown#serverSelector\").result[1],serverUsername=bd:query(\"Input#usernameInput\").result[1],channelsContainer=bd:query(\"ScrollContainer#channels\").result[1],messageContainer=bd:query(\"ScrollContainer#messages\").result[1]}bd:addTheme(dd.masterTheme)\
- _d:get(\"servers\",function(b_a)b_a=dc.parse(b_a)\
- cd.servers=b_a;for c_a,d_a in pairs(cd.servers)do\
- dd.serverSelector:addOption(d_a,d_a)end end)local __a\
- __a=function()\
- return\
- _d:get(\"receive/\"..cd.server..\"/\"..cd.channel,function(b_a)\
- local c_a=dc.parse(b_a)\
- ac(c_a,function(_aa,aaa)return _aa.timestamp<aaa.timestamp end)cd.lastMessages=c_a\
- dd.messageContainer:clearNodes()local d_a=0\
- for _aa,aaa in pairs(cd.lastMessages)do\
- local baa=Label(aaa.author..\":\",1,_aa+d_a):set({colour=colors.cyan})\
- local caa=TextContainer(aaa.content,1,_aa+d_a+1,50,3):set({backgroundColour=colors.black})dd.messageContainer:addNode(baa)\
- dd.messageContainer:addNode(caa)d_a=d_a+3 end end)end;local a_a\
- a_a=function()\
- return\
- _d:get(\"server/\"..cd.server..\"/channels\",function(b_a)\
- b_a=dc.parse(b_a)cd.channels=b_a;dd.channelsContainer:clearNodes()\
- for c_a,d_a in\
- pairs(cd.channels)do\
- local _aa=Button(\"#\"..d_a):set({height=3,width=10,horizontalAlign=\"centre\",verticalAlign=\"centre\",X=1,Y=1 + ( (c_a-1)*3)})\
- _aa:on(\"trigger\",function(aaa)cd.channel=d_a;return __a()end)dd.channelsContainer:addNode(_aa)end end)end\
- bd:query(\"#serverNextButton\"):on(\"trigger\",function(b_a)\
- local c_a=dd.serverSelector:getSelectedValue()local d_a=dd.serverUsername.value\
- if c_a and#d_a>0 then cd.server=c_a\
- cd.username=d_a;a_a()return dd.pages:selectPage(\"chat\")end end)\
- bd:query(\"#chatBackButton\"):on(\"trigger\",function(b_a)cd.server=\"\"cd.channel=\"\"return\
- dd.pages:selectPage(\"serverSelect\")end)\
- bd:query(\"#toggleChannels\"):on(\"trigger\",function(b_a)\
- cd.channelsOpen=not cd.channelsOpen;b_a.text=cd.channelsOpen and\"<\"or\">\"\
- return\
- bd:query(\"#channelsContainer\").result[1]:animate(\"animateChannelContainer\",\"X\",\
- cd.channelsOpen and 1 or-8,0.3,cd.channelsOpen and\"inCubic\"or\"outCubic\",function()\
- end)end)\
- bd:query(\"#chatInput\"):on(\"trigger\",function(b_a,c_a,d_a)local _aa=c_a;b_a.value=\"\"\
- local aaa=dc.stringify({user=cd.username,content=_aa})return\
- _d:post(\"send/\"..cd.server..\"/\"..cd.channel,aaa,function()end)end)dd.pages:selectPage(\"serverSelect\")\
- ad=os.startTimer(1)\
- bd:addThread(Thread(function()\
- while true do local b_a={coroutine.yield()}\
- if b_a[1]==\"timer\"and\
- b_a[2]==ad then\
- if dd.server~=\"\"and dd.channel~=\"\"then __a()end;ad=os.startTimer(2)end end end))bd:addThread(_d:startRequestsThread())\
- bd:addThread(_d:handleResponsesThread())return bd:start()",["nodes/node.ti"]="",["fix.lua"]="local b\
- b=function(c)\
- if fs.exists(c)then return dofile(c)else return dofile(c..\".lua\")end end;return{require=b}",["json.lua"]="local ba={}\
- local function ca(cb)if type(cb)~='table'then return type(cb)end;local db=1\
- for _c in pairs(cb)do if\
- cb[db]~=nil then db=db+1 else return'table'end end;if db==1 then return'table'else return'array'end end\
- local function da(cb)local db={'\\\\','\"','/','\\b','\\f','\\n','\\r','\\t'}\
- local _c={'\\\\','\"','/','b','f','n','r','t'}\
- for ac,bc in ipairs(db)do cb=cb:gsub(bc,'\\\\'.._c[ac])end;return cb end\
- local function _b(cb,db,_c,ac)db=db+#cb:match('^%s*',db)\
- if\
- cb:sub(db,db)~=_c then if ac then\
- error('Expected '.._c..' near position '..db)end;return db,false end;return db+1,true end\
- local function ab(cb,db,_c)_c=_c or''local ac='End of input found while parsing string.'if db>#cb then\
- error(ac)end;local bc=cb:sub(db,db)if bc=='\"'then return _c,db+1 end;if\
- bc~='\\\\'then return ab(cb,db+1,_c..bc)end\
- local cc={b='\\b',f='\\f',n='\\n',r='\\r',t='\\t'}local dc=cb:sub(db+1,db+1)if not dc then error(ac)end;return ab(cb,db+2,_c..\
- (cc[dc]or dc))end\
- local function bb(cb,db)local _c=cb:match('^-?%d+%.?%d*[eE]?[+-]?%d*',db)\
- local ac=tonumber(_c)if not ac then\
- error('Error parsing number at position '..db..'.')end;return ac,db+#_c end\
- function ba.stringify(cb,db)local _c={}local ac=ca(cb)\
- if ac=='array'then if db then\
- error('Can\\'t encode array as key.')end;_c[#_c+1]='['\
- for bc,cc in ipairs(cb)do if bc>1 then\
- _c[#_c+1]=', 'end;_c[#_c+1]=ba.stringify(cc)end;_c[#_c+1]=']'elseif ac=='table'then if db then\
- error('Can\\'t encode table as key.')end;_c[#_c+1]='{'\
- for bc,cc in pairs(cb)do if#_c>1 then\
- _c[#_c+1]=', 'end;_c[#_c+1]=ba.stringify(bc,true)\
- _c[#_c+1]=':'_c[#_c+1]=ba.stringify(cc)end;_c[#_c+1]='}'elseif ac=='string'then return'\"'..da(cb)..'\"'elseif ac=='number'then if db then return\
- '\"'..tostring(cb)..'\"'end;return\
- tostring(cb)elseif ac=='boolean'then return tostring(cb)elseif ac=='nil'then return'null'else error('Unjsonifiable type: '..\
- ac..'.')end;return table.concat(_c)end;ba.null={}\
- function ba.parse(cb,db,_c)db=db or 1;if db>#cb then\
- error('Reached unexpected end of input.')end\
- local ac=db+#cb:match('^%s*',db)local bc=cb:sub(ac,ac)\
- if bc=='{'then local cc,dc,_d={},true,true;ac=ac+1\
- while true do\
- dc,ac=ba.parse(cb,ac,'}')if dc==nil then return cc,ac end;if not _d then\
- error('Comma missing between object items.')end;ac=_b(cb,ac,':',true)\
- cc[dc],ac=ba.parse(cb,ac)ac,_d=_b(cb,ac,',')end elseif bc=='['then local cc,dc,_d={},true,true;ac=ac+1\
- while true do dc,ac=ba.parse(cb,ac,']')if dc==nil then\
- return cc,ac end;if not _d then\
- error('Comma missing between array items.')end;cc[#cc+1]=dc;ac,_d=_b(cb,ac,',')end elseif bc=='\"'then return ab(cb,ac+1)elseif bc=='-'or bc:match('%d')then return bb(cb,ac)elseif bc==\
- _c then return nil,ac+1 else\
- local cc={['true']=true,['false']=false,['null']=ba.null}for _d,ad in pairs(cc)do local bd=ac+#_d-1\
- if cb:sub(ac,bd)==_d then return ad,bd+1 end end;local dc='position '..ac..\
- ': '..cb:sub(ac,ac+10)error(\
- 'Invalid json syntax starting at '..dc)end end;return ba",["styles/master.theme"]="<Input>\
- <backgroundColour>lightGray</backgroundColour>\
- </Input>\
- \
- <Button id=serverNextButton>\
- <horizontalAlign>centre</horizontalAlign>\
- <backgroundColour>cyan</backgroundColour>\
- <activeColour>black</activeColour>\
- <activeBackgroundColour>white</activeBackgroundColour>\
- </Button>\
- \
- <Input id=chatInput>\
- <backgroundColour>white</backgroundColour>\
- <colour>lightGrey</colour>\
- <focusedColour>black</focusedColour>\
- </Input>\
- \
- <ScrollContainer id=messages>\
- <backgroundColour>gray</backgroundColour>\
- <scrollbarColour>lightBlue</scrollbarColour>\
- <activeScrollbarColour>blue</activeScrollbarColour>\
- <trayColour>lightGray</trayColour>\
- </ScrollContainer>\
- \
- <Container id=channelsContainer>\
- <backgroundColour>black</backgroundColour>\
- </Container>\
- \
- <ScrollContainer id=channels>\
- <backgroundColour>black</backgroundColour>\
- </ScrollContainer>\
- \
- <Button id=chatBackButton>\
- <horizontalAlign>centre</horizontalAlign>\
- <backgroundColour>black</backgroundColour>\
- <colour>lightGray</colour>\
- </Button>\
- \
- <TextContainer class=\"message\">\
- <backgroundColour>green</backgroundColour>\
- </TextContainer>\
- ",["markup/master.tml"]="<PageContainer X=1 Y=1 width=51 height=19>\
- \
- <Page id=serverSelect xScrollAllowed=false>\
- <Label X=22 Y=3 text=\"DisCCord\" />\
- <Label X=7 Y=6 text=\"Server:\" />\
- <Label X=27 Y=6 text=\"Username:\" />\
- <Input X=27 Y=7 limit=20 width=18 id=usernameInput />\
- <Button X=17 Y=11 width=18 id=serverNextButton text=\"Next\" />\
- <Dropdown X=7 Y=7 width=18 maxHeight=4 id=serverSelector />\
- </Page>\
- \
- <Page id=chat>\
- <Button X=45 Y=19 text=\"back\" width=7 id=chatBackButton />\
- \
- <ScrollContainer X=2 Y=1 height=18 width=50 id=messages xScrollAllowed=false/>\
- \
- <Input X=2 Y=19 width=43 limit=100 id=chatInput placeholder=\"Insert text here...\"/>\
- \
- <Container X=\"-8\" Y=1 height=19 width=10 id=channelsContainer>\
- <ScrollContainer X=1 Y=2 width=10 height=18 id=channels/>\
- <Label X=1 Y=1 text=\"Channels \" backgroundColour=black/>\
- <Button X=10 Y=1 width=1 text=\">\" id=toggleChannels/>\
- </Container>\
- </Page>\
- \
- </PageContainer>\
- ",["http.lua"]="local aa,ba,ca,da,_b;aa=table.insert\
- ba={[\"Content-Type\"]=\"application/json; charset=UTF-8\",[\"Content-Encoding\"]=\"identity\"}ca=\"http://misoshiki-bot-misoshiki.44fs.preview.openshiftapps.com/\"\
- do local ab\
- local bb={}bb.__index=bb\
- ab=setmetatable({__init=function(cb,db,_c,ac,bc)cb.url=ca..db;cb.callback=bc;cb.headers=ac;cb.data=_c\
- cb.running=false;cb.processed=false end,__base=bb,__name=\"AsyncHTTPRequest\"},{__index=bb,__call=function(cb,...)\
- local db=setmetatable({},bb)cb.__init(db,...)return db end})bb.__class=ab;da=ab end\
- do local ab\
- local bb={get=function(cb,db,_c)return aa(cb.requests,da(db,nil,nil,_c))end,post=function(cb,db,_c,ac)return\
- aa(cb.requests,da(db,_c,ba,ac))end,startRequestsThread=function(cb)\
- return\
- Thread(function()while true do sleep(0)\
- for db,_c in\
- pairs(cb.requests)do if not _c.running then _c.running=true\
- http.request(_c.url,_c.data,_c.headers)end end end end)end,handleResponsesThread=function(cb)\
- return\
- Thread(function()\
- while\
- true do local db={coroutine.yield(\"http_success\")}\
- local _c,ac=db[2],false\
- for bc,cc in pairs(cb.requests)do\
- if not ac then\
- if cc.url==_c and not cc.processed then ac=true\
- local dc=db[3]local _d=dc.readAll()dc:close()\
- pcall(function()return cc.callback(_d)end)cc.processed=true end end end end end)end}bb.__index=bb\
- ab=setmetatable({__init=function(cb)cb.requests={}end,__base=bb,__name=\"AsyncHTTPQueue\"},{__index=bb,__call=function(cb,...)\
- local db=setmetatable({},bb)cb.__init(db,...)return db end})bb.__class=ab;_b=ab end;return{AsyncHTTPQueue=_b,AsyncHTTPRequest=da}"}local dc=
- type(getfenv)=="function"and getfenv()or _ENV or _G;if dc.TI_VFS_RAW then
- dc=dc.TI_VFS_RAW end;local _d=dc.fs
- local ad=setmetatable({fs=setmetatable({},{__index=_G["fs"]}),os=setmetatable({},{__index=_G["os"]})},{__index=dc})local bd=ad["fs"]
- local cd=setmetatable({},{__index=function(caa,daa)if daa=="TI_VFS_RAW"then return ad end
- return ad[daa]end})cd._G=cd;cd._ENV=cd
- local dd={["markup"]=true,["styles"]=true,["nodes"]=true}
- local __a={["^"]="%^",["$"]="%$",["("]="%(",[")"]="%)",["%"]="%%",["*"]="[^/]*",["."]="%.",["["]="%[",["]"]="%]",["+"]="%+",["-"]="%-"}
- function cd.load(caa,daa,_ba,aba)return load(caa,daa or'(load)',_ba,aba or cd)end
- function cd.loadstring(caa,daa)return cd.load(caa,daa,'t',cd)end
- function cd.loadfile(caa,daa)local _ba=cd;local aba=fs.open(caa,"r")if aba then local bba,cba=load(aba.readAll(),fs.getName(caa),'t',
- daa or cd)
- aba.close()return bba,cba end
- return nil,'File not found'end
- if type(setfenv)=="function"then setfenv(cd.loadfile,cd)end
- function cd.os.run(caa,daa,...)local _ba=cd;local aba,bba={...},caa
- setmetatable(bba,{__index=cd})local cba,dba=loadfile(daa,bba)
- if cba then local _ca,aca=pcall(function()
- cba(table.unpack(aba))end)
- if not _ca then if aca and
- aca~=""then printError(aca)end;return false end;return true end;if dba and dba~=""then printError(dba)end;return false end;local a_a={}
- function cd.os.loadAPI(caa)local daa,_ba=cd,fs.getName(caa)if a_a[_ba]==true then
- printError("API ".._ba..
- " is already being loaded")return false end;a_a[_ba]=true
- local aba=setmetatable({},{__index=cd})local bba,cba=loadfile(caa,aba)
- if bba then local _ca,aca=pcall(bba)if not _ca then
- printError(aca)a_a[_ba]=nil;return false end else printError(cba)a_a[_ba]=
- nil;return false end;local dba={}
- for _ca,aca in pairs(aba)do if _ca~="_ENV"then dba[_ca]=aca end end;cd[_ba],a_a[_ba]=dba,nil;return true end;cd.os.loadAPI"/rom/apis/io"
- function cd.dofile(caa)local daa=cd
- local _ba,aba=loadfile(caa,cd)if _ba then return _ba()else error(aba,2)end end
- if type(setfenv)=="function"then setfenv(cd.dofile,cd)end
- function bd.open(caa,daa)caa=fs.combine("",caa)
- if cc[caa]then
- if
- daa=="w"or daa=="wb"or daa=="a"or daa=="ab"then return
- error("Cannot open file in mode '"..tostring(daa)..
- "'. File is inside of Titanium VFS and is read only")end;local _ba,aba=cc[caa],{}if daa=="rb"then
- aba.read=function()if#_ba==0 then return end
- local bba=_ba:sub(1,1):byte()_ba=_ba:sub(2)return bba end end
- aba.readLine=function()if
- #_ba==0 then return end;local bba,cba=_ba:match"^([^\n\r]*)[\n\r](.*)$"
- _ba=cba or""return bba or _ba end
- aba.readAll=function()if#_ba==0 then return end;local bba=_ba;_ba=""return bba end;aba.close=function()_ba=""end;return aba else return
- _d.open(fs.combine(bc,caa),daa)end end
- function bd.isReadOnly(caa)caa=fs.combine("",caa)if cc[caa]then return true end;return
- _d.isReadOnly(fs.combine(bc,caa))end;function bd.getSize(caa)
- return cc[caa]and#cc[caa]or _d.getSize(caa)end
- function bd.list(caa)caa=fs.combine("",caa)local daa=
- _d.isDir(caa)and _d.list(caa)or{}
- local function _ba(aba)for i=1,#daa do if
- daa[i]==aba then return end end;daa[#daa+1]=aba end
- if dd[caa]then
- for aba in pairs(cc)do if aba:match(("^%s/"):format(caa))then
- _ba(aba:match(("^%s/([^/]+)"):format(caa)))end end elseif caa==""then
- for aba in pairs(cc)do _ba(aba:match"^([^/]+)")end end;return daa end
- function bd.find(caa)caa=fs.combine("",caa)local daa=_d.find(caa)or{}
- caa=("^(%s)(.*)$"):format(caa:gsub(".",__a))
- for _ba in pairs(cc)do local aba,bba=_ba:match(caa)
- if aba and
- (bba==""or bba:sub(1,1)=="/")then local cba
- for i=1,#daa do if daa[i]==aba then cba=true;break end end;if not cba then daa[#daa+1]=aba end end end;return daa end
- function bd.isDir(caa)caa=fs.combine("",caa)return dd[caa]or
- _d.isDir(fs.combine(bc,caa))end
- function bd.exists(caa)caa=fs.combine("",caa)
- if cc[caa]or dd[caa]then return true end;return _d.exists(fs.combine(bc,caa))end;local b_a=fs.combine(bc,"/tpm")
- if not fs.exists(b_a)then if not http then return
- error"HTTP API required"end
- local caa=http.get"https://gitlab.com/hbomb79/Titanium-Package-Manager/raw/master/tpm"if not caa then return error"Failed to download TPM"end
- local daa=fs.open(b_a,"w")daa.write(caa.readAll())caa.close()
- daa.close()end;local c_a,d_a=loadfile(b_a)if not c_a then return
- error("Failed to load TPM '"..tostring(d_a).."'")end
- c_a"fetch"
- c_a("--disposable","--depend",shell.getRunningProgram(),"install","Titanium:v0.1.0-alpha.7")if not cd.Titanium then
- cd.dofile("/.tpm/packages/Titanium/v0.1.0-alpha.7")end;local _aa=cd.Titanium
- if not _aa then
- return
- error"Failed to execute Titanium package. Titanium is not loaded. Please load Titanium before executing this package, or repackage this application using the --titanium flag."end;local aaa,baa=cd.loadfile"main.lua"if aaa then aaa()else
- return error("Failed to run file from bundle vfs: "..
- tostring(baa))end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement