irc/src/chatcmds.lua

73 lines
2.1 KiB
Lua
Raw Normal View History

2012-12-22 04:16:28 +01:00
minetest.register_chatcommand("msg", {
params = "<name> <message>";
description = "Send a private message to an IRC user";
privs = { shout=true; };
func = function ( name, param )
if (not mt_irc.connect_ok) then
minetest.chat_send_player(name, "IRC: You are not connected use /irc_connect.");
return;
end
local pos = param:find(" ", 1, true);
if (not pos) then return; end
local name = param:sub(1, pos - 1);
local msg = param:sub(pos + 1);
local t = {
name=name;
message=msg;
};
local text = mt_irc.message_format_out:gsub("%$%(([^)]+)%)", t)
irc.send("PRIVMSG", name, text);
end;
});
minetest.register_chatcommand("irc_connect", {
params = "";
description = "Connect to the IRC server";
privs = { irc_admin=true; };
func = function ( name, param )
if (mt_irc.connect_ok) then
minetest.chat_send_player(name, "IRC: You are already connected.");
return;
end
mt_irc.connect_ok = pcall(irc.connect, {
network = mt_irc.server;
port = mt_irc.port;
nick = mt_irc.server_nick;
pass = mt_irc.password;
timeout = mt_irc.timeout;
channel = mt_irc.channel;
});
minetest.chat_send_player(name, "IRC: You are now connected.");
irc.say(mt_irc.channel, name.." joined the channel.");
end;
});
minetest.register_chatcommand("join", {
params = "";
description = "Join the IRC channel";
privs = { shout=true; };
func = function ( name, param )
mt_irc.join(name);
end;
});
minetest.register_chatcommand("part", {
params = "";
description = "Part the IRC channel";
privs = { shout=true; };
func = function ( name, param )
mt_irc.part(name);
end;
});
minetest.register_chatcommand("me", {
params = "<action>";
description = "chat action (eg. /me orders a pizza)";
privs = { shout=true };
func = function(name, param)
2012-12-22 21:22:45 +01:00
minetest.chat_send_all("* "..name.." "..param);
irc.say(mt_irc.channel, "* "..name.." "..param);
2012-12-22 04:16:28 +01:00
end,
})