From 8f7c520067d4555b599014b5e8b9283d91ff9bc0 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 7 Dec 2015 22:51:27 +0000 Subject: [PATCH] Add chatplus.send_mail --- mods/chatplus/init.lua | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/mods/chatplus/init.lua b/mods/chatplus/init.lua index c841b31..15df456 100644 --- a/mods/chatplus/init.lua +++ b/mods/chatplus/init.lua @@ -303,9 +303,23 @@ minetest.register_chatcommand("inbox", { else chatplus.showInbox(name,false) end - end, + end }) +function chatplus.send_mail(name, to, msg) + minetest.log("To: "..to..", From: "..name..", MSG: "..msg) + if chatplus.log_handle ~= nil then + chatplus.log("To: "..to..", From: "..name..", MSG: "..msg) + end + if chatplus.players[to] then + table.insert(chatplus.players[to].inbox,os.date("%d/%m").." <"..name..">: "..msg) + minetest.chat_send_player(name,"Message sent") + chatplus.save() + else + minetest.chat_send_player(name,"Player "..to.." does not exist") + end +end + minetest.register_chatcommand("mail", { params = "name msg", description = "mail: add a message to a player's inbox", @@ -318,17 +332,7 @@ minetest.register_chatcommand("mail", { return end - minetest.log("To: "..to..", From: "..name..", MSG: "..msg) - if chatplus.log_handle ~= nil then - chatplus.log("To: "..to..", From: "..name..", MSG: "..msg) - end - if chatplus.players[to] then - table.insert(chatplus.players[to].inbox,os.date("%d/%m").." <"..name..">: "..msg) - minetest.chat_send_player(name,"Message sent") - chatplus.save() - else - minetest.chat_send_player(name,"Player "..to.." does not exist") - end + chatplus.send_mail(name, to, msg) end, })