code: def set_invite_only(self, invite_only):
          
          join_rule = "invite" if invite_only else "public"
          try:
              self.client.api.set_join_rule(self.room_id, join_rule)
              self.invite_only = invite_only
              return True
          except MatrixRequestError:
              return False
docs: Set how the room can be joined.
  
          Args:
              invite_only(bool): If True, users will have to be invited to join
                  the room. If False, anyone who knows the room link can join.
  
          Returns:
              True if successful, False if not