muc_log.vala
changeset 8 dfd274c668f9
parent 4 8785de25b6bd
child 9 d3260253f0bd
--- 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(" "," "));
+                        }
+                        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(" "," ");
+                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(" "," ");
+                room.write(Time.local(new time_t()), "part", "*", nick+" has left the room");
+            }
+        });
     }
     public override string name() {
         return "muc_log";