File tree 1 file changed +27
-15
lines changed
packages/client-telegram/src
1 file changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -622,22 +622,34 @@ export class MessageManager {
622
622
caption ?: string
623
623
) : Promise < void > {
624
624
try {
625
- if ( ! fs . existsSync ( imagePath ) ) {
626
- throw new Error ( `File not found: ${ imagePath } ` ) ;
627
- }
628
-
629
- const fileStream = fs . createReadStream ( imagePath ) ;
630
-
631
- await ctx . telegram . sendPhoto (
632
- ctx . chat . id ,
633
- {
634
- source : fileStream ,
635
- } ,
636
- {
637
- caption ,
625
+ if ( / ^ ( h t t p | h t t p s ) : \/ \/ / . test ( imagePath ) ) {
626
+ // Handle HTTP URLs
627
+ await ctx . telegram . sendPhoto (
628
+ ctx . chat . id ,
629
+ imagePath ,
630
+ {
631
+ caption ,
632
+ }
633
+ ) ;
634
+ } else {
635
+ // Handle local file paths
636
+ if ( ! fs . existsSync ( imagePath ) ) {
637
+ throw new Error ( `File not found: ${ imagePath } ` ) ;
638
638
}
639
- ) ;
640
-
639
+
640
+ const fileStream = fs . createReadStream ( imagePath ) ;
641
+
642
+ await ctx . telegram . sendPhoto (
643
+ ctx . chat . id ,
644
+ {
645
+ source : fileStream ,
646
+ } ,
647
+ {
648
+ caption,
649
+ }
650
+ ) ;
651
+ }
652
+
641
653
elizaLogger . info ( `Image sent successfully: ${ imagePath } ` ) ;
642
654
} catch ( error ) {
643
655
elizaLogger . error ( "Error sending image:" , error ) ;
You can’t perform that action at this time.
0 commit comments