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:
27
telegram_bot/src/services/qr.ts
Normal file
27
telegram_bot/src/services/qr.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import QRCode from 'qrcode';
|
||||
import { logger } from './logger';
|
||||
|
||||
/**
|
||||
* Generate a QR code as a buffer from a Lightning invoice
|
||||
*/
|
||||
export async function generateQRCode(data: string): Promise<Buffer> {
|
||||
try {
|
||||
const buffer = await QRCode.toBuffer(data.toUpperCase(), {
|
||||
errorCorrectionLevel: 'M',
|
||||
type: 'png',
|
||||
margin: 2,
|
||||
width: 300,
|
||||
color: {
|
||||
dark: '#000000',
|
||||
light: '#FFFFFF',
|
||||
},
|
||||
});
|
||||
return buffer;
|
||||
} catch (error) {
|
||||
logger.error('Failed to generate QR code', { error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export default { generateQRCode };
|
||||
|
||||
Reference in New Issue
Block a user