Compare commits

...

5 Commits

Author SHA1 Message Date
Anand S b4fbccd64a Add support for configurable coloring of IRC messages in-game
IRC channel messages are colored green by default
IRC PMs are colored purple by default
2018-11-02 21:54:36 -07:00
D Tim Cummings c9c57a6f93 Avoid deprecation warnings.
* This change avoids 21 deprecation warnings in debug.txt on every server start

2018-05-29 23:46:10: WARNING[Main]: WARNING: minetest.setting_* functions are deprecated.  Use methods on the minetest.settings object.

* Provide backward compatibility by testing for existence of new methods before using them
2018-06-18 16:45:44 -03:00
texmex f57bdba5e9 Make username and realname configurable. 2017-06-14 19:55:28 -03:00
red-001 070eb51236 Remove minetest colour codes before sending messages to IRC. 2017-05-04 18:59:58 -03:00
Diego Martínez e80bbe3a62 Fix warning about deprecated call.
Fixes #39.
2017-05-02 21:52:44 -03:00
7 changed files with 31 additions and 14 deletions

View File

@ -51,7 +51,8 @@ function irc.bot_command(msg, text)
return
end
minetest.chat_send_player(player_to,
"PM from "..msg.user.nick.."@IRC: "..message, false)
minetest.colorize(irc.config.pm_color,
"PM from "..msg.user.nick.."@IRC: "..message, false))
irc.reply("Message sent!")
return
end

View File

@ -31,7 +31,7 @@ minetest.register_on_chat_message(function(name, message)
if nl then
message = message:sub(1, nl - 1)
end
irc.say(irc.playerMessage(name, message))
irc.say(irc.playerMessage(name, core.strip_colors(message)))
end)

View File

@ -6,12 +6,24 @@ irc.config = {}
local function setting(stype, name, default, required)
local value
if stype == "bool" then
value = minetest.setting_getbool("irc."..name)
elseif stype == "string" then
value = minetest.setting_get("irc."..name)
elseif stype == "number" then
value = tonumber(minetest.setting_get("irc."..name))
if minetest.settings and minetest.settings.get and minetest.settings.get_bool then
-- The current methods for getting settings
if stype == "bool" then
value = minetest.settings:get_bool("irc."..name)
elseif stype == "string" then
value = minetest.settings:get("irc."..name)
elseif stype == "number" then
value = tonumber(minetest.settings:get("irc."..name))
end
else
-- The old methods for getting settings for backward compatibility. Deprecated on 0.4.16+
if stype == "bool" then
value = minetest.setting_getbool("irc."..name)
elseif stype == "string" then
value = minetest.setting_get("irc."..name)
elseif stype == "number" then
value = tonumber(minetest.setting_get("irc."..name))
end
end
if value == nil then
if required then
@ -32,6 +44,8 @@ setting("string", "server", nil, true) -- Server address to connect to
setting("number", "port", 6667) -- Server port to connect to
setting("string", "NSPass") -- NickServ password
setting("string", "sasl.user", irc.config.nick) -- SASL username
setting("string", "username", "Minetest") -- Username/ident
setting("string", "realname", "Minetest") -- Real name/GECOS
setting("string", "sasl.pass") -- SASL password
setting("string", "channel", nil, true) -- Channel to join
setting("string", "key") -- Key for the channel
@ -51,4 +65,5 @@ setting("bool", "debug", false) -- Enable debug output
setting("bool", "enable_player_part", true) -- Whether to enable players joining and parting the channel
setting("bool", "auto_join", true) -- Whether to automatically show players in the channel when they join
setting("bool", "auto_connect", true) -- Whether to automatically connect to the server on mod load
setting("string", "chat_color", "#339933") -- Color of IRC chat in-game, green by default
setting("string", "pm_color", "#8800AA") -- Color of IRC PMs in-game, purple by default

View File

@ -101,7 +101,7 @@ end
function irc.hooks.channelChat(msg)
local text = normalize(msg.args[2])
irc:check_botcmd(msg)
irc.check_botcmd(msg)
-- Don't let a user impersonate someone else by using the nick "IRC"
local fake = msg.user.nick:lower():match("^[il|]rc$")

View File

@ -137,8 +137,8 @@ function irc.connect()
end
irc.conn = irc.lib.new({
nick = irc.config.nick,
username = "Minetest",
realname = "Minetest",
username = irc.config.username,
realname = irc.config.realname,
})
irc.doHook(irc.conn)

View File

@ -8,7 +8,7 @@ function irc.logChat(message)
end
function irc.sendLocal(message)
minetest.chat_send_all(message)
minetest.chat_send_all(minetest.colorize(irc.config.chat_color, message))
irc.logChat(message)
end

View File

@ -63,7 +63,8 @@ end)
function irc.sendLocal(message)
for name, _ in pairs(irc.joined_players) do
minetest.chat_send_player(name, message)
minetest.chat_send_player(name,
minetest.colorize(irc.config.chat_color, message))
end
irc.logChat(message)
end