mirror of
https://github.com/minetest-mods/irc.git
synced 2025-07-01 07:30:30 +02:00
Added basic API docs, implemented !uptime bot command, made quick fix to ignore lines starting with '/' and changed default auto* settings to true.
This commit is contained in:
@ -71,3 +71,21 @@ mt_irc.register_bot_command("whereis", {
|
||||
irc.say(from, "There's No player named `"..args.."'");
|
||||
end;
|
||||
});
|
||||
|
||||
local starttime = os.time();
|
||||
|
||||
mt_irc.register_bot_command("uptime", {
|
||||
params = "";
|
||||
description = "Tell how much time the server has been up";
|
||||
privs = { shout=true; };
|
||||
func = function ( name, param )
|
||||
local t = os.time();
|
||||
local diff = os.difftime(t, starttime);
|
||||
local fmt = "Server has been running for %d:%02d:%02d";
|
||||
irc.say(name, fmt:format(
|
||||
math.floor(diff / 60 / 60),
|
||||
math.mod(math.floor(diff / 60), 60),
|
||||
math.mod(math.floor(diff), 60)
|
||||
));
|
||||
end;
|
||||
});
|
||||
|
@ -93,8 +93,9 @@ minetest.register_on_leaveplayer(function ( player )
|
||||
end);
|
||||
|
||||
minetest.register_on_chat_message(function ( name, message )
|
||||
if (message:sub(1, 1) == "/") then return; end
|
||||
if (not mt_irc.connected_players[name]) then
|
||||
minetest.chat_send_player(name, "IRC: You are not connected. Please use /join");
|
||||
--minetest.chat_send_player(name, "IRC: You are not connected. Please use /join");
|
||||
return;
|
||||
end
|
||||
if (not mt_irc.connect_ok) then return; end
|
||||
@ -106,3 +107,7 @@ minetest.register_on_chat_message(function ( name, message )
|
||||
message = message;
|
||||
};
|
||||
end);
|
||||
|
||||
minetest.register_on_shutdown(function ( )
|
||||
irc.quit("Game shutting down.");
|
||||
end);
|
||||
|
@ -108,12 +108,3 @@ minetest.register_chatcommand("who", {
|
||||
minetest.chat_send_player(name, "Players On Channel:"..s);
|
||||
end;
|
||||
});
|
||||
|
||||
minetest.register_chatcommand("uptime", {
|
||||
params = "";
|
||||
description = "Tell how much time the server has been up";
|
||||
privs = { shout=true; };
|
||||
func = function ( name, param )
|
||||
local t = os.time();
|
||||
end;
|
||||
});
|
||||
|
@ -40,11 +40,9 @@ mt_irc.message_format_in = "<$(name)@IRC> $(message)";
|
||||
mt_irc.debug = true;
|
||||
|
||||
-- Whether to automatically join the channed when player joins
|
||||
-- (boolean, default false)
|
||||
-- For now leave this false if using autoconnect. Bot will join channel when first user
|
||||
-- types the /join command in game.
|
||||
mt_irc.auto_join = false;
|
||||
-- (boolean, default true)
|
||||
mt_irc.auto_join = true;
|
||||
|
||||
-- Whether to automatically connect to the server on mod load
|
||||
-- (boolean, default false)
|
||||
mt_irc.auto_connect = false;
|
||||
-- (boolean, default true)
|
||||
mt_irc.auto_connect = true;
|
||||
|
Reference in New Issue
Block a user