public void Execute(Room room, ref EventManager evMan, Dictionary<string, object> data)
        {
            // No point parsing all this data if no one's listening.
            if (!evMan.ConnectedListeners.ContainsKey(EventType.MessageStarToggled)) { return; }

            var starrerID = int.Parse(data["user_id"].ToString());

            if (starrerID == room.Me.ID && room.IgnoreOwnEvents) { return; }

            var id = int.Parse(data["message_id"].ToString());
            var starCount = 0;
            var pinCount = 0;

            if (data.ContainsKey("message_stars") && data["message_stars"] != null)
            {
                starCount = int.Parse(data["message_stars"].ToString());
            }

            if (data.ContainsKey("message_owner_stars") && data["message_owner_stars"] != null)
            {
                pinCount = int.Parse(data["message_owner_stars"].ToString());
            }

            var message = room[id];
            var user = room.GetUser(starrerID);

            evMan.TrackMessage(message);
            evMan.TrackUser(user);
            evMan.CallListeners(EventType.MessageStarToggled, message, user, starCount, pinCount);
        }
        public void Execute(Room room, ref EventManager evMan, Dictionary<string, object> data)
        {
            // No point parsing all this data if no one's listening.
            if (!evMan.ConnectedListeners.ContainsKey(EventType.UserAccessLevelChanged)) { return; }

            var granterID = int.Parse(data["user_id"].ToString());

            if (granterID == room.Me.ID && room.IgnoreOwnEvents) { return; }

            var targetUserID = int.Parse(data["target_user_id"].ToString());
            var content = (string)data["content"];
            var granter = room.GetUser(granterID);
            var targetUser = room.GetUser(targetUserID);
            var newAccessLevel = UserRoomAccess.Normal;

            switch (content)
            {
                case "Access now owner":
                {
                    newAccessLevel = UserRoomAccess.Owner;
                    break;
                }
                case "Access now read-write":
                {
                    newAccessLevel = UserRoomAccess.ExplicitReadWrite;
                    break;
                }
                case "Access now read-only":
                {
                    newAccessLevel = UserRoomAccess.ExplicitReadOnly;
                    break;
                }
            }

            evMan.TrackUser(granter);
            evMan.TrackUser(targetUser);
            evMan.CallListeners(EventType.UserAccessLevelChanged, granter, targetUser, newAccessLevel);
        }
示例#3
0
        public void Execute(Room room, ref EventManager evMan, Dictionary<string, object> data)
        {
            // No point parsing all this data if no one's listening.
            if (!evMan.ConnectedListeners.ContainsKey(EventType.UserLeft)) { return; }

            var userID = int.Parse(data["user_id"].ToString());

            if (userID == room.Me.ID && room.IgnoreOwnEvents) { return; }

            var user = room.GetUser(userID);

            evMan.TrackUser(user);
            evMan.CallListeners(EventType.UserLeft, user);
        }