Page cover

Launch on Telau Bot

You can simply launch in the bot conversation using the following template.

/launch
n: token name
$: ticker
b: initial buy (0.1 default)
d: description (optionnal)
x: x.com/ (optionnal)
t: t.me/ (optionnal)
w: website (optionnal)
l: launchpad (pump | bonk - pump.fun default)

Code Blocks (Some)

import fs from 'fs';
import path from 'path';

interface EnvConfig {
    [key: string]: string;
}

/**
 * Get environment variable with fallback to .env file
 * @param key The environment variable key
 * @returns The environment variable value or undefined if not found
 */
export function getEnvVar(key: string): string | undefined {
    // First try to get from system environment
    const systemValue = process.env[key];
    if (systemValue && systemValue.trim() !== '') {
        return systemValue;
    }

    // If not found or empty, try loading from .env file
    const envConfig = loadEnvFile();
    const envValue = envConfig[key];
    
    if (envValue && envValue.trim() !== '') {
        return envValue;
    }

    // Return undefined if not found
    return undefined;
}

/**
 * Load configuration from .env file
 * @returns Configuration object
 */
function loadEnvFile(): EnvConfig {
    const config: EnvConfig = {};
    
    // Try to load from .env file in parent directory
    const envPath = path.join(__dirname, '../../.env');
    
    try {
        const envContent = fs.readFileSync(envPath, 'utf8');
        
        // Parse .env file
        const lines = envContent.split('\n');
        
        for (const line of lines) {
            const trimmedLine = line.trim();
            
            // Skip empty lines and comments
            if (!trimmedLine || trimmedLine.startsWith('#')) {
                continue;
            }
            
            // Split key=value
            const [key, ...valueParts] = trimmedLine.split('=');
            if (!key || valueParts.length === 0) {
                continue;
            }
            
            let value = valueParts.join('=').trim();
            
            // Remove surrounding quotes
            if (value.length >= 2 && 
                ((value.startsWith('"') && value.endsWith('"')) || 
                 (value.startsWith("'") && value.endsWith("'")))) {
                value = value.slice(1, -1);
            }
            
            config[key.trim()] = value;
        }
        
    } catch (error) {
        console.log(error);
    }

    return config;
}

Last updated