Compare commits

...

10 Commits

Author SHA1 Message Date
Nedko Arnaudov dfa50fb86e Rename permeshu to ladici
permeshu was designed as personal message hub
ladici is similar, but is for Continuous Integration messaging
2023-11-22 17:41:29 +02:00
Nedko Arnaudov 8f57ab8a2b Don't involve the control channel object for incomming messages that have sender 2011-03-28 06:15:48 +03:00
Nedko Arnaudov 18b431c261 when specifying location for hub methods, supply the object instead of just name 2011-03-28 06:00:56 +03:00
Nedko Arnaudov 4dd58b1de1 rename hub:deliver() to hub:incoming_message() 2011-03-28 05:36:08 +03:00
Nedko Arnaudov 2ee3b5e5fb fix the quit command 2011-03-28 04:20:13 +03:00
Nedko Arnaudov 717688ccd5 basic message delivery 2011-03-28 03:44:46 +03:00
Nedko Arnaudov c4ca711514 remote channels 2011-03-28 02:04:59 +03:00
Nedko Arnaudov a3c874a2d6 enable the disconnect command code 2011-03-21 04:05:13 +02:00
Nedko Arnaudov a3fcfd8e94 RPL_NAMREPLY must end with RPL_ENDOFNAMES, not RPL_ENDOFWHO 2011-03-21 03:47:52 +02:00
Nedko Arnaudov 899fa9f241 protocol modules are not public modules 2011-03-21 03:43:35 +02:00
12 changed files with 172 additions and 237 deletions

1
README
View File

@ -1 +0,0 @@
PERsonal MESsage HUb

1
README.adoc Normal file
View File

@ -0,0 +1 @@
ladici - The LADI Continuous Integration software

127
hub.lua
View File

@ -1,22 +1,7 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
require 'misc'
@ -24,30 +9,31 @@ module(..., package.seeall)
local interface = nil
channel = {users={}}
function channel:new(o)
channel_cls = {}
function channel_cls:new(o)
o = o or {}
if not o.users then o.users = {} end
setmetatable(o, self)
self.__index = self
return o
end
function channel:set_name(name)
function channel_cls:set_name(name)
self.name = name
end
function channel:set_topic(topic)
function channel_cls:set_topic(topic)
self.topic = topic
end
function channel:attach(interface)
function channel_cls:attach()
if not interface then return end
print(("attaching channel '%s'"):format(tostring(self.name)))
interface.channel_join(self.name)
interface.channel_set_topic(self.name, self.topic)
--self:who()
end
function channel:get_users()
function channel_cls:get_users()
users = {}
for nick, user in pairs(self.users) do
users[nick] = user
@ -55,32 +41,39 @@ function channel:get_users()
return users
end
function channel:mode()
function channel_cls:mode()
-- send_to_peer(self.peer, "MODE " .. self.name .. ' +tn')
end
local control_channel = channel:new{name = '&control', topic = 'permeshu control channel'}
control_channel.users['@permeshu'] = {}
function control_channel:send_reply(msg)
if not interface then print(msg) end
interface.channel_send_msg(self.name, 'permeshu', msg)
function channel_cls:outgoing_message(msg, receiver)
print(('outgoing message for %s: "%s"'):format(receiver, msg))
end
-- function control_channel:disconnect_location(name)
-- location = locations.registry[name]
-- assert(location.connection)
-- location.connection.disconnect(function()
-- self:send_reply("Location [" .. name .. "] disconnected successfully")
-- location.connection = nil
-- end)
-- end
local control_channel = channel_cls:new{name = '&control', topic = 'ladici control channel', users = {['@ladici'] = {}}}
function control_channel:privmsg(command)
function control_channel:send_reply(msg, sender)
interface.send_msg(msg, sender or 'ladici', self.name)
end
function control_channel:disconnect_location(name)
location = locations.registry[name]
assert(location.connection)
location.connection.disconnect(function()
self:send_reply("Location [" .. name .. "] disconnected successfully")
location.connection = nil
end)
end
function control_channel:outgoing_message(command)
commands = {}
commands['quit'] =
function()
interface.disconnect()
for name,location in pairs(locations.registry) do
if location.connection then self:disconnect_location(name) end
end
return true -- break the receive loop
end
@ -132,7 +125,7 @@ end
local channels = {}
function join(channel)
local function register_channel(channel)
channels[channel.name] = channel
end
@ -140,10 +133,52 @@ function get_channel(channel)
return channels[channel]
end
join(control_channel)
register_channel(control_channel)
function deliver(sender, msg)
control_channel:send_reply(sender .. ': ' .. msg)
function incoming_message(msg, location, sender, channel)
if not interface then
if location then
if not sender then
msg = location.name .. ": " .. msg
elseif not channel then
msg = ('%s said "%s"'):format(sender, msg)
else
msg = ('%s said in #%s "%s"'):format(sender, channel, msg)
end
end
print(msg)
return
end
-- print(location)
if not sender then
control_channel:send_reply(location.name .. ": " .. msg, 'ladici')
elseif not channel then
-- private message
interface.send_msg(msg, location.name .. '/' .. sender)
else
-- channel message
interface.send_msg(msg, sender, '#' .. location.name .. '/' .. channel)
end
end
function outgoing_message(msg, receiver)
channel = get_channel(receiver)
if channel then return channel:outgoing_message(msg, receiver) end
end
function join(location, channel_name, nick)
channel_name = '#' .. location.name .. '/' .. channel_name
channel = get_channel(channel_name)
if not channel then
channel = channel_cls:new{name = channel_name}
register_channel(channel)
channel:attach()
end
if not channel.users[nick] then
channel.users[nick] = {}
end
end
function attach_interface(iface)
@ -151,7 +186,7 @@ function attach_interface(iface)
interface = iface
for name, obj in pairs(channels) do
obj:attach(interface)
obj:attach()
end
end

40
irc.lua
View File

@ -1,22 +1,7 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
module('irc', package.seeall)
@ -30,6 +15,25 @@ local function parse_and_consume(buffer, regexp)
return rest, a1, a2, a3, a4
end
function parse_nick_prefix(prefix)
rest = prefix
b, e, host = rest:find('@(.+)')
if not b then
host = nil
else
rest = rest:sub(0, b - 1)
end
b, e, user = rest:find('!(.+)')
if not b then
user = nil
nick = rest
else
nick = rest:sub(0, b - 1)
end
return nick, user, host
end
local function process_raw_msg(command_handlers, raw_msg, deliver)
-- print('----receive----' .. tostring(raw_msg))

View File

@ -1,29 +1,11 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
require 'protocols'
require 'hub'
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
module('irc_client', package.seeall)
function connect(location)
local function connect(location)
assert(location.args.host)
assert(location.args.nick)
@ -34,7 +16,7 @@ function connect(location)
local realname = location.args.realname or nick
local join = location.args.join
local print = function(msg) hub.deliver(location.name, msg) end
local print = function(msg) hub.incoming_message(msg, location) end
local peer
@ -69,16 +51,22 @@ function connect(location)
command_handlers['PRIVMSG'] =
function(prefix, command, params)
print(("'%s' -> '%s' : '%s'"):format(tostring(prefix), params[1], params[2]))
nick, user, host = irc.parse_nick_prefix(prefix)
-- print(("'%s' -> '%s' : '%s'"):format(nick, params[1], params[2]))
if params[1]:sub(1, 1) == "#" then
channel = params[1]:sub(2)
else
channel = nil
end
-- print(("channel is '%s'"):format(tostring(channel)))
hub.incoming_message(params[2], location, nick, channel)
end
command_handlers['JOIN'] = function(prefix, command, params)
print(("'%s' joined '%s'"):format(prefix, params[1]))
-- local channel = channel:new()
-- channel.users['@permeshu'] = {}
-- channel.users[nick] = {}
-- channel:join(peer, params[1], nick)
-- channels[channel.name] = channel
nick, user, host = irc.parse_nick_prefix(prefix)
print(("'%s':'%s':'%s' joined '%s'"):format(tostring(nick), tostring(user), tostring(host), params[1]))
hub.join(location, params[1]:sub(2), nick)
end
-- welcome
@ -180,3 +168,5 @@ local descriptor = {
}
protocols.register(descriptor)
return {} -- nothing directly public here

View File

@ -1,22 +1,7 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
require 'hub'
require 'irc'
@ -49,16 +34,15 @@ local function remote_client_thread(peer)
local interface = {
channel_join = function(channel) irc.send_to_peer(peer, ":" .. nick .. " JOIN " .. channel) end,
channel_set_topic = function(channel, topic) irc.send_to_peer(peer, ":permeshu 332 " .. nick .. ' ' .. channel .. ' :' .. (topic or '')) end,
channel_send_msg = function(channel, sender, msg) irc.send_to_peer(peer, ':' .. sender .. ' PRIVMSG ' .. channel .. ' :' .. msg) end,
channel_set_topic = function(channel, topic) irc.send_to_peer(peer, ":ladici 332 " .. nick .. ' ' .. channel .. ' :' .. (topic or '')) end,
send_msg = function(msg, sender, channel)
receiver = channel or nick
irc.send_to_peer(peer, ':' .. sender .. ' PRIVMSG ' .. receiver .. ' :' .. msg)
end,
disconnect =
function(channel)
peer.accept_disable()
for name,location in pairs(locations.registry) do
if location.connection then self:disconnect_location(name) end
end
irc.send_to_peer(peer, 'ERROR :Goodbye!')
end,
}
@ -66,7 +50,7 @@ local function remote_client_thread(peer)
local function maybe_welcome()
if not user or not nick then return end
send(":permeshu 001 " .. nick .. " Welcome to the Internet Relay Network " .. nick .. "!" .. user .. "@" .. host)
send(":ladici 001 " .. nick .. " Welcome to the Internet Relay Network " .. nick .. "!" .. user .. "@" .. host)
hub.attach_interface(interface)
attached = true
@ -99,9 +83,7 @@ local function remote_client_thread(peer)
function(prefix, command, params)
msg = params[2]
if not msg then unknown_command(prefix, command, params) return end
channel = hub.get_channel(params[1])
if not channel then unknown_command(prefix, command, params) return end -- unknown channel
return channel:privmsg(msg)
return hub.outgoing_message(msg, params[1])
end
command_handlers['WHO'] =
@ -109,10 +91,10 @@ local function remote_client_thread(peer)
channel = hub.get_channel(params[1])
if not channel then unknown_command(prefix, command, params) return end -- unknown channel
for unick, uobj in pairs(channel.get_users(channel)) do
irc.send_to_peer(peer, ":permeshu 353 " .. nick .. ' = ' .. channel.name .. ' :' .. unick)
irc.send_to_peer(peer, ":ladici 353 " .. nick .. ' = ' .. channel.name .. ' :' .. unick)
end
irc.send_to_peer(peer, ":permeshu 353 " .. nick .. ' = ' .. channel.name .. ' :' .. nick)
irc.send_to_peer(peer, ":permeshu 315 " .. nick .. ' ' .. channel.name .. ' :End of NAMES list')
irc.send_to_peer(peer, ":ladici 353 " .. nick .. ' = ' .. channel.name .. ' :' .. nick)
irc.send_to_peer(peer, ":ladici 366 " .. nick .. ' ' .. channel.name .. ' :End of NAMES list')
end
command_handlers['MODE'] =

23
ladici Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env lua
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
require 'protocols'
require 'hub'
require 'remotes'
require 'locations'
require 'irc_client'
require 'irc_server'
locations.register('localhost',
'IRC',
{host='localhost', nick='ladici', realname='Operator Real Name', join='#ladi'})
err = irc_server.create()
if err then
print(err)
else
while remotes.dispatch() do end
end

View File

@ -1,22 +1,7 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
module(..., package.seeall)

View File

@ -1,22 +1,7 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
module('misc', package.seeall)

39
permshu
View File

@ -1,39 +0,0 @@
#!/usr/bin/env lua
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
require 'remotes'
require 'locations'
require 'irc_client'
require 'irc_server'
locations.register('freenode',
'IRC',
{host='chat.freenode.net', nick='nedko_lua', realname='nedko@arnaudov.name', join='#permeshu'})
locations.register('unibg',
'IRC',
{host='irc.itdnet.net', nick='nedko_lua'})
err = irc_server.create()
if err then
print(err)
else
while remotes.dispatch() do end
end

View File

@ -1,22 +1,7 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
module(..., package.seeall)

View File

@ -1,22 +1,7 @@
-- -*- Mode: Lua; indent-tabs-mode: nil; lua-indent-level: 2 -*-
-- PERsonal MESsage HUb (permshu)
--
-- Copyright (C) 2010, 2011 Nedko Arnaudov <nedko@arnaudov.name>
--
-- permshu is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- permshu is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with permshu. If not, see <http://www.gnu.org/licenses/>
-- or write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-- LADI Continuous Integration (ladici)
-- SPDX-FileCopyrightText: Copyright © 2010-2023 Nedko Arnaudov */
-- SPDX-License-Identifier: GPL-2.0-or-later
require 'socket'
-- require 'misc'