Update sms.lua
This commit is contained in:
parent
a69679e1b7
commit
2fa32d771a
1 changed files with 19 additions and 5 deletions
|
@ -81,12 +81,17 @@ local x,y = 1,1
|
||||||
local mx,my = displayWin.getSize()
|
local mx,my = displayWin.getSize()
|
||||||
|
|
||||||
|
|
||||||
local function printMsg(msg)
|
local function printMsg(msg, save)
|
||||||
displayWin.setCursorBlink(false)
|
displayWin.setCursorBlink(false)
|
||||||
displayWin.setTextColor(colors.black)
|
displayWin.setTextColor(colors.black)
|
||||||
local nTerm = term.current()
|
local nTerm = term.current()
|
||||||
term.redirect(displayWin)
|
term.redirect(displayWin)
|
||||||
print(msg)
|
print(msg)
|
||||||
|
if save then
|
||||||
|
f = fs.open("/.sPhone/cache/sms/"..sendTo,"a")
|
||||||
|
f.write(msg.."\n")
|
||||||
|
f.close()
|
||||||
|
end
|
||||||
term.redirect(nTerm)
|
term.redirect(nTerm)
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
term.setCursorPos(7,1)
|
term.setCursorPos(7,1)
|
||||||
|
@ -126,7 +131,7 @@ local function readMsg()
|
||||||
pos = pos + 1
|
pos = pos + 1
|
||||||
if pos > #loading then pos = 1 end
|
if pos > #loading then pos = 1 end
|
||||||
elseif e[1] == "http_success" then
|
elseif e[1] == "http_success" then
|
||||||
printMsg("<You> "..rawMsg)
|
printMsg("<You> "..rawMsg,true)
|
||||||
break
|
break
|
||||||
elseif e[1] == "http_failure" then
|
elseif e[1] == "http_failure" then
|
||||||
term.redirect(ntv)
|
term.redirect(ntv)
|
||||||
|
@ -155,9 +160,18 @@ local function recMsg()
|
||||||
displayWin.setTextColor(colors.black)
|
displayWin.setTextColor(colors.black)
|
||||||
displayWin.clear()
|
displayWin.clear()
|
||||||
if sendTo ~= "" then
|
if sendTo ~= "" then
|
||||||
printMsg("Type /logout to exit")
|
printMsg("Type /logout to exit",false)
|
||||||
|
if fs.exists("/.sPhone/cache/sms/"..sendTo) then
|
||||||
|
local f = fs.open("/.sPhone/cache/sms/"..sendTo,"r")
|
||||||
|
local line = f.readLine()
|
||||||
|
repeat
|
||||||
|
printMsg(line,false)
|
||||||
|
line = f.readLine()
|
||||||
|
until not line
|
||||||
|
f.close()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
printMsg("All messages")
|
printMsg("All messages",false)
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
|
@ -173,7 +187,7 @@ local function recMsg()
|
||||||
if t then
|
if t then
|
||||||
date = t["date"]
|
date = t["date"]
|
||||||
mesg = "<"..t["from"].."> "..base64.decode(t["message"])
|
mesg = "<"..t["from"].."> "..base64.decode(t["message"])
|
||||||
printMsg(mesg)
|
printMsg(mesg,true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue