Python error handling (sends Discord DM)

This commit is contained in:
2025-02-18 14:22:26 +01:00
parent 7fc23896cb
commit cb2b5a508e
4 changed files with 39 additions and 3 deletions
+8
View File
@@ -8,6 +8,7 @@ use futures::StreamExt;
use std::sync::Arc;
use serde_json::Value;
use crate::messages::send_dm;
use crate::rs_println;
use crate::Args;
@@ -125,6 +126,13 @@ async fn handle_message(msg: tungstenite::protocol::Message, args: Args) {
tungstenite::Message::Text(text) => {
rs_println!("Received from Python: {}", text);
if text.starts_with("json:") {
let t_json: Value = serde_json::from_str(&text[5..]).unwrap();
if t_json.get("error").is_some() {
send_dm("Internal Python error!".to_string(), args).await;
}
}
unsafe {
if !REPLY_HELLO {
send_msg("[Connection test] Hello from Rust!").await;