diff options
| -rwxr-xr-x | telem.lua | 32 | 
1 files changed, 14 insertions, 18 deletions
| @@ -48,6 +48,13 @@ function update_boards()  	table.sort(boards)  end +function check_at_board() +	if current_board == "" then +		print("Not at any board!  Hit `l` to list boards, `g` to go to one.") +	end +	return current_board ~= "" +end +  function get_threads(board)  	local threads = {}  	for threaddir in lfs.dir(path.join(_BBS_ROOT, "boards", board)) do @@ -156,21 +163,15 @@ function do_list()  end  function do_messages() -	if current_board == "" then -		print("Not at any board!  Hit `l` to list boards, `g` to go to one.") -	else -		current_board_threads = get_threads(current_board) -		for i, thread in ipairs(current_board_threads) do -			print(tostring(i), os.date("%x %H:%M", thread.timestamp), thread.author, thread.subject, "("..tostring(thread.post_count).." posts)") -		end +	if not check_at_board() then return end +	current_board_threads = get_threads(current_board) +	for i, thread in ipairs(current_board_threads) do +		print(tostring(i), os.date("%x %H:%M", thread.timestamp), thread.author, thread.subject, "("..tostring(thread.post_count).." posts)")  	end  end  function do_new() -	if current_board == "" then -		print("Not at any board!") -		return -	end +	if not check_at_board() then return end  	-- Get subject for new thread  	io.write("Subject? ")  	local subject = io.read() @@ -264,9 +265,7 @@ type_dispatch["r"] = do_type_reply  type_dispatch["d"] = function() return end  function do_type() -	if current_board == "" then -		print("Not at any board!  Hit `l` to list boards, `g` to go to one.") -	end +	if not check_at_board() then return end  	io.write("Read which thread? ")  	local thread_id = tonumber(io.read())  	if not thread_id or thread_id < 0 or thread_id > #current_board_threads then @@ -300,10 +299,7 @@ function do_quit()  end  function do_reply() -	if current_board == "" then -		print("Not at any board!") -		return -	end +	if not check_at_board() then return end  	io.write("Reply to which thread? ")  	local thread_id = tonumber(io.read())  	if not thread_id or thread_id < 0 or thread_id > #current_board_threads then | 
