1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-16 07:20:31 +01:00
server-nalc/mods/irc/player_part.lua

70 lines
1.6 KiB
Lua
Raw Normal View History

2014-10-28 18:01:32 +01:00
-- This file is licensed under the terms of the BSD 2-clause license.
-- See LICENSE.txt for details.
function irc:player_part(name)
if not self.joined_players[name] then
minetest.chat_send_player(name, "IRC: You are not in the channel.")
return
end
self.joined_players[name] = nil
minetest.chat_send_player(name, "IRC: You are now out of the channel.")
end
2015-06-10 17:14:58 +02:00
2014-10-28 18:01:32 +01:00
function irc:player_join(name)
if self.joined_players[name] then
minetest.chat_send_player(name, "IRC: You are already in the channel.")
return
end
self.joined_players[name] = true
minetest.chat_send_player(name, "IRC: You are now in the channel.")
end
minetest.register_chatcommand("join", {
description = "Join the IRC channel",
privs = {shout=true},
func = function(name, param)
irc:player_join(name)
end
})
2015-06-10 17:14:58 +02:00
2014-10-28 18:01:32 +01:00
minetest.register_chatcommand("part", {
description = "Part the IRC channel",
privs = {shout=true},
func = function(name, param)
irc:player_part(name)
end
})
2015-06-10 17:14:58 +02:00
2014-10-28 18:01:32 +01:00
minetest.register_chatcommand("who", {
description = "Tell who is currently on the channel",
privs = {},
func = function(name, param)
local s = ""
for name, _ in pairs(irc.joined_players) do
s = s..", "..name
end
minetest.chat_send_player(name, "Players On Channel:"..s)
end
})
2015-06-10 17:14:58 +02:00
2014-10-28 18:01:32 +01:00
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
irc.joined_players[name] = irc.config.auto_join
end)
2015-06-10 17:14:58 +02:00
2014-10-28 18:01:32 +01:00
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
irc.joined_players[name] = nil
end)
function irc:sendLocal(message)
for name, _ in pairs(self.joined_players) do
minetest.chat_send_player(name, message)
end
end