Skip to content

Commit ac3f453

Browse files
VM ready code publish
2 parents 342f5d8 + 51a2070 commit ac3f453

4 files changed

Lines changed: 12 additions & 28 deletions

File tree

config/index.ts

Whitespace-only changes.

index.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { VercelRequest, VercelResponse } from '@vercel/node';
21
import dotenv from 'dotenv';
32
import express from 'express';
43
import bot, { registerCommands } from './services/bot';
@@ -11,23 +10,15 @@ const PORT = process.env.PORT || 3000;
1110

1211
registerCommands();
1312

14-
app.post('/', (req: VercelRequest, res: VercelResponse) => {
13+
app.post('/', (req, res) => {
1514
bot.processUpdate(req.body);
1615
res.status(200).send('OK');
1716
});
1817

19-
export default app;
20-
21-
22-
23-
24-
// --------------------
25-
// Express Setup
26-
// --------------------
2718
app.get('/', (_req, res) => {
2819
res.send('🚀 Bubblemaps-telegram-bot');
2920
});
3021

3122
app.listen(PORT, () => {
32-
console.log(`✅ Server is listening at http://localhost:${PORT}`);
23+
console.log(`✅ Server is running on port ${PORT}`);
3324
});

services/bot.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import TelegramBot, { Message } from 'node-telegram-bot-api';
22
import { getMapAvailability, getMapData, getMapIframeUrl, getMapMetadata, MapNode } from './bubblemapsService';
33
import { generateMapScreenshot } from './screenshotService';
4-
import axios from 'axios';
54

65
const bot = new TelegramBot(process.env.BOT_TOKEN as string);
76

8-
97
export function registerCommands() {
108

119
bot.onText(/\/start/, (msg: Message) => {
@@ -18,6 +16,8 @@ export function registerCommands() {
1816
// /help
1917
bot.onText(/\/help/, (msg: Message) => {
2018
const chatId = msg.chat.id;
19+
console.log(`[LOG] Help command requested by user ${msg.from?.id} (${msg.from?.username || 'unknown'})`);
20+
console.log(`[LOG] Chat ID: ${chatId}`);
2121
bot.sendMessage(chatId, `Here are the available commands:
2222
2323
🔹 Basic Commands:
@@ -53,14 +53,17 @@ export function registerCommands() {
5353
// /map [chain] [token]
5454
bot.onText(/\/map(?:\s+(\w+)\s+(0x[a-fA-F0-9]+))?/, async (msg: Message, match: RegExpExecArray | null) => {
5555
const chatId = msg.chat.id;
56+
console.log(`[LOG] Map command requested by user ${msg.from?.id} (${msg.from?.username || 'unknown'})`);
5657

5758
if (!match || match.length < 3 || !match[1] || !match[2]) {
59+
console.log(`[LOG] Invalid map command parameters`);
5860
bot.sendMessage(chatId, 'Please provide both chain and token address. Example: /map bsc 0x603c7f932ed1fc6575303d8fb018fdcbb0f39a95');
5961
return;
6062
}
6163

6264
const chain = match[1].toLowerCase();
6365
const token = match[2];
66+
console.log(`[LOG] Fetching map for chain: ${chain}, token: ${token}`);
6467

6568
bot.sendMessage(chatId, `🔍 Fetching map data for ${token} on ${chain}...`);
6669

@@ -107,7 +110,7 @@ export function registerCommands() {
107110
bot.sendMessage(chatId, 'Please provide both chain and token address. Example: /score bsc 0x603c7f932ed1fc6575303d8fb018fdcbb0f39a95');
108111
return;
109112
}
110-
113+
111114
const chain = match[1].toLowerCase();
112115
const token = match[2];
113116

@@ -151,14 +154,17 @@ export function registerCommands() {
151154
// /screenshot [chain] [token]
152155
bot.onText(/\/screenshot\s+(\w+)\s+(0x[a-fA-F0-9]+)/, async (msg: Message, match: RegExpExecArray | null) => {
153156
const chatId = msg.chat.id;
157+
console.log(`[LOG] Screenshot command requested by user ${msg.from?.id} (${msg.from?.username || 'unknown'})`);
154158

155159
if (!match || match.length < 3) {
160+
console.log(`[LOG] Invalid screenshot command parameters`);
156161
bot.sendMessage(chatId, 'Please provide both chain and token address. Example: /screenshot bsc 0x603c7f932ed1fc6575303d8fb018fdcbb0f39a95');
157162
return;
158163
}
159164

160165
const chain = match[1].toLowerCase();
161166
const token = match[2];
167+
console.log(`[LOG] Generating screenshot for chain: ${chain}, token: ${token}`);
162168

163169
bot.sendMessage(chatId, `📸 Generating screenshot for ${token} on ${chain}. This may take a moment...`);
164170

services/screenshotService.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// import puppeteer from 'puppeteer';
2-
3-
// import chromium from '@sparticuz/chromium';
41
import puppeteer from 'puppeteer';
5-
6-
72
import { getMapIframeUrl, getMapAvailability } from './bubblemapsService';
83

94
export const generateMapScreenshot = async (chain: string, token: string): Promise<Buffer | null> => {
@@ -19,15 +14,7 @@ export const generateMapScreenshot = async (chain: string, token: string): Promi
1914
const browser = await puppeteer.launch({
2015
args: ['--no-sandbox', '--disable-setuid-sandbox'],
2116
headless: true
22-
});
23-
24-
// const browser = await puppeteer.launch({
25-
// args: chromium.args,
26-
// defaultViewport: chromium.defaultViewport,
27-
// executablePath: await chromium.executablePath(),
28-
// headless: chromium.headless,
29-
// });
30-
17+
});
3118

3219
const page = await browser.newPage();
3320
await page.setViewport({ width: 1200, height: 800 });

0 commit comments

Comments
 (0)