Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
IRC: some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jprjr committed Apr 2, 2017
1 parent 8691301 commit c2e3e83
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions multistreamer/irc/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ function IRCServer.new(socket,user,parentServer)
end

server.clientFunctions = {
['AWAY'] = IRCServer.clientUnknown,
['AWAY'] = IRCServer.clientAway,
['INVITE'] = IRCServer.clientInvite,
['ISON'] = IRCServer.clientIson,
['JOIN'] = IRCServer.clientJoinRoom,
['KICK'] = IRCServer.clientKick,
['KICK'] = IRCServer.clientNotChanOp,
['LIST'] = IRCServer.clientList,
['MODE'] = IRCServer.clientMode,
['NOTICE'] = IRCServer.clientMessage,
Expand All @@ -104,13 +104,12 @@ function IRCServer.new(socket,user,parentServer)
['PING'] = IRCServer.clientPing,
['PRIVMSG'] = IRCServer.clientMessage,
['QUIT'] = IRCServer.clientQuit,
['REHASH'] = IRCServer.clientUnknown,
['RESTART'] = IRCServer.clientUnknown,
['SUMMON'] = IRCServer.clientUnknown,
['TOPIC'] = IRCServer.clientTopic,
['USERHOST'] = IRCServer.clientUnknown,
['USERS'] = IRCServer.clientUsers,
['REHASH'] = IRCServer.clientNotOp,
['RESTART'] = IRCServer.clientNotOp,
['SUMMON'] = IRCServer.clientSummon,
['TOPIC'] = IRCServer.clientNotChanOp,
['USERHOST'] = IRCServer.clientUserhost,
['USERS'] = IRCServer.clientUsers,
['WHO'] = IRCServer.clientWho,
['WHOIS'] = IRCServer.clientWhois,
}
Expand Down Expand Up @@ -648,6 +647,14 @@ function IRCServer:listRooms(nick,rooms)
return true, nil
end

function IRCServer:clientAway(nick,msg)
if #msg.args > 0 then
return self:sendClientFromServer(nick,'306','You have been marked as being away')
else
return self:sendClientFromServer(nick,'305','You are no longer marked as being away')
end
end

function IRCServer:clientIson(nick,msg)
local resp = ''
local i = 1
Expand All @@ -666,14 +673,15 @@ function IRCServer:clientIson(nick,msg)
end

function IRCServer:clientUserhost(nick,msg)
local resp = ':'
local resp = ''
local i = 1
for _,u in pairs(msg.args) do
if self.users[u] then
if i > 1 then
u = ' ' .. u
resp = resp .. ' '
end
resp = resp .. u .. '=' .. u .. '@' .. config.irc_hostname
i = i + 1
end
end
return self:sendClientFromServer(nick,'302', resp)
Expand Down Expand Up @@ -794,14 +802,18 @@ function IRCServer:clientOper(nick,msg)
return self:sendClientFromServer(nick,'464','Password incorrect')
end

function IRCServer:clientKick(nick,msg)
return self:sendClientFromServer(nick,'482',msg.args[1],'You\'re not channel operator')
function IRCServer:clientNotOp(nick,msg)
return self:sendClientFromServer(nick,'481','Permission Denied- You\'re not an IRC operator')
end

function IRCServer:clientTopic(nick,msg)
function IRCServer:clientNotChanOp(nick,msg)
return self:sendClientFromServer(nick,'482',msg.args[1],'You\'re not channel operator')
end

function IRCServer:clientSummon(nick,msg)
return self:sendClientFromServer(nick,'445','SUMMON has been disabled')
end

function IRCServer:clientUsers(nick,msg)
return self:sendClientFromServer(nick,'446','USERS has been disabled')
end
Expand Down

0 comments on commit c2e3e83

Please sign in to comment.