Author: bdonlan
Date: 2005-07-18 19:58:20 -0400 (Mon, 18 Jul 2005)
New Revision: 880
Modified:
trunk/clients/ravish/ravish2.rb
Log:
Track users on each channel, route QUIT
Modified: trunk/clients/ravish/ravish2.rb
===================================================================
--- trunk/clients/ravish/ravish2.rb 2005-07-18 23:23:32 UTC (rev 879)
+++ trunk/clients/ravish/ravish2.rb 2005-07-18 23:58:20 UTC (rev 880)
@@ -89,6 +89,8 @@
@haver = Haver::Client.new @conf['server']
@haver.add_observer self
@haver.start
+
+ @chancontents = {}
end
def global_prefix
@@ -318,11 +320,18 @@
else
srvmsg "Stray JOIN: #{uid} has joined #{cid}"
end
+
+ clist = @chancontents[cid]
+ if clist.nil?
+ @chancontents[cid] = clist = Hash.new
+ end
+ clist[uid] = 1
end
def ev_PART cid, uid
win = find_window :channel, cid
if @nick and uid == @nick
+ @chancontents.delete cid
if win
@windows.delete win
@term.delete_window win.window
@@ -335,12 +344,21 @@
else
srvmsg "Stray PART: #{uid} parts #{cid}"
end
+ clist = @chancontents[cid]
+ if !clist.nil?
+ clist.delete uid
+ end
end
- def ev_QUIT uid, type, detail
- # FIXME: Temporary; we need to keep a list of the users in each
- # channel.
+ def ev_QUIT uid, type, detail=""
srvmsg "Quits: #{uid} (#{type}#{detail ? ": " + detail : ''})"
+ @chancontents.each_key { |cid|
+ if @chancontents[cid][uid]
+ win = find_window :channel, cid
+ win.window.print "#{uid} has quit: (#{type}#{detail ? ": " +
detail : ''})"
+ @chancontents[cid].delete uid
+ end
+ }
end
def ev_LIST cid, ns, *users
@@ -358,6 +376,13 @@
users.sort!
win.columnize users, {'before_each' =>
'%(listdecs)[%(listitem)',
'after_each' =>
'%(listdecs)]%(default)'}
+
+ if win != @servwin && ns == 'user'
+ clist = @chancontents[cid] = Hash.new
+ users.each { |uid|
+ clist[uid] = 1
+ }
+ end
end
def ev_IN cid, uid, type, *msg