aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2019-05-06 20:13:05 +0000
committerSolderpunk <solderpunk@sdf.org>2019-05-06 20:13:05 +0000
commit812c306824420483cf41ec249a8f5e2ed5a9ef75 (patch)
tree19969cf7e5207e9b38dbc0b3fb95468b6083485d
parentAdd (R)ecent function to show 10 most recently active threads. (diff)
Add (H)ide function to hold threads which haven't been updated in 90 days.
-rwxr-xr-xtelem.lua21
1 files changed, 20 insertions, 1 deletions
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