Exemplo n.º 1
0
        public bool SetUserRoomAccess(UserRoomAccess access, int userID)
        {
            if (hasLeft)
            {
                throw new InvalidOperationException("Cannot change user's access level when you have left the room.");
            }
            if (!Me.IsMod || !Me.IsRoomOwner)
            {
                throw new InvalidOperationException("Unable to change user's access level. You have insufficient privileges (must be a room owner or moderator).");
            }

            var action = new ChatAction(ActionType.KickMute, new Func<object>(() =>
            {
                while (true)
                {
                    var data = "fkey=" + fkey + "&aclUserId=" + userID + "&userAccess=";

                    switch (access)
                    {
                        case UserRoomAccess.Normal:
                        {
                            data += "remove";
                            break;
                        }

                        case UserRoomAccess.ExplicitReadOnly:
                        {
                            data += "read-only";
                            break;
                        }

                        case UserRoomAccess.ExplicitReadWrite:
                        {
                            data += "read-write";
                            break;
                        }

                        case UserRoomAccess.Owner:
                        {
                            data += "owner";
                            break;
                        }
                    }

                    var resContent = RequestManager.Post(cookieKey, chatRoot + "/rooms/setuseraccess/" + ID, data);

                    if (string.IsNullOrEmpty(resContent)) { return false; }
                    if (HandleThrottling(resContent)) { continue; }

                    return true;
                }
            }));

            return (bool?)actEx.ExecuteAction(action) ?? false;
        }
Exemplo n.º 2
0
 public bool SetUserRoomAccess(UserRoomAccess access, User user)
 {
     return SetUserRoomAccess(access, user.ID);
 }