From 812c306824420483cf41ec249a8f5e2ed5a9ef75 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Mon, 6 May 2019 20:13:05 +0000 Subject: Add (H)ide function to hold threads which haven't been updated in 90 days. --- telem.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'telem.lua') diff --git a/telem.lua b/telem.lua index d2fe594..8f6e5dd 100755 --- a/telem.lua +++ b/telem.lua @@ -45,6 +45,7 @@ current_thread_posts = {} -- Array of post tables, containing posts associated w current_post_index = nil -- Integer index into current_thread_posts colours = true -- Boolean, controls whether to use ANSI colours reversemessages = false -- Boolean, controls message sort order +hideold = false -- Boolean, controls whether to hide old threads -- Setuid stuff @@ -145,7 +146,14 @@ function get_threads(board) thread.updated_by = post.author end end - table.insert(threads, thread) + if hideold then + local age = os.time() - thread.updated + if age < 7776000 then -- 90 days, in seconds + table.insert(threads, thread) + end + else + table.insert(threads, thread) + end ::continue:: end if reversemessages then @@ -262,6 +270,16 @@ function do_setmessageorder() end end +function do_sethideold() + if hideold then + hideold = false + print("Showing old threads.") + else + hideold = true + print("Hiding old threads.") + end +end + function do_go() io.write("Go to which board? (use name or index) ") local board = string.upper(io.read()) @@ -664,6 +682,7 @@ load_scan_times() -- Build dispatch table mapping chars to functions dispatch = {} dispatch["h"] = do_help +dispatch["H"] = do_sethideold dispatch["g"] = do_go dispatch["l"] = do_list dispatch["m"] = do_messages -- cgit v1.2.3