--[[ /////////////////////////////////////////////////// PSPirc v0.1b by .::AsErTo::. aserto@gmail.com www.pspircclient.org /////////////////////////////////////////////////// ]] -- Loads Wlan Module Wlan.init() --Loads danzeff keyboard dofile("danzeff.lua") kb = Danzeff:New() kb:Init(255,104) -- Variables chattext={} chattext[1]={} conn=false window="not connected" tabs={} tabs[1]="not connected" tabnum=1 scroll=1 tstart=1 nicks={} nicks[1]={} nickmsg=false editmode=false keyrep=Timer.new() square=false -- Functions function showtext(n) -- shows text if string.sub(tabs[tabnum],1 ,1)=="#" then mcols=conf.maxcolwnl else mcols=conf.maxcols end tlen = table.getn(chattext[n]) if tlen > conf.maxrows then tstart = tlen - conf.maxrows else tstart = 1 end i=1 while tstart <= tlen do llen=string.len(chattext[n][tstart]) if llen<=mcols then screen:print(10, 10+(10*i), string.sub(chattext[n][tstart], scroll, llen-scroll+1), vkeycolor) else screen:print(10, 10+(10*i), string.sub(chattext[n][tstart], scroll, conf.maxcolwnl), vkeycolor) end i=i+1 tstart=tstart+1 end end function getargs(s) local args = {} for w in string.gfind(s, "%S+") do table.insert(args, w) end return args end function savetoconfig(var, val) file = io.open("pspirc.conf", "r") if file then all="" for line in file:lines() do all=all..line.."\n" varexists = string.find(line, "conf."..var) if varexists then varline=line end end file:close() if varline then file = io.open("pspirc.conf", "w") if file then all=string.gsub(all, varline, "conf."..var.."="..val.."") file:write(string.sub(all, 1, string.len(all)-1)) file:close() dofile("pspirc.conf") return "* "..var.." => "..val else return "* Error: can't open config file." end else return "* Error: you can't put your shit in my config file." end else return "* Error: can't open config file." end end function findpattern(text, pattern, start) a=string.find(text, pattern, start) if a~=nil then return string.sub(text, a) else return nil end end function trim (s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end function shownicklist(n) if string.sub(tabs[tabnum],1,1)=="#" then table.sort(n) i=1 while i<=table.getn(n) do if string.len(n[i])>7 then screen:print(415, 15+(10*i), string.sub(n[i], 1, 7), vkeycolor) else screen:print(415, 15+(10*i), string.sub(n[i], 1, 7), vkeycolor) end i=i+1 end end end function chantotab(c) i=1 while i<=table.getn(tabs) do if tabs[i]==c then return i end i=i+1 end return nil end function octal_replace(s) -- irc sends octal escape chars, lua uses decimal ones... -- TODO return (s) end --function iptolong(nip) -- We don't need it because dcc send is not implemented -- local ip = {} -- for w in string.gfind(nip, "^.+") do -- table.insert(ip, w) -- end -- return(tonumber(ip[4])+256*tonumber(ip[3])+256*256*tonumber(ip[2])+256*256*256*tonumber(ip[1])) --end --function longtoip(long) -- for 1.0 and 1.5 on luaplayer 0.20 -- ip = "" -- for i=3,0,-1 do -- ip = ip .. math.floor((long / math.pow(256,i))) -- long = long - math.floor((long / math.pow(256,i)))*math.pow(256,i) -- if i>0 then ip = ip .. "." end -- end -- return ip --end function longtoip(long) --This is for 2.01+ (luaplayer 0.16 + eloader 0.97) if id == "" then error("invalid id") end socket = Socket.connect("pspirc.altervista.org", 80) while not socket:isConnected() do if Controls.read():start() then return end System.sleep(100) end bytesSent = socket:send("GET /long2ip.php?long="..long.." HTTP/1.0\r\n") bytesSent = socket:send("host: pspirc.altervista.org\r\n\r\n") total = "" request = 0 while true do buffer = socket:recv() if string.len(buffer) > 0 then total = total..buffer request = 1 else if request == 1 then request = 2 end end if request == 2 then socket:close() break end if Controls.read():start() then break end end pos = string.find(total,"\r\n\r\n") or 1 ip = string.sub(total,pos+4) return ip end function getnick(s) if string.find(s, "!")~=nil then return string.sub(s,1,string.find(s, "!")-1) else return s end end function filesize (file) local current = file:seek() local size = file:seek("end") file:seek("set", current) return size end function table.find(t,w) i=1 while i<=table.getn(t) do if string.lower(t[i])==string.lower(w) then return i end i=i+1 end return false end function addchattext(tab, t) if string.sub(tabs[tab],1,1)=="#" then max=conf.maxcolwnl else max=conf.maxcols end if string.len(t)>max then i=0 while i<=math.floor(string.len(t)/max) do if i==0 then table.insert(chattext[tab], string.sub(t,1,max)) else table.insert(chattext[tab], " "..string.sub(t,(max*i+1),max*(i+1)+max-1)) end i=i+1 end else table.insert(chattext[tab], t) end end -- Defines some colors titlecolor = Color.new(236, 0, 140) vkeycolor = Color.new(0, 0, 0) -- Loads Config File dofile("pspirc.conf") -- Loads background bg = Image.load("background.png") screen:blit(0, 0, bg, 0, 0, bg:width(), bg:height(), false) screen.waitVblankStart() screen.flip() keynum=1 pingtmr=Timer.new() nick=conf.nick srv="" text="/server "..conf.srv version="0.1b" if conf.conn then square=true end -- Welcome msg addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum," ********* ********* *********") addchattext(tabnum," * * *") addchattext(tabnum," ********* ********* *********") addchattext(tabnum," * * *") addchattext(tabnum," * ********* *") addchattext(tabnum," I R C") addchattext(tabnum,"") addchattext(tabnum," by .::AsErTo::.") addchattext(tabnum," aserto@gmail.com") addchattext(tabnum," www.pspircclient.org") addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum,"") addchattext(tabnum,"") -- Endless While while true do screen:blit(0, 0, bg, 0, 0, bg:width(), bg:height(), false) screen.waitVblankStart() pad = Controls.read() if editmode==true then keyrep:start() kb:Display() key=kb:Input(Controls.read()) if key~=prevkey or reptime>50 then if key==4 or key==3 then editmode=false elseif key==1 then text=string.sub(text,1,string.len(text)-1) elseif key==2 then text=text.." " elseif key==10 then editmode=false square=true elseif key==0 or key==8 or key==9 then --nothing... else text=text..string.char(key) end end prevkey = key reptime=keyrep:time() keyrep:stop() keyrep:reset() end -- this is to avoid control repetition if pad~=prevPad then if pad:down() then square=true elseif pad:up() and not editmode then elseif pad:triangle() and not editmode then -- Enables danzeff keyboard editmode=true elseif square then square=false -- if is a command executes it... else sends a message :P if string.sub(text, 1, string.len("/server")) == "/server" then -- Connects to a server sarg=getargs(text) if sarg[2]==nil then table.insert(chattext[1], "* Error: you must specify a server.") else if sarg[3]==nil then sarg[3]=6667 end if sarg[3]==" " then sarg[3]=6667 end if sarg[3]=="" then sarg[3]=6667 end table.insert(chattext[1], "* Connecting to "..sarg[2].." ...") showtext(tabnum) charge=string.sub(" "..System.powerGetBatteryLifePercent(), -3) time_now=os.date("*t") screen:print(392, 5, string.format("%02d", time_now.hour)..":"..string.format("%02d", time_now.min).." "..charge.."%", titlecolor) window=tabs[tabnum] screen:print(100, 5, window, titlecolor) screen.flip() Wlan.useConnectionConfig(conf.wlan_n) sock=Socket.connect(tostring(sarg[2]), tonumber(sarg[3])) tries=0 while not sock:isConnected() do System.sleep(100) tries=tries+1 if tries==5 then failed=true break end end bytesSent = sock:send("NICK "..conf.nick.."\r\n") bytesSent = sock:send("USER "..conf.user.." pspirc "..sarg[2].." :"..conf.RealName.."\r\n") table.insert(chattext[1], "* Connected to "..sarg[2].." .") window=sarg[2] tabs[1]=sarg[2] showtext(tabnum) charge=string.sub(" "..System.powerGetBatteryLifePercent(), -3) time_now=os.date("*t") screen:print(392, 5, string.format("%02d", time_now.hour)..":"..string.format("%02d", time_now.min).." "..charge.."%", titlecolor) window=tabs[tabnum] screen:print(100, 5, window, titlecolor) screen.flip() conn=true pingtmr:start() end elseif string.sub(text, 1, string.len("/join")) == "/join" then -- joins a channel if conn==true then jarg = getargs(text) if jarg[2]==nil then table.insert(chattext[tabnum], "* Error: you have to specify a channel.") else jarg[2]="#"..trim(string.gsub(jarg[2], "#", " ")) bytesSent = sock:send("JOIN "..jarg[2].."\r\n") end end if conf.debug==true then print("joins a channel") end elseif string.sub(text, 1, string.len("/topic")) == "/topic" then -- changes chan topic if conn==true then targ=getargs(text) if targ[2]~=nil then table.insert(chattext[tabnum], "* Error: you have to specify a channel.") if targ[3]~=nil then topic="" i=3 while i<=table.getn(targ) do topic=topic.." "..targ[i] i=i+1 end bytesSent = sock:send("TOPIC "..targ[2].." :"..trim(topic).."\r\n") else table.insert(chattext[tabnum], "* Error: you have to specify a topic.") end else end end elseif string.sub(text, 1, string.len("/kick")) == "/kick" then --kicks somebody if conn==true then karg=getargs(text) if karg[2]~=nil then if karg[3]~=nil then if karg[4]==nil then bytesSent = sock:send("KICK "..karg[2].." "..karg[3].."\r\n") else i=4 motive="" while i<=table.getn(karg) do motive=motive.." "..karg[i] i=i+1 end bytesSent = sock:send("KICK "..karg[2].." "..karg[3].." :"..trim(motive).."\r\n") end else table.insert(chattext[tabnum], "* Error: you have to specify a nick.") end else table.insert(chattext[tabnum], "* Error: you have to specify a channel.") end end elseif string.sub(text, 1, string.len("/mode")) == "/mode" then -- sets modes if conn==true then marg=getargs(text) i=2 modes="" while i<=table.getn(marg) do modes=modes.." "..marg[i] i=i+1 end bytesSent = sock:send("MODE "..trim(modes).."\r\n") end elseif string.sub(text, 1, string.len("/dccget")) == "/dccget" then -- gets a file garg=getargs(text) if table.getn(garg)~=5 then table.insert(chattext[tabnum], "* Error: bad argument count for /dccget") else dcc=Socket.connect(tostring(garg[2]), tonumber(garg[4])) tries=0 failed=false while not dcc:isConnected() do System.sleep(100) tries=tries+1 if tries==5 then failed=true break end end if failed==true then table.insert(chattext[tabnum], "* Error: connection timed out.") else table.insert(chattext[tabnum], "* Receving file...") table.insert(chattext[tabnum], "* Press start to abort.") showtext(tabnum) shownicklist(nicks[tabnum]) charge=string.sub(" "..System.powerGetBatteryLifePercent(), -3) time_now=os.date("*t") screen:print(392, 5, string.format("%02d", time_now.hour)..":"..string.format("%02d", time_now.min).." "..charge.."%", titlecolor) window=tabs[tabnum] screen:print(100, 5, window, titlecolor) screen.flip() dccfile="" rbytes=0 finished=false file=io.open(conf.downdir..garg[3], "w") if not file then table.insert(chattext[tabnum], "* Error: could not open the file.") else file:close() while true do pa=Controls:read() if pa:start() then table.insert(chattext[tabnum], "* DCC RECV aborted.") dcc:close() break end buffer = dcc:recv() if string.len(buffer)>0 then dccstate=1 rbytes=rbytes+string.len(buffer) file=io.open(conf.downdir..garg[3], "a") if not file then table.insert(chattext[tabnum], "* Error: DCC RECV failed.") dcc:close() break end file:write(buffer) file:close() else if state==1 then state=2 end --dcc transfer finished end if dccstate==2 or rbytes==tonumber(garg[5]) then dcc:close() table.insert(chattext[tabnum], "* DCC RECV completed.") break end end end end end elseif string.sub(text, 1, string.len("/dccsend")) == "/dccsend" then -- sends a file table.insert(chattext[tabnum], "* DCC SEND is not implemented because is unuseful.") elseif string.sub(text, 1, string.len("/clear")) == "/clear" then -- clears screen chattext[tabnum]={} elseif string.sub(text, 1, string.len("/set")) == "/set" then ar=getargs(text) if ar[2]==nil then table.insert(chattext[tabnum], "* Error: you have to enter a variable as 2nd argument.") elseif ar[3]==nil then if conf[ar[2]]==nil then table.insert(chattext[tabnum], "* Error: this variable doesn't exist.") else table.insert(chattext[tabnum], "* "..ar[2].." => "..conf[ar[2]]) end else --sets the var table.insert(chattext[tabnum], savetoconfig(ar[2], ar[3])) end elseif string.sub(text, 1, string.len("/about")) == "/about" then -- about table.insert(chattext[tabnum], "* PSPirc v"..version) table.insert(chattext[tabnum], "* Coded by .::AsErTo::. aserto[at]gmail.com") elseif string.sub(text, 1, string.len("/query")) == "/query" then qarg=getargs(text) -- opens a query if qarg[2]==nil then table.insert(chattext[tabnum], "* Error: you have to specify a nick.") else if not table.find(tabs, qarg[2]) then table.insert(tabs, qarg[2]) chattext[table.getn(chattext)+1]={} tabnum=table.getn(tabs) bg = Image.load("background.png") screen:blit(0, 0, bg, 0, 0, bg:width(), bg:height(), false) screen.waitVblankStart() screen.flip() else tabnum=table.find(tabs, qarg[2]) end end elseif string.sub(text, 1, string.len("/usbon")) == "/usbon" then -- Activates Usb disk mode --System.usbDiskModeActivate() --addchattext(tabnum, "* Usb disk mode activated") addchattext(tabnum, "* Usb disk mode doesn't work on 2.01+") elseif string.sub(text, 1, string.len("/usboff")) == "/usboff" then -- Activates Usb disk mode --System.usbDiskModeDeactivate() --addchattext(tabnum, "* Usb disk mode deactivated") addchattext(tabnum, "* Usb disk mode doesn't work on 2.01+") elseif string.sub(text, 1, string.len("/screenshot")) == "/screenshot" then --takes a screenshot if conf.scrsfile==nil then conf.scrsfile="screen.png" end screen:save(conf.scrsfile) addchattext(tabnum, "* Screenshot taken.") elseif string.sub(text, 1, 1) == "/" then -- sends the command to server if conn==true then bytesSent = sock:send(string.sub(text, 2).."\r\n") end else -- this is not a command... if conn==true and tabnum~=1 then bytesSent = sock:send("PRIVMSG "..window.." :"..text.."\r\n") addchattext(tabnum, "<"..nick.."> "..text) else table.insert(chattext[tabnum], "* Error: You are not on a channel.") end end text="" elseif pad:select() and not editmode then if tabnum~=table.getn(tabs) then tabnum=tabnum+1 else tabnum=1 end if string.sub(tabs[tabnum],1,1)=="#" then bg = Image.load("background_nicklist.png") else bg = Image.load("background.png") end end end -- Ping if conn==true then if pingtmr:time()>20090 and pingtmr:time()<30000 then bytesSent = sock:send("PING PSPirc\r\n") pingtmr:stop() pingtmr:reset(0) pingtmr:start() end end prevPad = pad if pad:start() and not editmode then if conn==true then bytesSent = sock:send("QUIT :Leaving\r\n") sock:close() end Wlan.term() break end -- Read input from server... if conn==true then buffer = sock:recv() if string.len(buffer) > 0 then for line in string.gfind(buffer, "[^\r\n]+") do --line=octal_replace(line) rarg=getargs(line) if rarg[1]~=nil then sender=string.sub(rarg[1], 2, string.len(rarg[1])) end command=rarg[2] nichan=rarg[3] msg="" if rarg[4]~=nil then a=4 if command=="332" then a=5 end while a<=table.getn(rarg) do msg=msg.." "..rarg[a] a=a+1 end end msg=string.sub(msg, 3, -1) if command~=nil then if command=="001" then --Server welcome msg addchattext(tabnum, octal_replace(msg)) srv=sender end if command=="002" then --Some server info addchattext(tabnum, octal_replace(msg)) end if command=="003" then --Server creation date addchattext(tabnum, octal_replace(msg)) end if command=="004" then --IRCd info addchattext(tabnum, octal_replace(msg)) end if command=="251" then --Number of users addchattext(tabnum, octal_replace(msg)) end if command=="252" then --Number of operators addchattext(tabnum, octal_replace(msg)) end if command=="254" then --Number of channels formed addchattext(tabnum, octal_replace(msg)) end if command=="255" then --Number of clients and servers addchattext(tabnum, octal_replace(msg)) end if command=="265" then --Local users info addchattext(tabnum, octal_replace(msg)) end if command=="266" then --Local users info addchattext(tabnum, octal_replace(msg)) end if command=="375" then --MOTD start addchattext(tabnum, octal_replace(msg)) end if command=="372" then --MOTD content addchattext(tabnum, octal_replace(msg)) end if command=="376" then --MOTD end addchattext(tabnum, octal_replace(msg)) -- Autojoin function i=1 while i<=table.getn(conf.chans) do bytesSent = sock:send("JOIN "..conf.chans[i].."\r\n") i=i+1 end end if command=="332" then --Join, topic, nicks table.insert(tabs, rarg[4]) chattext[table.getn(chattext)+1]={} nicks[table.getn(nicks)+1]={} tabnum=table.getn(tabs) bg = Image.load("background_nicklist.png") screen:blit(0, 0, bg, 0, 0, bg:width(), bg:height(), false) screen.waitVblankStart() screen.flip() table.insert(chattext[tabnum], "* Now you are talking on "..rarg[4]) bytesSent = sock:send("WHO "..rarg[4].."\r\n") -- i know... this is very lame... but works! bytesSent = sock:send("WHO "..rarg[4].."\r\n") bytesSent = sock:send("WHO "..rarg[4].."\r\n") bytesSent = sock:send("WHO "..rarg[4].."\r\n") bytesSent = sock:send("WHO "..rarg[4].."\r\n") bytesSent = sock:send("WHO "..rarg[4].."\r\n") addchattext(chantotab(rarg[4]), "* Topic for "..rarg[4].." is \""..octal_replace(msg).."\"") end if command=="333" then --Topic set date and nick --td=os.date("*t", tonumber(rarg[6])) --table.insert(chattext[chantotab(rarg[4])], "* Topic set by "..rarg[5].." on "..string.format("%02d", td.day).."/"..string.format("%02d", td.month).."/"..td.year.." at "..string.format("%02d", td.hour)..":"..string.format("%02d", td.min)..":"..string.format("%02d", td.sec)) --table.insert(chattext[i], "* Topic set by "..rarg[5]) end if command=="352" then -- Response to WHO command if rarg[8]~=nil and rarg[8]~="" and rarg[9]~=nil and rarg[9]~="" then if not table.find(nicks[chantotab(rarg[4])], rarg[8]) then table.insert(nicks[chantotab(rarg[4])], rarg[8]) end end end if command=="307" or command=="311" or command=="312" or command=="317" or command=="318" or command=="319" then -- Response to WHOIS command addchattext(tabnum,octal_replace(msg)) end if command=="433" then --Nick already in use addchattext(tabnum,octal_replace(msg)) text="/nick " end if command=="482" then --Error... addchattext(tabnum,octal_replace(msg)) end if command=="NOTICE" then -- /notice command if sender==nick then sep="-" else sep="*" end if sender==srv then addchattext(tabnum, octal_replace(msg)) else snick=getnick(sender) if snick~=nil then addchattext(tabnum, sep..snick..sep..octal_replace(msg)) end end end if command=="PRIVMSG" then -- Standard message snick=getnick(sender) if string.sub(msg, 1, 1)=="\001" then -- this is a ctcp request... msg=string.gsub(msg, "\001", "") carg=getargs(msg) if carg[1]=="ACTION" then msg=trim(string.gsub(msg, "ACTION", "")) --action table.insert(chattext[chantotab(rarg[3])], "* "..snick.." "..octal_replace(msg)) end if carg[1]=="DCC" then -- dcc request... if carg[2]=="SEND" then --dcc send fname=carg[3] hrip=longtoip(carg[4]) -- Human Readable Ip... port=carg[5] fsize=carg[6] -- file size in bytes addchattext(tabnum, "* "..snick.." has offered "..fname.." ("..fsize.." b)") text="/dccget "..hrip.." "..fname.." "..port.." "..fsize end end else if string.sub(nichan,1,1)=="#" then addchattext(chantotab(nichan), "<"..snick.."> "..octal_replace(msg)) else if table.find(tabs, snick) then addchattext(chantotab(snick), "<"..snick.."> "..octal_replace(msg)) else table.insert(tabs, snick) chattext[table.getn(chattext)+1]={} tabnum=table.getn(tabs) bg = Image.load("background.png") screen:blit(0, 0, bg, 0, 0, bg:width(), bg:height(), false) screen.waitVblankStart() screen.flip() addchattext(chantotab(snick), "<"..snick.."> "..octal_replace(msg)) end end end end if command=="JOIN" then --Somebody has joined jnick=getnick(sender) if jnick~=nick and jnick~=nil then rarg[3]=string.gsub(rarg[3], ":", "") table.insert(chattext[chantotab(rarg[3])], "* "..jnick.." has joined "..string.sub(rarg[3], 2, string.len(rarg[3]))) table.insert(nicks[chantotab(rarg[3])], jnick) end end if command=="PART" then --Somebody has left pnick=getnick(sender) if pnick~=nick then addchattext(chantotab(rarg[3]), "* "..pnick.." has left "..rarg[3]) table.remove(nicks[chantotab(rarg[3])], table.find(nicks[chantotab(rarg[3])], pnick)) end end if command=="TOPIC" then --Somebody has changed topic tnick=getnick(sender) i=4 topic="" while i<=table.getn(rarg) do if string.sub(rarg[i], 1, 1)==":" then rarg[i]=string.sub(rarg[i], 2, string.len(rarg[i])) end topic=topic.." "..rarg[i] i=i+1 end addchattext(chantotab(rarg[3]), "* "..tnick.." has changed the topic to: \""..trim(topic).."\"") end if command=="KICK" then --somebody has been kicked knick=getnick(sender) i=5 motive="" while i<=table.getn(rarg) do if string.sub(rarg[i], 1, 1)==":" then rarg[i]=string.sub(rarg[i], 2, string.len(rarg[i])) end motive=motive.." "..rarg[i] i=i+1 end if rarg[4]==nick then table.insert(chattext[1], "* You have been kicked from "..rarg[3].." by "..knick.." ("..trim(motive)..")") table.remove(chattext, chantotab(rarg[3])) table.remove(nicks, chantotab(rarg[3])) table.remove(tabs, chantotab(rarg[3])) tabnum=1 bg = Image.load("background.png") else addchattext(chantotab(rarg[3]), "* "..rarg[4].." has been kicked by "..knick.." ("..trim(motive)..")") table.remove(nicks[chantotab(rarg[3])], table.find(nicks[chantotab(rarg[3])], rarg[4])) end end if command=="MODE" then -- somebody has changed modes mnick=getnick(sender) i=4 modes="" while i<=table.getn(rarg) do modes=modes.." "..rarg[i] i=i+1 end if string.sub(rarg[3], 1, 1)=="#" then addchattext(chantotab(rarg[3]), "* "..mnick.." sets mode"..modes) else addchattext(1, "* "..mnick.." sets mode"..modes) end end if command=="QUIT" then --somebody has quitted qnick=string.gsub(getnick(sender), ":", "") i=1 while i<=table.getn(nicks) do n=table.find(nicks[i], qnick) if n then table.insert(chattext[i], "* "..qnick.." has quit IRC") table.remove(nicks[i],n) end i=i+1 end end if command=="NICK" then --somebody has changed nick nnick=string.gsub(getnick(sender), ":", "") i=1 while i<=table.getn(nicks) do n=table.find(nicks[i], nnick) if n then table.insert(chattext[i], "* "..nnick.." is now known as "..string.gsub(rarg[3], ":", "")) nicks[i][n]=string.gsub(rarg[3], ":", "") end i=i+1 end end end showtext(tabnum) shownicklist(nicks[tabnum]) charge=string.sub(" "..System.powerGetBatteryLifePercent(), -3) time_now=os.date("*t") screen:print(392, 5, string.format("%02d", time_now.hour)..":"..string.format("%02d", time_now.min).." "..charge.."%", titlecolor) window=tabs[tabnum] screen:print(100, 5, window, titlecolor) screen.flip() end end end -- shows chattext editbox text and vkey showtext(tabnum) shownicklist(nicks[tabnum]) tlen=string.len(text) if tlen<=conf.maxcols then screen:print(10, 260, text, vkeycolor) else screen:print(10, 260, string.sub(text, -1*conf.maxcols), vkeycolor) end -- battery charge and time... charge=string.sub(" "..System.powerGetBatteryLifePercent(), -3) time_now=os.date("*t") screen:print(392, 5, string.format("%02d", time_now.hour)..":"..string.format("%02d", time_now.min).." "..charge.."%", titlecolor) window=tabs[tabnum] screen:print(100, 5, window, titlecolor) if editmode then kb:Display() end screen.waitVblankStart() screen.flip() end