### Build and Run Soulfind from Source Source: https://context7.com/soulfind-dev/soulfind/llms.txt Commands for installing dependencies, compiling the project, and running the server or setup tools using dub. ```bash # Install dependencies (Debian/Ubuntu) sudo apt install ldc dub libsqlite3-dev # Install dependencies (macOS with Homebrew) brew install ldc dub # Basic compilation dub build # Build release binary with optimizations (LTO, static linking) dub build --config=release # Compile and run server directly dub run :server # Compile and run soulsetup tool dub run :setup # Use a specific compiler DC=ldc2 dub build DC=dmd dub build DC=gdc dub build # Run unit tests dub test --config=unittest # Compiled binaries are output to bin/ directory ls bin/ # soulfind - Server executable # soulsetup - Management tool executable ``` -------------------------------- ### Start Soulfind Server Source: https://context7.com/soulfind-dev/soulfind/llms.txt Launches the Soulfind server with various configuration options. Use -d for custom database path, -p for port, and --debug for logging. ```bash soulfind ``` ```bash soulfind -d /var/db/soulfind/production.db ``` ```bash soulfind -p 2242 ``` ```bash soulfind --debug ``` ```bash soulfind -d /data/soulfind.db -p 2242 --debug ``` -------------------------------- ### Run Soulfind Container Source: https://github.com/soulfind-dev/soulfind/blob/master/README.md Start the Soulfind server container with persistent data volume and port mapping. ```bash docker run -d --name soulfind -v soulfind-data:/data -p 2242:2242 ghcr.io/soulfind-dev/soulfind ``` -------------------------------- ### Compile and Run Soulfind CLI Tool Source: https://github.com/soulfind-dev/soulfind/blob/master/BUILDING.md This command compiles the Soulfind project and immediately runs the setup CLI tool for server management. ```sh dub run :setup ``` -------------------------------- ### Configure Server Port Source: https://context7.com/soulfind-dev/soulfind/llms.txt Get or set the server's listening port. The default port is 2242. ```d // Server configuration ushort port = db.server_port(); // Get listening port (default: 2242) db.set_server_port(2242); // Set listening port ``` -------------------------------- ### Configure Maximum Users Source: https://context7.com/soulfind-dev/soulfind/llms.txt Get or set the maximum number of users the server can handle. The default is 100000. ```d uint maxUsers = db.server_max_users(); // Get max users (default: 100000) db.set_server_max_users(50000); // Set max users ``` -------------------------------- ### Configure Message of the Day (MOTD) Source: https://context7.com/soulfind-dev/soulfind/llms.txt Get or set the server's Message of the Day. Supports dynamic variables like %username% and %users%. ```d string motd = db.server_motd(); // Get message of the day db.set_server_motd("Welcome to %username%! %users% users online."); // Available MOTD variables: // %sversion% - server version // %users% - connected user count // %username% - connecting user's name // %version% - user's client version ``` -------------------------------- ### Get User Statistics Source: https://context7.com/soulfind-dev/soulfind/llms.txt Retrieve statistics for a user, including upload speed, shared files, and folders. ```d // Get user stats auto stats = db.user_stats("username"); if (stats.exists) { uint speed = stats.upload_speed; uint files = stats.shared_files; uint folders = stats.shared_folders; } ``` -------------------------------- ### Get SQLite Version Source: https://context7.com/soulfind-dev/soulfind/llms.txt Retrieve the version of the SQLite library used by the database. ```d // Get SQLite version string sqliteVersion = db.sqlite_version(); ``` -------------------------------- ### Initialize and Manage Server Operations Source: https://context7.com/soulfind-dev/soulfind/llms.txt Use the Server class to handle user connections, room management, messaging, and file searching. Requires importing soulfind.server.server and soulfind.server.user. ```d import soulfind.server.server : Server; import soulfind.server.user : User; // Initialize server with database auto server = new Server("soulfind.db"); // Start listening for connections bool success = server.listen(2242); // Pass 0 for default port from DB // User management server.add_user(user); server.del_user("username"); User user = server.get_user("username"); size_t onlineCount = server.num_connected_users(); // Iterate connected users foreach (ref user; server.connected_users()) { writeln(user.username, " - ", user.client_version); } // Room management auto room = server.add_room("roomname"); auto privateRoom = server.add_room("private-room", "owner"); server.del_room("roomname"); auto existingRoom = server.get_room("roomname"); size_t roomCount = server.num_joined_rooms(); // Private room membership (returns success/failure) server.grant_room_membership("room", "actor", "target"); server.revoke_room_membership("room", "actor", "target"); server.grant_room_operatorship("room", "owner", "target"); server.revoke_room_operatorship("room", "owner", "target"); // Global room (aggregates all room chat) server.add_global_room_user(user); server.remove_global_room_user("username"); bool inGlobal = server.is_global_room_joined("username"); // Private messaging server.send_pm("from_user", "to_user", "Hello!"); server.send_pm("server", "username", "System message"); // From server server.del_pm(messageId, "recipient"); server.deliver_queued_pms("username"); // Deliver offline messages on login // File searching server.search_files(token, "search query", "requesting_user"); server.search_user_files(token, "query", "from_user", "target_user"); server.search_room_files(token, "query", "username", "roomname"); server.send_search_filters("username"); // Send filter list to client server.refresh_search_filters(); // Reload filters from DB // Recommendations (based on user interests) auto globalRecs = server.global_recommendations(); auto userRecs = server.user_recommendations("username"); auto itemRecs = server.item_recommendations("jazz"); auto similarUsers = server.user_similar_users("username"); string[] itemUsers = server.item_similar_users("electronic"); // Broadcasting server.send_to_all(message); server.send_to_watching("username", message); // Users watching this user server.send_to_joined_rooms("username", message); server.send_room_list("username"); // Admin commands (from in-client messaging) server.handle_command("admin_user", "kick baduser"); ``` -------------------------------- ### Manage Soulfind Server with soulsetup Source: https://context7.com/soulfind-dev/soulfind/llms.txt Interactively configures Soulfind server settings via a CLI tool. Use -d for a specific database file and -b to create a backup. Debug logging is available with --debug. ```bash soulsetup ``` ```bash soulsetup -d /var/db/soulfind/soulfind.db ``` ```bash soulsetup -b /backups/soulfind-backup.db ``` ```bash soulsetup --debug ``` -------------------------------- ### Help Command Source: https://context7.com/soulfind-dev/soulfind/llms.txt Display a list of available user commands. ```bash help ``` -------------------------------- ### Initialize Database Connection Source: https://context7.com/soulfind-dev/soulfind/llms.txt Initializes a connection to the Soulfind database, creating tables if they do not exist. ```d import soulfind.db : Database; // Initialize database (creates tables if needed) auto db = new Database("soulfind.db"); ``` -------------------------------- ### Building from Source Source: https://context7.com/soulfind-dev/soulfind/llms.txt Instructions for compiling the Soulfind project using the D build system (dub). ```APIDOC ## Building from Source ### Description Compile Soulfind using the D build system (dub) with various compilers. The project requires a D compiler (ldc, dmd, or gdc), the dub build system, and SQLite3 development libraries. ### Commands - `dub build`: Basic compilation. - `dub build --config=release`: Build release binary with optimizations. - `dub run :server`: Compile and run server directly. - `dub run :setup`: Compile and run soulsetup tool. - `dub test --config=unittest`: Run unit tests. ``` -------------------------------- ### Create New User Source: https://context7.com/soulfind-dev/soulfind/llms.txt Adds a new user to the database with a PBKDF2-hashed password. Requires creating a salt and hashing the password first. ```d import soulfind.db : Database; import soulfind.pwhash : create_salt, hash_password; import soulfind.defines : pbkdf2_iterations; import std.datetime : days, Clock; auto db = new Database("soulfind.db"); // Create a new user string salt = create_salt(); string hash = hash_password("password123", salt, pbkdf2_iterations); bool added = db.add_user("newuser", hash); ``` -------------------------------- ### Run Soulsetup CLI Source: https://github.com/soulfind-dev/soulfind/blob/master/README.md Execute the soulsetup management tool within a temporary container instance. ```bash docker run -it -v soulfind-data:/data --rm ghcr.io/soulfind-dev/soulfind soulsetup ``` -------------------------------- ### Default Connection Settings Source: https://context7.com/soulfind-dev/soulfind/llms.txt Sets default parameters for network connections, including the backlog length for incoming connections and the buffer size for message handling. Also defines the maximum size for incoming messages to prevent buffer overflows. ```d // Connection settings enum conn_backlog_length = 512; enum conn_buffer_size = 8192; enum max_in_msg_size = 8192; ``` -------------------------------- ### Build Soulfind Binary with Dub Source: https://github.com/soulfind-dev/soulfind/blob/master/BUILDING.md Use this command to compile the Soulfind project. Binaries will be placed in the 'bin/' directory. ```sh dub build ``` -------------------------------- ### Backup Database File Source: https://github.com/soulfind-dev/soulfind/blob/master/README.md Create a safe backup of the active database file using the --backup argument. ```bash soulsetup -b path/to/save/backup.db ``` -------------------------------- ### List Public Rooms Command Source: https://context7.com/soulfind-dev/soulfind/llms.txt List all available public rooms on the server. ```bash rooms ``` -------------------------------- ### Manage User Privileges Source: https://context7.com/soulfind-dev/soulfind/llms.txt Add or remove user privileges with specified durations, or remove all privileges. ```d // Privilege management db.add_user_privileges("username", 365.days); // Add 1 year privileges db.remove_user_privileges("username", 30.days); // Remove 30 days db.remove_user_privileges("username", Duration.max); // Remove all auto privilegedUntil = db.user_privileged_until("username"); ``` -------------------------------- ### Default Server Configuration Values Source: https://context7.com/soulfind-dev/soulfind/llms.txt Defines default constants for server operation, including database filename, port, maximum users, private mode status, and a default message of the day. These are used when no custom configuration is present. ```d // Server defaults enum default_db_filename = "soulfind.db"; enum default_port = 2242; enum default_max_users = 100000; enum default_private_mode = false; enum default_motd = "Soulfind %sversion%"; ``` -------------------------------- ### Server Uptime Command Source: https://context7.com/soulfind-dev/soulfind/llms.txt View the current server uptime. ```bash uptime ``` -------------------------------- ### Build Release Binary with Dub Source: https://github.com/soulfind-dev/soulfind/blob/master/BUILDING.md Compile a release-optimized binary with Link Time Optimization and static compilation. This command is for supported platforms. ```sh dub build --config=release ``` -------------------------------- ### Deploy Soulfind with Docker Source: https://context7.com/soulfind-dev/soulfind/llms.txt Deploys Soulfind using Docker, including persistent data storage and port mapping. The soulsetup tool can also be run within a container. ```bash docker pull ghcr.io/soulfind-dev/soulfind ``` ```bash docker run -d \ --name soulfind \ -v soulfind-data:/data \ -p 2242:2242 \ ghcr.io/soulfind-dev/soulfind ``` ```bash docker run -it \ -v soulfind-data:/data \ --rm \ ghcr.io/soulfind-dev/soulfind soulsetup ``` ```bash docker rm soulfind docker run -d \ --name soulfind \ -v soulfind-data:/data \ -p 1234:1234 \ ghcr.io/soulfind-dev/soulfind ``` -------------------------------- ### Compile and Run Soulfind Server Source: https://github.com/soulfind-dev/soulfind/blob/master/BUILDING.md This command compiles the Soulfind project and immediately runs the server component. ```sh dub run :server ``` -------------------------------- ### Specify Database File Path Source: https://github.com/soulfind-dev/soulfind/blob/master/README.md Override the default database location using the --database argument. ```bash soulfind -d path/to/database.db ``` ```bash soulsetup -d path/to/database.db ``` -------------------------------- ### Enable Debug Logging Source: https://github.com/soulfind-dev/soulfind/blob/master/README.md Activate detailed debug output for troubleshooting. ```bash soulfind --debug ``` ```bash soulsetup --debug ``` -------------------------------- ### Check User Existence Source: https://context7.com/soulfind-dev/soulfind/llms.txt Verify if a user account exists in the database. ```d // Check if user exists bool exists = db.user_exists("username"); ``` -------------------------------- ### Default Timeout and Interval Settings Source: https://context7.com/soulfind-dev/soulfind/llms.txt Specifies default durations for timeouts and intervals related to user actions and server checks. Includes settings for login timeouts, kick durations, and various check intervals for user activity and searches. Note the different wish intervals for privileged and unprivileged users. ```d // Timeouts and intervals enum login_timeout = 1.minutes; enum kick_duration = 2.minutes; enum user_check_interval = 15.seconds; enum search_dist_interval = 650.msecs; enum wish_interval = 12.minutes; // Unprivileged users enum wish_interval_privileged = 2.minutes; // Privileged users ``` -------------------------------- ### Build with LDC Compiler Source: https://github.com/soulfind-dev/soulfind/blob/master/BUILDING.md Specify the LDC compiler using the DC environment variable to build Soulfind. ```sh DC=ldc2 dub build ``` -------------------------------- ### Configure Private Mode Source: https://context7.com/soulfind-dev/soulfind/llms.txt Check or set the server's private mode, which disables new registrations. ```d bool privateMode = db.server_private_mode(); // Check if registration disabled db.set_server_private_mode(true); // Disable new registrations ``` -------------------------------- ### List Users and Count Source: https://context7.com/soulfind-dev/soulfind/llms.txt Retrieve lists of all users, admins, banned users, or privileged users based on current time. Also provides the total user count. ```d // List users string[] allUsers = db.usernames(); string[] admins = db.usernames("admin", Clock.currTime.toUnixTime); string[] banned = db.usernames("banned", Clock.currTime.toUnixTime); string[] privileged = db.usernames("privileges", Clock.currTime.toUnixTime); size_t totalUsers = db.num_users(); ``` -------------------------------- ### Build with GDC Compiler Source: https://github.com/soulfind-dev/soulfind/blob/master/BUILDING.md Specify the GDC compiler using the DC environment variable to build Soulfind. ```sh DC=gdc dub build ``` -------------------------------- ### View Room Information Command Source: https://context7.com/soulfind-dev/soulfind/llms.txt Display information about a specific public room. ```bash roominfo roomname ``` -------------------------------- ### Default Limits for Recommendations and Tickers Source: https://context7.com/soulfind-dev/soulfind/llms.txt Sets default maximum counts for system-generated recommendations and room tickers. These limits help manage server resources and the amount of information presented to users. ```d // Other limits enum max_global_recommendations = 200; enum max_user_recommendations = 100; enum max_user_interests = 30; enum max_room_tickers = 200; ``` -------------------------------- ### Backup Database Source: https://context7.com/soulfind-dev/soulfind/llms.txt Perform a database backup. This operation is safe to run while the server is active. ```d // Database backup (safe while server is running) bool success = db.backup("/backups/soulfind-backup.db"); ``` -------------------------------- ### Manage Chat Rooms with D Source: https://context7.com/soulfind-dev/soulfind/llms.txt Use the Database class to create, delete, and query chat rooms, including membership and operator controls. ```d import soulfind.db : Database; import soulfind.defines : RoomType, RoomMemberType, RoomTicker; auto db = new Database("soulfind.db"); // Create rooms db.add_room("public-room"); // Create public room db.add_room("private-room", "owneruser"); // Create private room with owner // Delete room db.del_room("roomname"); // Get room type RoomType type = db.get_room_type("roomname"); // Returns: RoomType._public, RoomType._private, or RoomType.non_existent // List rooms string[] publicRooms = db.public_rooms(); string[] ownedRooms = db.owned_rooms("username"); string[] memberRooms = db.member_rooms!(RoomMemberType.any)("username"); string[] operatedRooms = db.member_rooms!(RoomMemberType.operator)("username"); // Private room access control string owner = db.get_room_owner("private-room"); bool canAccess = db.can_access_room("private-room", "username"); // Membership management db.grant_room_membership("private-room", "newmember"); db.revoke_room_membership("private-room", "member"); RoomMemberType memberType = db.get_room_member_type("private-room", "username"); // Operator management db.grant_room_operatorship("private-room", "operator"); db.revoke_room_operatorship("private-room", "operator"); string[] operators = db.room_members!(RoomMemberType.operator)("private-room"); string[] allMembers = db.room_members!(RoomMemberType.any)("private-room"); // Room tickers (scrolling messages) db.add_ticker("roomname", "username", "My status message"); db.del_ticker("roomname", "username"); RoomTicker[] tickers = db.room_tickers("roomname"); RoomTicker[] userTickers = db.user_tickers!(RoomType._public)("username"); db.del_user_tickers!(RoomType._public)("username"); // Remove all user's tickers ulong tickerCount = db.num_room_tickers("roomname"); ``` -------------------------------- ### Server Class Operations Source: https://context7.com/soulfind-dev/soulfind/llms.txt Overview of the primary methods available in the Server class for managing users, rooms, messaging, and search functionality. ```APIDOC ## Server Class API ### Description The Server class coordinates all runtime operations including connections, searches, messaging, rooms, and users. ### Methods - **listen(port)**: Starts the server on the specified port. - **add_user(user)**: Registers a new user. - **del_user(username)**: Removes a user. - **get_user(username)**: Retrieves a user object. - **add_room(name, [owner])**: Creates a new room. - **grant_room_membership(room, actor, target)**: Grants membership to a user. - **send_pm(from, to, message)**: Sends a private message. - **search_files(token, query, user)**: Executes a file search. - **global_recommendations()**: Retrieves global recommendations. - **send_to_all(message)**: Broadcasts a message to all connected users. ``` -------------------------------- ### Soulfind Admin Commands (In-Client) Source: https://context7.com/soulfind-dev/soulfind/llms.txt Execute administrative commands by messaging the 'server' user in a Soulseek client. Commands include user management, server status, and announcements. ```text # View all available admin commands help ``` ```text # List all admin accounts admins ``` ```text # List users by category users # All registered users users connected # Currently online users users banned # Banned users users privileged # Users with privileges ``` ```text # View detailed user information userinfo username ``` ```text # Ban a user (optionally specify days, default is forever) ban username # Ban forever ban 30 username # Ban for 30 days ``` ```text # Unban a user unban username ``` ```text # Kick user temporarily (optionally specify minutes, default is 2) kick username # Kick for 2 minutes kick 60 username # Kick for 60 minutes ``` ```text # Kick all connected users kickall # Kick all for 2 minutes kickall 30 # Kick all for 30 minutes ``` ```text # Send announcement to all online users announcement Server maintenance in 10 minutes ``` ```text # Send private message to all registered users (online and offline) message Important update: new features available ``` -------------------------------- ### Database Configuration API Source: https://context7.com/soulfind-dev/soulfind/llms.txt Manage server configuration settings stored in the SQLite database. ```APIDOC ## Database Configuration API The Database class manages all persistent storage using SQLite. Configuration values are stored in the config table and can be accessed programmatically. The database uses WAL mode for concurrent access safety. ### Initialize database ```d import soulfind.db : Database; auto db = new Database("soulfind.db"); ``` ### Server Configuration #### Get listening port ```d ushort port = db.server_port(); // Get listening port (default: 2242) ``` #### Set listening port ```d db.set_server_port(2242); // Set listening port ``` #### Get max users ```d uint maxUsers = db.server_max_users(); // Get max users (default: 100000) ``` #### Set max users ```d db.set_server_max_users(50000); // Set max users ``` #### Check if registration disabled ```d bool privateMode = db.server_private_mode(); // Check if registration disabled ``` #### Disable new registrations ```d db.set_server_private_mode(true); // Disable new registrations ``` #### Get message of the day ```d string motd = db.server_motd(); // Get message of the day ``` #### Set message of the day ```d db.set_server_motd("Welcome to %username%! %users% users online."); // Available MOTD variables: // %sversion% - server version // %users% - connected user count // %username% - connecting user's name // %version% - user's client version ``` ### Database Backup #### Backup database ```d // Database backup (safe while server is running) bool success = db.backup("/backups/soulfind-backup.db"); ``` ### Get SQLite Version #### Get SQLite version ```d string sqliteVersion = db.sqlite_version(); ``` ``` -------------------------------- ### User Commands (In-Client) Source: https://context7.com/soulfind-dev/soulfind/llms.txt Users can execute commands by messaging the 'server' user for self-service features. ```APIDOC ## User Commands (In-Client) Regular users can execute commands by messaging the "server" user. Users have access to self-service features including data export and account deletion. ### View available user commands ``` help ``` ### Export your account data in JSON format ``` exportdata ``` ### Delete your account (requires confirmation) ``` deleteaccount # Shows confirmation prompt deleteaccount confirm yourusername # Actually deletes account ``` ``` -------------------------------- ### Delete User Account Commands Source: https://context7.com/soulfind-dev/soulfind/llms.txt Commands to initiate and confirm user account deletion. The first command shows a confirmation prompt, and the second executes the deletion. ```bash deleteaccount # Shows confirmation prompt ``` ```bash deleteaccount confirm yourusername # Actually deletes account ``` -------------------------------- ### Manage Admin Status Source: https://context7.com/soulfind-dev/soulfind/llms.txt Grant, revoke, or check the expiration time of administrator privileges for a user. ```d // Admin management db.add_admin("username", 30.days); // Make admin for 30 days db.add_admin("username", Duration.max); // Make permanent admin db.del_admin("username"); // Remove admin status auto adminUntil = db.admin_until("username"); ``` -------------------------------- ### Build with DMD Compiler Source: https://github.com/soulfind-dev/soulfind/blob/master/BUILDING.md Specify the DMD compiler using the DC environment variable to build Soulfind. ```sh DC=dmd dub build ``` -------------------------------- ### Set Listening Port Source: https://github.com/soulfind-dev/soulfind/blob/master/README.md Enforce a specific port for the server to listen on. ```bash soulfind -p 1234 ``` -------------------------------- ### Configure User Searchability Source: https://context7.com/soulfind-dev/soulfind/llms.txt Hide or restore a user's visibility in search results. Check if a user is currently hidden from searches. ```d // Search filtering db.set_user_unsearchable("spammer"); // Hide user from searches db.set_user_searchable("spammer"); // Restore searchability bool hidden = db.is_user_unsearchable("username"); ``` -------------------------------- ### Configure Search Filters with D Source: https://context7.com/soulfind-dev/soulfind/llms.txt Manage server-side and client-side search phrase filtering to block inappropriate content. ```d import soulfind.db : Database; import soulfind.defines : SearchFilterType; auto db = new Database("soulfind.db"); // Server-side filters (block at server before distribution) db.filter_search_phrase!(SearchFilterType.server)("inappropriate phrase"); db.unfilter_search_phrase!(SearchFilterType.server)("phrase to allow"); string[] serverFilters = db.search_filters!(SearchFilterType.server)(); size_t serverFilterCount = db.num_search_filters!(SearchFilterType.server)(); // Client-side filters (sent to clients for local filtering) db.filter_search_phrase!(SearchFilterType.client)("unwanted term"); db.unfilter_search_phrase!(SearchFilterType.client)("term to allow"); string[] clientFilters = db.search_filters!(SearchFilterType.client)(); size_t clientFilterCount = db.num_search_filters!(SearchFilterType.client)(); // Check if a search query matches any server-side filter bool isFiltered = db.is_search_query_filtered("search query with inappropriate phrase"); ``` -------------------------------- ### Pull Soulfind Container Image Source: https://github.com/soulfind-dev/soulfind/blob/master/README.md Download the latest Soulfind container image from the GitHub Container Registry. ```bash docker pull ghcr.io/soulfind-dev/soulfind ``` -------------------------------- ### Export User Data Command Source: https://context7.com/soulfind-dev/soulfind/llms.txt Export your account data in JSON format. This is a self-service feature for users. ```bash exportdata ``` -------------------------------- ### Default Security Configuration Values Source: https://context7.com/soulfind-dev/soulfind/llms.txt Specifies default security-related constants, including the number of iterations for PBKDF2 password hashing and the default username for server-side operations. These are crucial for secure user authentication and server identification. ```d // Security enum pbkdf2_iterations = 100000; enum server_username = "server"; ``` -------------------------------- ### Update User Password Source: https://context7.com/soulfind-dev/soulfind/llms.txt Updates an existing user's password by hashing the new password with a new salt. ```d // Update password string newSalt = create_salt(); string newHash = hash_password("newpassword", newSalt, pbkdf2_iterations); db.update_user_password("username", newHash); ``` -------------------------------- ### User Management API Source: https://context7.com/soulfind-dev/soulfind/llms.txt Manage user accounts, privileges, bans, and admin status through the Database class. ```APIDOC ## User Management API Manage user accounts, privileges, bans, and admin status through the Database class. Users are stored with PBKDF2-hashed passwords. Privileges, bans, and admin status use Unix timestamps for expiration. ### Initialize Database ```d import soulfind.db : Database; import soulfind.pwhash : create_salt, hash_password; import soulfind.defines : pbkdf2_iterations; import std.datetime : days, Clock; auto db = new Database("soulfind.db"); ``` ### User Account Management #### Create a new user ```d string salt = create_salt(); string hash = hash_password("password123", salt, pbkdf2_iterations); bool added = db.add_user("newuser", hash); ``` #### Check if user exists ```d bool exists = db.user_exists("username"); ``` #### Update password ```d string newSalt = create_salt(); string newHash = hash_password("newpassword", newSalt, pbkdf2_iterations); db.update_user_password("username", newHash); ``` #### Delete user ```d // Delete user (cascades to rooms, tickers, etc.) bool deleted = db.del_user("username"); ``` #### Get user stats ```d auto stats = db.user_stats("username"); if (stats.exists) { uint speed = stats.upload_speed; uint files = stats.shared_files; uint folders = stats.shared_folders; } ``` ### Admin Management #### Make user admin for a duration ```d db.add_admin("username", 30.days); // Make admin for 30 days db.add_admin("username", Duration.max); // Make permanent admin ``` #### Remove admin status ```d db.del_admin("username"); // Remove admin status ``` #### Get admin expiration time ```d auto adminUntil = db.admin_until("username"); ``` ### Privilege Management #### Add user privileges for a duration ```d db.add_user_privileges("username", 365.days); // Add 1 year privileges ``` #### Remove user privileges for a duration ```d db.remove_user_privileges("username", 30.days); // Remove 30 days db.remove_user_privileges("username", Duration.max); // Remove all ``` #### Get privilege expiration time ```d auto privilegedUntil = db.user_privileged_until("username"); ``` ### Ban Management #### Ban user for a duration ```d db.ban_user("username", 7.days); // Ban for 7 days db.ban_user("username", Duration.max); // Ban forever ``` #### Unban user ```d db.unban_user("username"); ``` #### Get ban expiration time ```d auto bannedUntil = db.user_banned_until("username"); ``` ### Search Filtering #### Hide user from searches ```d db.set_user_unsearchable("spammer"); // Hide user from searches ``` #### Restore searchability ```d db.set_user_searchable("spammer"); // Restore searchability ``` #### Check if user is unsearchable ```d bool hidden = db.is_user_unsearchable("username"); ``` ### List Users #### Get all usernames ```d string[] allUsers = db.usernames(); ``` #### Get filtered usernames (admins, banned, privileged) ```d string[] admins = db.usernames("admin", Clock.currTime.toUnixTime); string[] banned = db.usernames("banned", Clock.currTime.toUnixTime); string[] privileged = db.usernames("privileges", Clock.currTime.toUnixTime); ``` #### Get total number of users ```d size_t totalUsers = db.num_users(); ``` ``` -------------------------------- ### Manage User Bans Source: https://context7.com/soulfind-dev/soulfind/llms.txt Ban or unban a user for a specified duration, or permanently. Also retrieves ban expiration time. ```d // Ban management db.ban_user("username", 7.days); // Ban for 7 days db.ban_user("username", Duration.max); // Ban forever db.unban_user("username"); auto bannedUntil = db.user_banned_until("username"); ``` -------------------------------- ### Delete User Account Source: https://context7.com/soulfind-dev/soulfind/llms.txt Deletes a user account from the database. This action cascades and removes associated data like rooms and tickers. ```d // Delete user (cascades to rooms, tickers, etc.) bool deleted = db.del_user("username"); ``` -------------------------------- ### Search Filter Management API Source: https://context7.com/soulfind-dev/soulfind/llms.txt Configure server-side and client-side search phrase filtering. Server-side filters block searches before distribution. Client-side filters are sent to clients for local filtering. Both types help manage inappropriate content. ```APIDOC ## Search Filter Management API ### Description Configure server-side and client-side search phrase filtering. Server-side filters block searches before distribution. Client-side filters are sent to clients for local filtering. Both types help manage inappropriate content. ### Methods - **filter_search_phrase(filter_type: SearchFilterType, phrase: string)**: Adds a phrase to the specified filter type (server or client). - **unfilter_search_phrase(filter_type: SearchFilterType, phrase: string)**: Removes a phrase from the specified filter type. - **search_filters(filter_type: SearchFilterType)**: Returns a list of all phrases for the specified filter type. - **num_search_filters(filter_type: SearchFilterType)**: Returns the count of phrases for the specified filter type. - **is_search_query_filtered(query: string)**: Checks if a search query matches any server-side filter. ### Example Usage ```d import soulfind.db : Database; import soulfind.defines : SearchFilterType; auto db = new Database("soulfind.db"); // Server-side filters (block at server before distribution) db.filter_search_phrase!(SearchFilterType.server)("inappropriate phrase"); db.unfilter_search_phrase!(SearchFilterType.server)("phrase to allow"); string[] serverFilters = db.search_filters!(SearchFilterType.server)(); size_t serverFilterCount = db.num_search_filters!(SearchFilterType.server)(); // Client-side filters (sent to clients for local filtering) db.filter_search_phrase!(SearchFilterType.client)("unwanted term"); db.unfilter_search_phrase!(SearchFilterType.client)("term to allow"); string[] clientFilters = db.search_filters!(SearchFilterType.client)(); size_t clientFilterCount = db.num_search_filters!(SearchFilterType.client)(); // Check if a search query matches any server-side filter bool isFiltered = db.is_search_query_filtered("search query with inappropriate phrase"); ``` ``` -------------------------------- ### Room Management API Source: https://context7.com/soulfind-dev/soulfind/llms.txt Manage chat rooms including public rooms, private rooms with membership control, and room tickers. Public rooms are created automatically when users join. Private rooms require an owner and have explicit membership and operator roles. ```APIDOC ## Room Management API ### Description Manage chat rooms including public rooms, private rooms with membership control, and room tickers. Public rooms are created automatically when users join. Private rooms require an owner and have explicit membership and operator roles. ### Methods - **add_room(name: string, owner: string = null)**: Creates a new room. If owner is specified, it's a private room. - **del_room(name: string)**: Deletes a room. - **get_room_type(name: string)**: Returns the type of the room (public, private, or non-existent). - **public_rooms()**: Returns a list of all public rooms. - **owned_rooms(username: string)**: Returns a list of rooms owned by the specified user. - **member_rooms(username: string, member_type: RoomMemberType = RoomMemberType.any)**: Returns a list of rooms the user is a member of, optionally filtered by member type. - **get_room_owner(room_name: string)**: Returns the owner of a private room. - **can_access_room(room_name: string, username: string)**: Checks if a user can access a private room. - **grant_room_membership(room_name: string, username: string)**: Grants membership to a user in a private room. - **revoke_room_membership(room_name: string, username: string)**: Revokes membership from a user in a private room. - **get_room_member_type(room_name: string, username: string)**: Returns the membership type of a user in a room. - **grant_room_operatorship(room_name: string, username: string)**: Grants operator status to a user in a private room. - **revoke_room_operatorship(room_name: string, username: string)**: Revokes operator status from a user in a private room. - **room_members(room_name: string, member_type: RoomMemberType = RoomMemberType.any)**: Returns a list of members in a room, optionally filtered by type. - **add_ticker(room_name: string, username: string, message: string)**: Adds a ticker message to a room. - **del_ticker(room_name: string, username: string)**: Deletes a user's ticker message from a room. - **room_tickers(room_name: string)**: Returns all ticker messages for a room. - **user_tickers(username: string, room_type: RoomType = RoomType._public)**: Returns all tickers for a user in a specified room type. - **del_user_tickers(username: string, room_type: RoomType = RoomType._public)**: Deletes all tickers for a user in a specified room type. - **num_room_tickers(room_name: string)**: Returns the count of ticker messages in a room. ### Example Usage ```d import soulfind.db : Database; import soulfind.defines : RoomType, RoomMemberType, RoomTicker; auto db = new Database("soulfind.db"); // Create rooms db.add_room("public-room"); // Create public room db.add_room("private-room", "owneruser"); // Create private room with owner // Delete room db.del_room("roomname"); // Get room type RoomType type = db.get_room_type("roomname"); // Returns: RoomType._public, RoomType._private, or RoomType.non_existent // List rooms string[] publicRooms = db.public_rooms(); string[] ownedRooms = db.owned_rooms("username"); string[] memberRooms = db.member_rooms!(RoomMemberType.any)("username"); string[] operatedRooms = db.member_rooms!(RoomMemberType.operator)("username"); // Private room access control string owner = db.get_room_owner("private-room"); bool canAccess = db.can_access_room("private-room", "username"); // Membership management db.grant_room_membership("private-room", "newmember"); db.revoke_room_membership("private-room", "member"); RoomMemberType memberType = db.get_room_member_type("private-room", "username"); // Operator management db.grant_room_operatorship("private-room", "operator"); db.revoke_room_operatorship("private-room", "operator"); string[] operators = db.room_members!(RoomMemberType.operator)("private-room"); string[] allMembers = db.room_members!(RoomMemberType.any)("private-room"); // Room tickers (scrolling messages) db.add_ticker("roomname", "username", "My status message"); db.del_ticker("roomname", "username"); RoomTicker[] tickers = db.room_tickers("roomname"); RoomTicker[] userTickers = db.user_tickers!(RoomType._public)("username"); db.del_user_tickers!(RoomType._public)("username"); // Remove all user's tickers ulong tickerCount = db.num_room_tickers("roomname"); ``` ``` -------------------------------- ### Default Length Limits for User-Generated Content Source: https://context7.com/soulfind-dev/soulfind/llms.txt Defines maximum lengths for various user-generated content fields to ensure data integrity and prevent abuse. This includes chat messages, interests, room names, and search queries. ```d // Length limits enum max_chat_message_length = 2048; enum max_interest_length = 64; enum max_room_name_length = 24; enum max_room_ticker_length = 1024; enum max_search_query_length = 256; enum max_username_length = 30; ``` -------------------------------- ### Remove User Tickers Command Source: https://context7.com/soulfind-dev/soulfind/llms.txt Remove public room tickers associated with a username. ```bash removetickers username ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.