Add forward and send as to email
This commit is contained in:
parent
eb5b2514e6
commit
b9dfb1b5b0
1 changed files with 29 additions and 20 deletions
|
@ -2,6 +2,9 @@ email = {
|
||||||
log = function(msg) end
|
log = function(msg) end
|
||||||
}
|
}
|
||||||
local _loading = true
|
local _loading = true
|
||||||
|
local send_as = {}
|
||||||
|
local forward_to = {}
|
||||||
|
local storage = minetest.get_mod_storage()
|
||||||
|
|
||||||
if minetest.global_exists("chatplus") then
|
if minetest.global_exists("chatplus") then
|
||||||
email.log = chatplus.log
|
email.log = chatplus.log
|
||||||
|
@ -37,6 +40,9 @@ function email.load()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
forward_to = minetest.parse_json(storage:get_string("forward_to")) or {}
|
||||||
|
send_as = minetest.parse_json(storage:get_string("send_as")) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function email.save()
|
function email.save()
|
||||||
|
@ -164,29 +170,32 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
||||||
end]]--
|
end]]--
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function email.send_mail(name, to, msg)
|
function email.send_mail(aname, ato, msg)
|
||||||
minetest.log("Email - To: "..to..", From: "..name..", MSG: "..msg)
|
local name = send_as[aname] or aname
|
||||||
|
local to = forward_to[ato] or ato
|
||||||
|
|
||||||
|
minetest.log("action", "Email - To: "..to..", From: "..name..", MSG: "..msg)
|
||||||
email.log("Email - To: "..to..", From: "..name..", MSG: "..msg)
|
email.log("Email - To: "..to..", From: "..name..", MSG: "..msg)
|
||||||
if true then
|
if not minetest.player_exists(to) then
|
||||||
local mail = {
|
|
||||||
date = os.date("%Y-%m-%d %H:%M:%S"),
|
|
||||||
from = name,
|
|
||||||
msg = msg}
|
|
||||||
|
|
||||||
if email.inboxes[to] then
|
|
||||||
table.insert(email.inboxes[to], mail)
|
|
||||||
else
|
|
||||||
email.inboxes[to] = { mail }
|
|
||||||
end
|
|
||||||
|
|
||||||
email.save()
|
|
||||||
|
|
||||||
minetest.chat_send_player(to, "Mail from " .. name .. ": " .. msg)
|
|
||||||
|
|
||||||
return true, "Message sent to " .. to
|
|
||||||
else
|
|
||||||
return false, "Player '" .. to .. "' does not exist"
|
return false, "Player '" .. to .. "' does not exist"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local mail = {
|
||||||
|
date = os.date("%Y-%m-%d %H:%M:%S"),
|
||||||
|
from = name,
|
||||||
|
msg = msg}
|
||||||
|
|
||||||
|
if email.inboxes[to] then
|
||||||
|
table.insert(email.inboxes[to], mail)
|
||||||
|
else
|
||||||
|
email.inboxes[to] = { mail }
|
||||||
|
end
|
||||||
|
|
||||||
|
email.save()
|
||||||
|
|
||||||
|
minetest.chat_send_player(to, "Mail from " .. name .. ": " .. msg)
|
||||||
|
|
||||||
|
return true, "Message sent to " .. ato
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("inbox", {
|
minetest.register_chatcommand("inbox", {
|
||||||
|
|
Loading…
Reference in a new issue