From 83f885ee8d762551a6c5d8ea5ab3719cde76464a Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 7 Apr 2023 19:39:22 -0400 Subject: add bottom encode/decode --- src/utils.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index db5a5c4..4157e3b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,4 +1,5 @@ use crate::consts::*; +use bottomify::bottom::{decode_string, encode_string}; use include_dir::{include_dir, Dir}; use rand::seq::SliceRandom; use std::collections::HashMap; @@ -65,3 +66,24 @@ pub async fn get_copypasta(name: &str) -> Vec { let err = format!("couldn't find {:?} in files", name); vec![err] } + +/* + * encodes a string into bottom 🥺 + */ +pub async fn bottom_encode(string: &str) -> String { + encode_string(&string) +} + +/* + * decodes a bottom string into english 🥸 + */ +pub async fn bottom_decode(string: &str) -> String { + let decoded = decode_string(&string); + match decoded { + Ok(ret) => ret, + Err(why) => { + println!("couldn't decode {:?}! ({:?})", string, why); + "couldn't decode that! sowwy 🥺".to_string() + } + } +} -- cgit v1.2.3