aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2018-12-07 18:26:36 +0000
committerSolderpunk <solderpunk@sdf.org>2018-12-07 18:26:36 +0000
commitbb45599c1e7aa124f9ea3c2144ac689e104c1387 (patch)
treef30c30c870674e7576c50f343d753aabbbc9e9af
parentUse new BBS file spec. (diff)
Add reply support.
-rwxr-xr-xtelem.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/telem.lua b/telem.lua
index 794666a..593908a 100755
--- a/telem.lua
+++ b/telem.lua
@@ -1,9 +1,11 @@
#!/usr/bin/lua5.2
telemver = "0.3 // 2018-05-04"
+file = require("pl.file")
io = require("io")
-os = require("os")
lfs = require("lfs")
+os = require("os")
+path = require("pl.path")
string = require("string")
table = require("table")
@@ -12,6 +14,9 @@ bad_topics["."] = true
bad_topics[".."] = true
bad_topics["topic"] = true
+-- This is, obvviously, not secure and will need to be updated
+username = os.getenv("USER")
+
current_board = ""
current_thread_index = nil
@@ -163,12 +168,25 @@ function do_type_prev()
end
function do_type_reply()
+ filename = os.tmpname()
+ os.execute("$EDITOR " .. filename)
+ timestamp = tostring(os.time())
+ newfilename = timestamp .. "-" .. username
+ newpath = path.join(thread.directory, newfilename)
+ ret, str = file.move(filename, newpath)
+ if not ret then
+ print(str)
+ end
+ current_thread_posts = get_posts(thread)
+ current_thread_index = #current_thread_posts
+ do_type_show_post(current_thread_index)
end
type_dispatch = {}
type_dispatch["f"] = do_type_first
type_dispatch["n"] = do_type_next
type_dispatch["p"] = do_type_prev
+type_dispatch["r"] = do_type_reply
type_dispatch["d"] = function() return end
function do_type()
@@ -198,7 +216,7 @@ function do_type()
end
function show_type_prompt()
- io.write("type prompt ([f]irst, [n]ext, [p]rev, [d]one)>")
+ io.write("[f]irst, [n]ext, [p]rev, [r]eply, [d]one >")
end
function do_type_show_post(index)