1
0
mirror of https://github.com/minetest-mods/irc.git synced 2024-12-28 01:30:21 +01:00
irc/callback.lua

41 lines
989 B
Lua
Raw Normal View History

2013-04-30 00:07:44 +02:00
-- This file is licensed under the terms of the BSD 2-clause license.
-- See LICENSE.txt for details.
2013-01-08 16:50:47 +01:00
2013-04-30 00:07:44 +02:00
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
if irc.connected and irc.config.send_join_part then
irc:say("*** "..name.." joined the game")
2013-04-25 23:00:44 +02:00
end
2013-04-30 00:07:44 +02:00
end)
2013-04-30 00:07:44 +02:00
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
if irc.connected and irc.config.send_join_part then
irc:say("*** "..name.." left the game")
2013-04-25 23:00:44 +02:00
end
2013-04-30 00:07:44 +02:00
end)
2013-01-08 16:50:47 +01:00
2013-04-30 00:07:44 +02:00
minetest.register_on_chat_message(function(name, message)
if not irc.connected
2013-04-30 00:07:44 +02:00
or message:sub(1, 1) == "/"
or message:sub(1, 5) == "[off]"
or not irc.joined_players[name]
2013-04-30 00:07:44 +02:00
or (not minetest.check_player_privs(name, {shout=true})) then
return
2013-04-25 23:00:44 +02:00
end
2014-01-09 02:39:21 +01:00
local nl = message:find("\n", 1, true)
if nl then
message = message:sub(1, nl - 1)
end
irc:say(irc:playerMessage(name, message))
2013-04-30 00:07:44 +02:00
end)
2013-04-30 00:07:44 +02:00
minetest.register_on_shutdown(function()
irc:disconnect("Game shutting down.")
end)