feat: Add Telegram bot with group support
- Full Telegram bot implementation for Lightning Jackpot - Commands: /start, /buy, /tickets, /wins, /address, /jackpot, /help - Lightning invoice generation with QR codes - Payment polling and confirmation notifications - User state management (Redis/in-memory fallback) - Group support with admin settings panel - Configurable draw announcements and reminders - Centralized messages for easy i18n - Docker configuration included
This commit is contained in:
50
telegram_bot/src/config/index.ts
Normal file
50
telegram_bot/src/config/index.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
function required(name: string): string {
|
||||
const value = process.env[name];
|
||||
if (!value) {
|
||||
throw new Error(`Missing required environment variable: ${name}`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function optional(name: string, defaultValue: string): string {
|
||||
return process.env[name] || defaultValue;
|
||||
}
|
||||
|
||||
function optionalInt(name: string, defaultValue: number): number {
|
||||
const value = process.env[name];
|
||||
if (!value) return defaultValue;
|
||||
const parsed = parseInt(value, 10);
|
||||
return isNaN(parsed) ? defaultValue : parsed;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
telegram: {
|
||||
botToken: required('TELEGRAM_BOT_TOKEN'),
|
||||
},
|
||||
api: {
|
||||
baseUrl: optional('API_BASE_URL', 'http://localhost:3000'),
|
||||
},
|
||||
frontend: {
|
||||
baseUrl: optional('FRONTEND_BASE_URL', 'http://localhost:3001'),
|
||||
},
|
||||
redis: {
|
||||
url: process.env.REDIS_URL || null,
|
||||
},
|
||||
bot: {
|
||||
maxTicketsPerPurchase: optionalInt('MAX_TICKETS_PER_PURCHASE', 100),
|
||||
paymentPollIntervalMs: optionalInt('PAYMENT_POLL_INTERVAL_MS', 5000),
|
||||
paymentPollTimeoutMs: optionalInt('PAYMENT_POLL_TIMEOUT_MS', 900000), // 15 minutes
|
||||
invoiceExpiryMinutes: optionalInt('INVOICE_EXPIRY_MINUTES', 15),
|
||||
},
|
||||
logging: {
|
||||
level: optional('LOG_LEVEL', 'info'),
|
||||
},
|
||||
nodeEnv: optional('NODE_ENV', 'development'),
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
Reference in New Issue
Block a user