mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-11 10:30:25 +01:00
Add an IRC mod wich works... (very rare, like Mithril...)
This commit is contained in:
parent
8c637bac28
commit
43faf2b5bc
@ -46,13 +46,13 @@ function irc:bot_command(msg, text)
|
||||
cmd = text
|
||||
args = ""
|
||||
end
|
||||
|
||||
|
||||
if not self.bot_commands[cmd] then
|
||||
self:reply("Unknown command '"..cmd.."'. Try 'list'."
|
||||
.." Or use @playername <message> to send a private message")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local success, message = self.bot_commands[cmd].func(msg.user, args)
|
||||
if message then
|
||||
self:reply(message)
|
||||
|
Binary file not shown.
@ -1,28 +1,12 @@
|
||||
-- This file is licensed under the terms of the BSD 2-clause license.
|
||||
-- See LICENSE.txt for details.
|
||||
|
||||
local ie = ...
|
||||
|
||||
-- MIME is part of LuaSocket
|
||||
local b64e = ie.require("mime").b64
|
||||
local b64e = require("mime").b64
|
||||
|
||||
irc.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.
|
||||
local stripped_chars = {"\2", "\31"}
|
||||
@ -34,7 +18,7 @@ stripped_chars = "["..table.concat(stripped_chars, "").."]"
|
||||
local function normalize(text)
|
||||
-- Strip colors
|
||||
text = text:gsub("\3[0-9][0-9,]*", "")
|
||||
text = subaccent(text)
|
||||
|
||||
return text:gsub(stripped_chars, "")
|
||||
end
|
||||
|
||||
@ -254,7 +238,7 @@ function irc.hooks.preregister(conn)
|
||||
conn:send("CAP REQ sasl")
|
||||
conn:send("AUTHENTICATE PLAIN")
|
||||
conn:send("AUTHENTICATE "..authString)
|
||||
conn:send("CAP END")
|
||||
--LuaIRC will send CAP END
|
||||
end
|
||||
|
||||
|
||||
|
@ -3,40 +3,25 @@
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
-- Handle mod security if needed
|
||||
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 =
|
||||
package.path =
|
||||
-- To find LuaIRC's init.lua
|
||||
modpath.."/?/init.lua;"
|
||||
-- For LuaIRC to find its files
|
||||
..modpath.."/?.lua;"
|
||||
..ie.package.path
|
||||
..";/usr/lib/*/lua/5.1/socket/*.so"
|
||||
..package.path
|
||||
|
||||
-- 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/share and /usr/lib.
|
||||
if not rawget(_G, "jit") and package.config:sub(1, 1) == "/" then
|
||||
ie.package.path = ie.package.path..
|
||||
if not rawget(_G,"jit") and package.config:sub(1, 1) == "/" then
|
||||
package.path = package.path..
|
||||
";/usr/share/lua/5.1/?.lua"..
|
||||
";/usr/share/lua/5.1/?/init.lua"
|
||||
ie.package.path = ie.package.path..
|
||||
";/usr/lib/lua/5.1/?.so"
|
||||
package.cpath = package.cpath..
|
||||
-- ";/usr/lib/lua/5.1/?.so"
|
||||
";/usr/lib/x86_64-linux-gnu/lua/5.1/?.so"
|
||||
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 = {
|
||||
version = "0.2.0",
|
||||
connected = false,
|
||||
@ -45,7 +30,7 @@ irc = {
|
||||
recent_message_count = 0,
|
||||
joined_players = {},
|
||||
modpath = modpath,
|
||||
lib = lib,
|
||||
lib = require("irc"),
|
||||
}
|
||||
|
||||
-- Compatibility
|
||||
@ -53,7 +38,7 @@ mt_irc = irc
|
||||
|
||||
dofile(modpath.."/config.lua")
|
||||
dofile(modpath.."/messages.lua")
|
||||
loadfile(modpath.."/hooks.lua")(ie)
|
||||
dofile(modpath.."/hooks.lua")
|
||||
dofile(modpath.."/callback.lua")
|
||||
dofile(modpath.."/chatcmds.lua")
|
||||
dofile(modpath.."/botcmds.lua")
|
||||
@ -119,6 +104,9 @@ function irc:connect()
|
||||
return
|
||||
end
|
||||
|
||||
print("== This is a debug line, please check for it ==")
|
||||
print(self.config.NSPass)
|
||||
print("=== DEBUG FINISHED ===")
|
||||
if self.config.NSPass then
|
||||
self:say("NickServ", "IDENTIFY "..self.config.NSPass)
|
||||
end
|
||||
|
@ -185,7 +185,7 @@ function meta:think()
|
||||
self.lastThought = socket.gettime()
|
||||
end
|
||||
|
||||
local handlers = rawget(_G, "handlers")
|
||||
local handlers = handlers
|
||||
|
||||
function meta:handle(msg)
|
||||
local handler = irc.handlers[msg.command]
|
||||
|
@ -103,12 +103,6 @@ function msg_meta:fromRFC1459(line)
|
||||
|
||||
local pos
|
||||
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)
|
||||
|
||||
self.args = self.args or {}
|
||||
|
@ -13,7 +13,7 @@ end
|
||||
function set:add(connection)
|
||||
local socket = connection.socket
|
||||
insert(self.sockets, socket)
|
||||
|
||||
|
||||
self.connections[socket] = connection
|
||||
insert(self.connections, connection)
|
||||
end
|
||||
@ -32,13 +32,13 @@ end
|
||||
|
||||
function set:select()
|
||||
local read, write, err = select(self.sockets, nil, self.timeout)
|
||||
|
||||
|
||||
if read then
|
||||
for k, socket in ipairs(read) do
|
||||
read[k] = self.connections[socket]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return read, err
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ function irc:player_part(name)
|
||||
self.joined_players[name] = nil
|
||||
minetest.chat_send_player(name, "IRC: You are now out of the channel.")
|
||||
end
|
||||
|
||||
|
||||
function irc:player_join(name)
|
||||
if self.joined_players[name] then
|
||||
minetest.chat_send_player(name, "IRC: You are already in the channel.")
|
||||
@ -28,7 +28,7 @@ minetest.register_chatcommand("join", {
|
||||
irc:player_join(name)
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("part", {
|
||||
description = "Part the IRC channel",
|
||||
privs = {shout=true},
|
||||
@ -36,7 +36,7 @@ minetest.register_chatcommand("part", {
|
||||
irc:player_part(name)
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("who", {
|
||||
description = "Tell who is currently on the channel",
|
||||
privs = {},
|
||||
@ -49,13 +49,13 @@ minetest.register_chatcommand("who", {
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
irc.joined_players[name] = irc.config.auto_join
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
irc.joined_players[name] = nil
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user