mirror of
https://github.com/minetest-mods/irc.git
synced 2024-12-28 09:40:17 +01:00
Fixed server crash on unknown bot command
This commit is contained in:
parent
83db0a739d
commit
026ca11b10
@ -136,6 +136,7 @@ add_custom_target(copy_files_mt_irc
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy src/callback.lua ${dir}
|
COMMAND ${CMAKE_COMMAND} -E copy src/callback.lua ${dir}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy src/friends.lua ${dir}
|
COMMAND ${CMAKE_COMMAND} -E copy src/friends.lua ${dir}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy src/chatcmds.lua ${dir}
|
COMMAND ${CMAKE_COMMAND} -E copy src/chatcmds.lua ${dir}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy src/botcmds.lua ${dir}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy README.txt ${dir}
|
COMMAND ${CMAKE_COMMAND} -E copy README.txt ${dir}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy doc/LICENSE.txt ${dir}
|
COMMAND ${CMAKE_COMMAND} -E copy doc/LICENSE.txt ${dir}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy doc/CHANGES.txt ${dir}
|
COMMAND ${CMAKE_COMMAND} -E copy doc/CHANGES.txt ${dir}
|
||||||
|
@ -27,48 +27,6 @@ irc.register_callback("channel_msg", function ( channel, from, message )
|
|||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
mt_irc.bot_commands = {
|
|
||||||
help = {
|
|
||||||
func = function ( from, args )
|
|
||||||
irc.say(from, "HELP:");
|
|
||||||
irc.say(from, ">username message");
|
|
||||||
irc.say(from, " Send private message <message> to <username>");
|
|
||||||
irc.say(from, "!who");
|
|
||||||
irc.say(from, " Return list of players currently in-game");
|
|
||||||
irc.say(from, "!help");
|
|
||||||
irc.say(from, " Show this help message");
|
|
||||||
end;
|
|
||||||
};
|
|
||||||
who = {
|
|
||||||
func = function ( from, args )
|
|
||||||
local s = "";
|
|
||||||
for k, v in pairs(mt_irc.connected_players) do
|
|
||||||
if (v) then
|
|
||||||
s = s.." "..k;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
irc.say(from, "Players On Channel:"..s);
|
|
||||||
end;
|
|
||||||
};
|
|
||||||
whereis = {
|
|
||||||
-- !whereis PLAYER
|
|
||||||
func = function ( from, args )
|
|
||||||
if (args == "") then
|
|
||||||
irc.say(from, "Usage: !whereis PLAYER");
|
|
||||||
return;
|
|
||||||
end
|
|
||||||
local list = minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 100000);
|
|
||||||
for _, obj in ipairs(list) do
|
|
||||||
if (obj:is_player() and (obj:get_player_name() == args)) then
|
|
||||||
local fmt = "Player %s is at (%.2f,%.2f,%.2f)";
|
|
||||||
local pos = obj:getpos();
|
|
||||||
irc.say(from, fmt:format(args, pos.x, pos.y, pos.z));
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
local function bot_command ( from, message )
|
local function bot_command ( from, message )
|
||||||
|
|
||||||
local pos = message:find(" ", 1, true);
|
local pos = message:find(" ", 1, true);
|
||||||
@ -83,6 +41,7 @@ local function bot_command ( from, message )
|
|||||||
|
|
||||||
if (not mt_irc.bot_commands[cmd]) then
|
if (not mt_irc.bot_commands[cmd]) then
|
||||||
irc.say(from, "Unknown command `"..cmd.."'. Try `!help'.");
|
irc.say(from, "Unknown command `"..cmd.."'. Try `!help'.");
|
||||||
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
mt_irc.bot_commands[cmd].func(from, args);
|
mt_irc.bot_commands[cmd].func(from, args);
|
||||||
|
@ -125,6 +125,7 @@ end
|
|||||||
|
|
||||||
dofile(MODPATH.."/callback.lua");
|
dofile(MODPATH.."/callback.lua");
|
||||||
dofile(MODPATH.."/chatcmds.lua");
|
dofile(MODPATH.."/chatcmds.lua");
|
||||||
|
dofile(MODPATH.."/botcmds.lua");
|
||||||
dofile(MODPATH.."/friends.lua");
|
dofile(MODPATH.."/friends.lua");
|
||||||
|
|
||||||
if (mt_irc.auto_connect) then
|
if (mt_irc.auto_connect) then
|
||||||
|
Loading…
Reference in New Issue
Block a user