Add some logging to the telex mod.

This commit is contained in:
Auke Kok 2019-07-31 17:41:04 -07:00
parent 72818051e4
commit 89e86ba692
2 changed files with 9 additions and 5 deletions

View File

@ -137,12 +137,14 @@ function telex.deliver(message)
pmeta:set_string("telex_mbox", telex.encode(mbox))
minetest.chat_send_player(message.to, "You have a new message from <" ..
message.from .. ">, use a terminal to read your messages");
minetest.log("action", "delivered a message from <" .. message.from .. "> back to <" .. message.to .. ">")
else
-- append to spool
message.age = 3 * 86400 -- 3 days max in spool
local spool = telex.decode(S:get_string("telex_spool"))
table.insert(spool, message)
S:set_string("telex_spool", telex.encode(spool))
minetest.log("action", "spooled a message from <" .. message.from .. "> back to <" .. message.to .. ">")
end
end
@ -150,6 +152,7 @@ end
function telex.retour(message)
if message.from == "MAILER-DEAMON" then
-- discard, we tried hard enough!
minetest.log("action", "discarded an expired spool message from <" .. message.from .. "> back to <" .. message.to .. ">")
return
end
@ -162,6 +165,7 @@ function telex.retour(message)
table.insert(message.content, 1, "Your message to <" .. to .. "> was unable to be delivered.")
table.insert(message.content, 2, "================== ORIGINAL MESSAGE BELOW ================")
telex.deliver(message)
minetest.log("action", "returned a message from <" .. from .. "> back to <" .. to .. ">")
end
-- returns message/mbox

View File

@ -55,17 +55,17 @@ term.help = {
unlock = "unlocks the terminal",
write = "write text to a file",
edit = "edits a file in an editor",
telex = "run the telex command"
telex = "run the telex command - send and receive messages"
}
term.telex_help = {
help = "display help information for subcommands",
list = "list received telex messages",
draft = "create a new telex message",
draft = "create a new, or edit an outgoing telex message",
discard = "discard the current telex draft message",
send = "send the current draft telex message",
remove = "remove a telex message by number",
read = "read a telex message by number"
send = "send the current draft telex message to a recipient",
remove = "remove a received telex message by number",
read = "read a received telex message by number"
}
local function make_formspec(output, prompt)