diff options
| author | salmonik <salmonik@tuta.io> | 2026-09-03 17:50:12 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-09-03 17:50:12 +0200 |
| commit | 74a3027d62b190419a840bfa35fc6c9d720e88fe (patch) | |
| tree | 6d237ad02323660cab2f1ccb812b54d976728be9 | |
| parent | fix: cosmetic changes (diff) | |
| download | senator-sperma-74a3027d62b190419a840bfa35fc6c9d720e88fe.tar.gz senator-sperma-74a3027d62b190419a840bfa35fc6c9d720e88fe.zip | |
remove ` from TTS and make events use lang.rs
Signed-off-by: salmonik <salmonik@tuta.io>
| -rw-r--r-- | src/events/mod.rs | 57 | ||||
| -rw-r--r-- | src/lang.rs | 82 |
2 files changed, 108 insertions, 31 deletions
diff --git a/src/events/mod.rs b/src/events/mod.rs index ae0e1e4..e4f1b22 100644 --- a/src/events/mod.rs +++ b/src/events/mod.rs | |||
| @@ -145,9 +145,11 @@ pub async fn handle_voice_state_update( | |||
| 145 | info!("User {user_id} joined voice"); | 145 | info!("User {user_id} joined voice"); |
| 146 | 146 | ||
| 147 | if let Some(lc) = log_channel { | 147 | if let Some(lc) = log_channel { |
| 148 | let msg = format!( | 148 | let msg = lang::fmt_log_ev_joined( |
| 149 | "[{current_time}] {member_name} dołączył na {} <t:{current_ts}:R>", | 149 | ¤t_time, |
| 150 | va.channel_name | 150 | &member_name, |
| 151 | current_ts, | ||
| 152 | &va.channel_name, | ||
| 151 | ); | 153 | ); |
| 152 | lc.say(ctx, &msg).await.ok(); | 154 | lc.say(ctx, &msg).await.ok(); |
| 153 | } | 155 | } |
| @@ -189,10 +191,13 @@ pub async fn handle_voice_state_update( | |||
| 189 | } | 191 | } |
| 190 | 192 | ||
| 191 | if let Some(lc) = log_channel { | 193 | if let Some(lc) = log_channel { |
| 192 | let msg = format!( | 194 | let msg = lang::fmt_log_ev_left( |
| 193 | "[{current_time}] {member_name} rozłączył się z {} <t:{current_ts}:R>\n\ | 195 | ¤t_time, |
| 194 | Aktywny: {active_str} | AFK: {afk_str}", | 196 | &member_name, |
| 195 | channel_name, | 197 | current_ts, |
| 198 | &channel_name, | ||
| 199 | &active_str, | ||
| 200 | &afk_str, | ||
| 196 | ); | 201 | ); |
| 197 | lc.say(ctx, &msg).await.ok(); | 202 | lc.say(ctx, &msg).await.ok(); |
| 198 | } | 203 | } |
| @@ -201,8 +206,11 @@ pub async fn handle_voice_state_update( | |||
| 201 | database::upsert_voice_activity(&data.db_pool, &va).await?; | 206 | database::upsert_voice_activity(&data.db_pool, &va).await?; |
| 202 | } else { | 207 | } else { |
| 203 | if let Some(lc) = log_channel { | 208 | if let Some(lc) = log_channel { |
| 204 | let msg = format!( | 209 | let msg = lang::fmt_log_ev_left_no_data( |
| 205 | "[{current_time}] {member_name} rozłączył się z {channel_name} <t:{current_ts}:R>" | 210 | ¤t_time, |
| 211 | &member_name, | ||
| 212 | current_ts, | ||
| 213 | &channel_name, | ||
| 206 | ); | 214 | ); |
| 207 | lc.say(ctx, &msg).await.ok(); | 215 | lc.say(ctx, &msg).await.ok(); |
| 208 | } | 216 | } |
| @@ -227,18 +235,14 @@ pub async fn handle_voice_state_update( | |||
| 227 | database::upsert_voice_activity(&data.db_pool, &va).await?; | 235 | database::upsert_voice_activity(&data.db_pool, &va).await?; |
| 228 | 236 | ||
| 229 | let afk_str = format_duration(afk_duration); | 237 | let afk_str = format_duration(afk_duration); |
| 230 | // Python behavior: after.self_mute is always false here so always "odgłuchnął" | ||
| 231 | let activity = if new.self_mute { | ||
| 232 | "odciszył" | ||
| 233 | } else { | ||
| 234 | "odgłuchnął" | ||
| 235 | }; | ||
| 236 | 238 | ||
| 237 | if let Some(lc) = log_channel { | 239 | if let Some(lc) = log_channel { |
| 238 | let msg = format!( | 240 | let msg = lang::fmt_log_ev_activity( |
| 239 | "[{current_time}] {member_name} {activity} się na {} <t:{current_ts}:R>\n\ | 241 | ¤t_time, |
| 240 | AFK: {afk_str}", | 242 | &member_name, |
| 241 | va.channel_name, | 243 | current_ts, |
| 244 | &va.channel_name, | ||
| 245 | &afk_str, | ||
| 242 | ); | 246 | ); |
| 243 | lc.say(ctx, &msg).await.ok(); | 247 | lc.say(ctx, &msg).await.ok(); |
| 244 | } | 248 | } |
| @@ -258,16 +262,19 @@ pub async fn handle_voice_state_update( | |||
| 258 | 262 | ||
| 259 | let active_str = format_duration(active_duration); | 263 | let active_str = format_duration(active_duration); |
| 260 | let activity = if new.self_mute { | 264 | let activity = if new.self_mute { |
| 261 | "wyciszył" | 265 | lang::L_EV_WORD_MUTED |
| 262 | } else { | 266 | } else { |
| 263 | "ogłuchnął" | 267 | lang::L_EV_WORD_DEAFENED |
| 264 | }; | 268 | }; |
| 265 | 269 | ||
| 266 | if let Some(lc) = log_channel { | 270 | if let Some(lc) = log_channel { |
| 267 | let msg = format!( | 271 | let msg = lang::fmt_log_ev_unactivity( |
| 268 | "[{current_time}] {member_name} {activity} się na {} <t:{current_ts}:R>\n\ | 272 | ¤t_time, |
| 269 | Aktywny: {active_str}", | 273 | &member_name, |
| 270 | va.channel_name, | 274 | current_ts, |
| 275 | &va.channel_name, | ||
| 276 | activity, | ||
| 277 | &active_str, | ||
| 271 | ); | 278 | ); |
| 272 | lc.say(ctx, &msg).await.ok(); | 279 | lc.say(ctx, &msg).await.ok(); |
| 273 | } | 280 | } |
diff --git a/src/lang.rs b/src/lang.rs index 6b4e747..de0c7d7 100644 --- a/src/lang.rs +++ b/src/lang.rs | |||
| @@ -348,22 +348,92 @@ pub const L_EV_MESSAGE_HANDLER_ERROR: &str = "Błąd ustanawiacza głosu"; | |||
| 348 | // ── Event TTS phrases ───────────────────────────────────────────────── | 348 | // ── Event TTS phrases ───────────────────────────────────────────────── |
| 349 | 349 | ||
| 350 | pub fn fmt_ev_joined(name: &str) -> String { | 350 | pub fn fmt_ev_joined(name: &str) -> String { |
| 351 | format!("`{name}` sie zespawnił") | 351 | format!("{name} sie zespawnił") |
| 352 | } | 352 | } |
| 353 | pub fn fmt_ev_left(name: &str) -> String { | 353 | pub fn fmt_ev_left(name: &str) -> String { |
| 354 | format!("`{name}` jest chujem") | 354 | format!("{name} jest chujem") |
| 355 | } | 355 | } |
| 356 | pub fn fmt_ev_deafened(name: &str) -> String { | 356 | pub fn fmt_ev_deafened(name: &str) -> String { |
| 357 | format!("`{name}` jest bity przez ojca") | 357 | format!("{name} jest bity przez ojca") |
| 358 | } | 358 | } |
| 359 | pub fn fmt_ev_undeafened(name: &str) -> String { | 359 | pub fn fmt_ev_undeafened(name: &str) -> String { |
| 360 | format!("`{name}` uciekł od ojca") | 360 | format!("{name} uciekł od ojca") |
| 361 | } | 361 | } |
| 362 | pub fn fmt_ev_muted(name: &str) -> String { | 362 | pub fn fmt_ev_muted(name: &str) -> String { |
| 363 | format!("`{name}` idzie robić jajecznice") | 363 | format!("{name} idzie robić jajecznice") |
| 364 | } | 364 | } |
| 365 | pub fn fmt_ev_unmuted(name: &str) -> String { | 365 | pub fn fmt_ev_unmuted(name: &str) -> String { |
| 366 | format!("`{name}` zrobił jajecznice") | 366 | format!("{name} zrobił jajecznice") |
| 367 | } | ||
| 368 | |||
| 369 | // —— Event log phrases ————————————————————————————————————————————————— | ||
| 370 | |||
| 371 | pub fn fmt_log_ev_joined( | ||
| 372 | current_time: &str, | ||
| 373 | name: &str, | ||
| 374 | current_ts: i64, | ||
| 375 | channel_name: &str, | ||
| 376 | ) -> String { | ||
| 377 | format!( | ||
| 378 | "[{current_time}] `{name}` dołączył na {} <t:{current_ts}:R>", | ||
| 379 | channel_name | ||
| 380 | ) | ||
| 381 | } | ||
| 382 | |||
| 383 | pub fn fmt_log_ev_left( | ||
| 384 | current_time: &str, | ||
| 385 | name: &str, | ||
| 386 | current_ts: i64, | ||
| 387 | channel_name: &str, | ||
| 388 | active_str: &str, | ||
| 389 | afk_str: &str, | ||
| 390 | ) -> String { | ||
| 391 | format!( | ||
| 392 | "[{current_time}] `{name}` rozłączył się z {} <t:{current_ts}:R>\n\ | ||
| 393 | Aktywny: {active_str} | AFK: {afk_str}", | ||
| 394 | channel_name, | ||
| 395 | ) | ||
| 396 | } | ||
| 397 | |||
| 398 | pub fn fmt_log_ev_activity( | ||
| 399 | current_time: &str, | ||
| 400 | name: &str, | ||
| 401 | current_ts: i64, | ||
| 402 | channel_name: &str, | ||
| 403 | afk_str: &str, | ||
| 404 | ) -> String { | ||
| 405 | // Always "odgłuchnął": this fn is only called when !is_afk, so the user | ||
| 406 | // cannot still be self-muted. | ||
| 407 | format!( | ||
| 408 | "[{current_time}] `{name}` odgłuchnął się na {channel_name} <t:{current_ts}:R>\n\ | ||
| 409 | AFK: {afk_str}" | ||
| 410 | ) | ||
| 411 | } | ||
| 412 | |||
| 413 | pub const L_EV_WORD_MUTED: &str = "wyciszył"; | ||
| 414 | pub const L_EV_WORD_DEAFENED: &str = "ogłuchnął"; | ||
| 415 | |||
| 416 | pub fn fmt_log_ev_unactivity( | ||
| 417 | current_time: &str, | ||
| 418 | name: &str, | ||
| 419 | current_ts: i64, | ||
| 420 | channel_name: &str, | ||
| 421 | activity: &str, | ||
| 422 | active_str: &str, | ||
| 423 | ) -> String { | ||
| 424 | format!( | ||
| 425 | "[{current_time}] `{name}` {activity} się na {channel_name} <t:{current_ts}:R>\n\ | ||
| 426 | Aktywny: {active_str}" | ||
| 427 | ) | ||
| 428 | } | ||
| 429 | |||
| 430 | pub fn fmt_log_ev_left_no_data( | ||
| 431 | current_time: &str, | ||
| 432 | name: &str, | ||
| 433 | current_ts: i64, | ||
| 434 | channel_name: &str, | ||
| 435 | ) -> String { | ||
| 436 | format!("[{current_time}] `{name}` rozłączył się z {channel_name} <t:{current_ts}:R>") | ||
| 367 | } | 437 | } |
| 368 | 438 | ||
| 369 | // ── AI assistant (events/message handler) ───────────────────────────── | 439 | // ── AI assistant (events/message handler) ───────────────────────────── |
