minetest-mods / irc

IRC Mod for Minetest
BSD 2-Clause "Simplified" License
43 stars 31 forks source link

IRC should override `minetest.send_join/leave_message` #72

Open magnetar47 opened 1 year ago

magnetar47 commented 1 year ago

Hello. We have a mod in CTF that over-rides minetest.send_join/leave_message to hide the join and leave messages of a certain group of players. While that works for in-game messages, IRC bypasses the aforementioned functions and directly outputs the message to the channel (if set to send join/leave messages). So mods don't have the opportunity to suppress join/leave messages for select players, and other such use-cases.

I was wondering if IRC could instead override minetest.send_join/leave_message like so:

local old_join_func = minetest.send_join_message
function minetest.send_join_message(player_name, ...)
    // Announce player join on IRC channel
    irc.say("*** "..name.." joined the game")

    return old_join_func(player_name, ...)
end

So then I can do:

local old_join_func - minetest.send_join_message
function minetest.send_join_message(pname, ...)
    -- Skip join message if player matches super special criteria
    if not super_special_criteria(pname) then
        return old_join_func(pname, ...)
    end
end

Thoughts and discussion welcome. I'd be willing to implement this if people think this is a good idea.