Add private messaging with /msg
authorShadowNinja <noreply@gmail.com>
Thu, 28 Mar 2013 01:37:09 +0000 (21:37 -0400)
committerPilzAdam <pilzadam@minetest.net>
Fri, 5 Apr 2013 13:25:59 +0000 (15:25 +0200)
builtin/chatcommands.lua

index 4b09f7b2bee3b44813e74af9afe6917d8abf5d21..9f14749f44db6e8c5205871b78071b23964b75b8 100644 (file)
@@ -665,3 +665,23 @@ minetest.register_chatcommand("clearobjects", {
                minetest.chat_send_all("*** Cleared all objects.")
        end,
 })
+
+minetest.register_chatcommand("msg", {
+       params = "<name> <message>",
+       description = "Send a private message",
+       privs = {shout=true},
+       func = function(name, param)
+               local found, _, sendto, message = param:find("^([^%s]+)%s(.+)$")
+               if found then
+                       if minetest.env:get_player_by_name(sendto) then
+                               minetest.log("action", "PM from "..name.." to "..sendto..": "..message)
+                               minetest.chat_send_player(sendto, "PM from "..name..": "..message)
+                               minetest.chat_send_player(name, "Message sent")
+                       else
+                               minetest.chat_send_player(name, "The player "..sendto.." is not online")
+                       end
+               else
+                       minetest.chat_send_player(name, "Invalid usage, see /help msg")
+               end
+       end,
+})