@@ -5,7 +5,7 @@ mod message_updater;
55mod raw_pcm_conversions;
66mod state;
77
8- use std:: time:: Duration ;
8+ use std:: { fmt :: Write , time:: Duration } ;
99
1010use poise:: CreateReply ;
1111use scripty_i18n:: LanguageIdentifier ;
@@ -29,6 +29,7 @@ pub async fn transcribe_generic_message(
2929 resolved_language : LanguageIdentifier ,
3030) -> Result < ( ) , Error > {
3131 let target_msg_id = target_msg. id ;
32+ let target_guild_id = target_msg. guild_id ;
3233
3334 let ( tx, mut rx) = tokio:: sync:: mpsc:: channel ( 5 ) ;
3435 let file_transcript = FileTranscriptionHandler :: new ( target_msg, tx, invoking_user, false ) ;
@@ -92,13 +93,29 @@ pub async fn transcribe_generic_message(
9293 } ;
9394
9495 let final_transcripts = final_transcript_result??;
95- send_final_transcript_edit ( final_transcripts, reply_msg, & resolved_language) . await
96+
97+ let verbose = if let Some ( guild_id) = target_guild_id {
98+ let db = scripty_db:: get_db ( ) ;
99+ sqlx:: query!(
100+ "SELECT be_verbose FROM guilds WHERE guild_id = $1" ,
101+ guild_id. get( ) as i64
102+ )
103+ . fetch_optional ( db)
104+ . await ?
105+ . is_some_and ( |r| r. be_verbose )
106+ } else {
107+ // always be verbose in DMs
108+ true
109+ } ;
110+
111+ send_final_transcript_edit ( final_transcripts, reply_msg, & resolved_language, verbose) . await
96112}
97113
98114async fn send_final_transcript_edit (
99115 mut final_transcripts : Vec < TranscriptResult > ,
100116 mut reply_msg : MessageUpdater < ' _ > ,
101117 resolved_language : & LanguageIdentifier ,
118+ verbose : bool ,
102119) -> Result < ( ) , Error > {
103120 let edit_msg = if final_transcripts. is_empty ( ) {
104121 CreateReply :: new ( ) . content ( format_message ! (
@@ -116,6 +133,7 @@ async fn send_final_transcript_edit(
116133 transcript_result,
117134 resolved_language,
118135 true ,
136+ verbose,
119137 ) ;
120138 edit_msg. content ( msg_content)
121139 } else {
@@ -128,6 +146,7 @@ async fn send_final_transcript_edit(
128146 transcript,
129147 resolved_language,
130148 false ,
149+ verbose,
131150 ) ;
132151 }
133152 edit_msg. content ( msg_content)
@@ -144,6 +163,7 @@ fn format_transcript_msg<'a>(
144163 TranscriptResult { filename, state } : TranscriptResult ,
145164 resolved_language : & LanguageIdentifier ,
146165 is_single : bool ,
166+ verbose : bool ,
147167) -> CreateReply < ' a > {
148168 match state {
149169 TranscriptResultEnum :: Success {
@@ -152,29 +172,45 @@ fn format_transcript_msg<'a>(
152172 transcript,
153173 } if transcript. len ( ) <= 1800 && is_single => {
154174 // this is the sole transcript, and it is under 1800 characters, so we can send it inline
155- msg_content. push_str ( & format_message ! (
156- resolved_language,
157- "transcribe-message-inline-header"
158- ) ) ;
159- msg_content. push ( '\n' ) ;
175+ if verbose {
176+ msg_content. push_str ( & format_message ! (
177+ resolved_language,
178+ "transcribe-message-inline-header"
179+ ) ) ;
180+ msg_content. push ( '\n' ) ;
181+ }
160182 for line in transcript. split_inclusive ( '\n' ) {
161183 msg_content. push_str ( "> " ) ;
162184 msg_content. push_str ( line) ;
163185 }
164186
165187 msg_content. push ( '\n' ) ;
166- msg_content. push_str ( & format_message ! (
167- resolved_language,
168- "transcribe-message-time-taken-single-file" ,
169- timeTaken: format!( "{:.3}" , took. as_secs_f64( ) ) ,
170- fileLength: format!( "{:.3}" , file_length)
171- ) ) ;
172- msg_content. push ( '\n' ) ;
173- if took. as_secs_f64 ( ) > file_length {
188+
189+ let took_f64 = took. as_secs_f64 ( ) ;
190+ let unusually_long = took_f64 > file_length;
191+ if verbose {
174192 msg_content. push_str ( & format_message ! (
175193 resolved_language,
176- "transcribe-message-unusually-long"
194+ "transcribe-message-time-taken-single-file" ,
195+ timeTaken: format!( "{:.3}" , took. as_secs_f64( ) ) ,
196+ fileLength: format!( "{:.3}" , file_length)
177197 ) ) ;
198+ msg_content. push ( '\n' ) ;
199+ if unusually_long {
200+ msg_content. push_str ( & format_message ! (
201+ resolved_language,
202+ "transcribe-message-unusually-long"
203+ ) ) ;
204+ }
205+ } else {
206+ write ! (
207+ msg_content,
208+ "-# {:.3} ({:.3}){}" ,
209+ took. as_secs_f64( ) ,
210+ file_length,
211+ if unusually_long { " ⚠" } else { "" }
212+ )
213+ . expect ( "writing to string should be infallible" )
178214 }
179215
180216 msg
0 commit comments