aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2018-12-06 20:22:51 +0000
committerSolderpunk <solderpunk@sdf.org>2018-12-06 20:22:51 +0000
commit8cd8d2449ae1cd0efd5222090f02a1f5515d0bb0 (patch)
treeb31289fa3991e754bf26909ae9e8021972c3d4ef
parentimplement "unimplemented" commands (diff)
Use new BBS file spec.
Diffstat (limited to '')
-rwxr-xr-xtelem.lua33
1 files changed, 19 insertions, 14 deletions
diff --git a/telem.lua b/telem.lua
index 63e5c70..794666a 100755
--- a/telem.lua
+++ b/telem.lua
@@ -49,10 +49,8 @@ function get_threads(board)
_, _, timestamp, thread.author = string.find(topic, "(%d+)-(%a+)")
thread.timestamp = tonumber(timestamp)
- io.input(thread.directory.."/original")
- io.read("*line")
+ io.input(thread.directory.."/subject")
thread.subject = io.read("*line")
- _, _, thread.subject = string.find(thread.subject, "%[SUBJECT%] (.+)")
io.input(io.stdin)
posts = get_posts(thread)
@@ -74,18 +72,19 @@ end
function get_posts(thread)
local posts = {}
for reply in lfs.dir(thread.directory) do
- if string.sub(reply, 1,1) ~= "." then
- post = {}
- post.filename = thread.directory .. "/" .. reply
- if reply == "original" then
- post.author = thread.author
- post.timestamp = thread.timestamp
- else
- _, _, timestamp, post.author = string.find(reply, "(%d+)-(%a+)")
- post.timestamp = tonumber(timestamp)
- end
- table.insert(posts, post)
+ if string.sub(reply, 1,1) == "." then goto continue end
+ if reply == "subject" then goto continue end
+ post = {}
+ post.filename = thread.directory .. "/" .. reply
+ if reply == "original" then
+ post.author = thread.author
+ post.timestamp = thread.timestamp
+ else
+ _, _, timestamp, post.author = string.find(reply, "(%d+)-(%a+)")
+ post.timestamp = tonumber(timestamp)
end
+ table.insert(posts, post)
+ ::continue::
end
table.sort(posts, function(x,y) return x.timestamp < y.timestamp end)
return posts
@@ -177,6 +176,7 @@ function do_type()
local thread_id = string.upper(io.read())
thread = current_thread_index[tonumber(thread_id)]
print("I've been asked to type the thread: " .. thread.subject)
+ current_thread_subject = thread.subject
current_thread_posts = get_posts(thread)
current_thread_index = #current_thread_posts
do_type_show_post(current_thread_index)
@@ -203,7 +203,12 @@ end
function do_type_show_post(index)
local post = current_thread_posts[index]
+ print("SUBJECT: " .. current_thread_subject)
+ print("AUTHOR: " .. post.author)
+ print("POSTED: " .. os.date("%H:%M %B %d, %Y", post.timestamp))
+ print("--------------------------------")
cat_file(post.filename)
+ print("--------------------------------")
end
function do_quit()