mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-11 18:40:25 +01:00
Add an IRC mod wich works... (very rare, like Mithril...)
This commit is contained in:
parent
8c637bac28
commit
43faf2b5bc
Binary file not shown.
@ -1,28 +1,12 @@
|
|||||||
-- This file is licensed under the terms of the BSD 2-clause license.
|
-- This file is licensed under the terms of the BSD 2-clause license.
|
||||||
-- See LICENSE.txt for details.
|
-- See LICENSE.txt for details.
|
||||||
|
|
||||||
local ie = ...
|
|
||||||
|
|
||||||
-- MIME is part of LuaSocket
|
-- MIME is part of LuaSocket
|
||||||
local b64e = ie.require("mime").b64
|
local b64e = require("mime").b64
|
||||||
|
|
||||||
irc.hooks = {}
|
irc.hooks = {}
|
||||||
irc.registered_hooks = {}
|
irc.registered_hooks = {}
|
||||||
|
|
||||||
local accent_chars = { {"À", "A"},{"Á", "A"},{"Â", "A"},{"Ã", "A"},{"Ä", "A"},{"Å", "A"},{"Ç", "C"},{"È", "E"},{"É", "E"},{"Ê", "E"},
|
|
||||||
{"Ë", "E"},{"<EFBFBD>", "I"},{"Í", "I"},{"<EFBFBD>", "I"},{"Ï", "I"},{"Ñ", "N"},{"Ò", "O"},{"Ó", "O"},{"Ô", "O"},{"Õ", "O"},
|
|
||||||
{"Ö", "O"},{"<EFBFBD>", "O"},{"Ù", "U"},{"Ú", "U"},{"Û", "U"},{"Ü", "U"},{"<EFBFBD>", "Y"},{"à", "a"},{"á", "a"},{"â", "a"},
|
|
||||||
{"ã", "a"},{"ä", "a"},{"å", "a"},{"ç", "c"},{"è", "e"},{"é", "e"},{"ê", "e"},{"ë", "e"},{"ì", "i"},{"í", "i"},
|
|
||||||
{"î", "i"},{"ï", "i"},{"ñ", "n"},{"ò", "o"},{"ó", "o"},{"ô", "o"},{"õ", "o"},{"ö", "o"},{"<EFBFBD>", "o"},{"ù", "u"},
|
|
||||||
{"ú", "u"},{"û", "u"},{"ü", "u"},{"<EFBFBD>", "Y"}
|
|
||||||
}
|
|
||||||
|
|
||||||
local function subaccent(text)
|
|
||||||
for _, c in pairs(accent_chars) do
|
|
||||||
text = text:gsub(c[1], c[2])
|
|
||||||
end
|
|
||||||
return text
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO: Add proper conversion from CP1252 to UTF-8.
|
-- TODO: Add proper conversion from CP1252 to UTF-8.
|
||||||
local stripped_chars = {"\2", "\31"}
|
local stripped_chars = {"\2", "\31"}
|
||||||
@ -34,7 +18,7 @@ stripped_chars = "["..table.concat(stripped_chars, "").."]"
|
|||||||
local function normalize(text)
|
local function normalize(text)
|
||||||
-- Strip colors
|
-- Strip colors
|
||||||
text = text:gsub("\3[0-9][0-9,]*", "")
|
text = text:gsub("\3[0-9][0-9,]*", "")
|
||||||
text = subaccent(text)
|
|
||||||
return text:gsub(stripped_chars, "")
|
return text:gsub(stripped_chars, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -254,7 +238,7 @@ function irc.hooks.preregister(conn)
|
|||||||
conn:send("CAP REQ sasl")
|
conn:send("CAP REQ sasl")
|
||||||
conn:send("AUTHENTICATE PLAIN")
|
conn:send("AUTHENTICATE PLAIN")
|
||||||
conn:send("AUTHENTICATE "..authString)
|
conn:send("AUTHENTICATE "..authString)
|
||||||
conn:send("CAP END")
|
--LuaIRC will send CAP END
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,40 +3,25 @@
|
|||||||
|
|
||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
-- Handle mod security if needed
|
package.path =
|
||||||
local ie, req_ie = _G, minetest.request_insecure_environment
|
|
||||||
if req_ie then ie = req_ie() end
|
|
||||||
if not ie then
|
|
||||||
error("The IRC mod requires access to insecure functions in order "..
|
|
||||||
"to work. Please add the irc mod to your secure.trusted_mods "..
|
|
||||||
"setting or disable the irc mod.")
|
|
||||||
end
|
|
||||||
|
|
||||||
ie.package.path =
|
|
||||||
-- To find LuaIRC's init.lua
|
-- To find LuaIRC's init.lua
|
||||||
modpath.."/?/init.lua;"
|
modpath.."/?/init.lua;"
|
||||||
-- For LuaIRC to find its files
|
-- For LuaIRC to find its files
|
||||||
..modpath.."/?.lua;"
|
..modpath.."/?.lua;"
|
||||||
..ie.package.path
|
..package.path
|
||||||
..";/usr/lib/*/lua/5.1/socket/*.so"
|
|
||||||
|
|
||||||
-- The build of Lua that Minetest comes with only looks for libraries under
|
-- The build of Lua that Minetest comes with only looks for libraries under
|
||||||
-- /usr/local/share and /usr/local/lib but LuaSocket is often installed under
|
-- /usr/local/share and /usr/local/lib but LuaSocket is often installed under
|
||||||
-- /usr/share and /usr/lib.
|
-- /usr/share and /usr/lib.
|
||||||
if not rawget(_G, "jit") and package.config:sub(1, 1) == "/" then
|
if not rawget(_G,"jit") and package.config:sub(1, 1) == "/" then
|
||||||
ie.package.path = ie.package.path..
|
package.path = package.path..
|
||||||
";/usr/share/lua/5.1/?.lua"..
|
";/usr/share/lua/5.1/?.lua"..
|
||||||
";/usr/share/lua/5.1/?/init.lua"
|
";/usr/share/lua/5.1/?/init.lua"
|
||||||
ie.package.path = ie.package.path..
|
package.cpath = package.cpath..
|
||||||
";/usr/lib/lua/5.1/?.so"
|
-- ";/usr/lib/lua/5.1/?.so"
|
||||||
|
";/usr/lib/x86_64-linux-gnu/lua/5.1/?.so"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Temporarily set require so that LuaIRC can access it
|
|
||||||
local old_require = require
|
|
||||||
require = ie.require
|
|
||||||
local lib = ie.require("irc")
|
|
||||||
require = old_require
|
|
||||||
|
|
||||||
irc = {
|
irc = {
|
||||||
version = "0.2.0",
|
version = "0.2.0",
|
||||||
connected = false,
|
connected = false,
|
||||||
@ -45,7 +30,7 @@ irc = {
|
|||||||
recent_message_count = 0,
|
recent_message_count = 0,
|
||||||
joined_players = {},
|
joined_players = {},
|
||||||
modpath = modpath,
|
modpath = modpath,
|
||||||
lib = lib,
|
lib = require("irc"),
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Compatibility
|
-- Compatibility
|
||||||
@ -53,7 +38,7 @@ mt_irc = irc
|
|||||||
|
|
||||||
dofile(modpath.."/config.lua")
|
dofile(modpath.."/config.lua")
|
||||||
dofile(modpath.."/messages.lua")
|
dofile(modpath.."/messages.lua")
|
||||||
loadfile(modpath.."/hooks.lua")(ie)
|
dofile(modpath.."/hooks.lua")
|
||||||
dofile(modpath.."/callback.lua")
|
dofile(modpath.."/callback.lua")
|
||||||
dofile(modpath.."/chatcmds.lua")
|
dofile(modpath.."/chatcmds.lua")
|
||||||
dofile(modpath.."/botcmds.lua")
|
dofile(modpath.."/botcmds.lua")
|
||||||
@ -119,6 +104,9 @@ function irc:connect()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print("== This is a debug line, please check for it ==")
|
||||||
|
print(self.config.NSPass)
|
||||||
|
print("=== DEBUG FINISHED ===")
|
||||||
if self.config.NSPass then
|
if self.config.NSPass then
|
||||||
self:say("NickServ", "IDENTIFY "..self.config.NSPass)
|
self:say("NickServ", "IDENTIFY "..self.config.NSPass)
|
||||||
end
|
end
|
||||||
|
@ -185,7 +185,7 @@ function meta:think()
|
|||||||
self.lastThought = socket.gettime()
|
self.lastThought = socket.gettime()
|
||||||
end
|
end
|
||||||
|
|
||||||
local handlers = rawget(_G, "handlers")
|
local handlers = handlers
|
||||||
|
|
||||||
function meta:handle(msg)
|
function meta:handle(msg)
|
||||||
local handler = irc.handlers[msg.command]
|
local handler = irc.handlers[msg.command]
|
||||||
|
@ -103,12 +103,6 @@ function msg_meta:fromRFC1459(line)
|
|||||||
|
|
||||||
local pos
|
local pos
|
||||||
self.command, pos = line:match("(%S+)()")
|
self.command, pos = line:match("(%S+)()")
|
||||||
-- /MFF BEGIN
|
|
||||||
if not pos then
|
|
||||||
minetest.log("error", "[IRC] This crash message was intended to see the value of a breaking variable. line = " .. (line or "nil"))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
-- /MFF END (Mg|06/01/2015)
|
|
||||||
line = line:sub(pos)
|
line = line:sub(pos)
|
||||||
|
|
||||||
self.args = self.args or {}
|
self.args = self.args or {}
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user