irc2/callback.lua

42 lines
1.1 KiB
Lua
Raw Permalink Normal View History

2013-04-29 15:07:44 -07:00
-- This file is licensed under the terms of the BSD 2-clause license.
-- See LICENSE.txt for details.
2013-01-08 07:50:47 -08:00
2013-04-29 15:07:44 -07:00
minetest.register_on_joinplayer(function(player)
local name = player:get_player_name()
2019-07-24 18:53:22 -07:00
if irc2.connected and irc2.config.send_join_part then
irc2.say("*** "..name.." joined the game")
2013-04-25 14:00:44 -07:00
end
2013-04-29 15:07:44 -07:00
end)
minetest.register_on_leaveplayer(function(player, timed_out)
2013-04-29 15:07:44 -07:00
local name = player:get_player_name()
2019-07-24 18:53:22 -07:00
if irc2.connected and irc2.config.send_join_part then
irc2.say("*** "..name.." left the game"..
(timed_out and " (Timed out)" or ""))
2013-04-25 14:00:44 -07:00
end
2013-04-29 15:07:44 -07:00
end)
2013-01-08 07:50:47 -08:00
2013-04-29 15:07:44 -07:00
minetest.register_on_chat_message(function(name, message)
2019-07-24 18:53:22 -07:00
if not irc2.connected
2013-04-29 15:07:44 -07:00
or message:sub(1, 1) == "/"
or message:sub(1, 5) == "[off]"
2019-07-24 18:53:22 -07:00
or not irc2.joined_players[name]
2013-04-29 15:07:44 -07:00
or (not minetest.check_player_privs(name, {shout=true})) then
return
2013-04-25 14:00:44 -07:00
end
2014-01-08 17:39:21 -08:00
local nl = message:find("\n", 1, true)
if nl then
message = message:sub(1, nl - 1)
end
2020-08-20 12:25:28 -07:00
irc2.say(irc2.playerMessage(name, minetest.strip_colors(message)))
2013-04-29 15:07:44 -07:00
end)
2013-04-29 15:07:44 -07:00
minetest.register_on_shutdown(function()
2019-07-24 18:53:22 -07:00
irc2.disconnect("Game shutting down.")
end)