cf:close()
end
+local function export_messages(handle, output_file_name)
+
+ local fh = assert(io.open(output_file_name, "w"))
+
+ for cnum,cname in ipairs(qb.conferences) do
+ msgs = {}
+ dofile(qb.path .. "/conferences/" .. cname .. ".msgs")
+ for i,msg in ipairs(msgs) do
+ if string.match(string.lower(msg.from), "^%s*" .. string.lower(handle) .. "%s*$") then
+ fh:write("MessageArea: " .. cname .. "\n")
+ fh:write("MessageNum: " .. msg.number .. "\n")
+ fh:write("From: " .. msg.from .. "\n")
+ fh:write("To: " .. msg.to .. "\n")
+ fh:write("Subject: " .. msg.subject .. "\n")
+ fh:write("Date: " .. msg.date .. "\n")
+ fh:write("Time: " .. msg.time .. "\n")
+ fh:write("---\n")
+ fh:write(msg.text .. "\n\n")
+ end
+ end
+ end
+end
--- QWK formatting ---
store_nncp_userdata()
else
+
local handle = nncp_userdata[node_id].handle
if not handle then
return false
end
- print("Accepting REP packet from user '" .. handle .. "'")
- -- Accept REP packet
+ if string.match(input_string, "^%s*export") then
+ -- Constructing text file for export
- local rep_file_name = os.tmpname()
- fs.rmfile(rep_file_name)
- local rep_file_name = rep_file_name .. ".rep"
+ local out_file_name = os.tmpname()
- local rf = assert(io.open(rep_file_name, "w"))
- rf:write(input_string)
- rf:close()
+ export_messages(handle, out_file_name)
- if qb.md5sum then
- -- Check for duplicate REP submissions
-
- local md5 = fs.getmd5(rep_file_name)
- local stored_md5 = nncp_userdata[node_id].md5
- if stored_md5 and md5 == stored_md5 then
- print("Error: Duplicate REP submission detected. Skipping.")
- return false
- end
+ print(qb.nncp_file .. " " .. out_file_name .. " " ..
+ node_id .. ":" .. qb.bbsid .. ".export.txt")
+ -- os.execute(qb.nncp_file .. " " .. out_file_name .. " " ..
+ -- node_id .. ":" .. qb.bbsid .. ".export.txt")
- nncp_userdata[node_id].md5 = md5
- store_nncp_userdata()
- end
+ fs.rmfile(out_file_name)
- qwk.import_rep(handle, rep_file_name)
+ else
+ print("Accepting REP packet from user '" .. handle .. "'")
+ -- Accept REP packet
+
+ local rep_file_name = os.tmpname()
+ fs.rmfile(rep_file_name)
+ local rep_file_name = rep_file_name .. ".rep"
+
+ local rf = assert(io.open(rep_file_name, "w"))
+ rf:write(input_string)
+ rf:close()
+
+ if qb.md5sum then
+ -- Check for duplicate REP submissions
+
+ local md5 = fs.getmd5(rep_file_name)
+ local stored_md5 = nncp_userdata[node_id].md5
+ if stored_md5 and md5 == stored_md5 then
+ print("Error: Duplicate REP submission detected. Skipping.")
+ return false
+ end
+
+ nncp_userdata[node_id].md5 = md5
+ store_nncp_userdata()
+ end
- fs.rmfile(rep_file_name)
+ qwk.import_rep(handle, rep_file_name)
+
+ fs.rmfile(rep_file_name)
+ end
end
end