@@ -39,7 +39,7 @@ impl DiscordEndpoint {
3939 fn dm_tagged_content ( content : & str , origin : Option < & MessageOrigin > ) -> String {
4040 if let Some ( MessageOrigin :: Agent { name, .. } ) = origin {
4141 // Subtle Markdown tag so recipients know which facet is speaking
42- format ! ( "*[{}]* {}" , name, content)
42+ format ! ( "*[{}]*\n {}" , name, content)
4343 } else {
4444 content. to_string ( )
4545 }
@@ -515,7 +515,12 @@ impl DiscordEndpoint {
515515 }
516516
517517 /// Send a message to a specific Discord channel
518- async fn send_to_channel ( & self , channel_id : ChannelId , content : String ) -> Result < ( ) > {
518+ async fn send_to_channel (
519+ & self ,
520+ channel_id : ChannelId ,
521+ mut content : String ,
522+ origin : Option < & MessageOrigin > ,
523+ ) -> Result < ( ) > {
519524 info ! (
520525 "send_to_channel called with content: '{}', is_reaction: {}" ,
521526 content,
@@ -599,6 +604,13 @@ impl DiscordEndpoint {
599604 }
600605 }
601606
607+ // If this is a DM channel, add facet tag for clarity
608+ if let Ok ( channel) = channel_id. to_channel ( & self . http ) . await {
609+ if matches ! ( channel, serenity:: model:: channel:: Channel :: Private ( _) ) {
610+ content = Self :: dm_tagged_content ( & content, origin) ;
611+ }
612+ }
613+
602614 // Fall back to sending as regular message with timeout
603615 match tokio:: time:: timeout (
604616 std:: time:: Duration :: from_secs ( 10 ) ,
@@ -760,20 +772,20 @@ impl MessageEndpoint for DiscordEndpoint {
760772 "Failed to reply to message: {}, falling back to channel send" ,
761773 e
762774 ) ;
763- self . send_to_channel ( channel, content) . await ?;
775+ self . send_to_channel ( channel, content, origin ) . await ?;
764776 } else {
765777 info ! ( "Replied to message {} in channel {}" , msg_id, channel_id) ;
766778 return Ok ( Some ( format ! ( "reply:{}:{}" , channel_id, msg_id) ) ) ;
767779 }
768780 } else {
769781 // Can't find original message, just send to channel
770- self . send_to_channel ( channel, content) . await ?;
782+ self . send_to_channel ( channel, content, origin ) . await ?;
771783 }
772784 } else {
773- self . send_to_channel ( channel, content) . await ?;
785+ self . send_to_channel ( channel, content, origin ) . await ?;
774786 }
775787 } else {
776- self . send_to_channel ( channel, content) . await ?;
788+ self . send_to_channel ( channel, content, origin ) . await ?;
777789 }
778790 return Ok ( Some ( format ! ( "channel:{}" , channel_id) ) ) ;
779791 }
@@ -797,7 +809,7 @@ impl MessageEndpoint for DiscordEndpoint {
797809 }
798810 }
799811 }
800- self . send_to_channel ( channel_id, content) . await ?;
812+ self . send_to_channel ( channel_id, content, origin ) . await ?;
801813 return Ok ( Some ( format ! ( "channel:{}" , channel_id) ) ) ;
802814 }
803815
@@ -829,7 +841,7 @@ impl MessageEndpoint for DiscordEndpoint {
829841 }
830842 }
831843 }
832- self . send_to_channel ( ChannelId :: new ( channel_id) , content)
844+ self . send_to_channel ( ChannelId :: new ( channel_id) , content, origin )
833845 . await ?;
834846 return Ok ( Some ( format ! ( "channel:{}" , channel_id) ) ) ;
835847 }
@@ -860,7 +872,7 @@ impl MessageEndpoint for DiscordEndpoint {
860872 {
861873 // Prefer channel if both are present (came from a channel message)
862874 if let Ok ( chan_id) = channel_id. parse :: < u64 > ( ) {
863- self . send_to_channel ( ChannelId :: new ( chan_id) , content)
875+ self . send_to_channel ( ChannelId :: new ( chan_id) , content, origin )
864876 . await ?;
865877 return Ok ( Some ( format ! ( "channel:{}" , chan_id) ) ) ;
866878 } else if let Ok ( usr_id) = user_id. parse :: < u64 > ( ) {
@@ -879,7 +891,7 @@ impl MessageEndpoint for DiscordEndpoint {
879891
880892 // Fall back to default channel if configured
881893 if let Some ( channel) = self . default_channel {
882- self . send_to_channel ( channel, content) . await ?;
894+ self . send_to_channel ( channel, content, origin ) . await ?;
883895 return Ok ( Some ( format ! ( "default_channel:{}" , channel) ) ) ;
884896 }
885897
0 commit comments