Skip to content

Commit 86f56d5

Browse files
committed
Added case insenstive
1 parent 7f2be0e commit 86f56d5

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

trackscape-discord-api/src/controllers/chat_controller.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::websocket_server::DiscordToClanChatMessage;
2-
use crate::{handler, ChatServerHandle};
2+
use crate::{handler, ChatServerHRandle};
33
use actix_web::web::Data;
44
use actix_web::{error, post, web, Error, HttpRequest, HttpResponse, Scope};
55
use celery::Celery;

trackscape-discord-shared/src/database/pb_activities_db.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ impl PersonalBestActivitiesDb {
3636
PersonalBestActivitiesModel::COLLECTION_NAME,
3737
);
3838

39+
//Matches case insensitive and exact name from start and end
40+
let name_filter = format!("^{}$", trimmed_activity_name);
41+
let re = mongodb::bson::Regex {
42+
pattern: name_filter,
43+
options: "i".to_string(),
44+
};
45+
3946
let filter = doc! {
40-
"activity_name": trimmed_activity_name
47+
"activity_name": re
4148
};
49+
4250
match collection.find_one(filter.clone(), None).await? {
4351
Some(activity) => {
4452
return Ok(activity);

trackscape-discord-shared/src/jobs/runelite_commands/pb_command.rs

+41-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::get_runelite_api_url;
22
use crate::{database::clan_mates::ClanMates, jobs::job_helpers::get_mongodb};
33
use anyhow::{anyhow, Ok};
44
use capitalize::Capitalize;
5-
use rand::Rng;
65
use reqwest::StatusCode;
76
use tokio::time::sleep;
87

@@ -19,14 +18,6 @@ pub async fn get_pb(message: String, player: String, guild_id: u64) -> Result<()
1918
//Should match whats in RL with spaces and each capitalized.
2019
println!("Long Boss name is: {}", trimmed_boss);
2120

22-
//Easter egg
23-
if trimmed_boss.to_lowercase() == "nerdicus" {
24-
let random_pb: f64 = rand::thread_rng().gen_range(0.50..10_000.00);
25-
let random_pb_round = (random_pb * 100f64).trunc() / 100.0;
26-
let _ = log_pb(trimmed_boss, player, guild_id, random_pb_round).await?; // Await the log_pb function call and assign the result to a variable
27-
return Ok(());
28-
}
29-
3021
let runelite_api_url = get_runelite_api_url().await?;
3122
let full_url = format!(
3223
"{}/chat/pb?name={}&boss={}",
@@ -240,6 +231,24 @@ fn get_boss_long_name(message: &String) -> String {
240231
"hs4" | "hs 4" => "Hallowed Sepulchre Floor 4",
241232
"hs5" | "hs 5" => "Hallowed Sepulchre Floor 5",
242233

234+
// Colossal Wyrm Basic Agility Course
235+
"wbac"
236+
| "cwbac"
237+
| "wyrmb"
238+
| "wyrmbasic"
239+
| "wyrm basic"
240+
| "colossal basic"
241+
| "colossal wyrm basic" => "Colossal Wyrm Agility Course (Basic)",
242+
243+
// Colossal Wyrm Advanced Agility Course
244+
"waac"
245+
| "cwaac"
246+
| "wyrma"
247+
| "wyrmadvanced"
248+
| "wyrm advanced"
249+
| "colossal advanced"
250+
| "colossal wyrm advanced" => "Colossal Wyrm Agility Course (Advanced)",
251+
243252
// Prifddinas Agility Course
244253
"prif" | "prifddinas" => "Prifddinas Agility Course",
245254

@@ -356,7 +365,29 @@ fn get_boss_long_name(message: &String) -> String {
356365
// lunar chest variants
357366
"lunar chests" | "perilous moons" | "perilous moon" | "moons of peril" => "Lunar Chest",
358367

359-
//TODO have to return and captlize the first letter of each word
368+
// hunter rumour variants
369+
"hunterrumour" | "hunter contract" | "hunter contracts" | "hunter tasks"
370+
| "hunter task" | "rumours" | "rumour" => "Hunter Rumours",
371+
372+
// sol heredit
373+
"sol" | "colo" | "colosseum" | "fortis colosseum" => "Sol Heredit",
374+
375+
"bird egg" | "bird eggs" | "bird's egg" | "bird's eggs" => "Bird's egg offerings",
376+
377+
"amox" => "Amoxliatl",
378+
379+
"the hueycoatl" | "huey" => "Hueycoatl",
380+
381+
"crystal chest" => "crystal chest",
382+
383+
"larran small chest" | "larran's small chest" => "Larran's small chest",
384+
385+
"larran chest" | "larran's chest" | "larran big chest" | "larran's big chest" => {
386+
"Larran's big chest"
387+
}
388+
389+
"brimstone chest" => "Brimstone chest",
390+
360391
_ => {
361392
match_found = false;
362393
""

0 commit comments

Comments
 (0)