html terminal
read message.txt
| -rw-r--r-- | src/bot/schematic.rs | 13 | ||||
| -rw-r--r-- | src/bot/schematics.rs | 0 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/bot/schematic.rs b/src/bot/schematic.rs index 370e2cb..d845033 100644 --- a/src/bot/schematic.rs +++ b/src/bot/schematic.rs @@ -12,7 +12,7 @@ use super::{strip_colors, SUCCESS}; static RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(```)?(\n)?([^`]+)(\n)?(```)?").unwrap()); -pub async fn from_attachments(attchments: &[Attachment]) -> Result<Option<Schematic<'_>>> { +async fn from_attachments(attchments: &[Attachment]) -> Result<Option<Schematic<'_>>> { for a in attchments { if a.filename.ends_with("msch") { let s = a.download().await?; @@ -21,6 +21,15 @@ pub async fn from_attachments(attchments: &[Attachment]) -> Result<Option<Schema continue; }; return Ok(Some(s)); + // discord uploads base64 as a file when its too long + } else if a.filename == "message.txt" { + let Ok(s) = String::from_utf8(a.download().await?) else { + continue; + }; + let Ok(s) = Schematic::deserialize_base64(&s) else { + continue; + }; + return Ok(Some(s)); } } Ok(None) @@ -84,7 +93,7 @@ pub fn to_png(s: &Schematic<'_>) -> Vec<u8> { .unwrap() } -pub fn from_msg<'l>(msg: &str) -> Result<Schematic<'l>> { +fn from_msg<'l>(msg: &str) -> Result<Schematic<'l>> { let schem_text = RE .captures(msg) .ok_or(anyhow!("couldnt find schematic"))? diff --git a/src/bot/schematics.rs b/src/bot/schematics.rs deleted file mode 100644 index e69de29..0000000 --- a/src/bot/schematics.rs +++ /dev/null |