aboutsummaryrefslogtreecommitdiff
path: root/telem.lua
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2018-12-08 12:33:22 +0000
committerSolderpunk <solderpunk@sdf.org>2018-12-08 12:33:22 +0000
commit115df33276490095f8f727a6f4a4023855e4012f (patch)
tree0fbe33596bb23504f8aa05f1ebd27c9419cc572a /telem.lua
parentFix bug so that usernames with numbers in them are parsed correctly. (diff)
Assorted minor tidy ups.
Diffstat (limited to 'telem.lua')
-rwxr-xr-xtelem.lua30
1 files changed, 12 insertions, 18 deletions
diff --git a/telem.lua b/telem.lua
index fb5f5d1..8d1dcb8 100755
--- a/telem.lua
+++ b/telem.lua
@@ -16,7 +16,7 @@ bad_topics["."] = true
bad_topics[".."] = true
bad_topics["topic"] = true
--- This is, obvviously, not secure and will need to be updated
+-- TODO: This is, obviously, not secure and will need to be updated
username = os.getenv("USER")
current_board = ""
@@ -56,7 +56,7 @@ function get_threads(board)
_, _, timestamp, thread.author = string.find(topic, "(%d+)-(%g+)")
thread.timestamp = tonumber(timestamp)
- io.input(thread.directory.."/subject")
+ io.input(path.join(thread.directory, "subject"))
thread.subject = io.read("*line")
io.input(io.stdin)
@@ -82,7 +82,7 @@ function get_posts(thread)
if string.sub(reply, 1,1) == "." then goto continue end
if reply == "subject" then goto continue end
post = {}
- post.filename = thread.directory .. "/" .. reply
+ post.filename = path.join(thread.directory, reply)
if reply == "original" then
post.author = thread.author
post.timestamp = thread.timestamp
@@ -101,9 +101,9 @@ function do_board()
-- Creates a new (empty) board
-- Get details
- print("New board name? Max 19 chars") -- TODO: Check and enforce 19 chars
+ io.write("New board name? (Max 19 chars) ") -- TODO: Check and enforce 19 chars
board = string.upper(io.read())
- print("Description?")
+ io.write("Description? ")
desc = io.read()
-- Create directory
board_dir = path.join(_BBS_ROOT, "boards", board)
@@ -120,13 +120,12 @@ function do_board()
end
function do_go()
- print("Which board?")
+ io.write("Go to which board? ")
board = string.upper(io.read())
- -- TODO: display list of boards only if no board entered
if board == "" then
do_list()
elseif boards[board] == nil then
- print("No such board")
+ print("No such board! Hit `l` to list boards.")
else
current_board = board
end
@@ -169,11 +168,11 @@ end
function do_new()
if current_board == "" then
- print("Not at any board")
+ print("Not at any board!")
return
end
-- Get subject for new thread
- print("Subject?")
+ io.write("Subject? ")
subject = io.read()
-- Save body of post to temp file
filename = os.tmpname()
@@ -245,19 +244,14 @@ type_dispatch["r"] = do_type_reply
type_dispatch["d"] = function() return end
function do_type()
- print("Which thread?")
+ io.write("Display which thread? ")
local thread_id = string.upper(io.read())
thread = current_thread_index[tonumber(thread_id)]
- print("I've been asked to type the thread: " .. thread.subject)
current_thread_subject = thread.subject
current_thread_posts = get_posts(thread)
current_thread_index = #current_thread_posts
do_type_show_post(current_thread_index)
print(string.format("Viewing post %d of %d in thread", current_thread_index, #current_thread_posts))
--- for i, post in ipairs(posts) do
--- print(tostring(i), os.date("%x %H:%M", post.timestamp), post.author)
- --cat_file(post.filename)
--- end
repeat
show_type_prompt()
c = getchar()
@@ -271,7 +265,7 @@ function do_type()
end
function show_type_prompt()
- io.write("[f]irst, [n]ext, [p]rev, [r]eply, [d]one >")
+ io.write("[f]irst, [n]ext, [p]rev, [r]eply, [d]one > ")
end
function do_type_show_post(index)
@@ -293,7 +287,7 @@ function do_reply()
print("Not at any board!")
return
end
- print("Reply to which thread?")
+ io.write("Reply to which thread? ")
local thread_id = string.upper(io.read())
thread = current_thread_index[tonumber(thread_id)]
current_thread_subject = thread.subject