@@ -66,58 +66,22 @@ export function registerCommands() {
6666 const token = match [ 2 ] ;
6767 console . log ( `[LOG] Fetching map for chain: ${ chain } , token: ${ token } ` ) ;
6868
69- // Send initial loading message and store the message object
70- const loadingMessage = await bot . sendMessage ( chatId , `🔍 Fetching map data for ${ token } on ${ chain } ...` ) ;
71-
72- // Start loading animation
73- const loadingAnimationFrames = [ '⏳' , '⌛️' , '⏳' , '⌛️' ] ;
74- let frameIndex = 0 ;
75- const loadingInterval = setInterval ( async ( ) => {
76- try {
77- await bot . editMessageText (
78- `🔍 Fetching map data for ${ token } on ${ chain } ... ${ loadingAnimationFrames [ frameIndex ] } ` ,
79- {
80- chat_id : chatId ,
81- message_id : loadingMessage . message_id
82- }
83- ) ;
84- frameIndex = ( frameIndex + 1 ) % loadingAnimationFrames . length ;
85- } catch ( error ) {
86- // Ignore errors during animation (e.g., if the message was already deleted)
87- console . log ( "Animation update error:" , error ) ;
88- }
89- } , 800 ) ;
69+ bot . sendMessage ( chatId , `🔍 Fetching map data for ${ token } on ${ chain } ...` ) ;
9070
9171 try {
9272 // Check map availability
9373 const availability = await getMapAvailability ( chain , token ) ;
9474
9575 if ( availability . status !== 'OK' || ! availability . availability ) {
96- clearInterval ( loadingInterval ) ;
97- bot . editMessageText (
98- `❌ Map not available for this token. ${ availability . message || '' } ` ,
99- {
100- chat_id : chatId ,
101- message_id : loadingMessage . message_id
102- }
103- ) ;
76+ bot . sendMessage ( chatId , `❌ Map not available for this token. ${ availability . message || '' } ` ) ;
10477 return ;
10578 }
10679
10780 // Get map data
10881 const mapData = await getMapData ( chain , token ) ;
10982
110- // Clear the loading animation
111- clearInterval ( loadingInterval ) ;
112-
11383 if ( 'message' in mapData && mapData . message ) {
114- bot . editMessageText (
115- `❌ Error: ${ mapData . message } ` ,
116- {
117- chat_id : chatId ,
118- message_id : loadingMessage . message_id
119- }
120- ) ;
84+ bot . sendMessage ( chatId , `❌ Error: ${ mapData . message } ` ) ;
12185 return ;
12286 }
12387
@@ -132,22 +96,10 @@ export function registerCommands() {
13296 *View the interactive bubble map:*
13397 ${ mapUrl } ` ;
13498
135- bot . editMessageText ( message , {
136- chat_id : chatId ,
137- message_id : loadingMessage . message_id ,
138- parse_mode : 'Markdown'
139- } ) ;
99+ bot . sendMessage ( chatId , message , { parse_mode : 'Markdown' } ) ;
140100 } catch ( error ) {
141- // Clear the loading animation
142- clearInterval ( loadingInterval ) ;
143101 console . error ( 'Error in /map command:' , error ) ;
144- bot . editMessageText (
145- '❌ An error occurred while fetching the map data. Please try again later.' ,
146- {
147- chat_id : chatId ,
148- message_id : loadingMessage . message_id
149- }
150- ) ;
102+ bot . sendMessage ( chatId , '❌ An error occurred while fetching the map data. Please try again later.' ) ;
151103 }
152104 } ) ;
153105
@@ -163,49 +115,19 @@ export function registerCommands() {
163115 const chain = match [ 1 ] . toLowerCase ( ) ;
164116 const token = match [ 2 ] ;
165117
166- // Send initial loading message and store the message object
167- const loadingMessage = await bot . sendMessage ( chatId , `🔍 Fetching decentralization score for ${ token } on ${ chain } ...` ) ;
168-
169- // Start loading animation with different emoji set
170- const loadingAnimationFrames = [ '🔍' , '🔎' , '🔍' , '🔎' ] ;
171- let frameIndex = 0 ;
172- const loadingInterval = setInterval ( async ( ) => {
173- try {
174- await bot . editMessageText (
175- `Analyzing token ${ token } on ${ chain } ... ${ loadingAnimationFrames [ frameIndex ] } ` ,
176- {
177- chat_id : chatId ,
178- message_id : loadingMessage . message_id
179- }
180- ) ;
181- frameIndex = ( frameIndex + 1 ) % loadingAnimationFrames . length ;
182- } catch ( error ) {
183- // Ignore errors during animation
184- console . log ( "Animation update error:" , error ) ;
185- }
186- } , 800 ) ;
118+ bot . sendMessage ( chatId , `🔍 Fetching decentralization score for ${ token } on ${ chain } ...` ) ;
187119
188120 try {
189121 const metadata = await getMapMetadata ( chain , token ) ;
190122
191123 if ( metadata . status !== 'OK' ) {
192- clearInterval ( loadingInterval ) ;
193- bot . editMessageText (
194- `❌ Error: ${ metadata . message || 'Failed to fetch metadata' } ` ,
195- {
196- chat_id : chatId ,
197- message_id : loadingMessage . message_id
198- }
199- ) ;
124+ bot . sendMessage ( chatId , `❌ Error: ${ metadata . message || 'Failed to fetch metadata' } ` ) ;
200125 return ;
201126 }
202127
203128 // Get token data for additional info
204129 const mapData = await getMapData ( chain , token ) ;
205130
206- // Clear the loading animation
207- clearInterval ( loadingInterval ) ;
208-
209131 let scoreEmoji = '🟢' ;
210132 if ( metadata . decentralisation_score && metadata . decentralisation_score < 50 ) {
211133 scoreEmoji = '🔴' ;
@@ -223,22 +145,10 @@ export function registerCommands() {
223145 *Token Address:* \`${ token } \`
224146 *Chain:* ${ chain . toUpperCase ( ) } ` ;
225147
226- bot . editMessageText ( message , {
227- chat_id : chatId ,
228- message_id : loadingMessage . message_id ,
229- parse_mode : 'Markdown'
230- } ) ;
148+ bot . sendMessage ( chatId , message , { parse_mode : 'Markdown' } ) ;
231149 } catch ( error ) {
232- // Clear the loading animation
233- clearInterval ( loadingInterval ) ;
234150 console . error ( 'Error in /score command:' , error ) ;
235- bot . editMessageText (
236- '❌ An error occurred while fetching the score data. Please try again later.' ,
237- {
238- chat_id : chatId ,
239- message_id : loadingMessage . message_id
240- }
241- ) ;
151+ bot . sendMessage ( chatId , '❌ An error occurred while fetching the score data. Please try again later.' ) ;
242152 }
243153 } ) ;
244154
@@ -257,27 +167,7 @@ export function registerCommands() {
257167 const token = match [ 2 ] ;
258168 console . log ( `[LOG] Generating screenshot for chain: ${ chain } , token: ${ token } ` ) ;
259169
260- // Send initial loading message and store the message object
261- const loadingMessage = await bot . sendMessage ( chatId , `📸 Generating screenshot for ${ token } on ${ chain } . This may take a moment...` ) ;
262-
263- // Start loading animation with camera emoji
264- const loadingAnimationFrames = [ '📷' , '📸' , '📷' , '📸' ] ;
265- let frameIndex = 0 ;
266- const loadingInterval = setInterval ( async ( ) => {
267- try {
268- await bot . editMessageText (
269- `Generating screenshot for ${ token } on ${ chain } ... ${ loadingAnimationFrames [ frameIndex ] } ` ,
270- {
271- chat_id : chatId ,
272- message_id : loadingMessage . message_id
273- }
274- ) ;
275- frameIndex = ( frameIndex + 1 ) % loadingAnimationFrames . length ;
276- } catch ( error ) {
277- // Ignore errors during animation
278- console . log ( "Animation update error:" , error ) ;
279- }
280- } , 800 ) ;
170+ bot . sendMessage ( chatId , `📸 Generating screenshot for ${ token } on ${ chain } . This may take a moment...` ) ;
281171
282172 try {
283173 const response = await axios . post (
@@ -291,12 +181,6 @@ export function registerCommands() {
291181 }
292182 ) ;
293183
294- // Clear the loading animation
295- clearInterval ( loadingInterval ) ;
296-
297- // Delete the loading message since we'll send a new photo
298- await bot . deleteMessage ( chatId , loadingMessage . message_id ) ;
299-
300184 if ( response . status !== 200 || ! response . data ) {
301185 bot . sendMessage ( chatId , '❌ Failed to generate screenshot. The map might not be available.' ) ;
302186 return ;
@@ -321,16 +205,8 @@ export function registerCommands() {
321205 } ) ;
322206
323207 } catch ( error ) {
324- // Clear the loading animation
325- clearInterval ( loadingInterval ) ;
326208 console . error ( 'Error in /screenshot command:' , error ) ;
327- bot . editMessageText (
328- '❌ An error occurred while generating the screenshot. Please try again later.' ,
329- {
330- chat_id : chatId ,
331- message_id : loadingMessage . message_id
332- }
333- ) ;
209+ bot . sendMessage ( chatId , '❌ An error occurred while generating the screenshot. Please try again later.' ) ;
334210 }
335211 } ) ;
336212
@@ -346,42 +222,13 @@ export function registerCommands() {
346222 const chain = match [ 1 ] . toLowerCase ( ) ;
347223 const token = match [ 2 ] ;
348224
349- // Send initial loading message and store the message object
350- const loadingMessage = await bot . sendMessage ( chatId , `🔍 Fetching top holders for ${ token } on ${ chain } ...` ) ;
351-
352- // Start loading animation
353- const loadingAnimationFrames = [ '👥' , '👤' , '👥' , '👤' ] ;
354- let frameIndex = 0 ;
355- const loadingInterval = setInterval ( async ( ) => {
356- try {
357- await bot . editMessageText (
358- `Analyzing holders for ${ token } on ${ chain } ... ${ loadingAnimationFrames [ frameIndex ] } ` ,
359- {
360- chat_id : chatId ,
361- message_id : loadingMessage . message_id
362- }
363- ) ;
364- frameIndex = ( frameIndex + 1 ) % loadingAnimationFrames . length ;
365- } catch ( error ) {
366- // Ignore errors during animation
367- console . log ( "Animation update error:" , error ) ;
368- }
369- } , 800 ) ;
225+ bot . sendMessage ( chatId , `🔍 Fetching top holders for ${ token } on ${ chain } ...` ) ;
370226
371227 try {
372228 const mapData = await getMapData ( chain , token ) ;
373229
374- // Clear the loading animation
375- clearInterval ( loadingInterval ) ;
376-
377230 if ( 'message' in mapData && mapData . message ) {
378- bot . editMessageText (
379- `❌ Error: ${ mapData . message } ` ,
380- {
381- chat_id : chatId ,
382- message_id : loadingMessage . message_id
383- }
384- ) ;
231+ bot . sendMessage ( chatId , `❌ Error: ${ mapData . message } ` ) ;
385232 return ;
386233 }
387234
@@ -400,22 +247,10 @@ export function registerCommands() {
400247
401248 holdersText += `\n*Total Holders Analyzed:* ${ mapData . nodes . length } ` ;
402249
403- bot . editMessageText ( holdersText , {
404- chat_id : chatId ,
405- message_id : loadingMessage . message_id ,
406- parse_mode : 'Markdown'
407- } ) ;
250+ bot . sendMessage ( chatId , holdersText , { parse_mode : 'Markdown' } ) ;
408251 } catch ( error ) {
409- // Clear the loading animation
410- clearInterval ( loadingInterval ) ;
411252 console . error ( 'Error in /holders command:' , error ) ;
412- bot . editMessageText (
413- '❌ An error occurred while fetching the holders data. Please try again later.' ,
414- {
415- chat_id : chatId ,
416- message_id : loadingMessage . message_id
417- }
418- ) ;
253+ bot . sendMessage ( chatId , '❌ An error occurred while fetching the holders data. Please try again later.' ) ;
419254 }
420255 } ) ;
421256
0 commit comments