diff --git a/blastmud_game/src/message_handler/user_commands.rs b/blastmud_game/src/message_handler/user_commands.rs index 0720cd0..f1a45fc 100644 --- a/blastmud_game/src/message_handler/user_commands.rs +++ b/blastmud_game/src/message_handler/user_commands.rs @@ -389,20 +389,86 @@ pub async fn handle(_session: &ListenerSession, _msg: &str, _pool: &DBPool) -> D unimplemented!(); } -pub fn is_likely_explicit(msg: &str) -> bool { - static EXPLICIT_MARKER_WORDS: OnceCell> = OnceCell::new(); - let markers = EXPLICIT_MARKER_WORDS.get_or_init(|| { +pub fn is_likely_illegal(msg: &str) -> bool { + static ILLEGAL_MARKER_WORDS: OnceCell> = OnceCell::new(); + let illegal_markers = ILLEGAL_MARKER_WORDS.get_or_init(|| { vec![ - "fuck", "sex", "cock", "cunt", "dick", "pussy", "whore", "orgasm", "erection", - "nipple", "boob", "tit", + "lolita", + "jailbait", + "abu sayyaf", + "al-qa’ida", + "al-qaida", + "al-shabaab", + "boko haram", + "hamas", + "tahrir al-sham", + "​hizballah", + "hezbollah", + "hurras al-din", + "​islamic state", + "​jaish-e-mohammad", + "jama’at mujahideen", + "jamaat mujahideen", + "jama’at nusrat", + "jamaat nusrat", + "jemaah islamiyah", + "kurdistan workers", + "lashkar-e-tayyiba", + "likud", + "national socialist order", + "palestinian islamic jihad", + "sonnenkrieg", + "race war", + // For now we'll block all URLs - we could allow by domain perhaps? + "http:", + "https:", + "ftp:", ] }); - for word in markers { - if msg.contains(word) { + static MINOR_MARKER_WORDS: OnceCell> = OnceCell::new(); + let minor_markers = + MINOR_MARKER_WORDS.get_or_init(|| vec!["young", "underage", "child", "teen", "minor"]); + static EXPLICIT_MARKER_WORDS: OnceCell> = OnceCell::new(); + let explicit_markers = EXPLICIT_MARKER_WORDS.get_or_init(|| { + vec![ + "fuck", + "sex", + "cock", + "cunt", + "dick", + "pussy", + "whore", + "orgasm", + "erection", + "nipple", + "boob", + "tit", + "xxx", + "nsfw", + "uncensored", + ] + }); + let msg_lower = msg.to_lowercase(); + for word in illegal_markers { + if msg_lower.contains(word) { return true; } } - false + + let mut minor_word = false; + let mut explicit_word = false; + for word in minor_markers { + if msg_lower.contains(word) { + minor_word = true; + } + } + for word in explicit_markers { + if msg_lower.contains(word) { + explicit_word = true; + } + } + + explicit_word && minor_word } pub fn get_user_or_fail<'l>(ctx: &'l VerbContext) -> UResult<&'l User> { diff --git a/blastmud_game/src/message_handler/user_commands/corp.rs b/blastmud_game/src/message_handler/user_commands/corp.rs index 58b8bdf..83a3418 100644 --- a/blastmud_game/src/message_handler/user_commands/corp.rs +++ b/blastmud_game/src/message_handler/user_commands/corp.rs @@ -55,7 +55,7 @@ async fn corp_invite(ctx: &mut VerbContext<'_>, remaining: &str) -> UResult<()> user_error("Only players can be hired.".to_owned())?; } - let (their_sess, their_sess_dat) = match ctx + let (their_sess, _their_sess_dat) = match ctx .trans .find_session_for_player(&target_user.item_code) .await? @@ -109,7 +109,7 @@ async fn corp_invite(ctx: &mut VerbContext<'_>, remaining: &str) -> UResult<()> ctx.trans.queue_for_session(&their_sess, Some(&format!( ansi!("{} wants to hire you into {}! Type corp join {} to accept.{}\n"), - &player.display_for_sentence(!their_sess_dat.less_explicit_mode, 1, true), + &player.display_for_sentence(true, 1, true), &corp.name, &corp.name, if new_mem.allow_combat { diff --git a/blastmud_game/src/message_handler/user_commands/cut.rs b/blastmud_game/src/message_handler/user_commands/cut.rs index ffa8b45..d810d1b 100644 --- a/blastmud_game/src/message_handler/user_commands/cut.rs +++ b/blastmud_game/src/message_handler/user_commands/cut.rs @@ -60,11 +60,10 @@ impl QueueCommandHandler for QueueHandler { Some(it) => it, }; - let explicit = ctx.explicit().await?; if corpse.location != ctx.item.location { user_error(format!( "You try to cut {} but realise it is no longer there.", - corpse.display_for_sentence(explicit, 1, false) + corpse.display_for_sentence(true, 1, false) ))? } ensure_has_butcher_tool(&ctx.trans, &ctx.item).await?; @@ -131,11 +130,10 @@ impl QueueCommandHandler for QueueHandler { Some(it) => it, }; - let explicit = ctx.explicit().await?; if corpse.location != ctx.item.location { user_error(format!( "You try to cut {} but realise it is no longer there.", - corpse.display_for_sentence(explicit, 1, false) + corpse.display_for_sentence(true, 1, false) ))? } diff --git a/blastmud_game/src/message_handler/user_commands/drink.rs b/blastmud_game/src/message_handler/user_commands/drink.rs index 68594c0..29fa2d2 100644 --- a/blastmud_game/src/message_handler/user_commands/drink.rs +++ b/blastmud_game/src/message_handler/user_commands/drink.rs @@ -43,7 +43,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location && item.location != ctx.item.refstr() { user_error(format!( "You try to drink {} but realise you no longer have it", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } let msg = format!( @@ -81,7 +81,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location && item.location != ctx.item.refstr() { user_error(format!( "You try to drink {} but realise you no longer have it!", - &item.display_for_sentence(ctx.explicit().await?, 1, false) + &item.display_for_sentence(true, 1, false) ))? } let liquid_details = item diff --git a/blastmud_game/src/message_handler/user_commands/drop.rs b/blastmud_game/src/message_handler/user_commands/drop.rs index cb50b6d..387fd05 100644 --- a/blastmud_game/src/message_handler/user_commands/drop.rs +++ b/blastmud_game/src/message_handler/user_commands/drop.rs @@ -128,7 +128,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) { user_error(format!( "You try to drop {} but realise you no longer have it", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } if item.action_type == LocationActionType::Worn { @@ -168,7 +168,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) { user_error(format!( "You try to drop {} but realise you no longer have it!", - &item.display_for_sentence(ctx.explicit().await?, 1, false) + &item.display_for_sentence(true, 1, false) ))? } if item.action_type == LocationActionType::Worn { @@ -192,7 +192,7 @@ impl QueueCommandHandler for QueueHandler { { CapacityLevel::AboveItemLimit => user_error(format!( "You can't drop {}, because it is so cluttered here there is no where to put it!", - &item.display_for_sentence(ctx.explicit().await?, 1, false) + &item.display_for_sentence(true, 1, false) ))?, _ => (), } diff --git a/blastmud_game/src/message_handler/user_commands/eat.rs b/blastmud_game/src/message_handler/user_commands/eat.rs index 8e42c66..5e8f3b8 100644 --- a/blastmud_game/src/message_handler/user_commands/eat.rs +++ b/blastmud_game/src/message_handler/user_commands/eat.rs @@ -41,7 +41,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) { user_error(format!( "You try to eat {} but realise you no longer have it", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } let msg = format!( @@ -76,7 +76,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) { user_error(format!( "You try to eat {} but realise you no longer have it!", - &item.display_for_sentence(ctx.explicit().await?, 1, false) + &item.display_for_sentence(true, 1, false) ))? } if item.action_type == LocationActionType::Worn { diff --git a/blastmud_game/src/message_handler/user_commands/fill.rs b/blastmud_game/src/message_handler/user_commands/fill.rs index 62c0c67..d22937e 100644 --- a/blastmud_game/src/message_handler/user_commands/fill.rs +++ b/blastmud_game/src/message_handler/user_commands/fill.rs @@ -51,13 +51,13 @@ impl QueueCommandHandler for QueueHandler { if to_item.location != ctx.item.location && to_item.location != ctx.item.refstr() { user_error(format!( "You try to fill {} but realise you no longer have it", - to_item.display_for_sentence(ctx.explicit().await?, 1, false) + to_item.display_for_sentence(true, 1, false) ))? } if from_item.location != ctx.item.location && from_item.location != ctx.item.refstr() { user_error(format!( "You try to fill from {} but realise you no longer have it", - to_item.display_for_sentence(ctx.explicit().await?, 1, false) + to_item.display_for_sentence(true, 1, false) ))? } @@ -106,20 +106,20 @@ impl QueueCommandHandler for QueueHandler { if to_item.location != ctx.item.location && to_item.location != ctx.item.refstr() { user_error(format!( "You try to fill {} but realise you no longer have it", - to_item.display_for_sentence(ctx.explicit().await?, 1, false) + to_item.display_for_sentence(true, 1, false) ))? } if from_item.location != ctx.item.location && from_item.location != ctx.item.refstr() { user_error(format!( "You try to fill from {} but realise you no longer have it", - to_item.display_for_sentence(ctx.explicit().await?, 1, false) + to_item.display_for_sentence(true, 1, false) ))? } let from_liquid_details = match from_item.liquid_details.as_ref() { None => user_error(format!( "{} appears to be empty.", - from_item.display_for_sentence(ctx.explicit().await?, 1, true) + from_item.display_for_sentence(true, 1, true) ))?, Some(v) => v, }; @@ -132,7 +132,7 @@ impl QueueCommandHandler for QueueHandler { if available_vol == 0 { user_error(format!( "{} appears to be empty.", - from_item.display_for_sentence(ctx.explicit().await?, 1, true) + from_item.display_for_sentence(true, 1, true) ))? } @@ -142,7 +142,7 @@ impl QueueCommandHandler for QueueHandler { { None => user_error(format!( "You can't find a way to fill {}.", - to_item.display_for_sentence(ctx.explicit().await?, 1, false) + to_item.display_for_sentence(true, 1, false) ))?, Some(v) => v, }; @@ -153,7 +153,7 @@ impl QueueCommandHandler for QueueHandler { user_error(format!( "You don't think putting {} into {} is a good idea.", liq_type.display(), - to_item.display_for_sentence(ctx.explicit().await?, 1, false) + to_item.display_for_sentence(true, 1, false) ))?; } } @@ -170,7 +170,7 @@ impl QueueCommandHandler for QueueHandler { if actually_transferred == 0 { user_error(format!( "You don't think you can get any more into {}.", - to_item.display_for_sentence(ctx.explicit().await?, 1, false) + to_item.display_for_sentence(true, 1, false) ))?; } diff --git a/blastmud_game/src/message_handler/user_commands/gear.rs b/blastmud_game/src/message_handler/user_commands/gear.rs index 8ba7686..e6c3768 100644 --- a/blastmud_game/src/message_handler/user_commands/gear.rs +++ b/blastmud_game/src/message_handler/user_commands/gear.rs @@ -60,14 +60,7 @@ impl UserVerb for Verb { if !worn.is_empty() { worn.push_str(", "); } - worn.push_str(if ctx.session_dat.less_explicit_mode { - item.display_less_explicit - .as_ref() - .map(|s| s.as_str()) - .unwrap_or(&item.display) - } else { - &item.display - }); + worn.push_str(&item.display); for entry in damage_ranges.iter_mut() { if let Some(soak_data) = wear_data.soaks.get(entry.0) { let (old_min, old_max) = entry.1; diff --git a/blastmud_game/src/message_handler/user_commands/get.rs b/blastmud_game/src/message_handler/user_commands/get.rs index 3bf70bd..073bf6d 100644 --- a/blastmud_game/src/message_handler/user_commands/get.rs +++ b/blastmud_game/src/message_handler/user_commands/get.rs @@ -38,7 +38,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location { user_error(format!( "You try to get {} but realise it is no longer there", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } let msg = format!( @@ -62,8 +62,8 @@ impl QueueCommandHandler for QueueHandler { { user_error(format!( "You try to get something from {} but realise {} is no longer there", - container.display_for_sentence(ctx.explicit().await?, 1, false), - container.display_for_sentence(ctx.explicit().await?, 1, false), + container.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } let item = ctx @@ -74,8 +74,8 @@ impl QueueCommandHandler for QueueHandler { if item.location != container.refstr() { user_error(format!( "You try to get {} but realise it is no longer in {}", - item.display_for_sentence(ctx.explicit().await?, 1, false), - container.display_for_sentence(ctx.explicit().await?, 1, false), + item.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } let msg = format!( @@ -111,7 +111,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location { user_error(format!( "You try to get {} but realise it is no longer there", - &item.display_for_sentence(ctx.explicit().await?, 1, false) + &item.display_for_sentence(true, 1, false) ))? } @@ -137,8 +137,8 @@ impl QueueCommandHandler for QueueHandler { { user_error(format!( "You try to get something from {} but realise {} is no longer there", - container.display_for_sentence(ctx.explicit().await?, 1, false), - container.display_for_sentence(ctx.explicit().await?, 1, false), + container.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } let item = ctx @@ -149,8 +149,8 @@ impl QueueCommandHandler for QueueHandler { if item.location != container.refstr() { user_error(format!( "You try to get {} but realise it is no longer in {}", - item.display_for_sentence(ctx.explicit().await?, 1, false), - container.display_for_sentence(ctx.explicit().await?, 1, false), + item.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } let msg = format!( @@ -180,14 +180,10 @@ impl QueueCommandHandler for QueueHandler { CapacityLevel::AboveItemLimit => { user_error("You just can't hold that many things!".to_owned())? } - CapacityLevel::OverBurdened => { - let explicit = ctx.explicit().await?; - user_error(format!( - "{} You can't get {} because it is too heavy!", - if explicit { "Fuck!" } else { "Rats!" }, - &item.display_for_sentence(explicit, 1, false) - ))? - } + CapacityLevel::OverBurdened => user_error(format!( + "Fuck! You can't get {} because it is too heavy!", + &item.display_for_sentence(true, 1, false) + ))?, _ => (), } diff --git a/blastmud_game/src/message_handler/user_commands/improvise.rs b/blastmud_game/src/message_handler/user_commands/improvise.rs index dd3c685..f128e2c 100644 --- a/blastmud_game/src/message_handler/user_commands/improvise.rs +++ b/blastmud_game/src/message_handler/user_commands/improvise.rs @@ -101,10 +101,6 @@ impl QueueCommandHandler for WithQueueHandler { } else { None }; - let explicit = session - .as_ref() - .map(|s| !s.1.less_explicit_mode) - .unwrap_or(false); let opts: Vec<&'static PossessionData> = improv_by_ingredient() .get( item.possession_type @@ -114,12 +110,11 @@ impl QueueCommandHandler for WithQueueHandler { .ok_or_else(|| { UserError(format!( "You can't think of anything you could make with {}", - item.display_for_sentence(explicit, 1, false) + item.display_for_sentence(true, 1, false) )) })? .iter() .filter_map(|it| possession_data().get(&it.output).map(|v| *v)) - .filter(|pd| explicit || pd.display_less_explicit.is_none()) .collect(); let result_data = opts .as_slice() @@ -127,7 +122,7 @@ impl QueueCommandHandler for WithQueueHandler { .ok_or_else(|| { UserError(format!( "You can't think of anything you could make with {}", - item.display_for_sentence(explicit, 1, false) + item.display_for_sentence(true, 1, false) )) })?; if let Some((sess, _)) = session { @@ -138,7 +133,7 @@ impl QueueCommandHandler for WithQueueHandler { "You think you could make {} {} from {}\n", indefinite_article(result_data.display), result_data.display, - item.display_for_sentence(explicit, 1, false) + item.display_for_sentence(true, 1, false) )), ) .await?; @@ -225,10 +220,6 @@ impl QueueCommandHandler for FromQueueHandler { } else { None }; - let explicit = session - .as_ref() - .map(|s| !s.1.less_explicit_mode) - .unwrap_or(false); match possession_id_iter.next() { None => { let choice = ingredients_left @@ -292,7 +283,7 @@ impl QueueCommandHandler for FromQueueHandler { ) { user_error(format!( "You try adding {}, but it doesn't really seem to fit right.", - &item.display_for_sentence(explicit, 1, false) + &item.display_for_sentence(true, 1, false) ))?; } let skill_result = skill_check_and_grind( @@ -314,7 +305,7 @@ impl QueueCommandHandler for FromQueueHandler { &sess, Some(&format!( "You try adding {}, but it goes badly and you waste it.\n", - &item.display_for_sentence(explicit, 1, false) + &item.display_for_sentence(true, 1, false) )), ) .await?; @@ -327,7 +318,7 @@ impl QueueCommandHandler for FromQueueHandler { &sess, Some(&format!( "You try and fail at adding {}.\n", - &item.display_for_sentence(explicit, 1, false) + &item.display_for_sentence(true, 1, false) )), ) .await?; @@ -339,7 +330,7 @@ impl QueueCommandHandler for FromQueueHandler { &sess, Some(&format!( "You try adding {}.\n", - &item.display_for_sentence(explicit, 1, false), + &item.display_for_sentence(true, 1, false), )), ) .await?; diff --git a/blastmud_game/src/message_handler/user_commands/inventory.rs b/blastmud_game/src/message_handler/user_commands/inventory.rs index 9d6e52b..072658b 100644 --- a/blastmud_game/src/message_handler/user_commands/inventory.rs +++ b/blastmud_game/src/message_handler/user_commands/inventory.rs @@ -49,7 +49,7 @@ impl UserVerb for Verb { total += it_total; response.push_str(&format!( "{} [{}]{}\n", - item.display_for_sentence(!ctx.session_dat.less_explicit_mode, items.len(), true), + item.display_for_sentence(true, items.len(), true), weight(it_total), match item.action_type { LocationActionType::Worn => " (worn)", diff --git a/blastmud_game/src/message_handler/user_commands/list.rs b/blastmud_game/src/message_handler/user_commands/list.rs index 1f80efb..0222c07 100644 --- a/blastmud_game/src/message_handler/user_commands/list.rs +++ b/blastmud_game/src/message_handler/user_commands/list.rs @@ -47,14 +47,7 @@ impl UserVerb for Verb { for stock in &room.stock_list { if let Some(possession_type) = possession_data().get(&stock.possession_type) { - let display = if ctx.session_dat.less_explicit_mode { - possession_type - .display_less_explicit - .as_ref() - .unwrap_or(&possession_type.display) - } else { - &possession_type.display - }; + let display = &possession_type.display; let mut price = stock.list_price; if stock.poverty_discount && price > user.credits { diff --git a/blastmud_game/src/message_handler/user_commands/look.rs b/blastmud_game/src/message_handler/user_commands/look.rs index 04bac1b..72450f1 100644 --- a/blastmud_game/src/message_handler/user_commands/look.rs +++ b/blastmud_game/src/message_handler/user_commands/look.rs @@ -21,7 +21,7 @@ use crate::{ dynzone, possession_type::{possession_data, recipe_craft_by_recipe}, room::{self, Direction}, - species::{species_info_map, SpeciesType}, + species::species_info_map, }, }; use ansi::{ansi, flow_around, word_wrap}; @@ -66,11 +66,7 @@ pub async fn describe_normal_item( let mut phrases = Vec::::new(); for group_items in all_groups { let head = &group_items[0]; - let mut details = head.display_for_sentence( - !ctx.session_dat.less_explicit_mode, - group_items.len(), - false, - ); + let mut details = head.display_for_sentence(true, group_items.len(), false); match head.action_type { LocationActionType::Wielded => details.push_str(" (wielded)"), LocationActionType::Worn => continue, @@ -171,28 +167,18 @@ pub async fn describe_normal_item( )); } } else { - if !ctx.session_dat.less_explicit_mode { - any_part_text = true; - contents_desc.push_str(&format!( - "{} {} {} completely bare. ", - &language::caps_first(&item.pronouns.possessive), - part.display(item.sex.clone()), - part.copula(item.sex.clone()) - )); - } + any_part_text = true; + contents_desc.push_str(&format!( + "{} {} {} completely bare. ", + &language::caps_first(&item.pronouns.possessive), + part.display(item.sex.clone()), + part.copula(item.sex.clone()) + )); } } if any_part_text { contents_desc.push_str("\n"); } - } else if (item.item_type == "npc" || item.item_type == "player") - && item.species == SpeciesType::Human - && !ctx.session_dat.less_explicit_mode - { - contents_desc.push_str(&format!( - "{} is completely naked.\n", - &language::caps_first(&item.pronouns.subject) - )); } let health_max = max_health(&item); @@ -293,11 +279,7 @@ pub async fn describe_normal_item( contents_desc.push_str("You will need:\n"); for (input_pt, count) in &recipe_craft_data.craft_data.inputs.iter().counts() { if let Some(pd) = possession_data().get(&input_pt) { - let thing = if ctx.session_dat.less_explicit_mode { - pd.display_less_explicit.unwrap_or(pd.display) - } else { - pd.display - }; + let thing = pd.display; contents_desc.push_str(&format!( " {} {}\n", count, @@ -313,14 +295,8 @@ pub async fn describe_normal_item( None => contents_desc.push_str("You can make this without any special bench.\n"), Some(bench) => { if let Some(pd) = possession_data().get(bench) { - contents_desc.push_str(&format!( - "You'll need to make this on a {}.\n", - if ctx.session_dat.less_explicit_mode { - pd.display_less_explicit.unwrap_or(pd.display) - } else { - pd.display - } - )) + contents_desc + .push_str(&format!("You'll need to make this on a {}.\n", pd.display)) } } } @@ -520,11 +496,7 @@ async fn list_room_contents<'l>(ctx: &'l VerbContext<'_>, item: &'l Item) -> URe let head = &group_items[0]; let is_creature = head.item_type == "player" || head.item_type.starts_with("npc"); buf.push(' '); - buf.push_str(&head.display_for_sentence( - !ctx.session_dat.less_explicit_mode, - group_items.len(), - true, - )); + buf.push_str(&head.display_for_sentence(true, group_items.len(), true)); buf.push_str(if group_items.len() > 1 { " are " } else { diff --git a/blastmud_game/src/message_handler/user_commands/make.rs b/blastmud_game/src/message_handler/user_commands/make.rs index 9b28379..5b9cedf 100644 --- a/blastmud_game/src/message_handler/user_commands/make.rs +++ b/blastmud_game/src/message_handler/user_commands/make.rs @@ -396,11 +396,7 @@ impl UserVerb for Verb { &instructions.display_for_session(&ctx.session_dat), possession_data() .get(bench_type) - .map(|pd| if ctx.session_dat.less_explicit_mode { - pd.display_less_explicit.unwrap_or(pd.display) - } else { - pd.display - }) + .map(|pd| pd.display) .unwrap_or("bench") ))?, (Some(bench_type), Some(bench)) @@ -411,13 +407,7 @@ impl UserVerb for Verb { &instructions.display_for_session(&ctx.session_dat), possession_data() .get(bench_type) - .map(|pd| { - if ctx.session_dat.less_explicit_mode { - pd.display_less_explicit.unwrap_or(pd.display) - } else { - pd.display - } - }) + .map(|pd| pd.display) .unwrap_or("bench") ))? } diff --git a/blastmud_game/src/message_handler/user_commands/map.rs b/blastmud_game/src/message_handler/user_commands/map.rs index 37b2c92..d07c237 100644 --- a/blastmud_game/src/message_handler/user_commands/map.rs +++ b/blastmud_game/src/message_handler/user_commands/map.rs @@ -450,11 +450,9 @@ impl MapType for LmapType { None => None, Some((ex_t, ex_c)) => { match ctx.trans.find_item_by_type_code(ex_t, ex_c).await?.as_ref() { - Some(dest_item) => Some(dest_item.display_for_sentence( - !ctx.session_dat.less_explicit_mode, - 1, - true, - )), + Some(dest_item) => { + Some(dest_item.display_for_sentence(true, 1, true)) + } None => None, } } diff --git a/blastmud_game/src/message_handler/user_commands/page.rs b/blastmud_game/src/message_handler/user_commands/page.rs index 413dd01..51a0a00 100644 --- a/blastmud_game/src/message_handler/user_commands/page.rs +++ b/blastmud_game/src/message_handler/user_commands/page.rs @@ -1,5 +1,5 @@ use super::{ - get_player_item_or_fail, is_likely_explicit, parsing::parse_to_space, search_item_for_user, + get_player_item_or_fail, is_likely_illegal, parsing::parse_to_space, search_item_for_user, user_error, ItemSearchParams, UResult, UserVerb, UserVerbRef, VerbContext, }; use ansi::{ansi, ignore_special_characters}; @@ -51,6 +51,10 @@ impl UserVerb for Verb { _ => user_error("Only players accept pages".to_string())?, } + if is_likely_illegal(&say_what) { + user_error("Your message was rejected by the content filter".to_string())?; + } + ctx.trans .queue_for_session( ctx.session, @@ -74,24 +78,23 @@ impl UserVerb for Verb { .await? { None => user_error("That character is asleep.".to_string())?, - Some((other_session, other_session_dets)) => { - if other_session_dets.less_explicit_mode && is_likely_explicit(&say_what) { - user_error("That player is on a client that doesn't allow explicit \ - content, and your message looked explicit, so it wasn't sent." - .to_owned())? - } else { - if let Some(mut user) = - ctx.trans.find_by_username(&to_whom.item_code).await? - { - user.last_page_from = Some(player_item.item_code.clone()); - ctx.trans.save_user_model(&user).await?; - } - ctx.trans.queue_for_session(&other_session, Some(&format!( - ansi!("Your wristpad beeps with page from {}: \"{}\"\n"), - player_item.display_for_session(&ctx.session_dat), - say_what - ))).await?; + Some((other_session, _other_session_dets)) => { + if let Some(mut user) = + ctx.trans.find_by_username(&to_whom.item_code).await? + { + user.last_page_from = Some(player_item.item_code.clone()); + ctx.trans.save_user_model(&user).await?; } + ctx.trans + .queue_for_session( + &other_session, + Some(&format!( + ansi!("Your wristpad beeps with page from {}: \"{}\"\n"), + player_item.display_for_session(&ctx.session_dat), + say_what + )), + ) + .await?; } } } diff --git a/blastmud_game/src/message_handler/user_commands/put.rs b/blastmud_game/src/message_handler/user_commands/put.rs index 88fa9ee..956b8aa 100644 --- a/blastmud_game/src/message_handler/user_commands/put.rs +++ b/blastmud_game/src/message_handler/user_commands/put.rs @@ -42,8 +42,8 @@ impl QueueCommandHandler for QueueHandler { if container.location != ctx.item.location && container.location != ctx.item.refstr() { user_error(format!( "You try to put something in {} but realise {} is no longer there", - container.display_for_sentence(ctx.explicit().await?, 1, false), - container.display_for_sentence(ctx.explicit().await?, 1, false), + container.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } let item = ctx @@ -54,8 +54,8 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.refstr() { user_error(format!( "You try to put {} in {}, but realise you no longer have it", - item.display_for_sentence(ctx.explicit().await?, 1, false), - container.display_for_sentence(ctx.explicit().await?, 1, false), + item.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } let msg = format!( @@ -83,7 +83,6 @@ impl QueueCommandHandler for QueueHandler { _ => user_error("Expected Put command".to_owned())?, }; - let is_explicit = ctx.explicit().await?; let container = ctx .trans .find_item_by_type_code("possession", &container_code) @@ -92,8 +91,8 @@ impl QueueCommandHandler for QueueHandler { if container.location != ctx.item.location && container.location != ctx.item.refstr() { user_error(format!( "You try to put something in {} but realise {} is no longer there", - container.display_for_sentence(is_explicit, 1, false), - container.display_for_sentence(is_explicit, 1, false), + container.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } let item = ctx @@ -104,8 +103,8 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.refstr() { user_error(format!( "You try to put {} in {}, but realise you no longer have it", - item.display_for_sentence(is_explicit, 1, false), - container.display_for_sentence(is_explicit, 1, false), + item.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), ))? } @@ -120,8 +119,8 @@ impl QueueCommandHandler for QueueHandler { .ok_or_else(|| { UserError(format!( "You try to put {} in {}, but can't find out a way to get anything in it", - item.display_for_sentence(is_explicit, 1, false), - container.display_for_sentence(is_explicit, 1, false), + item.display_for_sentence(true, 1, false), + container.display_for_sentence(true, 1, false), )) })?; container_data.checker.check_place(&container, &item)?; @@ -148,12 +147,12 @@ impl QueueCommandHandler for QueueHandler { match check_item_capacity(ctx.trans, &container, possession_data.weight).await? { CapacityLevel::AboveItemLimit => user_error(format!( "{} just can't hold that many things!", - container.display_for_sentence(is_explicit, 1, true), + container.display_for_sentence(true, 1, true), ))?, CapacityLevel::OverBurdened => user_error(format!( "{} You can't place {} because it is too heavy!", - if is_explicit { "Fuck!" } else { "Rats!" }, - &ctx.item.display_for_sentence(is_explicit, 1, false) + if true { "Fuck!" } else { "Rats!" }, + &ctx.item.display_for_sentence(true, 1, false) ))?, _ => (), } diff --git a/blastmud_game/src/message_handler/user_commands/recline.rs b/blastmud_game/src/message_handler/user_commands/recline.rs index a33b177..51e003d 100644 --- a/blastmud_game/src/message_handler/user_commands/recline.rs +++ b/blastmud_game/src/message_handler/user_commands/recline.rs @@ -64,7 +64,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location { user_error(format!( "You try to reclining on {} but realise it's no longer here", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } } @@ -124,7 +124,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location { user_error(format!( "You try to recline on {} but realise it's no longer here", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } ( diff --git a/blastmud_game/src/message_handler/user_commands/remove.rs b/blastmud_game/src/message_handler/user_commands/remove.rs index 83af020..c9d1dbe 100644 --- a/blastmud_game/src/message_handler/user_commands/remove.rs +++ b/blastmud_game/src/message_handler/user_commands/remove.rs @@ -17,7 +17,7 @@ async fn check_removeable(ctx: &mut QueuedCommandContext<'_>, item: &Item) -> UR if item.location != ctx.item.refstr() { user_error(format!( "You try to remove {} but realise you no longer have it.", - &item.display_for_sentence(ctx.explicit().await?, 1, false) + &item.display_for_sentence(true, 1, false) ))? } @@ -68,7 +68,7 @@ async fn check_removeable(ctx: &mut QueuedCommandContext<'_>, item: &Item) -> UR }) { user_error(format!( "You can't do that without first removing your {} from your {}.", - &other_item.display_for_sentence(ctx.explicit().await?, 1, false), + &other_item.display_for_sentence(true, 1, false), part.display(ctx.item.sex.clone()) ))?; } diff --git a/blastmud_game/src/message_handler/user_commands/say.rs b/blastmud_game/src/message_handler/user_commands/say.rs index 3f5ee59..c990c75 100644 --- a/blastmud_game/src/message_handler/user_commands/say.rs +++ b/blastmud_game/src/message_handler/user_commands/say.rs @@ -1,5 +1,6 @@ use super::{ - get_player_item_or_fail, user_error, UResult, UserError, UserVerb, UserVerbRef, VerbContext, + get_player_item_or_fail, is_likely_illegal, user_error, UResult, UserError, UserVerb, + UserVerbRef, VerbContext, }; #[double] use crate::db::DBTrans; @@ -31,6 +32,11 @@ pub async fn say_to_room<'l>( .to_owned(), )? } + + if is_likely_illegal(&say_what) { + user_error("Your message was rejected by the content filter".to_string())?; + } + let msg = format!( ansi!("{} says: \"{}\"\n"), from_item.display_for_sentence(true, 1, true), diff --git a/blastmud_game/src/message_handler/user_commands/sit.rs b/blastmud_game/src/message_handler/user_commands/sit.rs index 219f30a..844ac33 100644 --- a/blastmud_game/src/message_handler/user_commands/sit.rs +++ b/blastmud_game/src/message_handler/user_commands/sit.rs @@ -60,7 +60,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location { user_error(format!( "You try to sit on {} but realise it's no longer here", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } } @@ -116,7 +116,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != ctx.item.location { user_error(format!( "You try to sit on {} but realise it's no longer here", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } ( diff --git a/blastmud_game/src/message_handler/user_commands/use_cmd.rs b/blastmud_game/src/message_handler/user_commands/use_cmd.rs index bbc0704..3f668d0 100644 --- a/blastmud_game/src/message_handler/user_commands/use_cmd.rs +++ b/blastmud_game/src/message_handler/user_commands/use_cmd.rs @@ -44,7 +44,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != format!("player/{}", ctx.item.item_code) { user_error(format!( "You try to use {} but realise you no longer have it", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } let (target_type, target_code) = match target_type_code.split_once("/") { @@ -71,11 +71,10 @@ impl QueueCommandHandler for QueueHandler { && target.location != ctx.item.location && target.location != format!("player/{}", ctx.item.item_code) { - let explicit = ctx.explicit().await?; - let target_name = target.display_for_sentence(explicit, 1, false); + let target_name = target.display_for_sentence(true, 1, false); user_error(format!( "You try to use {} on {}, but realise {} is no longer here", - item.display_for_sentence(explicit, 1, false), + item.display_for_sentence(true, 1, false), target_name, target_name ))? @@ -143,7 +142,7 @@ impl QueueCommandHandler for QueueHandler { if item.location != format!("player/{}", ctx.item.item_code) { user_error(format!( "You try to use {} but realise you no longer have it", - item.display_for_sentence(ctx.explicit().await?, 1, false) + item.display_for_sentence(true, 1, false) ))? } let (ref target_type, ref target_code) = match target_type_code.split_once("/") { @@ -161,11 +160,10 @@ impl QueueCommandHandler for QueueHandler { if target.location != ctx.item.location && target.location != format!("player/{}", ctx.item.item_code) { - let explicit = ctx.explicit().await?; - let target_name = target.display_for_sentence(explicit, 1, false); + let target_name = target.display_for_sentence(true, 1, false); user_error(format!( "You try to use {} on {}, but realise {} is no longer here", - item.display_for_sentence(explicit, 1, false), + item.display_for_sentence(true, 1, false), target_name, target_name ))? @@ -183,7 +181,7 @@ impl QueueCommandHandler for QueueHandler { if !check_consent(ctx.trans, "use", consent_type, &ctx.item, &target).await? { user_error(format!( "{} doesn't allow {} from you", - &target.display_for_sentence(ctx.explicit().await?, 1, true), + &target.display_for_sentence(true, 1, true), consent_type.to_str() ))? } @@ -197,7 +195,7 @@ impl QueueCommandHandler for QueueHandler { if item.charges < 1 { user_error(format!( "{} has no {} {} left", - item.display_for_sentence(ctx.explicit().await?, 1, true), + item.display_for_sentence(true, 1, true), &language::pluralise(charge_data.charge_name_prefix), charge_data.charge_name_suffix ))?; diff --git a/blastmud_game/src/message_handler/user_commands/wear.rs b/blastmud_game/src/message_handler/user_commands/wear.rs index 282eb8e..7031ee6 100644 --- a/blastmud_game/src/message_handler/user_commands/wear.rs +++ b/blastmud_game/src/message_handler/user_commands/wear.rs @@ -35,11 +35,10 @@ impl QueueCommandHandler for QueueHandler { None => user_error("Item not found".to_owned())?, Some(it) => it, }; - let explicit = ctx.explicit().await?; if item.location != ctx.item.refstr() { user_error(format!( "You try to wear {} but realise you no longer have it", - item.display_for_sentence(explicit, 1, false) + item.display_for_sentence(true, 1, false) ))? } @@ -88,11 +87,10 @@ impl QueueCommandHandler for QueueHandler { None => user_error("Item not found".to_owned())?, Some(it) => it, }; - let explicit = ctx.explicit().await?; if item.location != ctx.item.refstr() { user_error(format!( "You try to wear {} but realise it is no longer there.", - &item.display_for_sentence(explicit, 1, false) + &item.display_for_sentence(true, 1, false) ))? } diff --git a/blastmud_game/src/message_handler/user_commands/whisper.rs b/blastmud_game/src/message_handler/user_commands/whisper.rs index f21a2ff..f9a2046 100644 --- a/blastmud_game/src/message_handler/user_commands/whisper.rs +++ b/blastmud_game/src/message_handler/user_commands/whisper.rs @@ -1,5 +1,5 @@ use super::{ - get_player_item_or_fail, is_likely_explicit, parsing::parse_to_space, search_item_for_user, + get_player_item_or_fail, is_likely_illegal, parsing::parse_to_space, search_item_for_user, user_error, ItemSearchParams, UResult, UserVerb, UserVerbRef, VerbContext, }; use crate::static_content::npc::npc_by_code; @@ -40,6 +40,10 @@ impl UserVerb for Verb { _ => user_error("Only characters (players / NPCs) accept whispers".to_string())?, } + if is_likely_illegal(&say_what) { + user_error("Your message was rejected by the content filter".to_string())?; + } + ctx.trans .queue_for_session( ctx.session, @@ -75,24 +79,18 @@ impl UserVerb for Verb { .await? { None => user_error("That character is asleep.".to_string())?, - Some((other_session, other_session_dets)) => { - if other_session_dets.less_explicit_mode && is_likely_explicit(&say_what) { - user_error("That player is on a client that doesn't allow explicit \ - content, and your message looked explicit, so it wasn't sent." - .to_owned())? - } else { - ctx.trans - .queue_for_session( - &other_session, - Some(&format!( - ansi!("{} whispers to {}: \"{}\"\n"), - player_item.display_for_session(&ctx.session_dat), - to_whom.display_for_session(&ctx.session_dat), - say_what - )), - ) - .await?; - } + Some((other_session, _other_session_dets)) => { + ctx.trans + .queue_for_session( + &other_session, + Some(&format!( + ansi!("{} whispers to {}: \"{}\"\n"), + player_item.display_for_session(&ctx.session_dat), + to_whom.display_for_session(&ctx.session_dat), + say_what + )), + ) + .await?; } } } diff --git a/blastmud_game/src/models/item.rs b/blastmud_game/src/models/item.rs index 7bbf393..4d55241 100644 --- a/blastmud_game/src/models/item.rs +++ b/blastmud_game/src/models/item.rs @@ -736,8 +736,8 @@ impl Item { buf } } - pub fn display_for_session<'l>(self: &'l Self, session: &Session) -> String { - self.display_for_sentence(!session.less_explicit_mode, 1, false) + pub fn display_for_session<'l>(self: &'l Self, _session: &Session) -> String { + self.display_for_sentence(true, 1, false) } pub fn details_for_session<'l>(self: &'l Self, session: &Session) -> Option<&'l str> { diff --git a/blastmud_game/src/models/session.rs b/blastmud_game/src/models/session.rs index 2d8b970..0cd8bc7 100644 --- a/blastmud_game/src/models/session.rs +++ b/blastmud_game/src/models/session.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; #[serde(default)] pub struct Session { pub source: String, - pub less_explicit_mode: bool, + pub less_explicit_mode: bool, // DEPRECATED pub last_active: Option>, // Reminder: Consider backwards compatibility when updating this. New fields should generally // be an Option, or you should ensure the default value is sensible, or things will diff --git a/blastmud_game/src/regular_tasks/queued_command.rs b/blastmud_game/src/regular_tasks/queued_command.rs index 6f9ad95..d208e74 100644 --- a/blastmud_game/src/regular_tasks/queued_command.rs +++ b/blastmud_game/src/regular_tasks/queued_command.rs @@ -173,14 +173,6 @@ impl<'l> QueuedCommandContext<'l> { .await? }) } - pub async fn explicit(&self) -> UResult { - Ok(self - .trans - .find_session_for_player(&self.item.item_code) - .await? - .map(|(_, sess)| !sess.less_explicit_mode) - .unwrap_or(false)) - } } #[async_trait] diff --git a/blastmud_game/src/services/combat.rs b/blastmud_game/src/services/combat.rs index 56e611b..50c6286 100644 --- a/blastmud_game/src/services/combat.rs +++ b/blastmud_game/src/services/combat.rs @@ -1017,7 +1017,7 @@ pub async fn switch_to_power_attack(ctx: &VerbContext<'_>, who: &Arc) -> U let pow_att = match wielded.power_attack.as_ref() { None => user_error(format!( "{} is unsuitable for powerattacking", - wield_it.display_for_sentence(!ctx.session_dat.less_explicit_mode, 1, true) + wield_it.display_for_sentence(true, 1, true) ))?, Some(v) => v, };