Join, part and participant list
authorStiletto <blasux@blasux.ru>
Wed, 24 Oct 2012 01:03:02 +0400
changeset 8 dfd274c668f9
parent 7 a49fb1ec5e2a
child 9 d3260253f0bd
Join, part and participant list
logs/style.css
muc_log.vala
--- a/logs/style.css	Wed Oct 24 00:37:31 2012 +0400
+++ b/logs/style.css	Wed Oct 24 01:03:02 2012 +0400
@@ -125,6 +125,12 @@
 	font-weight: bold;
 }
 
-tr.logstart td.text {
-    color: #3f0;
+tr.logstart td.text, tr.logstop td.text, tr.userlist td.text, tr.userlist td.nick {
+    color: #00008B;
 }
+tr.join td.nick, tr.join td.text {
+    color: #005500;
+}
+tr.part td.nick, tr.part td.text {
+    color: #550000;
+}
--- a/muc_log.vala	Wed Oct 24 00:37:31 2012 +0400
+++ b/muc_log.vala	Wed Oct 24 01:03:02 2012 +0400
@@ -100,7 +100,19 @@
             switch (news) {
                 case ModuleMuc.State.CONNECTED:
                     if (getconf(conf.jid, "log", "no")=="yes") {
-                        rooms[conf.jid] = new RoomLog(this, conf.jid);
+                        var room = new RoomLog(this, conf.jid); 
+                        rooms[conf.jid] = room;
+                        var sb = new StringBuilder();
+                        var notfirst = false;
+                        sb.append("Participants: ");
+                        foreach (var occupant in conf.occupants.values) {
+                            if (notfirst)
+                                sb.append(", ");
+                            else
+                                notfirst=true;
+                            sb.append(Markup.escape_text(occupant.nick).replace(" ","&nbsp;"));
+                        }
+                        room.write(Time.local(new time_t()), "userlist", "", sb.str);
                     }
                     break;
                 case ModuleMuc.State.DISCONNECTED:
@@ -117,6 +129,20 @@
                 }
             }
         });
+        muc.on_join.connect( (conf, user) => {
+            var room = rooms[conf.jid];
+            if (room!=null) {
+                var nick = Markup.escape_text(user.nick).replace(" ","&nbsp;");
+                room.write(Time.local(new time_t()), "join", "*", nick+" has joined the room");
+            }
+        });
+        muc.on_part.connect( (conf, user) => {
+            var room = rooms[conf.jid];
+            if (room!=null) {
+                var nick = Markup.escape_text(user.nick).replace(" ","&nbsp;");
+                room.write(Time.local(new time_t()), "part", "*", nick+" has left the room");
+            }
+        });
     }
     public override string name() {
         return "muc_log";