Skip to content

Commit

Permalink
Fixed caps module
Browse files Browse the repository at this point in the history
  • Loading branch information
ChickenNuggers committed Jan 26, 2016
1 parent fda201e commit 1c14ee7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
25 changes: 24 additions & 1 deletion plugins/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ return {
if args[2] == 'LS' or args[2] == 'ACK' or args[2] == 'NAK' then
to_process = { }
end
if args[2] == 'LS' or args[2] == 'ACK' then
if args[2] == 'LS' or args[2] == 'ACK' or args[2] == 'NEW' or args[2] == 'DEL' then
for item in trailing:gmatch('%S+') do
for _index_0 = 1, #caps do
local cap = caps[_index_0]
Expand All @@ -229,6 +229,29 @@ return {
end
if args[2] == 'LS' then
return self:send_raw(('CAP REQ :%s'):format(table.concat(to_process, ' ')))
elseif args[2] == 'NEW' then
local to_send = { }
for item in trailing:gmatch('%S+') do
for _index_0 = 1, #caps do
local cap = caps[_index_0]
if item == cap then
self:fire_hook('REQ_CAP')
to_send[#to_send + 1] = item
end
end
end
return self:send_raw(('CAP REQ :%s'):format(table.concat(to_send, ' ')))
elseif args[2] == 'DEL' then
local to_send = { }
for item in trailing:gmatch('%S+') do
for _index_0 = 1, #caps do
local cap = caps[_index_0]
if item == cap then
self:fire_hook('DEL_CAP')
to_send[#to_send + 1] = item
end
end
end
elseif args[2] == 'ACK' then
for _index_0 = 1, #to_process do
local cap = to_process[_index_0]
Expand Down
17 changes: 16 additions & 1 deletion plugins/data.moon
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,29 @@ serve_self ==> setmetatable(@, {__call: ()=>pairs(@)})
caps = {'extended-join', 'multi-prefix', 'away-notify', 'account-notify',
'chghost', 'server-time'}
to_process = {} if args[2] == 'LS' or args[2] == 'ACK' or args[2] == 'NAK'
if args[2] == 'LS' or args[2] == 'ACK'
if args[2] == 'LS' or args[2] == 'ACK' or args[2] == 'NEW' or args[2] == 'DEL'
for item in trailing\gmatch '%S+'
for cap in *caps
if item == cap
@fire_hook 'REQ_CAP' if args[2] == 'LS'
to_process[#to_process + 1] = cap
if args[2] == 'LS'
@send_raw ('CAP REQ :%s')\format table.concat(to_process, ' ')
elseif args[2] == 'NEW'
to_send = {}
for item in trailing\gmatch '%S+'
for cap in *caps
if item == cap
@fire_hook 'REQ_CAP'
to_send[#to_send + 1] = item
@send_raw ('CAP REQ :%s')\format table.concat(to_send, ' ')
elseif args[2] == 'DEL'
to_send = {}
for item in trailing\gmatch '%S+'
for cap in *caps
if item == cap
@fire_hook 'DEL_CAP'
to_send[#to_send + 1] = item
elseif args[2] == 'ACK'
for cap in *to_process
key, value = cap\match '^(.-)=(.+)'
Expand Down

0 comments on commit 1c14ee7

Please sign in to comment.