### Install Dependencies with Bun Source: https://subspace.institute/docs/laplace-chat/jupiter Installs project dependencies using the Bun runtime. This is a prerequisite for running the LAPLACE Jupiter bot. ```bash bun install ``` -------------------------------- ### Full config.js Configuration Example Source: https://subspace.institute/docs/eye-of-providence This comprehensive `config.js` example illustrates a full suite of configuration options available for the Subspace Institute project. It includes settings for loop intervals, API throttles for various platforms (Douyin, Bilibili, Weibo, etc.), custom proxy configurations, request options, custom cookies for authentication, API credentials for Twitch, and global settings for Telegram, QQ Guild, Sentry, and an image proxy. ```javascript export default { // Loop interval in milliseconds loopInterval: 60 * 1000, // A small amount of time to wait inserted before each account loopPauseTimeBase: 1000, // Math.random() time factor for `loopPauseTimeBase` loopPauseTimeRandomFactor: 2000, // 24 hours, if latest post older than this value, do not send notifications douyinBotThrottle: 36 * 3600 * 1000, douyinLiveBotThrottle: 1200 * 1000, // 20 mins // 65 mins, bilibili sometimes got limit rate for 60 mins. bilibiliBotThrottle: 65 * 60 * 1000, bilibiliLiveBotThrottle: 65 * 60 * 1000, bilibiliFollowingBotThrottle: 3600 * 1000, rssBotThrottle: 12 * 3600 * 1000, weiboBotThrottle: 3600 * 1000, ddstatsBotThrottle: 3600 * 1000, tapechatBotThrottle: 3600 * 1000, afdianBotThrottle: 3600 * 1000, qqMusicBotThrottle: 3600 * 1000, twitchBotThrottle: 65 * 60 * 1000, // Custom proxy to bypass bilibili API rate limit // Default: '' rateLimitProxy: 'http://10.2.1.2:7890', // Options for got // Default: // { // requestOptions: { // timeout: { // request: 4000 // } // } // } pluginOptions: { requestOptions: { timeout: { request: 3000, }, }, customCookies: { // Nov 11, 2021 // Douyin main site now requires `__ac_nonce` and `__ac_signature` to work douyin: `__ac_nonce=XXX; __ac_signature=XXX;`, // get `SESSDATA` cookie from https://www.bilibili.com/ bilibili: `SESSDATA=XXX`, // get `SUB` cookie from https://m.weibo.cn/ weibo: `SUB=XXX`, }, }, // Twitch API credentials // Create your twitch app: https://dev.twitch.tv/console twitch: { clientId: `xxx`, clientSecret: `yyy`, }, // Telegram global configs telegram: { enabled: true, apiBase: 'https://api.telegram.org/bot', token: '', // If bot belongs to a premium account. Accounts with premium perks has // 2048 characters limit (1024 for free accounts) for photo and video // captions // Defautl: false premium: true, // Define a special channel / chat to send debugging info. If this is not // defined. No debugging info will be sent. // Default: undefined debuggingChannelId: -10012345, }, // QQ Guild global configs qGuild: { enabled: true, // go-cqhttp endpoint // See https://github.com/Mrs4s/go-cqhttp to learn how to deploy qo-cqhttp // and send updates to QQ Guild apiBase: 'http://10.2.1.2:5700', }, // Sentry global configs sentry: { enabled: true, dsn: `https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@ingest.sentry.io/9`, environment: `production`, tracesSampleRate: 1.0, }, // Proxy to fetch images // For more info: https://github.com/willnorris/imageproxy // Default: '' imageProxy: `https://myimageproxy.tld/imageproxy/`, accounts: [ { // Use `false` to disable checking this profile // Default: true enabled: true, // Slug is used to identify accounts in logs slug: '嘉然', // Set to `true` to add `slug` at the beginning of the notification. // ie: #嘉然. Useful for pushing notifications with multiple accounts in // one channel // Default: false showSlug: true, // When `showSlug` is `true` and this option is defined. `slugNotification` // will be used instead of `slug`. This can be helpful when you have // multiple accounts but still want to show the same notification slug. // For example account A and B must be different slugs but when you set // `slugNotification`. They can be the same in the notifications. slugNotification: '嘉然', // bilibili account UID biliId: '672328094', // Check bilibili activity comments. Disabled by default // This fires another API to monitor comments and replies. It's not // recommended to enable this feature if you have a lot of accounts to // monitor or you will hit API rate limit soon. // Default: false bilibiliFetchComments: true, // In addition to `bilibiliFetchComments`, this also fetches the comments // and replies in the sticky dynamic // Default: false bilibiliFetchCommentsSticky: true, // How many page to fetch for comments. Should be >= 0. // 0 means fetch only 1 (index 0) page // Default: 5 bilibiliFetchCommentsLimit: 5, // In addition to `bilibiliFetchComments`, this disables fetching replies // in each comments. // Default: false bilibiliFetchCommentsDisableReplies: true, // Fetch specific users from comments and replies // Default: undefined bilibiliFetchCommentsWatchUsers: ['2132132180406'], } ], } ``` -------------------------------- ### Start Docker Compose and Create .env File Source: https://subspace.institute/docs/laplace-chat/jupiter Commands to create a `.env` file with Telegram API credentials and then start the Docker Compose service for the Subspace Institute bot. ```bash # Create .env file with your credentials echo "TELEGRAM_API_ID=your_telegram_api_id" > .env echo "TELEGRAM_API_HASH=your_telegram_api_hash" >> .env echo "TELEGRAM_BOT_TOKEN=your_bot_token" >> .env # Start the container docker-compose up -d ``` -------------------------------- ### LAPLACE Jupiter YAML Configuration Example Source: https://subspace.institute/docs/laplace-chat/jupiter Provides an example configuration structure for the LAPLACE Jupiter bot in YAML format. This includes settings for event bridge connections and room-specific routing rules. ```yaml # LAPLACE Event Bridge connection settings bridges: - name: primary url: wss://your-websocket-server.com token: optional_authentication_key - name: secondary url: wss://another-server.com token: another_token # Room configurations rooms: - room_id: 25034104 uid: 2132180406 # Streamer's UID slug: 明前奶绿 vip_users: [] telegram_announce_ch: -12345 telegram_watchers_ch: -12345 # Optional: Minimum gift price to notify (in coins, 1000 = 1 CNY, default: 100000) minimum_gift_price: 100000 # Optional: Minimum guard price to notify (in coins, 1000 = 1 CNY, default: 200000) minimum_guard_price: 200000 # Optional: Whether to notify room enter events (default: false) notify_room_enter: false # Optional: Only notify when VIP users enter (default: false) notify_watched_users_only: false # Optional: Specific bridge name to monitor this room (if not specified, all bridges will monitor) bridge: primary ``` -------------------------------- ### Copy Configuration File Source: https://subspace.institute/docs/laplace-chat/jupiter Copies the example configuration file to a new file named 'config.yaml'. This allows users to customize settings for the LAPLACE Jupiter bot. ```bash cp config.example.yaml config.yaml ``` -------------------------------- ### Minimal config.js Example Source: https://subspace.institute/docs/eye-of-providence This snippet shows a minimal configuration for `config.js`, focusing on essential account settings. It demonstrates how to define accounts with their enabled status and a unique slug. ```javascript export default { accounts: [ { enabled: true, slug: '嘉然', biliId: '672328094', }, ], } ``` -------------------------------- ### LAPLACE AI Chat and Translation API Usage Examples Source: https://context7.com/context7/subspace_institute/llms.txt This section provides bash examples for interacting with LAPLACE's AI Chat and Chat Translation APIs. It demonstrates the structure of POST requests, including required headers and JSON payloads containing authentication tokens, messages, model names, and translation parameters. Rate limits and prohibited activities are also listed. ```bash # AI Chat API Rate Limits # - 1,000 requests per day # - Max input: based on model context window # - Max attachment: 4MB per request # Chat Translation API Rate Limits # - 120 requests per minute # - Max input: based on model token limits # Example API usage (requires Login Sync token) curl -X POST https://edge-workers.laplace.cn/laplace/ai-chat \ -H "Content-Type: application/json" \ -d '{ "token": "your-login-sync-token", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Translate this to Japanese: Hello world"} ], "model": "gpt-4o-mini", "temperature": 0.7 }' # Translation API curl -X POST https://edge-workers.laplace.cn/laplace/chat-translation \ -H "Content-Type: application/json" \ -d '{ "token": "your-login-sync-token", "text": "今天天气真好", "source": "zh-CN", "target": "en-US" }' # Prohibited activities: # - Reverse engineering APIs # - Circumventing rate limits # - Sharing API credentials # - Generating illegal/harmful content # - Automated scraping # - Reselling without permission # Violations result in: # - Temporary API suspension # - Permanent token termination # - Additional usage restrictions # Data retention: 3650 days (10 years) for operational logs # SLA: 99% uptime, 12h notice for maintenance # Support: 144h response time for normal users ``` -------------------------------- ### Run eop_blive with Docker Source: https://subspace.institute/docs/eye-of-providence/eop_blive This snippet demonstrates how to run the eop_blive service using Docker. It shows how to mount a configuration file and specifies the image registry. Ensure you have Docker installed and a `config.ini` file present. ```docker docker run \ -v $(pwd)/config.ini:/app/config.ini:ro \ sparanoid/eop-blive # ...or use ghcr.io registry ghcr.io/sparanoid/eop-blive ``` -------------------------------- ### Start Bun Bridge Server (Deprecated) Source: https://subspace.institute/docs/laplace-chat/event-bridge Command to start the deprecated Bun/Node.js implementation of the LAPLACE Event Bridge. It requires Bun to be installed and allows for debug mode and token-based authentication. ```bash # Start the Bun server bun run --cwd packages/server-bun start --debug --auth "your-secure-token" ``` -------------------------------- ### Development Commands for eop Project Source: https://subspace.institute/docs/eye-of-providence Provides essential commands for setting up the development environment for the eop project. This includes installing dependencies using PNPM, creating a configuration file, and running the core application locally with verbose logging. ```bash # Install dependencies pnpm install # Create config file vi config.js # Execute locally pnpm core start -c config.js --verbose --once ``` -------------------------------- ### Run Bot Locally with Bun Source: https://subspace.institute/docs/laplace-chat/jupiter Commands to run the bot locally using Bun. This includes a standard run command, a command for hot reloading during development, and a general start script. ```bash bun run src/index.ts bun run dev bun run start ``` -------------------------------- ### Test WebSocket Connection with wscat (Shell) Source: https://subspace.institute/docs/laplace-chat/event-fetcher Provides command-line examples using 'wscat' to test the WebSocket API connection. Supports testing with Sec-WebSocket-Protocol header or token query parameter, and includes room filtering. ```shell # Via Sec-WebSocket-Protocol header wscat -c ws://localhost:8080 -s client -s # Via token query parameter wscat -c 'ws://localhost:8080/?token=' # With room filtering wscat -c 'ws://localhost:8080/?rooms=456117,25034104' # With both query-style authentication and room filtering wscat -c 'ws://localhost:8080/?token=&rooms=456117,25034104' ``` -------------------------------- ### Set Up LAPLACE Login Sync (Bash) Source: https://context7.com/context7/subspace_institute/llms.txt This bash script demonstrates how to set up LAPLACE Login Sync for synchronizing browser cookies. It outlines the installation of a browser extension, the format of sync credentials, and how to use these credentials in LAPLACE Chat, Event Fetcher, and custom CookieCloud servers. It also includes security measures for compromised sync keys. ```bash # Install browser extension from laplace.live/login-sync # Extension will generate sync credentials automatically # Format: @ # Example: a1b2c3d4e5f6@mySecretPassword123 # Use in LAPLACE Chat configurator: # 1. Paste sync key into "同步密钥" field # 2. Enable "使用 Login Sync" option # 3. Chat will auto-sync bilibili login state every 5 minutes # Use with LAPLACE Event Fetcher: # Add to docker-compose.yml environment: LOGIN_SYNC_TOKEN: a1b2c3d4e5f6@mySecretPassword123 # Use with custom CookieCloud server: # 1. Deploy CookieCloud server with HTTPS # 2. Configure browser extension with your server URL # 3. Set sync interval to 5 minutes # 4. Domain keywords: bilibili.com # 5. Sync Local Storage: No # Security: If sync key is compromised # 1. Logout from bilibili in browser # 2. Open extension, click "保存并同步" # 3. Click "重置" then "保存并同步" again # 4. Re-login to bilibili # 5. Update sync key everywhere it's used ``` -------------------------------- ### ElevenLabs TTS API Request (JavaScript) Source: https://subspace.institute/docs/open-platform/tts-elevenlabs Example JavaScript code to send a POST request to the ElevenLabs TTS API using the fetch API. It demonstrates how to construct the request body and headers. ```javascript async function generateSpeech(text, voice, token) { const response = await fetch('https://edge-workers.laplace.cn/laplace/tts-elevenlabs', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: text, voice: voice, token: token }) }); if (!response.ok) { const errorData = await response.json(); throw new Error(`API Error: ${errorData.message}`); } return response.blob(); // Assuming the response is audio/mpeg } ``` -------------------------------- ### Volcengine TTS API Request (Go) Source: https://subspace.institute/docs/open-platform/tts-volcengine Example Go code for sending a POST request to the Volcengine TTS API. It uses the `net/http` package to create a client, construct the request body, and send it. Error handling for network requests and response processing is included. ```go package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { url := "https://edge-workers.laplace.cn/laplace/tts-volcengine" requestBody := map[string]string{ "text": "Your text here", "voice": "string", "appId": "string", "token": "string" } jsonBody, err := json.Marshal(requestBody) if err != nil { fmt.Printf("Error marshalling JSON: %s\n", err) return } resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonBody)) if err != nil { fmt.Printf("Error making POST request: %s\n", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Printf("Error reading response body: %s\n", err) return } fmt.Printf("Status Code: %d\n", resp.StatusCode) fmt.Printf("Response Body: %s\n", string(body)) } ``` -------------------------------- ### Configure LAPLACE Live Bot with Bun Runtime (JavaScript) Source: https://context7.com/context7/subspace_institute/llms.txt Provides a configuration object for the LAPLACE Live Bot, designed to run with the Bun runtime. It details database connections (PostgreSQL, Redis), Bilibili room settings, LLM integration (OpenAI compatible), schedule API, administrator roles, and feature enablement for AI, check-in, and scheduling. It also includes examples of bot commands and user interactions. ```javascript // config.js example for deploying with Bun runtime export default { database: { postgres: process.env.DATABASE_URL, redis: process.env.REDIS_URL }, bilibili: { rooms: [456117, 25034104], loginSyncToken: process.env.LOGIN_SYNC_TOKEN }, llm: { // Compatible with any OpenAI API format apiBase: 'https://api.openai.com/v1', apiKey: process.env.OPENAI_API_KEY, model: 'gpt-4', temperature: 0.8, systemPrompt: 'You are Happy Jianguo, a friendly AI assistant in a bilibili livestream.' }, schedule: { apiUrl: 'https://laplace.live/api/events' }, admins: [ { uid: '123456', level: 'owner' }, { uid: '789012', level: 'moderator' } ], features: { ai: { enabled: true, autoStart: false }, checkin: { enabled: true }, schedule: { enabled: true } } }; // Bot commands usage in livestream chat: // /bot start - Enable bot (Mod only) // /bot stop - Disable bot (Mod only) // /bot ai start - Enable AI responses (Mod only) // /bot checkin start - Enable checkin feature (Mod only) // /bot status - Show bot status (Mod only) // /bot help - Show help (Everyone) // /bot ping - Ping test (Everyone) // User interactions: // @哈皮坚果 你好呀 - Trigger AI response // 日程 - Query today's schedule // 今天播吗 - Query if streaming today // 打卡 - Check in // 测试 - Test bot responsiveness ``` -------------------------------- ### Create Changeset for SDK Release Source: https://subspace.institute/docs/laplace-chat/event-bridge This command initiates the process of creating a changeset file to document changes made to the SDK. It guides the user through selecting the package, version bump, and writing a description for the release. ```shell bunx @changesets/cli ``` -------------------------------- ### ElevenLabs TTS API Request (C#) Source: https://subspace.institute/docs/open-platform/tts-elevenlabs Example C# code using HttpClient to send a POST request to the ElevenLabs TTS API. It shows serialization of the request object and handling the response. ```csharp using System; using System.Net.Http; using System.Text; using System.Text.Json; using System.Threading.Tasks; public class ElevenLabsTTS { public async Task GenerateSpeechAsync(string text, string voice, string token) { using (var httpClient = new HttpClient()) { var url = "https://edge-workers.laplace.cn/laplace/tts-elevenlabs"; var requestBody = new { text = text, voice = voice, token = token }; var jsonPayload = JsonSerializer.Serialize(requestBody); var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json"); var response = await httpClient.PostAsync(url, content); if (!response.IsSuccessStatusCode) { var errorContent = await response.Content.ReadAsStringAsync(); // Handle error response, possibly parse JSON error message throw new Exception($"API Error: {response.StatusCode} - {errorContent}"); } // Assuming the response is audio/mpeg var audioBytes = await response.Content.ReadAsByteArrayAsync(); // Process audioBytes } } } ``` -------------------------------- ### CSS with Partial Metadata Source: https://subspace.institute/docs/laplace-chat/templates An example of a CSS file for a remote template that only includes essential metadata fields like title and author. This demonstrates flexibility in providing template information, where only required fields must be present. ```css /* @title 气泡样式(魔改) @author LAPLACE Chat @updated May 10, 2025, 7:02:13 AM PDT */ @layer remote-css { body { background-color: rgba(0, 0, 0, 0); } /* 其他样式 */ ... } ``` -------------------------------- ### Volcengine TTS API Request (Java) Source: https://subspace.institute/docs/open-platform/tts-volcengine Example Java code demonstrating how to make a POST request to the Volcengine TTS API using Apache HttpClient. This snippet includes setting up the request, adding JSON data to the body, and handling the response. It is designed for environments where external libraries are permissible. ```java import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.json.JSONObject; public class VolcengineTTS { public static void main(String[] args) throws Exception { CloseableHttpClient client = HttpClients.createDefault(); HttpPost httpPost = new HttpPost("https://edge-workers.laplace.cn/laplace/tts-volcengine"); JSONObject json = new JSONObject(); json.put("text", "Your text here"); json.put("voice", "string"); json.put("appId", "string"); json.put("token", "string"); StringEntity entity = new StringEntity(json.toString()); httpPost.setEntity(entity); httpPost.setHeader("Content-Type", "application/json"); try { org.apache.http.client.methods.CloseableHttpResponse response = client.execute(httpPost); try { System.out.println("Status Code: " + response.getStatusLine().getStatusCode()); String responseBody = EntityUtils.toString(response.getEntity()); System.out.println("Response Body: " + responseBody); } finally { response.close(); } } finally { client.close(); } } } ``` -------------------------------- ### Volcengine TTS API Request (Python) Source: https://subspace.institute/docs/open-platform/tts-volcengine Example Python code utilizing the `requests` library to send a POST request to the Volcengine TTS API. It shows how to construct the JSON payload with required parameters and handle the response. Error handling for the HTTP request is demonstrated. ```python import requests import json url = "https://edge-workers.laplace.cn/laplace/tts-volcengine" headers = { "Content-Type": "application/json" } payload = { "text": "Your text here", "voice": "string", "appId": "string", "token": "string" } try: response = requests.post(url, headers=headers, data=json.dumps(payload)) response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx) if response.headers.get('Content-Type') == 'audio/mpeg': with open('output.mp3', 'wb') as f: f.write(response.content) print("Audio saved to output.mp3") else: print(f"Response JSON: {response.json()}") except requests.exceptions.RequestException as e: print(f"Error making request: {e}") ``` -------------------------------- ### ElevenLabs TTS API Request (Python) Source: https://subspace.institute/docs/open-platform/tts-elevenlabs Example Python code using the 'requests' library to send a POST request to the ElevenLabs TTS API. It shows how to format the JSON payload and handle potential errors. ```python import requests import json def generate_speech(text, voice, token): url = "https://edge-workers.laplace.cn/laplace/tts-elevenlabs" headers = { "Content-Type": "application/json" } payload = { "text": text, "voice": voice, "token": token } response = requests.post(url, headers=headers, data=json.dumps(payload)) if response.status_code != 200: error_data = response.json() raise Exception(f"API Error: {error_data['message']}") return response.content # Assuming the response is audio/mpeg ``` -------------------------------- ### Volcengine TTS API Request (JavaScript) Source: https://subspace.institute/docs/open-platform/tts-volcengine Example JavaScript code to make a POST request to the Volcengine TTS API using the fetch API. It demonstrates how to structure the request body with text, voice, appId, and token. This snippet highlights asynchronous operations and JSON handling. ```javascript async function textToSpeech(text, voice, appId, token) { const response = await fetch('https://edge-workers.laplace.cn/laplace/tts-volcengine', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: text, voice: voice, appId: appId, token: token }) }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.blob(); // Assuming the response is audio/mpeg } ``` -------------------------------- ### ElevenLabs TTS API Request (Java) Source: https://subspace.institute/docs/open-platform/tts-elevenlabs Example Java code using Apache HttpClient to send a POST request to the ElevenLabs TTS API. It includes setting headers, constructing the JSON body, and handling the response. ```java import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import com.fasterxml.jackson.databind.ObjectMapper; public class ElevenLabsTTS { public void generateSpeech(String text, String voice, String token) throws Exception { try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost request = new HttpPost("https://edge-workers.laplace.cn/laplace/tts-elevenlabs"); request.setHeader("Content-Type", "application/json"); ObjectMapper mapper = new ObjectMapper(); String jsonBody = mapper.writeValueAsString(new Payload(text, voice, token)); request.setEntity(new StringEntity(jsonBody)); try { String responseBody = httpClient.execute(request, httpResponse -> { int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != 200) { String errorMsg = EntityUtils.toString(httpResponse.getEntity()); // Handle error response, possibly parse JSON error message throw new Exception("API Error: " + errorMsg); } try { return EntityUtils.toString(httpResponse.getEntity()); // Assuming audio data } catch (Exception e) { throw new RuntimeException(e); } }); // Process the responseBody (audio data) } catch (Exception e) { e.printStackTrace(); throw e; } } } // Helper class for JSON payload static class Payload { public String text; public String voice; public String token; public Payload(String text, String voice, String token) { this.text = text; this.voice = voice; this.token = token; } } } ``` -------------------------------- ### Deploy LAPLACE Event Fetcher with Docker Compose (YAML) Source: https://context7.com/context7/subspace_institute/llms.txt Configures Docker Compose to deploy the LAPLACE Event Fetcher service, including PostgreSQL for the database and optional Redis for caching. This setup ensures the service runs reliably with defined environment variables for connections, room IDs, and API access. It also includes health checks for the database and restart policies. ```yaml # docker-compose.yml services: lef: image: ghcr.io/laplace-live/event-fetcher:latest environment: DATABASE_URL: postgresql://lef:lef@lef-pg:5432/lef ROOMS: 25034104,456117 TZ: Asia/Shanghai EVENTS_KEEP: 72 REDIS_URL: redis://lef-redis:6379 REDIS_EVENT_LIMIT: 100 LOGIN_SYNC_TOKEN: your-login-sync-token-here AUTH_KEY: random-auth-key-for-api-access ADMIN_KEY: random-admin-key-min-12-chars WEBSOCKET_BRIDGE: 1 WEBSOCKET_BRIDGE_AUTH: your-websocket-password RESTART_INTERVAL: "0 6,18 * * *" depends_on: - lef-pg - lef-redis ports: - "8080:8080" restart: always lef-pg: image: postgres:16-alpine environment: POSTGRES_DB: lef POSTGRES_USER: lef POSTGRES_PASSWORD: lef volumes: - lef-db:/var/lib/postgresql/data restart: always healthcheck: test: pg_isready -U lef -h 127.0.0.1 interval: 5s lef-redis: image: redis:latest volumes: - lef-redis:/data restart: always volumes: lef-db: lef-redis: # Deploy # docker-compose up -d # Check logs # docker-compose logs -f lef # Access API documentation # curl https://your-domain.com/openapi ``` -------------------------------- ### Volcengine TTS API Request (C#) Source: https://subspace.institute/docs/open-platform/tts-volcengine Example C# code using `HttpClient` to send a POST request to the Volcengine TTS API. It demonstrates constructing the JSON payload and handling the response. This snippet is suitable for .NET applications needing to integrate with the API. ```csharp using System; using System.Net.Http; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; public class VolcengineTTS { public static async Task Main(string[] args) { using (HttpClient client = new HttpClient()) { var payload = new { text = "Your text here", voice = "string", appId = "string", token = "string" }; string jsonPayload = JsonConvert.SerializeObject(payload); var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json"); try { HttpResponseMessage response = await client.PostAsync("https://edge-workers.laplace.cn/laplace/tts-volcengine", content); response.EnsureSuccessStatusCode(); // Throws an exception if the response status code is 4xx or 5xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine("Response Body: " + responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } } } } ``` -------------------------------- ### Get Events by Room ID Source: https://subspace.institute/docs/laplace-chat/event-fetcher Retrieves events from the database filtered by a specific room ID. An optional query parameter can be used to fetch all events. ```APIDOC ## GET /events/ ### Description Get events from the database by room id. ### Method GET ### Endpoint `/events/` ### Parameters #### Path Parameters - **room_id** (string) - Required - The ID of the room to retrieve events from. #### Query Parameters - **full** (boolean) - Optional - If set to `1`, fetches all events for the room_id. Otherwise, a subset of events may be returned. ### Request Example ``` GET /events/12345?full=1 ``` ### Response #### Success Response (200) - **events** (array) - A list of event objects. #### Response Example ```json { "events": [ { "type": "message", "message": "Hello, world!", "timestamp": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### Development Commands for LAPLACE Event Bridge Source: https://subspace.institute/docs/laplace-chat/event-fetcher Commands to run the development server, initialize and manage database migrations, and generate database schemas using Drizzle Kit. ```bash bun run dev # session 1 bunx drizzle-kit studio # session 2 # init db and create migrations bunx drizzle-kit migrate # Update schemas bunx drizzle-kit generate ``` -------------------------------- ### Connect to WebSocket API with Authentication (JavaScript) Source: https://subspace.institute/docs/laplace-chat/event-fetcher Demonstrates how to establish a WebSocket connection to the API, including authentication via the Sec-WebSocket-Protocol header or a query parameter. Handles optional room filtering for events. ```javascript const ws = new WebSocket('ws://localhost:8080/', ['client', 'auth-token']) // Alternatively, pass the token via the token query parameter: const ws = new WebSocket('ws://localhost:8080/?token=auth-token') // With room filtering: // Only receive events from rooms 456117 and 25034104 const ws = new WebSocket('ws://localhost:8080/?rooms=456117,25034104') // With query-style authentication and room filtering: const ws = new WebSocket('ws://localhost:8080/?token=auth-token&rooms=456117,25034104') ``` -------------------------------- ### ElevenLabs TTS API Request (cURL) Source: https://subspace.institute/docs/open-platform/tts-elevenlabs Example cURL command to send a POST request to the ElevenLabs TTS API. It includes the endpoint, content type, and a JSON payload with text, voice, and authentication token. ```bash curl -X POST "https://edge-workers.laplace.cn/laplace/tts-elevenlabs" \ -H "Content-Type: application/json" \ -d '{ "text": "感谢ドラゴンラプラスWeChat的SC:一发sc没被念到我就冷汗直流心跳加速头皮发麻双手痉挛两腿发颤,还不好意思刷弹幕说你漏了,我好怕你看到了装作没看到。我的sc通常很短只有一小时,只有短短的3600秒,但它存在的时候,我会用心跳来为它倒数。私のBANを解除してください。もう二度とスパムしません😭", "voice": "string", "token": "string" }' ``` -------------------------------- ### Run Subspace Institute Bot with Docker Source: https://subspace.institute/docs/laplace-chat/jupiter Command to run the Subspace Institute bot as a Docker container. It demonstrates mounting the configuration file and bot data directory, and setting necessary environment variables. ```bash docker run -d \ --name laplace-jupiter \ -v $(pwd)/config.yaml:/app/config.yaml:ro \ -v $(pwd)/bot-data:/app/bot-data \ -e TELEGRAM_API_ID=your_telegram_api_id \ -e TELEGRAM_API_HASH=your_telegram_api_hash \ -e TELEGRAM_BOT_TOKEN=your_bot_token \ ghcr.io/laplace-live/jupiter:local ``` -------------------------------- ### Connect to LAPLACE Event Bridge with SDK Source: https://subspace.institute/docs/laplace-chat/event-bridge Example of using the TypeScript/JavaScript SDK to connect to the LAPLACE Event Bridge. It demonstrates client instantiation with URL and token, connecting to the bridge, and listening for messages or any event. ```typescript import { LaplaceEventBridgeClient } from '@laplace.live/event-bridge-sdk' const client = new LaplaceEventBridgeClient({ url: 'ws://localhost:9696', token: 'your-auth-token', // If auth is enabled }) // Connect to the bridge await client.connect() // Listen for specific events client.on('message', event => { console.log('Received message:', event) }) // Listen for all events client.onAny(event => { console.log('Received event:', event.type) }) ``` -------------------------------- ### Docker Compose Deployment for LAPLACE Event Fetcher Source: https://subspace.institute/docs/laplace-chat/event-fetcher This configuration sets up the LAPLACE Event Fetcher service using Docker Compose. It defines the main fetcher service, a PostgreSQL database, and an optional Redis cache. Environment variables are used to configure database connection, target rooms, and timezone. The services depend on each other to ensure proper startup order. ```yaml services: lef: image: ghcr.io/laplace-live/event-fetcher:latest environment: DATABASE_URL: postgresql://lef:lef@lef-pg:5432/lef ROOMS: 25034104,456117 TZ: Asia/Shanghai # Recommended, this ensures all cron tasks are executed in CST depends_on: - lef-pg - lef-redis # See below restart: always lef-pg: image: postgres:16-alpine environment: POSTGRES_DB: lef POSTGRES_USER: lef POSTGRES_PASSWORD: lef volumes: - lef-db:/var/lib/postgresql/data restart: always healthcheck: test: pg_isready -U lef -h 127.0.0.1 interval: 5s # Redis is optional for serving recent chat messages lef-redis: image: redis:latest volumes: - lef-redis:/data restart: always volumes: lef-db: lef-redis: ``` -------------------------------- ### Build Docker Image for Subspace Institute Bot Source: https://subspace.institute/docs/laplace-chat/jupiter Instructions for building a Docker image for the Subspace Institute bot. It provides options for building locally using `docker buildx bake` or directly with `docker build`. ```bash # Build for local use docker buildx bake build-local # Or build using docker directly docker build -t ghcr.io/laplace-live/jupiter:local . ``` -------------------------------- ### Run Go Bridge Server Source: https://subspace.institute/docs/laplace-chat/event-bridge Instructions for running the Go implementation of the LAPLACE Event Bridge. Requires Go toolchain and supports debug mode or building a native binary with host and authentication configuration. ```go # Run from source (requires Go installed) go run ./packages/server --debug # Or build a native binary cd packages/server go build -o leb-server . ./leb-server --host 0.0.0.0 --auth "your-secure-token" ``` -------------------------------- ### Cartesia TTS API Request (cURL) Source: https://subspace.institute/docs/open-platform/tts-cartesia Example cURL command to send a POST request to the Cartesia TTS API for text-to-speech generation. It includes the API endpoint, content type, and a JSON payload with the text and authentication token. ```shell curl -X POST "https://edge-workers.laplace.cn/laplace/tts-cartesia" \ -H "Content-Type: application/json" \ -d '{ "text": "Hello, world!", "token": "string" }' ``` -------------------------------- ### Configure Douyin and Weibo Account IDs and Fetching Source: https://subspace.institute/docs/eye-of-providence Sets account identifiers for Douyin and Weibo, and enables comment fetching for Weibo. `weiboFetchCommentsSticky` also fetches comments from sticky statuses. Enabling comment fetching is not recommended for many accounts due to API rate limits. ```javascript // Douyin account ID douyinId: 'MS4wLjABAAAA5ZrIrbgva_HMeHuNn64goOD2XYnk4ItSypgRHlbSh1c', // Douyin live ID is separated and need to be calculated from `douyinId` douyinLiveId: '', // Weibo account ID weiboId: '7595006312', // Check Weibo activity comments. Disabled by default // This fires another API to monitor comments and replies. It's not // recommended to enable this feature if you have a lot of accounts to // monitor or you will hit API rate limit soon. // Default: false weiboFetchComments: true, // In addition to `weiboFetchComments`, this also fetches the comments // and replies in the sticky statuses // Default: false weiboFetchCommentsSticky: true, // Fetch specific users from comments and replies // Default: undefined weiboFetchCommentsWatchUsers: ['12345'] ``` -------------------------------- ### Moyin TTS API Request using cURL Source: https://subspace.institute/docs/open-platform/tts-moyin Example cURL request to the Moyin TTS API for generating speech audio. It demonstrates how to send a POST request with JSON payload containing text, token, and secret. ```curl curl -X POST "https://edge-workers.laplace.cn/laplace/tts-moyin" \ -H "Content-Type: application/json" \ -d '{ "text": "感谢ドラゴンラプラスWeChat的SC:一发sc没被念到我就冷汗直流心跳加速头皮发麻双手痉挛两腿打颤,还不好意思刷弹幕说你漏了,我好怕你看到了装作没看到。我的sc通常很短只有一小时,只有短短的3600秒,但它存在的时候,我会用心跳来为它倒数。私のBANを解除してください。もう二度とスパムしません😭", "token": "string", "secret": "string" }' ``` -------------------------------- ### Deploy Subspace Institute Bot with Docker Compose Source: https://subspace.institute/docs/laplace-chat/jupiter A `docker-compose.yml` file for deploying the Subspace Institute bot. It configures the service, environment variables, and volumes for persistent storage and configuration. ```yaml version: '3.8' services: jupiter: image: ghcr.io/laplace-live/jupiter:latest container_name: laplace-jupiter restart: unless-stopped environment: - TELEGRAM_API_ID=${TELEGRAM_API_ID} - TELEGRAM_API_HASH=${TELEGRAM_API_HASH} - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} volumes: - ./config.yaml:/app/config.yaml:ro - ./bot-data:/app/bot-data ```