From ad192c9983e9ddaa63194ab8115d979614c502aa Mon Sep 17 00:00:00 2001 From: plugd Date: Fri, 9 Aug 2024 12:56:13 +0200 Subject: [PATCH] Tidying UI. --- obbs | 69 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/obbs b/obbs index 4ff7187..086734c 100755 --- a/obbs +++ b/obbs @@ -17,7 +17,7 @@ local posix = require "posix" -local usage = [[Usage: obbs [-c config_file] COMMAND [arguments ...] +local usage = [[Usage: obbs [-c config_file] COMMAND arguments Here COMMAND is one of: newcfg @@ -243,11 +243,11 @@ function qwk.process_replies(archive_dir, obbs, user_name) end while mf:read(0) do - qwk.process_reply(mf, obbs) + qwk.process_reply(mf, obbs, user_name) end end -function qwk.process_reply(mf, obbs) +function qwk.process_reply(mf, obbs, user_name) local msg = {} mf:read(1) -- Message status (ignore for now) @@ -255,7 +255,8 @@ function qwk.process_reply(mf, obbs) msg.date = mf:read(8) msg.time = mf:read(5) msg.to = string.lower(string.gsub(mf:read(25), " ", "")) - msg.from = string.lower(string.gsub(mf:read(25), " ", "")) + mf:read(25) -- take user name from provided user name instead + msg.from = string.lower(string.sub(user_name, 1, 25)) msg.subject = string.gsub(mf:read(25), " ", "") mf:read(12) -- Password (unused) msg.replyto = tonumber(mf:read(8)) @@ -299,18 +300,18 @@ function cmd.newcfg () obbs.path = "." -- Path to OBBS root obbs.name = "My OBBS Name" -obbs.bbsid = "MYOBBSID" -- max 8 char +obbs.bbsid = "MYOBBSID" -- upper case, max 8 char obbs.sysop = "Sysop Name" --- obbs.hello_file = "hello" --- obbs.news_file = "news" --- obbs.goodbye_file = "goodbye" - obbs.conferences = { "Announcements", "General", "Meta" } + +-- Ensure these point to zip and unzip on your system +obbs.zip = "/usr/bin/zip" +obbs.unzip = "/usr/bin/unzip" ]] end @@ -319,7 +320,7 @@ function cmd.init () load_config() if fs.exists(obbs.path .. "/conferences") or - fs.exists(obbs.path .. "/outgoing") then + fs.exists(obbs.path .. "/notices") then print("One or more OBBS directories already exist. Aborting.") return false end @@ -330,19 +331,27 @@ function cmd.init () io.open(obbs.path .. "/conferences/" .. v .. ".next", "w"):write(1) end - fs.mkdir(obbs.path .. "/outgoing") + fs.mkdir(obbs.path .. "/notices") + fs.touch(obbs.path .. "/notices/hello") + fs.touch(obbs.path .. "/notices/news") + fs.touch(obbs.path .. "/notices/goodbye") end -- qwkout: generate QWK file function cmd.qwkout () load_config() - if not arg[1] then - print "Usage: obbs qwkout USER" + if not arg[2] then + print [[Usage: obbs qwkout USER OUTFILE + +Here OUTFILE is is the name of the output QWK file relative to +the current directory. The QWK file is traditionally named +BBSID.QWK, with BBSID being the 8 character ID of the BBS.]] return end local user_name = arg[1] + local qwk_filename = arg[2] local work_dir = fs.mktempdir() @@ -351,23 +360,9 @@ function cmd.qwkout () -- Copy BBS welcome, news and goodbye files - if obbs.hello and fs.exists(obbs.hello) then - fs.copy(obbs.hello, work_dir .. "/HELLO") - else - fs.touch(work_dir .. "/HELLO") - end - - if obbs.news and fs.exists(obbs.news) then - fs.copy(obbs.news, work_dir .. "/NEWS") - else - fs.touch(work_dir .. "/NEWS") - end - - if obbs.news and fs.exists(obbs.goodbye) then - fs.copy(obbs.goodbye, work_dir .. "/GOODBYE") - else - fs.touch(work_dir .. "/GOODBYE") - end + fs.copy(obbs.path .. "/notices/hello", work_dir .. "/HELLO") + fs.copy(obbs.path .. "/notices/news", work_dir .. "/NEWS") + fs.copy(obbs.path .. "/notices/goodbye", work_dir .. "/GOODBYE") -- Pack messages @@ -375,9 +370,9 @@ function cmd.qwkout () -- Create archive in outgoing - os.execute("zip -rj " .. obbs.path .. - "/outgoing/" .. obbs.bbsid .. - ".qwk " .. work_dir) + os.execute(obbs.zip .. " -rj " .. + obbs.path .. "/" .. qwk_filename .. + " " .. work_dir) fs.rmdir(work_dir, true) end @@ -388,7 +383,11 @@ function cmd.repin() load_config() if not arg[2] then - print "Usage: obbs repin FILE USER" + print [[Usage: obbs repin INFILE USER + +Here INFILE is the name of the REP file to import new messages +from. This is traditionally named BBSID.rep, where BBSID is +the 8 character max ID of the BBS, but obbs doesn't care about this.]] return end @@ -403,7 +402,7 @@ function cmd.repin() local work_dir = fs.mktempdir() fs.copy(rep_filename, work_dir .. "/repfile.rep") - os.execute("unzip " .. work_dir .. "/repfile.rep -d " .. work_dir) + os.execute(obbs.unzip .. " " .. work_dir .. "/repfile.rep -d " .. work_dir) qwk.process_replies(work_dir, obbs, user_name) -- 2.20.1