diff options
| author | Solderpunk <solderpunk@sdf.org> | 2018-12-07 18:56:44 +0000 | 
|---|---|---|
| committer | Solderpunk <solderpunk@sdf.org> | 2018-12-07 18:56:44 +0000 | 
| commit | 6f84ed910a034bea5d7622c3be5918a28c246ae0 (patch) | |
| tree | c2161f19682d2c19ddd558b78dd4d1b8fa78fccd | |
| parent | Add reply support. (diff) | |
Add new thread support.
Diffstat (limited to '')
| -rwxr-xr-x | telem.lua | 33 | 
1 files changed, 32 insertions, 1 deletions
@@ -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  | 
