From 0c8538bfb85e20b184ffa888795a60a11b2579d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez?= Date: Sat, 3 Dec 2016 03:13:48 -0300 Subject: [PATCH] Fix issue with previous commit. Mea culpa. It was possible an error caused `require` to not be reset, causing possible errors in the future. --- init.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index d6d36f1..628f809 100644 --- a/init.lua +++ b/init.lua @@ -110,11 +110,13 @@ function irc:connect() realname = "Minetest", }) self:doHook(self.conn) + + -- We need to swap the `require` function again since + -- LuaIRC `require`s `ssl` if `irc.secure` is true. + local old_require = require + require = ie.require + local good, message = pcall(function() - -- We need to swap the `require` function again since - -- LuaIRC `require`s `ssl` if `irc.secure` is true. - local old_require = require - require = ie.require self.conn:connect({ host = self.config.server, port = self.config.port, @@ -123,9 +125,10 @@ function irc:connect() reconnect = self.config.reconnect, secure = self.config.secure }) - require = old_require end) + require = old_require + if not good then minetest.log("error", ("IRC: Connection error: %s: %s -- Reconnecting in %d seconds...") :format(self.config.server, message, self.config.reconnect))