compat with mail mod fork (mt-mods)

master
Freeman 11 months ago
parent 6fcdccc578
commit 514b0bcd5a

@ -567,62 +567,30 @@ local function alert_owner_if_empty(pos)
local stock_msg = "Your vendor trading "..settings.input_item_qty.." "..minetest.registered_items[settings.input_item].description.." for "..settings.output_item_qty.." "..minetest.registered_items[settings.output_item].description.." at position "..minetest.pos_to_string(pos, 0).." has just run out of stock."
if not alerted and not status and errorcode == "no_output" then
-- Rubenwardy's Email Mod: https://github.com/rubenwardy/email
if mail_loaded then
local inbox = {}
-- load messages
if not mail.apiversion then
-- cheapie's mail mod https://cheapiesystems.com/git/mail/
if not mail.messages[owner] then mail.messages[owner] = {} end
inbox = mail.messages[owner]
elseif mail.apiversion >= 1.1 then
-- webmail fork https://github.com/thomasrudin-mt/mail (per player storage)
inbox = mail.getMessages(owner)
end
-- Instead of filling their inbox with mail, get the last message sent by "Fancy Vend" and append to the message
-- If there is no last message, then create a new one
local message
for i, msg in pairs(inbox) do
if msg.sender == "Fancy Vend" then -- Put a space in the name to avoid impersonation
message = msg
end
end
if message then
-- Set the message as unread
message.unread = true
-- Append to the end
message.body = message.body..stock_msg.."\n"
else
mail.send("Fancy Vend", owner, "You have unstocked vendors!", stock_msg.."\n")
end
-- save messages
if not mail.apiversion then
-- cheapie's mail mod https://cheapiesystems.com/git/mail/
mail.save()
elseif mail.apiversion >= 1.1 then
-- webmail fork https://github.com/thomasrudin-mt/mail
mail.setMessages(owner, inbox)
end
meta:set_string("alerted", "true")
return
elseif email_loaded then
email.send_mail("Fancy Vend", owner, stock_msg)
meta:set_string("alerted", "true")
if mail_loaded and mail.send then
local success, error = mail.send({
from = "Emerald Shop",
to = owner,
--cc = "carbon, copy",
--bcc = "blind, carbon, copy",
subject = S("Out of Stock!"),
body = stock_msg
})
-- if "success" is false the error parameter will contain a message
meta:set_string("alerted", "true")
return
-- Rubenwardy's Email Mod: https://github.com/rubenwardy/email
elseif email_loaded then
email.send_mail("Fancy Vend", owner, stock_msg)
meta:set_string("alerted", "true")
return
elseif tell_loaded then

Loading…
Cancel
Save