aboutsummaryrefslogtreecommitdiff
path: root/telem.lua
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2018-12-07 18:56:44 +0000
committerSolderpunk <solderpunk@sdf.org>2018-12-07 18:56:44 +0000
commit6f84ed910a034bea5d7622c3be5918a28c246ae0 (patch)
treec2161f19682d2c19ddd558b78dd4d1b8fa78fccd /telem.lua
parentAdd reply support. (diff)
Add new thread support.
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