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.
|
2012-12-22 04:16:28 +01:00
|
|
|
|
2013-04-30 00:07:44 +02:00
|
|
|
-- Note: This file does NOT conatin every chat command, only general ones.
|
|
|
|
-- Feature-specific commands (like /join) are in their own files.
|
2013-01-08 16:50:47 +01:00
|
|
|
|
|
|
|
|
2013-04-20 20:45:11 +02:00
|
|
|
minetest.register_chatcommand("irc_msg", {
|
2013-04-30 00:07:44 +02:00
|
|
|
params = "<name> <message>",
|
|
|
|
description = "Send a private message to an IRC user",
|
|
|
|
privs = {shout=true},
|
|
|
|
func = function(name, param)
|
|
|
|
if not mt_irc.connected then
|
|
|
|
minetest.chat_send_player(name, "Not connected to IRC. Use /irc_connect to connect.")
|
|
|
|
return
|
2013-04-25 23:00:44 +02:00
|
|
|
end
|
2013-04-30 00:07:44 +02:00
|
|
|
local found, _, toname, message = param:find("^([^%s]+)%s(.+)")
|
2013-04-25 23:00:44 +02:00
|
|
|
if not found then
|
2013-04-30 00:07:44 +02:00
|
|
|
minetest.chat_send_player(name, "Invalid usage, see /help irc_msg.")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local validNick = false
|
|
|
|
for nick, user in pairs(mt_irc.conn.channels[mt_irc.config.channel].users) do
|
|
|
|
if nick:lower() == toname:lower() then
|
|
|
|
validNick = true
|
|
|
|
break
|
|
|
|
end
|
2013-04-25 23:00:44 +02:00
|
|
|
end
|
2013-04-30 00:07:44 +02:00
|
|
|
if toname:find("Serv|Bot") then
|
|
|
|
validNick = false
|
|
|
|
end
|
|
|
|
if not validNick then
|
|
|
|
minetest.chat_send_player(name,
|
|
|
|
"You can not message that user. (Hint: They have to be in the channel)")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
mt_irc:queueMsg(mt_irc.msgs.playerMessage(toname, name, message))
|
2013-04-25 23:00:44 +02:00
|
|
|
minetest.chat_send_player(name, "Message sent!")
|
2013-04-30 00:07:44 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2012-12-22 04:16:28 +01:00
|
|
|
|
|
|
|
minetest.register_chatcommand("irc_connect", {
|
2013-04-30 00:07:44 +02:00
|
|
|
description = "Connect to the IRC server.",
|
|
|
|
privs = {irc_admin=true},
|
|
|
|
func = function(name, param)
|
|
|
|
if mt_irc.connected then
|
|
|
|
minetest.chat_send_player(name, "You are already connected to IRC.")
|
|
|
|
return
|
2013-04-25 23:00:44 +02:00
|
|
|
end
|
2013-04-30 00:07:44 +02:00
|
|
|
minetest.chat_send_player(name, "IRC: Connecting...")
|
|
|
|
mt_irc:connect()
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2012-12-22 04:16:28 +01:00
|
|
|
|
2012-12-31 16:53:01 +01:00
|
|
|
minetest.register_chatcommand("irc_disconnect", {
|
2013-04-30 00:07:44 +02:00
|
|
|
description = "Disconnect from the IRC server.",
|
|
|
|
privs = {irc_admin=true},
|
|
|
|
func = function(name, param)
|
|
|
|
if not mt_irc.connected then
|
|
|
|
minetest.chat_send_player(name, "You are not connected to IRC.")
|
|
|
|
return
|
2013-04-25 23:00:44 +02:00
|
|
|
end
|
2013-04-30 00:07:44 +02:00
|
|
|
mt_irc:disconnect("Manual disconnect.")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2012-12-31 16:53:01 +01:00
|
|
|
|
|
|
|
minetest.register_chatcommand("irc_reconnect", {
|
2013-04-30 00:07:44 +02:00
|
|
|
description = "Reconnect to the IRC server.",
|
|
|
|
privs = {irc_admin=true},
|
|
|
|
func = function(name, param)
|
|
|
|
if not mt_irc.connected then
|
|
|
|
minetest.chat_send_player(name, "You are not connected to IRC.")
|
|
|
|
return
|
2013-04-25 23:00:44 +02:00
|
|
|
end
|
2013-04-30 00:07:44 +02:00
|
|
|
mt_irc:disconnect("Reconnecting...")
|
|
|
|
mt_irc:connect()
|
|
|
|
end
|
|
|
|
})
|
2012-12-22 04:16:28 +01:00
|
|
|
|
|
|
|
|
2013-04-30 00:07:44 +02:00
|
|
|
minetest.register_chatcommand("irc_quote", {
|
|
|
|
params = "<command>",
|
|
|
|
description = "Send a raw command to the IRC server.",
|
|
|
|
privs = {irc_admin=true},
|
2012-12-22 04:16:28 +01:00
|
|
|
func = function(name, param)
|
2013-04-30 00:07:44 +02:00
|
|
|
if not mt_irc.connected then
|
|
|
|
minetest.chat_send_player(name, "You are not connected to IRC.")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
mt_irc:queueMsg(param)
|
|
|
|
minetest.chat_send_player(name, "Command sent!")
|
|
|
|
end
|
2012-12-22 04:16:28 +01:00
|
|
|
})
|
2012-12-27 02:29:22 +01:00
|
|
|
|
2013-04-30 00:07:44 +02:00
|
|
|
|
|
|
|
local oldme = minetest.chatcommands["me"].func
|
|
|
|
minetest.chatcommands["me"].func = function(name, param)
|
|
|
|
oldme(name, param)
|
|
|
|
mt_irc:say(("* %s %s"):format(name, param))
|
|
|
|
end
|
|
|
|
|