From 6f84ed910a034bea5d7622c3be5918a28c246ae0 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Fri, 7 Dec 2018 18:56:44 +0000 Subject: Add new thread support. --- telem.lua | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/telem.lua b/telem.lua index 593908a..36dfb02 100755 --- a/telem.lua +++ b/telem.lua @@ -143,6 +143,37 @@ function do_messages() current_thread_index = threads end +function do_new() + if current_board == "" then + print("Not at any board") + return + end + -- Get subject for new thread + print("Subject?") + subject = io.read() + -- Save body of post to temp file + filename = os.tmpname() + os.execute("$EDITOR " .. filename) + -- TODO: show and confirm + -- Make thread dir + timestamp = tostring(os.time()) + thread_dir = timestamp .. "-" .. username + thread_path = path.join("/home/solderpunk/bbs/boards/", current_board, thread_dir) + lfs.mkdir(thread_path) + -- Write subject file + file.write(path.join(thread_path, "subject"), + subject) + -- Move post file + post_file = thread_dir -- first post and thread directory names are the same! + newpath = path.join(thread_path, post_file) + ret, str = file.move(filename, newpath) + if not ret then + print(str) + end + -- Done! + print("Post submitted.") +end + -- Type stuff below function do_type_first() @@ -273,7 +304,7 @@ dispatch["w"] = do_who dispatch["s"] = do_unimplemented dispatch["="] = do_unimplemented dispatch["M"] = do_unimplemented -dispatch["n"] = do_unimplemented +dispatch["n"] = do_new dispatch["r"] = do_unimplemented dispatch["b"] = do_unimplemented dispatch["c"] = do_unimplemented -- cgit v1.2.3