aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtelem.lua33
1 files changed, 32 insertions, 1 deletions
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