### Install and Setup Craig Bot Source: https://context7.com/craigchat/craig/llms.txt Commands to clone the repository, install dependencies, and generate the Prisma client for the Craig bot. ```bash # Install dependencies git clone --recurse-submodules https://github.com/CraigChat/craig.git cd craig ./install.sh # Generate Prisma client yarn prisma:generate ``` -------------------------------- ### Docker Deployment Source: https://context7.com/craigchat/craig/llms.txt Build the Docker image and start the application using Docker Compose. Ensure Docker is installed and configured. ```bash docker build -t craig . ``` ```bash docker-compose up -d ``` -------------------------------- ### Basic config.json Structure Source: https://github.com/craigchat/craig/wiki/4.-Config.json This is the minimal `config.json` structure required to get the bot started. Replace placeholder values with your actual bot token, desired nickname, and relevant URLs. ```json { "token": "DISCORD BOT TOKEN", "nick": "BOTS NICKNAME", "url": "https://your_url", "longUrl": "https://your_url/home", "dlUrl": "https://your_url" } ``` -------------------------------- ### Run Craig Installation Script on Linux Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Execute the install script to automatically install dependencies and configure PostgreSQL. This script requires sudo privileges and generates an output log. ```shell ./install.sh ``` -------------------------------- ### Install Node.js Dependencies Source: https://github.com/craigchat/craig/wiki/2.-Cloning-&-Installing Install all required Node.js dependencies using npm. ```bash npm install ``` -------------------------------- ### Start Craig Bot (Single Shard) Source: https://context7.com/craigchat/craig/llms.txt Start the bot in single-shard mode. Navigate to the bot application directory before running the start command. ```bash cd apps/bot yarn start ``` -------------------------------- ### Copy configuration file Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Before editing, copy the example configuration file to a new file named 'install.config'. This file will hold your specific environment variables. ```bash cp ./install.config.example ./install.config ``` -------------------------------- ### Install apt packages for Craig Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md These are the essential apt packages required for running Craig on a Linux system. They are automatically installed by the install script. ```bash wget make inkscape ffmpeg flac fdkaac vorbis-tools opus-tools zip unzip lsb-release curl gpg redis postgresql dbus-x11 sed coreutils build-essential python-setuptools ``` -------------------------------- ### Install Screen Utility Source: https://github.com/craigchat/craig/wiki/5.-Running-the-Bot Installs the screen utility, which allows for persistent terminal sessions. ```bash sudo apt install screen ``` -------------------------------- ### Create Systemd Service File for Craig Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Define a systemd service to run the Craig installation script at startup. Replace USERNAME and /path/to/craig/ with your specific values. ```systemd [Unit] Description=Run Craig install script at startup [Service] Type=simple ExecStart=sudo /path/to/craig/install.sh User=USERNAME WorkingDirectory=/path/to/craig/ Restart=on-failure [Install] WantedBy=multi-user.target ``` -------------------------------- ### Install NVM using wget Source: https://github.com/craigchat/craig/wiki/1.-Pre-Requisites Installs Node Version Manager (NVM) using wget. This is an alternative to the cURL method. ```bash wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash ``` -------------------------------- ### Install Node.js Version 14 using NVM Source: https://github.com/craigchat/craig/wiki/1.-Pre-Requisites Installs Node.js version 14, which is known to work with Craig. This command also installs NPM. ```bash nvm install 14 ``` -------------------------------- ### Install Required Packages Source: https://github.com/craigchat/craig/wiki/1.-Pre-Requisites Installs essential packages for Craig Chat, including media tools, Node.js build tools, and PHP with common extensions. ```bash sudo apt install ffmpeg flac fdkaac zip unzip vorbis-tools opus-tools node-gyp make inkscape php7.3 php7.3-cli php7.3-mysql php7.3-gd php7.3-imagick php7.3-recode php7.3-tidy php7.3-xmlrpc php7.3-common php7.3-curl php7.3-mbstring php7.3-xml php7.3-bcmath php7.3-bz2 php7.3-intl php7.3-json php7.3-readline php7.3-zip libapache2-mod-php7.3 ``` -------------------------------- ### Start Screen Session Source: https://github.com/craigchat/craig/wiki/5.-Running-the-Bot Starts a new screen session named 'craig'. This session will persist even if you disconnect. ```bash screen -S craig ``` -------------------------------- ### Enable Craig Systemd Service Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Enable the systemd service to ensure Craig starts automatically on system boot. ```bash sudo systemctl enable craig.service ``` -------------------------------- ### View Previous Recordings Command Source: https://context7.com/craigchat/craig/llms.txt Lists the user's recent recordings that haven't expired yet. The response shows a paginated list with details like Guild, Channel, Start time, and options to Download or Delete. Example usage: /recordings. ```typescript // Command from apps/bot/src/commands/recordings.ts export default class Recordings extends GeneralCommand { constructor(creator: SlashCreator) { super(creator, { name: 'recordings', description: 'Access your previous recordings.', deferEphemeral: true }); } async run(ctx: CommandContext) { const recordings = await this.prisma.recording.findMany({ where: { userId: ctx.user.id, clientId: this.client.bot.user.id, expiresAt: { gt: new Date() } }, orderBy: { createdAt: 'desc' }, take: 10 }); return paginateRecordings(this.client, ctx.user.id); } } // Usage in Discord: // /recordings // Response shows paginated list: // Recording: aB3cD4eF5gH6 // Guild: My Podcast Server // Channel: podcast-room // Started: Jan 15, 2025 at 3:00 PM // [Download] [Delete] ``` -------------------------------- ### Set Ownership and Permissions for Install Script Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Restrict access to the install.sh script by setting ownership and execute permissions. Replace USERNAME and /path/to/craig/ with your specific values. ```bash sudo chown USERNAME:USERNAME /path/to/craig/install.sh sudo chmod 700 /path/to/craig/install.sh ``` -------------------------------- ### Install NVM using cURL Source: https://github.com/craigchat/craig/wiki/1.-Pre-Requisites Installs Node Version Manager (NVM) using cURL. This allows managing multiple Node.js versions. ```bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash ``` -------------------------------- ### Start Craig Bot (Sharded) Source: https://context7.com/craigchat/craig/llms.txt Initiate the bot with sharding enabled, suitable for large-scale deployments requiring multiple worker processes. ```bash yarn start:sharding ``` -------------------------------- ### Add Timestamp Note Command Source: https://context7.com/craigchat/craig/llms.txt Use this command to add a timestamped note to the current recording. The message is saved and can be retrieved via the API. Example usage: /note message:Start of interview section. ```typescript // Command from apps/bot/src/commands/note.ts export default class Note extends GeneralCommand { constructor(creator: SlashCreator) { super(creator, { name: 'note', description: 'Note something within the recording.', options: [ { type: CommandOptionType.STRING, name: 'message', description: 'The note to put down.', required: true } ] }); } async run(ctx: CommandContext) { const recording = this.recorder.recordings.get(ctx.guildID)! recording.note(ctx.options.message || ''); recording.pushToActivity(`${ctx.user.mention} added a note.`); return { content: 'Added the note to the recording!', ephemeral: true }; } } // Usage in Discord: // /note message:Start of interview section // Activity log shows: "00:15:32: @User added a note. - Start of interview section" // Notes are saved and can be retrieved via API: /api/recording/{id}/notes ``` -------------------------------- ### Update System Packages Source: https://github.com/craigchat/craig/wiki/1.-Pre-Requisites Updates the package list and upgrades installed packages. Run this after adding new repositories. ```bash sudo apt update && sudo apt upgrade ``` -------------------------------- ### Server Settings Command Source: https://context7.com/craigchat/craig/llms.txt Manage server-specific settings including access roles and bot profile customization. Use subcommands like 'view', 'access-role add', 'access-role remove', 'bot-profile edit', and 'bot-profile reset'. Example: /server-settings access-role add role:@Podcasters. ```typescript // Command structure from apps/bot/src/commands/serversettings.ts export default class ServerSettings extends GeneralCommand { constructor(creator: SlashCreator) { super(creator, { name: 'server-settings', description: 'Manage server settings.', options: [ { type: CommandOptionType.SUB_COMMAND, name: 'view' }, { type: CommandOptionType.SUB_COMMAND_GROUP, name: 'access-role', options: [ { type: CommandOptionType.SUB_COMMAND, name: 'add', options: [{ type: CommandOptionType.ROLE, name: 'role', required: true }] }, { type: CommandOptionType.SUB_COMMAND, name: 'remove', options: [{ type: CommandOptionType.ROLE, name: 'role', required: true }] } ] }, { type: CommandOptionType.SUB_COMMAND_GROUP, name: 'bot-profile', options: [ { type: CommandOptionType.SUB_COMMAND, name: 'edit' }, { type: CommandOptionType.SUB_COMMAND, name: 'reset' } ] } ] }); } } // View current settings: // /server-settings view // Response: "Access Roles: @Podcasters, @Streamers" // Add access role (allows role to manage recordings without Manage Server perm): // /server-settings access-role add role:@Podcasters // Remove access role: // /server-settings access-role remove role:@Podcasters ``` -------------------------------- ### Get Recording Info API Endpoint Source: https://context7.com/craigchat/craig/llms.txt Retrieves metadata about a specific recording using its ID. This includes guild, channel, requester information, and enabled features. Example usage: curl "https://domain.com/api/recording/aB3cD4eF5gH6?key=abc123". ```bash # Fetch recording information curl "https://domain.com/api/recording/aB3cD4eF5gH6?key=abc123" ``` -------------------------------- ### POST /api/commands/join - Start Recording Source: https://context7.com/craigchat/craig/llms.txt Initiates a multi-track recording session in a specified Discord voice channel. The bot joins the channel, indicates it's recording, and captures individual audio tracks for each participant. A recording ID, access key, and delete key are provided to the user. ```APIDOC ## POST /api/commands/join - Start Recording ### Description Starts a multi-track recording in a voice channel. The bot joins the specified channel, sets a `[RECORDING]` nickname indicator, and begins capturing audio from all participants. Each user gets their own audio track, and the recording is saved with unique access and delete keys. ### Method POST ### Endpoint /api/commands/join ### Parameters #### Query Parameters - **channel** (CHANNEL) - Required - The channel to record in. Accepts voice (2) and stage (13) channel types. ### Request Example ```json { "command": "join", "options": { "channel": "123456789012345678" } } ``` ### Response #### Success Response (200) - **recordingId** (string) - The unique identifier for the recording. - **accessKey** (string) - The key required to access and download the recording. - **deleteKey** (string) - The key required to permanently delete the recording. - **downloadUrl** (string) - The URL to download the recording. #### Response Example ```json { "recordingId": "aB3cD4eF5gH6", "accessKey": "xyz789abc", "deleteKey": "def123ghi", "downloadUrl": "https://domain.com/rec/aB3 দক্ষতাH6?key=xyz789abc" } ``` ``` -------------------------------- ### Install Specific Discord.js UWS Dependency Source: https://github.com/craigchat/craig/wiki/2.-Cloning-&-Installing Manually install a specific version of the @discordjs/uws dependency, which might be required for certain functionalities. ```bash npm install @discordjs/uws@^10.149.0 ``` -------------------------------- ### Add PHP 7.3 Repository Source: https://github.com/craigchat/craig/wiki/1.-Pre-Requisites Adds the Ondrej PHP repository to your system. This is required to install specific PHP versions. ```bash sudo add-apt-repository ppa:ondrej/php ``` -------------------------------- ### GET /api/recording/:id/notes - Get Recording Notes Source: https://context7.com/craigchat/craig/llms.txt Fetches all timestamped notes that were added during a recording session. ```APIDOC ## GET /api/recording/:id/notes ### Description Retrieves all timestamped notes added during the recording session. ### Method GET ### Endpoint /api/recording/:id/notes ### Query Parameters - **key** (string) - Required - Your API access key. ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **notes** (array) - An array of note objects. - **time** (string) - The timestamp of the note in milliseconds. - **note** (string) - The content of the note. ### Request Example ```bash curl "https://domain.com/api/recording/aB3cD4eF5gH6/notes?key=abc123" ``` ### Response Example ```json { "ok": true, "notes": [ { "time": "932000", "note": "Start of interview section" }, { "time": "1845000", "note": "Topic change: Project updates" }, { "time": "3120000", "note": "Q&A begins" } ] } ``` ``` -------------------------------- ### Get Recording Participants Source: https://context7.com/craigchat/craig/llms.txt Fetches the list of users who participated in a recording and their assigned track numbers. Requires the recording ID and an access key. ```bash # Fetch user list curl "https://domain.com/api/recording/aB3cD4eF5gH6/users?key=abc123" ``` -------------------------------- ### Define /join Command for Discord Bot Source: https://context7.com/craigchat/craig/llms.txt Defines the '/join' slash command for the Discord bot. Use this to start a multi-track recording in a voice channel. The bot joins the channel and captures audio from all participants into separate tracks. ```typescript // Command definition from apps/bot/src/commands/join.ts export default class Join extends GeneralCommand { constructor(creator: SlashCreator) { super(creator, { name: 'join', description: 'Start recording in a channel.', dmPermission: false, options: [ { type: CommandOptionType.CHANNEL, name: 'channel', description: 'The channel to record in.', channel_types: [2, 13] // Voice and Stage channels } ] }); } } ``` -------------------------------- ### Get Recording Notes Source: https://context7.com/craigchat/craig/llms.txt Retrieves all timestamped notes that were added during a recording session. Requires the recording ID and an access key. ```bash curl "https://domain.com/api/recording/aB3cD4eF5gH6/notes?key=abc123" ``` -------------------------------- ### GET /api/recording/:id/raw - Download Raw Recording Source: https://context7.com/craigchat/craig/llms.txt Allows downloading the original, unprocessed multi-track Ogg/Opus recording file. ```APIDOC ## GET /api/recording/:id/raw ### Description Downloads the raw multi-track Ogg/Opus recording file without processing. ### Method GET ### Endpoint /api/recording/:id/raw ### Query Parameters - **key** (string) - Required - Your API access key. ### Response #### Success Response (200) - **Content-Type**: audio/ogg ### Request Example ```bash curl -O "https://domain.com/api/recording/aB3cD4eF5gH6/raw?key=abc123" # Downloads: aB3cD4eF5gH6.ogg ``` ``` -------------------------------- ### Get Recording Duration Source: https://context7.com/craigchat/craig/llms.txt Retrieves the total duration of a recording in seconds. Requires the recording ID and an access key. ```bash curl "https://domain.com/api/recording/aB3cD4eF5gH6/duration?key=abc123" ``` -------------------------------- ### GET /api/recording/:id - Get Recording Info Source: https://context7.com/craigchat/craig/llms.txt Retrieves metadata about a recording including guild, channel, requester information, and enabled features. ```APIDOC ## GET /api/recording/:id - Get Recording Info ### Description Retrieves metadata about a recording including guild, channel, requester information, and enabled features. ### Method GET ### Endpoint /api/recording/:id ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the recording. #### Query Parameters - **key** (string) - Required - API key for authentication. ### Request Example ```bash curl "https://domain.com/api/recording/aB3cD4eF5gH6?key=abc123" ``` ### Response #### Success Response (200) - **guild** (string) - The name of the guild where the recording was made. - **channel** (string) - The name of the channel where the recording was made. - **requester** (string) - The username of the user who requested the recording. - **features** (array) - A list of enabled features for the recording. #### Response Example ```json { "guild": "My Podcast Server", "channel": "podcast-room", "requester": "User123", "features": ["mix", "auto-record", "cloud-drive"] } ``` ``` -------------------------------- ### Share Patron Perks Command Source: https://context7.com/craigchat/craig/llms.txt Allows patron users to share their premium features with an entire server. All recordings in that server will then use the patron's tier benefits. Example usage: /bless. ```typescript // Command from apps/bot/src/commands/bless.ts export default class Bless extends GeneralCommand { constructor(creator: SlashCreator) { super(creator, { name: 'bless', description: 'Bless this server, giving it your perks.', deferEphemeral: true, dmPermission: false }); } async run(ctx: CommandContext) { return await blessServer(ctx.user.id, ctx.guildID, this.emojis); } } // Usage in Discord: // /bless // Response: "You have blessed this server and gave it your perks. // All future recordings will have your features." // Server now inherits patron's features: // - Extended recording hours (up to 24h) // - Extended download expiry (up to 720h) // - Mix feature, auto-record, cloud drive, glowers, FLAC, MP3 ``` -------------------------------- ### GET /api/recording/:id/users - Get Recording Participants Source: https://context7.com/craigchat/craig/llms.txt Retrieves a list of users who participated in a specific recording, including their username and assigned track number. ```APIDOC ## GET /api/recording/:id/users ### Description Returns the list of users who participated in the recording with their track numbers. ### Method GET ### Endpoint /api/recording/:id/users ### Query Parameters - **key** (string) - Required - Your API access key. ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **users** (array) - An array of user objects. - **id** (string) - The unique identifier for the user. - **username** (string) - The username of the participant. - **discriminator** (string) - The discriminator for the username. - **globalName** (string) - The global display name of the user. - **track** (integer) - The track number assigned to the user for this recording. ### Request Example ```bash curl "https://domain.com/api/recording/aB3cD4eF5gH6/users?key=abc123" ``` ### Response Example ```json { "ok": true, "users": [ { "id": "111222333444555666", "username": "PodcastHost", "discriminator": "0", "globalName": "Podcast Host", "track": 1 }, { "id": "222333444555666777", "username": "GuestSpeaker", "discriminator": "0", "globalName": "Guest Speaker", "track": 2 } ] } ``` ``` -------------------------------- ### Configure visudo for Passwordless Script Execution Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Allow the install.sh script to run without a password prompt by adding an entry to the sudoers file. Replace USERNAME and /path/to/craig/ with your specific values. ```bash USERNAME ALL=(ALL) NOPASSWD: /path/to/craig/install.sh ``` -------------------------------- ### Navigate to Cook Directory Source: https://github.com/craigchat/craig/wiki/2.-Cloning-&-Installing Change directory into the 'cook' subdirectory where audio processing scripts are located. ```bash cd cook/ ``` -------------------------------- ### Clone Craig's source code Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Use this command to clone the Craig repository and its submodules, which is the first step in setting up a local instance. ```bash git clone --recurse-submodules https://github.com/CraigChat/craig.git ``` -------------------------------- ### GET /api/recording/:id/duration - Get Recording Duration Source: https://context7.com/craigchat/craig/llms.txt Retrieves the total duration of a specific recording in seconds. ```APIDOC ## GET /api/recording/:id/duration ### Description Returns the duration of the recording in seconds. ### Method GET ### Endpoint /api/recording/:id/duration ### Query Parameters - **key** (string) - Required - Your API access key. ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **duration** (number) - The duration of the recording in seconds. ### Request Example ```bash curl "https://domain.com/api/recording/aB3cD4eF5gH6/duration?key=abc123" ``` ### Response Example ```json { "ok": true, "duration": 3725.5 # Duration in seconds (1 hour, 2 minutes, 5.5 seconds) } ``` ``` -------------------------------- ### Run Database Migrations Source: https://context7.com/craigchat/craig/llms.txt Execute database migrations using Prisma. Ensure your environment is set up for Prisma before running. ```bash yarn prisma:deploy ``` -------------------------------- ### POST /server-settings - Configure Server Options Source: https://context7.com/craigchat/craig/llms.txt Manage server-specific settings including access roles and bot profile customization. ```APIDOC ## POST /server-settings - Configure Server Options ### Description Manage server-specific settings including access roles and bot profile customization. ### Method POST ### Endpoint /server-settings ### Sub-commands #### view - **Description**: View current server settings. - **Usage**: `/server-settings view` - **Response Example**: `Access Roles: @Podcasters, @Streamers` #### access-role add - **Description**: Add an access role (allows role to manage recordings without Manage Server perm). - **Method**: POST - **Endpoint**: `/server-settings/access-role/add` - **Parameters**: - **role** (Role) - Required - The role to add. - **Usage**: `/server-settings access-role add role:@Podcasters #### access-role remove - **Description**: Remove an access role. - **Method**: POST - **Endpoint**: `/server-settings/access-role/remove` - **Parameters**: - **role** (Role) - Required - The role to remove. - **Usage**: `/server-settings access-role remove role:@Podcasters #### bot-profile edit - **Description**: Edit the bot profile. - **Method**: POST - **Endpoint**: `/server-settings/bot-profile/edit` - **Parameters**: None specified. #### bot-profile reset - **Description**: Reset the bot profile to default. - **Method**: POST - **Endpoint**: `/server-settings/bot-profile/reset` - **Parameters**: None specified. ``` -------------------------------- ### Navigate to Craig Directory Source: https://github.com/craigchat/craig/wiki/2.-Cloning-&-Installing Change your current directory to the root of the cloned Craig repository. ```bash cd craig/ ``` -------------------------------- ### Advanced config.json with Local Hosting and Premium Features Source: https://github.com/craigchat/craig/wiki/4.-Config.json This configuration enables all premium features by default and assumes the website is hosted locally on the same machine as the bot. Ensure URLs are correctly set to `http://localhost/`. ```json { "token": "DISCORD BOT TOKEN", "nick": "BOTS NICKNAME", "url": "http://localhost/", "longUrl": "http://localhost/", "dlUrl": "http://localhost/", "rewards": false, "defaultFeatures": { "limits": {"record": 24, "download": 87660, "secondary": 20}, "auto": true, "mix": true, "glowers": true, "eccontinuous": true, "ecflac": true, "mp3": true } } ``` -------------------------------- ### Run Craig Application Source: https://github.com/craigchat/craig/wiki/5.-Running-the-Bot Executes the Craig application using Node.js. Ensure you are in the correct directory. ```bash node craig.js ``` -------------------------------- ### Required Environment Variables Source: https://context7.com/craigchat/craig/llms.txt Lists essential environment variables for running Craig, including Discord API credentials, database connection strings, and API server settings. ```bash # Discord Bot Credentials DISCORD_BOT_TOKEN="your-bot-token" DISCORD_APP_ID="your-app-id" CLIENT_ID="your-client-id" CLIENT_SECRET="your-client-secret" # Optional: Development server for slash command testing DEVELOPMENT_GUILD_ID="your-dev-server-id" # Database DATABASE_URL="postgresql://user:password@localhost:5432/craig?schema=public" # For Docker: DATABASE_URL="postgresql://user:password@db:5432/craig?schema=public" # API Server API_PORT=5029 API_HOST=127.0.0.1 # Use 0.0.0.0 for network access API_HOMEPAGE=http://localhost:5029 ``` -------------------------------- ### Build Craig Docker Image Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Build a Docker image for the Craig bot. Ensure Docker is running on the host machine before executing this command. ```shell docker build -t craig . ``` -------------------------------- ### Return to Craig Root Directory Source: https://github.com/craigchat/craig/wiki/2.-Cloning-&-Installing Navigate back to the root directory of the cloned Craig repository after completing the compilation steps. ```bash cd ../ ``` -------------------------------- ### Process Recording to FLAC in ZIP Source: https://context7.com/craigchat/craig/llms.txt Initiates audio processing to convert a raw recording to FLAC format and package it in a ZIP archive. Requires the recording ID, access key, and specifies the desired format and container. ```bash # Process recording to FLAC in a ZIP archive curl -X POST "https://domain.com/api/recording/aB3cD4eF5gH6/cook?key=abc123" \ -H "Content-Type: application/json" \ -d '{"format": "flac", "container": "zip"}' ``` -------------------------------- ### Compile C and SVG Files Source: https://github.com/craigchat/craig/wiki/2.-Cloning-&-Installing Compile all .c files into executables using gcc with optimization, and convert .svg files to .png using inkscape. This step is necessary for audio processing scripts. ```bash for i in *.c; do gcc -O3 -o ${i%.c} $i; done && for i in *.svg; do inkscape -e ${i%.svg}.png $i; done ``` -------------------------------- ### Clone Craig Repository Source: https://github.com/craigchat/craig/wiki/2.-Cloning-&-Installing Use this command to clone the official Craig repository from GitHub. ```bash git clone https://github.com/Yahweasel/craig.git ``` -------------------------------- ### Set API Host for external access Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Change the API_HOST to '0.0.0.0' in 'install.config' to allow access to the web GUI from any machine on the network, which is useful in headless environments. ```properties API_HOST=0.0.0.0 ``` -------------------------------- ### Find and Replace in Nano Editor Source: https://github.com/craigchat/craig/wiki/6.-Website-Setup These are commands for the nano text editor to initiate the search and replace functionality. Use these to update directory paths within configuration files. ```bash ^\ - Ctrl + \ (Will begin the search to replace feature in nano) /home/yahweasel - String to search for & replace /home/yourusername - String to replace with ``` -------------------------------- ### Monitor Craig Processes with PM2 Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Use 'pm2 monit' to observe the real-time resource usage and status of all managed processes. ```shell pm2 monit ``` -------------------------------- ### Process Recording to Mixed FLAC with Dynaudnorm Source: https://context7.com/craigchat/craig/llms.txt Initiates audio processing for a patron-only feature, converting to FLAC and outputting as a single mixed file with dynamic audio normalization enabled. Requires the recording ID and access key. ```bash # Process to mixed single-file output (patron feature) curl -X POST "https://domain.com/api/recording/aB3cD4eF5gH6/cook?key=abc123" \ -H "Content-Type: application/json" \ -d '{"format": "flac", "container": "mix", "dynaudnorm": true}' ``` -------------------------------- ### Configure database URL for Docker Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md If you are using Docker, you will need to modify the DATABASE_URL environment variable in your 'install.config' file to point to the correct database service. ```sh DATABASE_URL="postgresql://$POSTGRESQL_USER:$POSTGRESQL_PASSWORD@db:5432/$DATABASE_NAME?schema=public" ``` -------------------------------- ### Download Raw Recording Source: https://context7.com/craigchat/craig/llms.txt Downloads the original, unprocessed multi-track Ogg/Opus recording file. This is useful for manual processing or archival. Requires the recording ID and an access key. ```bash curl -O "https://domain.com/api/recording/aB3cD4eF5gH6/raw?key=abc123" ``` -------------------------------- ### Source NVM and Use Node Version Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Before running PM2 commands, ensure NVM is sourced and the correct Node.js version is active. ```shell source ~/.nvm/nvm.sh nvm use node ``` -------------------------------- ### Comment Out Redis Repository Line Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Workaround for Redis package signing errors on Kubuntu 23.10. Comment out the problematic line in the Redis sources list file. ```shell #deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb mantic main ``` -------------------------------- ### Set API Homepage for functional links Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Update API_HOMEPAGE in 'install.config' to the IP address or domain name of your Craig instance to ensure download links work correctly. ```properties API_HOMEPAGE=http://localhost:5029 ``` -------------------------------- ### Restart All Craig Processes Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Execute 'pm2 restart all' to gracefully stop and then restart all applications managed by PM2. ```shell pm2 restart all ``` -------------------------------- ### Access Recording Download via HTTP Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md When encountering browser issues with HTTPS on localhost for downloads, change the protocol from 'https://' to 'http://' by removing the 's'. ```url http://localhost:5029/rec/RECORDING_ID ``` -------------------------------- ### Monitor Bot with PM2 Source: https://context7.com/craigchat/craig/llms.txt Manage and monitor the bot process using PM2. Commands include monitoring, logging, restarting, and stopping all PM2-managed processes. ```bash pm2 monit ``` ```bash pm2 logs > pm2.log ``` ```bash pm2 restart all ``` ```bash pm2 stop all ``` -------------------------------- ### Configure Maximum Rewards for All Users Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Replace default Patreon reward tiers with this configuration to enable maximum rewards for all users. This is typically used by self-hosters who do not use Patreon. ```javascript rewardTiers: { [0]: { recordHours: 24, downloadExpiryHours: 720, features: ['mix', 'auto', 'drive', 'glowers', 'eccontinuous', 'ecflac', 'mp3'], sizeLimitMult: 5 } } ``` -------------------------------- ### Generate Avatar Videos Source: https://context7.com/craigchat/craig/llms.txt Creates animated avatar videos with speaking indicators for each participant. This is a patron-only feature that requires specifying format, container, and optional colors. Requires the recording ID and access key. ```bash # Generate avatar videos in MOV format with custom colors curl -X POST "https://domain.com/api/recording/aB3cD4eF5gH6/cook/avatars?key=abc123" \ -H "Content-Type: application/json" \ -d '{ "format": "movsfx", "container": "exe", "transparent": false, "bg": "1a1a2e", "fg": "00ff88" }' ``` -------------------------------- ### Edit index.php for Craig Chat Source: https://github.com/craigchat/craig/wiki/6.-Website-Setup Open the index.php file in your site's root directory using nano for editing. This is necessary to update directory paths. ```bash sudo nano /var/www/your_site/index.php ``` -------------------------------- ### Check Code Formatting with Yarn Source: https://github.com/craigchat/craig/blob/master/CONTRIBUTING.md Use this command to verify that your code contributions adhere to the project's established code style. It helps maintain consistency across the codebase. ```bash yarn lint ``` -------------------------------- ### Output Craig Process Logs to File Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Redirect the output of 'pm2 logs' to a file for later analysis or debugging. ```shell pm2 logs > pm2.log ``` -------------------------------- ### Sync Slash Commands to Discord Source: https://context7.com/craigchat/craig/llms.txt Synchronize slash commands with Discord. Use `yarn sync` for production environments to update all servers, and `yarn sync:dev` for development to target a specific guild. ```bash yarn sync ``` ```bash yarn sync:dev ``` -------------------------------- ### Check Craig Systemd Service Status Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Verify the status of the Craig systemd service after enabling it or after a reboot. ```bash sudo systemctl status craig.service ``` -------------------------------- ### Default Bot Configuration Source: https://context7.com/craigchat/craig/llms.txt Configures Discord bot behavior, reward tiers, and recording limits. Includes settings for Redis, sharding, and Discord API integration. ```javascript module.exports = { // Redis connection for caching and rate limiting redis: { host: 'localhost', port: 6379, keyPrefix: 'craig:' }, // Sharding configuration for large bot deployments sharding: { file: './index.js', shardCount: 2, readyTimeout: 60000 }, dexare: { token: process.env.DISCORD_BOT_TOKEN, applicationID: process.env.DISCORD_APP_ID, craig: { // Download page settings downloadProtocol: 'https', downloadDomain: 'localhost:5029', homepage: 'https://craig.chat/', dashboardURL: 'https://my.craig.chat', // Recording limits sizeLimit: 536870912, // 512MB default limit removeNickname: true, recordingFolder: '../../rec', // Real-time webapp for monitoring webapp: { on: true, url: 'ws://localhost:9001/shard', token: 'your-webapp-token', connectUrl: 'http://localhost:5000?id={id}&key={key}' }, // Patron reward tiers rewardTiers: { [0]: { // Free tier recordHours: 6, downloadExpiryHours: 168, // 7 days features: [] }, [10]: { // Tier 1 ($1 patron) recordHours: 6, downloadExpiryHours: 336, // 14 days features: ['drive', 'glowers'], sizeLimitMult: 2 }, [20]: { // Tier 2 ($4 patron) recordHours: 24, downloadExpiryHours: 720, // 30 days features: ['mix', 'auto', 'drive', 'glowers', 'eccontinuous'], sizeLimitMult: 2 }, [100]: { // Top tier recordHours: 24, downloadExpiryHours: 720, features: ['mix', 'auto', 'drive', 'glowers', 'eccontinuous', 'ecflac', 'mp3'], sizeLimitMult: 5 } } }, status: { type: 4, name: 'craig', state: 'Recording VCs' } } }; ``` -------------------------------- ### Move Craig Chat Web Directory to Apache Root Source: https://github.com/craigchat/craig/wiki/6.-Website-Setup Use this command to move the contents of the Craig Chat web directory to the Apache root if you have followed the Virtual Hosts tutorial. ```bash mv web/* /var/www/your_site ``` -------------------------------- ### Invite Craig Bot to Discord Server Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Use this URL to invite Craig to your Discord server. Replace CLIENT_ID with your bot's actual client ID. ```url https://discord.com/oauth2/authorize?client_id=CLIENT_ID&permissions=68176896&scope=bot%20applications.commands ``` -------------------------------- ### POST /api/recording/:id/cook/avatars - Generate Avatar Videos Source: https://context7.com/craigchat/craig/llms.txt Generates animated avatar videos for each participant, including speaking indicators. This is a patron-only feature. ```APIDOC ## POST /api/recording/:id/cook/avatars ### Description Creates animated avatar videos with speaking indicators for each participant (patron feature). ### Method POST ### Endpoint /api/recording/:id/cook/avatars ### Query Parameters - **key** (string) - Required - Your API access key. ### Request Body - **format** (string) - Required - The desired video format (e.g., "png", "movsfx", "movpngsfx", "movqtrle"). - **container** (string) - Optional - The desired container format (e.g., "zip", "exe" for mov formats). - **transparent** (boolean) - Optional - Whether the background should be transparent. - **bg** (string) - Optional - Background color in 6-character hex code (e.g., "1a1a2e"). - **fg** (string) - Optional - Foreground color in 6-character hex code (e.g., "00ff88"). ### Request Example ```bash # Generate avatar videos in MOV format with custom colors curl -X POST "https://domain.com/api/recording/aB3cD4eF5gH6/cook/avatars?key=abc123" \ -H "Content-Type: application/json" \ -d '{ "format": "movsfx", "container": "exe", "transparent": false, "bg": "1a1a2e", "fg": "00ff88" }' ``` ### Notes Available formats: png, movsfx, movpngsfx, movqtrle Containers: zip, exe (self-extracting for mov formats) bg/fg: 6-character hex color codes ``` -------------------------------- ### POST /bless - Share Patron Perks with Server Source: https://context7.com/craigchat/craig/llms.txt Allows patron users to share their premium features with an entire server, enabling all recordings in that server to use the patron's tier benefits. ```APIDOC ## POST /bless - Share Patron Perks with Server ### Description Allows patron users to share their premium features with an entire server, enabling all recordings in that server to use the patron's tier benefits. ### Method POST ### Endpoint /bless ### Parameters No parameters required. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **content** (string) - Confirmation message. #### Response Example ```json { "content": "You have blessed this server and gave it your perks. All future recordings will have your features." } ``` ### Notes Server now inherits patron's features: - Extended recording hours (up to 24h) - Extended download expiry (up to 720h) - Mix feature, auto-record, cloud drive, glowers, FLAC, MP3 ``` -------------------------------- ### POST /api/commands/autorecord - Automatic Recording Configuration Source: https://context7.com/craigchat/craig/llms.txt Manages automatic recording settings for voice channels. This command allows users to view, enable, or disable auto-recording based on specified conditions like minimum participants or specific user triggers. ```APIDOC ## POST /api/commands/autorecord - Automatic Recording Configuration ### Description Manages automatic recording triggers for voice channels. When conditions are met (minimum users or trigger users/roles join), recording starts automatically. ### Method POST ### Endpoint /api/commands/autorecord ### Parameters #### Request Body - **subCommand** (string) - Required - The action to perform: 'view', 'on', or 'off'. - **channel** (CHANNEL) - Required for 'on' and 'off' subcommands - The voice channel to configure. - **minimum** (INTEGER) - Optional for 'on' subcommand - The minimum number of users required to start recording (0-99). - **triggers** (STRING) - Optional for 'on' subcommand - A comma-separated list of user IDs or role IDs that trigger recording. - **postChannel** (CHANNEL) - Optional for 'on' subcommand - The channel where notifications will be sent. ### Request Example (Enable auto-record) ```json { "subCommand": "on", "channel": "123456789012345678", "minimum": 2 } ``` ### Request Example (View auto-record settings) ```json { "subCommand": "view" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation or status message. - **settings** (object) - (Only for 'view' subcommand) - Contains auto-record configurations for channels. #### Response Example (Enable) ```json { "message": "Auto-recording enabled for channel." } ``` #### Response Example (View) ```json { "message": "Auto-record settings:", "settings": [ { "channelId": "123456789012345678", "minimumUsers": 2, "triggers": [], "postChannelId": null } ] } ``` ``` -------------------------------- ### POST /api/recording/:id/cook - Process Recording Source: https://context7.com/craigchat/craig/llms.txt Initiates the audio processing for a recording, converting it into specified formats and containers. This can include features like dynamic audio normalization. ```APIDOC ## POST /api/recording/:id/cook ### Description Initiates audio processing to convert the raw Ogg/Opus recording into various output formats. ### Method POST ### Endpoint /api/recording/:id/cook ### Query Parameters - **key** (string) - Required - Your API access key. ### Request Body - **format** (string) - Required - The desired audio format (e.g., "flac", "aac", "vorbis", "wav", "opus", "mp3" (patron only)). - **container** (string) - Optional - The desired container format (e.g., "zip", "aupzip", "mix" (patron only)). - **dynaudnorm** (boolean) - Optional - Whether to apply dynamic audio normalization (patron only). ### Request Example ```bash # Process recording to FLAC in a ZIP archive curl -X POST "https://domain.com/api/recording/aB3cD4eF5gH6/cook?key=abc123" \ -H "Content-Type: application/json" \ -d '{"format": "flac", "container": "zip"}' ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **ready** (boolean) - Indicates if the processing is complete (for status check requests). - **download** (object) - Information about the downloadable file (when ready). - **file** (string) - The name of the downloaded file. - **format** (string) - The format of the processed audio. - **container** (string) - The container of the processed audio. ### Response Example ```json { "ok": true } ``` ### Notes Available formats: flac, aac, vorbis, wav, opus, mp3 (patron only) Available containers: zip, aupzip, mix (patron only) ``` -------------------------------- ### Add Redis Repository Line to sources.list Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Add the Redis repository line to the sources list, dynamically determining the distribution codename. This is part of a workaround for Redis package signing issues. ```shell echo "#deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list ``` -------------------------------- ### Stop All Craig Processes Source: https://github.com/craigchat/craig/blob/master/SELFHOST.md Use 'pm2 stop all' to terminate all running applications managed by PM2. ```shell pm2 stop all ``` -------------------------------- ### POST /recordings - View Previous Recordings Source: https://context7.com/craigchat/craig/llms.txt Lists the user's recent recordings that haven't expired yet. ```APIDOC ## POST /recordings - View Previous Recordings ### Description Lists the user's recent recordings that haven't expired yet. ### Method POST ### Endpoint /recordings ### Parameters No parameters required. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **content** (string) - Paginated list of recordings. #### Response Example ```json { "content": "Recording: aB3cD4eF5gH6\nGuild: My Podcast Server\nChannel: podcast-room\nStarted: Jan 15, 2025 at 3:00 PM\n[Download] [Delete]" } ``` ``` -------------------------------- ### Check Recording Processing Status Source: https://context7.com/craigchat/craig/llms.txt Checks the status of an ongoing audio processing job for a recording. Returns 'ready: true' and download information when processing is complete. Requires the recording ID and access key. ```bash # Check processing status curl "https://domain.com/api/recording/aB3cD4eF5gH6/cook?key=abc123" ``` -------------------------------- ### Define /stop Command for Discord Bot Source: https://context7.com/craigchat/craig/llms.txt Defines the '/stop' slash command for the Discord bot. Use this to end the current recording session. The audio file is finalized and saved locally, with options for cloud upload. ```typescript // Command definition from apps/bot/src/commands/stop.ts export default class Stop extends GeneralCommand { constructor(creator: SlashCreator) { super(creator, { name: 'stop', description: 'Stop your current recording.', dmPermission: false, deferEphemeral: true }); } async run(ctx: CommandContext) { // Validates permissions and recording existence const recording = this.recorder.recordings.get(ctx.guildID)! await recording.stop(false, ctx.user.id); return { content: 'Stopped recording.', ephemeral: true }; } } ```