@@ -148,36 +148,38 @@ async function withTelegram(note, messageSettings, login = false) {
148148
149149 return new Promise ( async ( resolve , reject ) => {
150150 try {
151- // Check for image in note content
152- const noteContent = await getNoteContents ( note . url )
153- const imageInfo = extractFirstImage ( noteContent . content )
151+ // Handle image processing independently
152+ let hasImage = false
153+ try {
154+ const noteContent = await getNoteContents ( note . url )
155+ const imageInfo = extractFirstImage ( noteContent . content )
154156
155- if ( imageInfo ?. imageUrl ) {
156- console . log ( 'Found image in note, sending photo first' )
157+ if ( imageInfo ?. imageUrl ) {
158+ console . log ( 'Found image in note, sending photo first' )
157159
158- // Create caption with subject and alt text
159- let caption = markdownv2 . bold ( markdownv2 . escape ( msg . prefix ) )
160- caption += markdownv2 . escape ( `\n\n` )
161- caption += markdownv2 . underline ( markdownv2 . escape ( msg . title ) )
162- caption += markdownv2 . escape ( `\n\n` )
160+ // Create caption with subject and alt text
161+ let caption = markdownv2 . bold ( markdownv2 . escape ( msg . prefix ) )
162+ caption += markdownv2 . escape ( `\n\n` )
163+ caption += markdownv2 . underline ( markdownv2 . escape ( msg . title ) )
164+ caption += markdownv2 . escape ( `\n\n` )
163165
164- // Use alt text if available, otherwise use preview text
165- const captionText = imageInfo . altText || msg . previewText
166- caption += markdownv2 . escape ( captionText )
166+ // Use alt text if available, otherwise use preview text
167+ const captionText = imageInfo . altText || msg . previewText
168+ caption += markdownv2 . escape ( captionText )
167169
168- if ( showEditLink ) {
169- caption += markdownv2 . escape ( `\n\n` )
170- caption += markdownv2 . url ( "Edit note" , msg . webUrl )
171- }
170+ if ( showEditLink ) {
171+ caption += markdownv2 . escape ( `\n\n` )
172+ caption += markdownv2 . url ( "Edit note" , msg . webUrl )
173+ }
172174
173- // Download and send image with size limits
174- try {
175+ // Download and send image with size limits
175176 const imageBuffer = await downloadImage ( imageInfo . dataFullresSrc || imageInfo . imageUrl )
176177 await sendPhotoToTelegram ( imageBuffer , caption , channelHandle )
177- } catch ( imageErr ) {
178- console . warn ( 'Failed to process image:' , imageErr . message )
179- // Continue without image - note text will still be sent
178+ hasImage = true
180179 }
180+ } catch ( imageErr ) {
181+ console . warn ( 'Image processing failed, continuing with text message:' , imageErr . message )
182+ // Image processing failure doesn't affect text message flow
181183 }
182184
183185 // Send note body text
@@ -198,7 +200,7 @@ async function withTelegram(note, messageSettings, login = false) {
198200 status : 200 ,
199201 title : msg . title ,
200202 body : msg . previewText ,
201- hasImage : ! ! imageInfo
203+ hasImage
202204 } )
203205 } catch ( err ) {
204206 console . error ( 'Title: ' , msg . title )
0 commit comments