Remove most references to less_explicit_mode

Instead add one basic illegality filter for everyone.
This commit is contained in:
Condorra 2023-12-29 23:48:31 +11:00
parent a68955deab
commit 3c302136d5
28 changed files with 214 additions and 223 deletions

View File

@ -389,20 +389,86 @@ pub async fn handle(_session: &ListenerSession, _msg: &str, _pool: &DBPool) -> D
unimplemented!(); unimplemented!();
} }
pub fn is_likely_explicit(msg: &str) -> bool { pub fn is_likely_illegal(msg: &str) -> bool {
static EXPLICIT_MARKER_WORDS: OnceCell<Vec<&'static str>> = OnceCell::new(); static ILLEGAL_MARKER_WORDS: OnceCell<Vec<&'static str>> = OnceCell::new();
let markers = EXPLICIT_MARKER_WORDS.get_or_init(|| { let illegal_markers = ILLEGAL_MARKER_WORDS.get_or_init(|| {
vec![ vec![
"fuck", "sex", "cock", "cunt", "dick", "pussy", "whore", "orgasm", "erection", "lolita",
"nipple", "boob", "tit", "jailbait",
"abu sayyaf",
"al-qaida",
"al-qaida",
"al-shabaab",
"boko haram",
"hamas",
"tahrir al-sham",
"hizballah",
"hezbollah",
"hurras al-din",
"islamic state",
"jaish-e-mohammad",
"jamaat mujahideen",
"jamaat mujahideen",
"jamaat 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 { static MINOR_MARKER_WORDS: OnceCell<Vec<&'static str>> = OnceCell::new();
if msg.contains(word) { let minor_markers =
MINOR_MARKER_WORDS.get_or_init(|| vec!["young", "underage", "child", "teen", "minor"]);
static EXPLICIT_MARKER_WORDS: OnceCell<Vec<&'static str>> = 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; 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> { pub fn get_user_or_fail<'l>(ctx: &'l VerbContext) -> UResult<&'l User> {

View File

@ -55,7 +55,7 @@ async fn corp_invite(ctx: &mut VerbContext<'_>, remaining: &str) -> UResult<()>
user_error("Only players can be hired.".to_owned())?; 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 .trans
.find_session_for_player(&target_user.item_code) .find_session_for_player(&target_user.item_code)
.await? .await?
@ -109,7 +109,7 @@ async fn corp_invite(ctx: &mut VerbContext<'_>, remaining: &str) -> UResult<()>
ctx.trans.queue_for_session(&their_sess, Some(&format!( ctx.trans.queue_for_session(&their_sess, Some(&format!(
ansi!("{} wants to hire you into {}! Type <bold>corp join {}<reset> to accept.{}\n"), ansi!("{} wants to hire you into {}! Type <bold>corp join {}<reset> 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,
&corp.name, &corp.name,
if new_mem.allow_combat { if new_mem.allow_combat {

View File

@ -60,11 +60,10 @@ impl QueueCommandHandler for QueueHandler {
Some(it) => it, Some(it) => it,
}; };
let explicit = ctx.explicit().await?;
if corpse.location != ctx.item.location { if corpse.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to cut {} but realise it is no longer there.", "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?; ensure_has_butcher_tool(&ctx.trans, &ctx.item).await?;
@ -131,11 +130,10 @@ impl QueueCommandHandler for QueueHandler {
Some(it) => it, Some(it) => it,
}; };
let explicit = ctx.explicit().await?;
if corpse.location != ctx.item.location { if corpse.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to cut {} but realise it is no longer there.", "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)
))? ))?
} }

View File

@ -43,7 +43,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.location && item.location != ctx.item.refstr() { if item.location != ctx.item.location && item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to drink {} but realise you no longer have it", "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!( let msg = format!(
@ -81,7 +81,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.location && item.location != ctx.item.refstr() { if item.location != ctx.item.location && item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to drink {} but realise you no longer have it!", "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 let liquid_details = item

View File

@ -128,7 +128,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) {
user_error(format!( user_error(format!(
"You try to drop {} but realise you no longer have it", "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 { 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) { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) {
user_error(format!( user_error(format!(
"You try to drop {} but realise you no longer have it!", "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 { if item.action_type == LocationActionType::Worn {
@ -192,7 +192,7 @@ impl QueueCommandHandler for QueueHandler {
{ {
CapacityLevel::AboveItemLimit => user_error(format!( CapacityLevel::AboveItemLimit => user_error(format!(
"You can't drop {}, because it is so cluttered here there is no where to put it!", "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)
))?, ))?,
_ => (), _ => (),
} }

View File

@ -41,7 +41,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) {
user_error(format!( user_error(format!(
"You try to eat {} but realise you no longer have it", "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!( let msg = format!(
@ -76,7 +76,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) { if item.location != format!("{}/{}", &ctx.item.item_type, &ctx.item.item_code) {
user_error(format!( user_error(format!(
"You try to eat {} but realise you no longer have it!", "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 { if item.action_type == LocationActionType::Worn {

View File

@ -51,13 +51,13 @@ impl QueueCommandHandler for QueueHandler {
if to_item.location != ctx.item.location && to_item.location != ctx.item.refstr() { if to_item.location != ctx.item.location && to_item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to fill {} but realise you no longer have it", "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() { if from_item.location != ctx.item.location && from_item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to fill from {} but realise you no longer have it", "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() { if to_item.location != ctx.item.location && to_item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to fill {} but realise you no longer have it", "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() { if from_item.location != ctx.item.location && from_item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to fill from {} but realise you no longer have it", "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() { let from_liquid_details = match from_item.liquid_details.as_ref() {
None => user_error(format!( None => user_error(format!(
"{} appears to be empty.", "{} 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, Some(v) => v,
}; };
@ -132,7 +132,7 @@ impl QueueCommandHandler for QueueHandler {
if available_vol == 0 { if available_vol == 0 {
user_error(format!( user_error(format!(
"{} appears to be empty.", "{} 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!( None => user_error(format!(
"You can't find a way to fill {}.", "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, Some(v) => v,
}; };
@ -153,7 +153,7 @@ impl QueueCommandHandler for QueueHandler {
user_error(format!( user_error(format!(
"You don't think putting {} into {} is a good idea.", "You don't think putting {} into {} is a good idea.",
liq_type.display(), 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 { if actually_transferred == 0 {
user_error(format!( user_error(format!(
"You don't think you can get any more into {}.", "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)
))?; ))?;
} }

View File

@ -60,14 +60,7 @@ impl UserVerb for Verb {
if !worn.is_empty() { if !worn.is_empty() {
worn.push_str(", "); worn.push_str(", ");
} }
worn.push_str(if ctx.session_dat.less_explicit_mode { worn.push_str(&item.display);
item.display_less_explicit
.as_ref()
.map(|s| s.as_str())
.unwrap_or(&item.display)
} else {
&item.display
});
for entry in damage_ranges.iter_mut() { for entry in damage_ranges.iter_mut() {
if let Some(soak_data) = wear_data.soaks.get(entry.0) { if let Some(soak_data) = wear_data.soaks.get(entry.0) {
let (old_min, old_max) = entry.1; let (old_min, old_max) = entry.1;

View File

@ -38,7 +38,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.location { if item.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to get {} but realise it is no longer there", "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!( let msg = format!(
@ -62,8 +62,8 @@ impl QueueCommandHandler for QueueHandler {
{ {
user_error(format!( user_error(format!(
"You try to get something from {} but realise {} is no longer there", "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(true, 1, false),
container.display_for_sentence(ctx.explicit().await?, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
let item = ctx let item = ctx
@ -74,8 +74,8 @@ impl QueueCommandHandler for QueueHandler {
if item.location != container.refstr() { if item.location != container.refstr() {
user_error(format!( user_error(format!(
"You try to get {} but realise it is no longer in {}", "You try to get {} but realise it is no longer in {}",
item.display_for_sentence(ctx.explicit().await?, 1, false), item.display_for_sentence(true, 1, false),
container.display_for_sentence(ctx.explicit().await?, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
let msg = format!( let msg = format!(
@ -111,7 +111,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.location { if item.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to get {} but realise it is no longer there", "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!( user_error(format!(
"You try to get something from {} but realise {} is no longer there", "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(true, 1, false),
container.display_for_sentence(ctx.explicit().await?, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
let item = ctx let item = ctx
@ -149,8 +149,8 @@ impl QueueCommandHandler for QueueHandler {
if item.location != container.refstr() { if item.location != container.refstr() {
user_error(format!( user_error(format!(
"You try to get {} but realise it is no longer in {}", "You try to get {} but realise it is no longer in {}",
item.display_for_sentence(ctx.explicit().await?, 1, false), item.display_for_sentence(true, 1, false),
container.display_for_sentence(ctx.explicit().await?, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
let msg = format!( let msg = format!(
@ -180,14 +180,10 @@ impl QueueCommandHandler for QueueHandler {
CapacityLevel::AboveItemLimit => { CapacityLevel::AboveItemLimit => {
user_error("You just can't hold that many things!".to_owned())? user_error("You just can't hold that many things!".to_owned())?
} }
CapacityLevel::OverBurdened => { CapacityLevel::OverBurdened => user_error(format!(
let explicit = ctx.explicit().await?; "Fuck! You can't get {} because it is too heavy!",
user_error(format!( &item.display_for_sentence(true, 1, false)
"{} You can't get {} because it is too heavy!", ))?,
if explicit { "Fuck!" } else { "Rats!" },
&item.display_for_sentence(explicit, 1, false)
))?
}
_ => (), _ => (),
} }

View File

@ -101,10 +101,6 @@ impl QueueCommandHandler for WithQueueHandler {
} else { } else {
None None
}; };
let explicit = session
.as_ref()
.map(|s| !s.1.less_explicit_mode)
.unwrap_or(false);
let opts: Vec<&'static PossessionData> = improv_by_ingredient() let opts: Vec<&'static PossessionData> = improv_by_ingredient()
.get( .get(
item.possession_type item.possession_type
@ -114,12 +110,11 @@ impl QueueCommandHandler for WithQueueHandler {
.ok_or_else(|| { .ok_or_else(|| {
UserError(format!( UserError(format!(
"You can't think of anything you could make with {}", "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() .iter()
.filter_map(|it| possession_data().get(&it.output).map(|v| *v)) .filter_map(|it| possession_data().get(&it.output).map(|v| *v))
.filter(|pd| explicit || pd.display_less_explicit.is_none())
.collect(); .collect();
let result_data = opts let result_data = opts
.as_slice() .as_slice()
@ -127,7 +122,7 @@ impl QueueCommandHandler for WithQueueHandler {
.ok_or_else(|| { .ok_or_else(|| {
UserError(format!( UserError(format!(
"You can't think of anything you could make with {}", "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 { if let Some((sess, _)) = session {
@ -138,7 +133,7 @@ impl QueueCommandHandler for WithQueueHandler {
"You think you could make {} {} from {}\n", "You think you could make {} {} from {}\n",
indefinite_article(result_data.display), indefinite_article(result_data.display),
result_data.display, result_data.display,
item.display_for_sentence(explicit, 1, false) item.display_for_sentence(true, 1, false)
)), )),
) )
.await?; .await?;
@ -225,10 +220,6 @@ impl QueueCommandHandler for FromQueueHandler {
} else { } else {
None None
}; };
let explicit = session
.as_ref()
.map(|s| !s.1.less_explicit_mode)
.unwrap_or(false);
match possession_id_iter.next() { match possession_id_iter.next() {
None => { None => {
let choice = ingredients_left let choice = ingredients_left
@ -292,7 +283,7 @@ impl QueueCommandHandler for FromQueueHandler {
) { ) {
user_error(format!( user_error(format!(
"You try adding {}, but it doesn't really seem to fit right.", "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( let skill_result = skill_check_and_grind(
@ -314,7 +305,7 @@ impl QueueCommandHandler for FromQueueHandler {
&sess, &sess,
Some(&format!( Some(&format!(
"You try adding {}, but it goes badly and you waste it.\n", "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?; .await?;
@ -327,7 +318,7 @@ impl QueueCommandHandler for FromQueueHandler {
&sess, &sess,
Some(&format!( Some(&format!(
"You try and fail at adding {}.\n", "You try and fail at adding {}.\n",
&item.display_for_sentence(explicit, 1, false) &item.display_for_sentence(true, 1, false)
)), )),
) )
.await?; .await?;
@ -339,7 +330,7 @@ impl QueueCommandHandler for FromQueueHandler {
&sess, &sess,
Some(&format!( Some(&format!(
"You try adding {}.\n", "You try adding {}.\n",
&item.display_for_sentence(explicit, 1, false), &item.display_for_sentence(true, 1, false),
)), )),
) )
.await?; .await?;

View File

@ -49,7 +49,7 @@ impl UserVerb for Verb {
total += it_total; total += it_total;
response.push_str(&format!( response.push_str(&format!(
"{} [{}]{}\n", "{} [{}]{}\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), weight(it_total),
match item.action_type { match item.action_type {
LocationActionType::Worn => " (worn)", LocationActionType::Worn => " (worn)",

View File

@ -47,14 +47,7 @@ impl UserVerb for Verb {
for stock in &room.stock_list { for stock in &room.stock_list {
if let Some(possession_type) = possession_data().get(&stock.possession_type) { if let Some(possession_type) = possession_data().get(&stock.possession_type) {
let display = if ctx.session_dat.less_explicit_mode { let display = &possession_type.display;
possession_type
.display_less_explicit
.as_ref()
.unwrap_or(&possession_type.display)
} else {
&possession_type.display
};
let mut price = stock.list_price; let mut price = stock.list_price;
if stock.poverty_discount && price > user.credits { if stock.poverty_discount && price > user.credits {

View File

@ -21,7 +21,7 @@ use crate::{
dynzone, dynzone,
possession_type::{possession_data, recipe_craft_by_recipe}, possession_type::{possession_data, recipe_craft_by_recipe},
room::{self, Direction}, room::{self, Direction},
species::{species_info_map, SpeciesType}, species::species_info_map,
}, },
}; };
use ansi::{ansi, flow_around, word_wrap}; use ansi::{ansi, flow_around, word_wrap};
@ -66,11 +66,7 @@ pub async fn describe_normal_item(
let mut phrases = Vec::<String>::new(); let mut phrases = Vec::<String>::new();
for group_items in all_groups { for group_items in all_groups {
let head = &group_items[0]; let head = &group_items[0];
let mut details = head.display_for_sentence( let mut details = head.display_for_sentence(true, group_items.len(), false);
!ctx.session_dat.less_explicit_mode,
group_items.len(),
false,
);
match head.action_type { match head.action_type {
LocationActionType::Wielded => details.push_str(" (wielded)"), LocationActionType::Wielded => details.push_str(" (wielded)"),
LocationActionType::Worn => continue, LocationActionType::Worn => continue,
@ -171,28 +167,18 @@ pub async fn describe_normal_item(
)); ));
} }
} else { } else {
if !ctx.session_dat.less_explicit_mode { any_part_text = true;
any_part_text = true; contents_desc.push_str(&format!(
contents_desc.push_str(&format!( "{} {} {} completely bare. ",
"{} {} {} completely bare. ", &language::caps_first(&item.pronouns.possessive),
&language::caps_first(&item.pronouns.possessive), part.display(item.sex.clone()),
part.display(item.sex.clone()), part.copula(item.sex.clone())
part.copula(item.sex.clone()) ));
));
}
} }
} }
if any_part_text { if any_part_text {
contents_desc.push_str("\n"); 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); let health_max = max_health(&item);
@ -293,11 +279,7 @@ pub async fn describe_normal_item(
contents_desc.push_str("You will need:\n"); contents_desc.push_str("You will need:\n");
for (input_pt, count) in &recipe_craft_data.craft_data.inputs.iter().counts() { for (input_pt, count) in &recipe_craft_data.craft_data.inputs.iter().counts() {
if let Some(pd) = possession_data().get(&input_pt) { if let Some(pd) = possession_data().get(&input_pt) {
let thing = if ctx.session_dat.less_explicit_mode { let thing = pd.display;
pd.display_less_explicit.unwrap_or(pd.display)
} else {
pd.display
};
contents_desc.push_str(&format!( contents_desc.push_str(&format!(
" {} {}\n", " {} {}\n",
count, 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"), None => contents_desc.push_str("You can make this without any special bench.\n"),
Some(bench) => { Some(bench) => {
if let Some(pd) = possession_data().get(bench) { if let Some(pd) = possession_data().get(bench) {
contents_desc.push_str(&format!( contents_desc
"You'll need to make this on a {}.\n", .push_str(&format!("You'll need to make this on a {}.\n", pd.display))
if ctx.session_dat.less_explicit_mode {
pd.display_less_explicit.unwrap_or(pd.display)
} else {
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 head = &group_items[0];
let is_creature = head.item_type == "player" || head.item_type.starts_with("npc"); let is_creature = head.item_type == "player" || head.item_type.starts_with("npc");
buf.push(' '); buf.push(' ');
buf.push_str(&head.display_for_sentence( buf.push_str(&head.display_for_sentence(true, group_items.len(), true));
!ctx.session_dat.less_explicit_mode,
group_items.len(),
true,
));
buf.push_str(if group_items.len() > 1 { buf.push_str(if group_items.len() > 1 {
" are " " are "
} else { } else {

View File

@ -396,11 +396,7 @@ impl UserVerb for Verb {
&instructions.display_for_session(&ctx.session_dat), &instructions.display_for_session(&ctx.session_dat),
possession_data() possession_data()
.get(bench_type) .get(bench_type)
.map(|pd| if ctx.session_dat.less_explicit_mode { .map(|pd| pd.display)
pd.display_less_explicit.unwrap_or(pd.display)
} else {
pd.display
})
.unwrap_or("bench") .unwrap_or("bench")
))?, ))?,
(Some(bench_type), Some(bench)) (Some(bench_type), Some(bench))
@ -411,13 +407,7 @@ impl UserVerb for Verb {
&instructions.display_for_session(&ctx.session_dat), &instructions.display_for_session(&ctx.session_dat),
possession_data() possession_data()
.get(bench_type) .get(bench_type)
.map(|pd| { .map(|pd| pd.display)
if ctx.session_dat.less_explicit_mode {
pd.display_less_explicit.unwrap_or(pd.display)
} else {
pd.display
}
})
.unwrap_or("bench") .unwrap_or("bench")
))? ))?
} }

View File

@ -450,11 +450,9 @@ impl MapType for LmapType {
None => None, None => None,
Some((ex_t, ex_c)) => { Some((ex_t, ex_c)) => {
match ctx.trans.find_item_by_type_code(ex_t, ex_c).await?.as_ref() { match ctx.trans.find_item_by_type_code(ex_t, ex_c).await?.as_ref() {
Some(dest_item) => Some(dest_item.display_for_sentence( Some(dest_item) => {
!ctx.session_dat.less_explicit_mode, Some(dest_item.display_for_sentence(true, 1, true))
1, }
true,
)),
None => None, None => None,
} }
} }

View File

@ -1,5 +1,5 @@
use super::{ 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, user_error, ItemSearchParams, UResult, UserVerb, UserVerbRef, VerbContext,
}; };
use ansi::{ansi, ignore_special_characters}; use ansi::{ansi, ignore_special_characters};
@ -51,6 +51,10 @@ impl UserVerb for Verb {
_ => user_error("Only players accept pages".to_string())?, _ => 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 ctx.trans
.queue_for_session( .queue_for_session(
ctx.session, ctx.session,
@ -74,24 +78,23 @@ impl UserVerb for Verb {
.await? .await?
{ {
None => user_error("That character is asleep.".to_string())?, None => user_error("That character is asleep.".to_string())?,
Some((other_session, other_session_dets)) => { Some((other_session, _other_session_dets)) => {
if other_session_dets.less_explicit_mode && is_likely_explicit(&say_what) { if let Some(mut user) =
user_error("That player is on a client that doesn't allow explicit \ ctx.trans.find_by_username(&to_whom.item_code).await?
content, and your message looked explicit, so it wasn't sent." {
.to_owned())? user.last_page_from = Some(player_item.item_code.clone());
} else { ctx.trans.save_user_model(&user).await?;
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!("<blue>Your wristpad beeps with page from {}: \"{}\"<reset>\n"),
player_item.display_for_session(&ctx.session_dat),
say_what
))).await?;
} }
ctx.trans
.queue_for_session(
&other_session,
Some(&format!(
ansi!("<blue>Your wristpad beeps with page from {}: \"{}\"<reset>\n"),
player_item.display_for_session(&ctx.session_dat),
say_what
)),
)
.await?;
} }
} }
} }

View File

@ -42,8 +42,8 @@ impl QueueCommandHandler for QueueHandler {
if container.location != ctx.item.location && container.location != ctx.item.refstr() { if container.location != ctx.item.location && container.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to put something in {} but realise {} is no longer there", "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(true, 1, false),
container.display_for_sentence(ctx.explicit().await?, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
let item = ctx let item = ctx
@ -54,8 +54,8 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.refstr() { if item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to put {} in {}, but realise you no longer have it", "You try to put {} in {}, but realise you no longer have it",
item.display_for_sentence(ctx.explicit().await?, 1, false), item.display_for_sentence(true, 1, false),
container.display_for_sentence(ctx.explicit().await?, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
let msg = format!( let msg = format!(
@ -83,7 +83,6 @@ impl QueueCommandHandler for QueueHandler {
_ => user_error("Expected Put command".to_owned())?, _ => user_error("Expected Put command".to_owned())?,
}; };
let is_explicit = ctx.explicit().await?;
let container = ctx let container = ctx
.trans .trans
.find_item_by_type_code("possession", &container_code) .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() { if container.location != ctx.item.location && container.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to put something in {} but realise {} is no longer there", "You try to put something in {} but realise {} is no longer there",
container.display_for_sentence(is_explicit, 1, false), container.display_for_sentence(true, 1, false),
container.display_for_sentence(is_explicit, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
let item = ctx let item = ctx
@ -104,8 +103,8 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.refstr() { if item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to put {} in {}, but realise you no longer have it", "You try to put {} in {}, but realise you no longer have it",
item.display_for_sentence(is_explicit, 1, false), item.display_for_sentence(true, 1, false),
container.display_for_sentence(is_explicit, 1, false), container.display_for_sentence(true, 1, false),
))? ))?
} }
@ -120,8 +119,8 @@ impl QueueCommandHandler for QueueHandler {
.ok_or_else(|| { .ok_or_else(|| {
UserError(format!( UserError(format!(
"You try to put {} in {}, but can't find out a way to get anything in it", "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), item.display_for_sentence(true, 1, false),
container.display_for_sentence(is_explicit, 1, false), container.display_for_sentence(true, 1, false),
)) ))
})?; })?;
container_data.checker.check_place(&container, &item)?; 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? { match check_item_capacity(ctx.trans, &container, possession_data.weight).await? {
CapacityLevel::AboveItemLimit => user_error(format!( CapacityLevel::AboveItemLimit => user_error(format!(
"{} just can't hold that many things!", "{} 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!( CapacityLevel::OverBurdened => user_error(format!(
"{} You can't place {} because it is too heavy!", "{} You can't place {} because it is too heavy!",
if is_explicit { "Fuck!" } else { "Rats!" }, if true { "Fuck!" } else { "Rats!" },
&ctx.item.display_for_sentence(is_explicit, 1, false) &ctx.item.display_for_sentence(true, 1, false)
))?, ))?,
_ => (), _ => (),
} }

View File

@ -64,7 +64,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.location { if item.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to reclining on {} but realise it's no longer here", "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 { if item.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to recline on {} but realise it's no longer here", "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)
))? ))?
} }
( (

View File

@ -17,7 +17,7 @@ async fn check_removeable(ctx: &mut QueuedCommandContext<'_>, item: &Item) -> UR
if item.location != ctx.item.refstr() { if item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to remove {} but realise you no longer have it.", "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!( user_error(format!(
"You can't do that without first removing your {} from your {}.", "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()) part.display(ctx.item.sex.clone())
))?; ))?;
} }

View File

@ -1,5 +1,6 @@
use super::{ 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] #[double]
use crate::db::DBTrans; use crate::db::DBTrans;
@ -31,6 +32,11 @@ pub async fn say_to_room<'l>(
.to_owned(), .to_owned(),
)? )?
} }
if is_likely_illegal(&say_what) {
user_error("Your message was rejected by the content filter".to_string())?;
}
let msg = format!( let msg = format!(
ansi!("<yellow>{} says: <reset><bold>\"{}\"<reset>\n"), ansi!("<yellow>{} says: <reset><bold>\"{}\"<reset>\n"),
from_item.display_for_sentence(true, 1, true), from_item.display_for_sentence(true, 1, true),

View File

@ -60,7 +60,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != ctx.item.location { if item.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to sit on {} but realise it's no longer here", "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 { if item.location != ctx.item.location {
user_error(format!( user_error(format!(
"You try to sit on {} but realise it's no longer here", "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)
))? ))?
} }
( (

View File

@ -44,7 +44,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != format!("player/{}", ctx.item.item_code) { if item.location != format!("player/{}", ctx.item.item_code) {
user_error(format!( user_error(format!(
"You try to use {} but realise you no longer have it", "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("/") { 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 != ctx.item.location
&& target.location != format!("player/{}", ctx.item.item_code) && target.location != format!("player/{}", ctx.item.item_code)
{ {
let explicit = ctx.explicit().await?; let target_name = target.display_for_sentence(true, 1, false);
let target_name = target.display_for_sentence(explicit, 1, false);
user_error(format!( user_error(format!(
"You try to use {} on {}, but realise {} is no longer here", "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,
target_name target_name
))? ))?
@ -143,7 +142,7 @@ impl QueueCommandHandler for QueueHandler {
if item.location != format!("player/{}", ctx.item.item_code) { if item.location != format!("player/{}", ctx.item.item_code) {
user_error(format!( user_error(format!(
"You try to use {} but realise you no longer have it", "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("/") { 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 if target.location != ctx.item.location
&& target.location != format!("player/{}", ctx.item.item_code) && target.location != format!("player/{}", ctx.item.item_code)
{ {
let explicit = ctx.explicit().await?; let target_name = target.display_for_sentence(true, 1, false);
let target_name = target.display_for_sentence(explicit, 1, false);
user_error(format!( user_error(format!(
"You try to use {} on {}, but realise {} is no longer here", "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,
target_name target_name
))? ))?
@ -183,7 +181,7 @@ impl QueueCommandHandler for QueueHandler {
if !check_consent(ctx.trans, "use", consent_type, &ctx.item, &target).await? { if !check_consent(ctx.trans, "use", consent_type, &ctx.item, &target).await? {
user_error(format!( user_error(format!(
"{} doesn't allow {} from you", "{} 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() consent_type.to_str()
))? ))?
} }
@ -197,7 +195,7 @@ impl QueueCommandHandler for QueueHandler {
if item.charges < 1 { if item.charges < 1 {
user_error(format!( user_error(format!(
"{} has no {} {} left", "{} 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), &language::pluralise(charge_data.charge_name_prefix),
charge_data.charge_name_suffix charge_data.charge_name_suffix
))?; ))?;

View File

@ -35,11 +35,10 @@ impl QueueCommandHandler for QueueHandler {
None => user_error("Item not found".to_owned())?, None => user_error("Item not found".to_owned())?,
Some(it) => it, Some(it) => it,
}; };
let explicit = ctx.explicit().await?;
if item.location != ctx.item.refstr() { if item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to wear {} but realise you no longer have it", "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())?, None => user_error("Item not found".to_owned())?,
Some(it) => it, Some(it) => it,
}; };
let explicit = ctx.explicit().await?;
if item.location != ctx.item.refstr() { if item.location != ctx.item.refstr() {
user_error(format!( user_error(format!(
"You try to wear {} but realise it is no longer there.", "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)
))? ))?
} }

View File

@ -1,5 +1,5 @@
use super::{ 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, user_error, ItemSearchParams, UResult, UserVerb, UserVerbRef, VerbContext,
}; };
use crate::static_content::npc::npc_by_code; 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())?, _ => 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 ctx.trans
.queue_for_session( .queue_for_session(
ctx.session, ctx.session,
@ -75,24 +79,18 @@ impl UserVerb for Verb {
.await? .await?
{ {
None => user_error("That character is asleep.".to_string())?, None => user_error("That character is asleep.".to_string())?,
Some((other_session, other_session_dets)) => { Some((other_session, _other_session_dets)) => {
if other_session_dets.less_explicit_mode && is_likely_explicit(&say_what) { ctx.trans
user_error("That player is on a client that doesn't allow explicit \ .queue_for_session(
content, and your message looked explicit, so it wasn't sent." &other_session,
.to_owned())? Some(&format!(
} else { ansi!("<blue>{} whispers to {}: \"{}\"<reset>\n"),
ctx.trans player_item.display_for_session(&ctx.session_dat),
.queue_for_session( to_whom.display_for_session(&ctx.session_dat),
&other_session, say_what
Some(&format!( )),
ansi!("<blue>{} whispers to {}: \"{}\"<reset>\n"), )
player_item.display_for_session(&ctx.session_dat), .await?;
to_whom.display_for_session(&ctx.session_dat),
say_what
)),
)
.await?;
}
} }
} }
} }

View File

@ -736,8 +736,8 @@ impl Item {
buf buf
} }
} }
pub fn display_for_session<'l>(self: &'l Self, session: &Session) -> String { pub fn display_for_session<'l>(self: &'l Self, _session: &Session) -> String {
self.display_for_sentence(!session.less_explicit_mode, 1, false) self.display_for_sentence(true, 1, false)
} }
pub fn details_for_session<'l>(self: &'l Self, session: &Session) -> Option<&'l str> { pub fn details_for_session<'l>(self: &'l Self, session: &Session) -> Option<&'l str> {

View File

@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
#[serde(default)] #[serde(default)]
pub struct Session { pub struct Session {
pub source: String, pub source: String,
pub less_explicit_mode: bool, pub less_explicit_mode: bool, // DEPRECATED
pub last_active: Option<DateTime<Utc>>, pub last_active: Option<DateTime<Utc>>,
// Reminder: Consider backwards compatibility when updating this. New fields should generally // 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 // be an Option, or you should ensure the default value is sensible, or things will

View File

@ -173,14 +173,6 @@ impl<'l> QueuedCommandContext<'l> {
.await? .await?
}) })
} }
pub async fn explicit(&self) -> UResult<bool> {
Ok(self
.trans
.find_session_for_player(&self.item.item_code)
.await?
.map(|(_, sess)| !sess.less_explicit_mode)
.unwrap_or(false))
}
} }
#[async_trait] #[async_trait]

View File

@ -1017,7 +1017,7 @@ pub async fn switch_to_power_attack(ctx: &VerbContext<'_>, who: &Arc<Item>) -> U
let pow_att = match wielded.power_attack.as_ref() { let pow_att = match wielded.power_attack.as_ref() {
None => user_error(format!( None => user_error(format!(
"{} is unsuitable for powerattacking", "{} 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, Some(v) => v,
}; };