summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2017-03-14 22:06:48 -0500
committercheapie <no-email-for-you@example.com>2017-03-14 22:07:03 -0500
commitef770c8c3256502f3d820331a8bf64379c6f3840 (patch)
treeea1f0f795798854d2696a2641c15eb4767cc7f06
downloadchat6-ef770c8c3256502f3d820331a8bf64379c6f3840.tar
chat6-ef770c8c3256502f3d820331a8bf64379c6f3840.tar.gz
chat6-ef770c8c3256502f3d820331a8bf64379c6f3840.tar.bz2
chat6-ef770c8c3256502f3d820331a8bf64379c6f3840.tar.xz
chat6-ef770c8c3256502f3d820331a8bf64379c6f3840.zip
Add content
-rw-r--r--LICENSE24
-rw-r--r--depends.txt1
-rw-r--r--init.lua87
3 files changed, 112 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/depends.txt b/depends.txt
new file mode 100644
index 0000000..20efb18
--- /dev/null
+++ b/depends.txt
@@ -0,0 +1 @@
+irc?
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..4b6cccf
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,87 @@
+local nick_colors = {
+ "#4E9A06", --19
+ "#CC0000", --20
+ "#5C3566", --22
+ "#C4A000", --24
+ "#73D216", --25
+ "#11A879", --26
+ "#58A19D", --27
+ "#57799E", --28
+ "#A04265", --29
+}
+
+local function get_nick_color(nick)
+ local color = 0
+ for i=1,string.len(nick),1 do
+ color = color + string.byte(string.sub(nick,i,i))
+ end
+ color = color % #nick_colors
+ return(nick_colors[color+1])
+end
+
+minetest.register_on_chat_message(function(fromname,msg)
+ local outgoingnick = minetest.setting_get("chat6.outgoing_nick_color") or "#CC0000"
+ local outgoingmsg = minetest.setting_get("chat6.outgoing_message_color") or "#CCCCCC"
+ local highlight = minetest.setting_get("chat6.highlight_color") or "#4E9A06"
+ local players = minetest.get_connected_players()
+ for _,player in pairs(players) do
+ local toname = player:get_player_name()
+ if toname == fromname then
+ local colorednick = minetest.colorize(outgoingnick,fromname)
+ local coloredmessage = minetest.colorize(outgoingmsg,msg)
+ minetest.chat_send_player(toname,string.format("<%s> %s",colorednick,coloredmessage))
+ elseif string.find(msg,toname) then
+ local colorednick = minetest.colorize(highlight,fromname)
+ local coloredmessage = minetest.colorize(highlight,msg)
+ minetest.chat_send_player(toname,string.format("<%s> %s",colorednick,coloredmessage))
+ else
+ local colorednick = minetest.colorize(get_nick_color(fromname),fromname)
+ minetest.chat_send_player(toname,string.format("<%s> %s",colorednick,msg))
+ end
+ end
+ return true
+end)
+
+minetest.override_chatcommand("me",{func=function(fromname,msg)
+ local outgoingnick = minetest.setting_get("chat6.outgoing_nick_color") or "#CC0000"
+ local outgoingmsg = minetest.setting_get("chat6.outgoing_message_color") or "#CCCCCC"
+ local highlight = minetest.setting_get("chat6.highlight_color") or "#4E9A06"
+ local players = minetest.get_connected_players()
+ for _,player in pairs(players) do
+ local toname = player:get_player_name()
+ if toname == fromname then
+ local colorednick = minetest.colorize(outgoingnick,fromname)
+ local coloredmessage = minetest.colorize(outgoingmsg,msg)
+ minetest.chat_send_player(toname,string.format("* %s %s",colorednick,coloredmessage))
+ elseif string.find(msg,toname) then
+ local colorednick = minetest.colorize(highlight,fromname)
+ local coloredmessage = minetest.colorize(highlight,msg)
+ minetest.chat_send_player(toname,string.format("* %s %s",colorednick,coloredmessage))
+ else
+ local colorednick = minetest.colorize(get_nick_color(fromname),fromname)
+ minetest.chat_send_player(toname,string.format("* %s %s",colorednick,msg))
+ end
+ end
+ if minetest.get_modpath("irc") then
+ irc:say(string.format("* %s %s",fromname,msg))
+ end
+ return true
+end})
+
+minetest.override_chatcommand("msg",{func=function(fromname,msg)
+ local highlight = minetest.setting_get("chat6.highlight_color") or "#4E9A06"
+ local toname, message = msg:match("^(%S+)%s(.+)$")
+ if (not toname) or (not msg) then
+ minetest.chat_send_player(fromname,minetest.colorize("#FF0000","Error")..": Player name or message missing")
+ return false
+ end
+ if not minetest.get_player_by_name(toname) then
+ minetest.chat_send_player(fromname,minetest.colorize("#FF0000","Error")..": Target player is not online")
+ return false
+ end
+ local colorednick = minetest.colorize(highlight,fromname)
+ local coloredmessage = minetest.colorize(highlight,message)
+ minetest.chat_send_player(fromname,"Message sent.")
+ minetest.chat_send_player(toname,string.format("PM from %s: %s",fromname,coloredmessage))
+ return true
+end})