1
0
mirror of https://github.com/minetest-mods/irc.git synced 2024-12-27 01:10:17 +01:00

Move some code from init.lua to config.lua

This commit is contained in:
ShadowNinja 2013-04-20 14:03:34 -04:00
parent 842306f109
commit c36e9d9f10
2 changed files with 19 additions and 28 deletions

View File

@ -15,26 +15,26 @@
-- *************************
-- Server to connect on joinplayer (string, default "irc.freenode.net")
mt_irc.server = minetest.setting_get("mt_irc.server");
mt_irc.server = minetest.setting_get("mt_irc.server") or "irc.freenode.net";
-- Port to connect on joinplayer (number, default 6667)
mt_irc.port = tonumber(minetest.setting_get("mt_irc.port"));
mt_irc.port = tonumber(minetest.setting_get("mt_irc.port")) or 6667;
-- Channel to connect on joinplayer (string, default "##mt-irc-mod")
mt_irc.channel = minetest.setting_get("mt_irc.channel");
mt_irc.channel = minetest.setting_get("mt_irc.channel") or "##mt-irc-mod";
-- ***********************
-- ** ADVANCED SETTINGS **
-- ***********************
-- Time between chat updates in seconds (number, default 0.2).
mt_irc.dtime = tonumber(minetest.setting_get("mt_irc.dtime"));
mt_irc.dtime = tonumber(minetest.setting_get("mt_irc.dtime")) or 0.2;
-- Underlying socket timeout in seconds (number, default 1.0).
mt_irc.timeout = tonumber(minetest.setting_get("mt_irc.timeout"));
-- Underlying socket timeout in seconds (number, default 60.0).
mt_irc.timeout = tonumber(minetest.setting_get("mt_irc.timeout")) or 60.0;
-- Nickname when using single conection (string, default "minetest-"..<server-id>);
-- (<server-id> is the server IP address packed as a 32 bit integer).
-- (<server-id> is a random string of 6 hexidecimal numbers).
mt_irc.server_nick = minetest.setting_get("mt_irc.server_nick");
-- Password to use when using single connection (string, default "")
@ -58,3 +58,15 @@ mt_irc.auto_join = not minetest.setting_getbool("mt_irc.disable_auto_join");
-- Whether to automatically connect to the server on mod load
-- (boolean, default true)
mt_irc.auto_connect = not minetest.setting_getbool("mt_irc.disable_auto_connect");
-- Set default server nick if not specified.
if (not mt_irc.server_nick) then
local pr = PseudoRandom(os.time());
-- Workaround for bad distribution in minetest PRNG implementation.
local fmt = "minetest-%02X%02X%02X";
mt_irc.server_nick = fmt:format(
pr:next(0, 255),
pr:next(0, 255),
pr:next(0, 255)
);
end

View File

@ -29,27 +29,6 @@ local irc = require 'irc';
irc.DEBUG = ((mt_irc.debug and true) or false);
-- Set defaults if not specified.
if (not mt_irc.server_nick) then
local pr = PseudoRandom(os.time());
-- Workaround for bad distribution in minetest PRNG implementation.
local fmt = "minetest-%02X%02X%02X";
mt_irc.server_nick = fmt:format(
pr:next(0, 255),
pr:next(0, 255),
pr:next(0, 255)
);
end
mt_irc.server = (mt_irc.server or "irc.freenode.net");
mt_irc.port = (mt_irc.port or 6667);
mt_irc.channel = (mt_irc.channel or "##mt-irc-mod");
mt_irc.dtime = (mt_irc.dtime or 0.2);
mt_irc.timeout = (mt_irc.timeout or 60.0);
mt_irc.message_format_out = (mt_irc.message_format_out or "<$(nick)> $(message)");
mt_irc.message_format_in = (mt_irc.message_format_in or "<$(name)@IRC[$(channel)]> $(message)");
if (mt_irc.connect_on_join == nil) then mt_irc.connect_on_join = false; end
if (mt_irc.connect_on_load == nil) then mt_irc.connect_on_load = false; end
minetest.register_privilege("irc_admin", {
description = "Allow IRC administrative tasks to be performed.";
give_to_singleplayer = true;