Skip to content

Commit 1546da3

Browse files
committed
I think thats leagues v1??
1 parent 624fbe9 commit 1546da3

File tree

3 files changed

+54
-18
lines changed

3 files changed

+54
-18
lines changed

trackscape-discord-bot/src/commands/toggle_broadcasts_command.rs

+24-5
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,32 @@ pub fn register() -> CreateCommand {
8585
BroadcastType::PersonalBest.to_string(),
8686
BroadcastType::PersonalBest.to_slug(),
8787
)
88+
.add_string_choice(
89+
BroadcastType::AreaUnlock.to_string(),
90+
BroadcastType::AreaUnlock.to_slug(),
91+
)
92+
.add_string_choice(
93+
BroadcastType::LeaguesRank.to_string(),
94+
BroadcastType::LeaguesRank.to_slug(),
95+
)
96+
.add_string_choice(
97+
BroadcastType::CombatMasteries.to_string(),
98+
BroadcastType::CombatMasteries.to_slug(),
99+
)
100+
.add_string_choice(
101+
BroadcastType::RelicTier.to_string(),
102+
BroadcastType::RelicTier.to_slug(),
103+
)
104+
.required(true),
105+
)
106+
.add_option(
107+
CreateCommandOption::new(
108+
CommandOptionType::Boolean,
109+
"toggle",
110+
"Turns on(true) or off(false) the broadcast type.",
111+
)
88112
.required(true),
89113
)
90-
.add_option(CreateCommandOption::new(
91-
CommandOptionType::Boolean,
92-
"toggle",
93-
"Turns on(true) or off(false) the broadcast type.",
94-
))
95114
}
96115

97116
pub async fn run(

trackscape-discord-shared/src/osrs_broadcast_extractor.rs

+12
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ pub mod osrs_broadcast_extractor {
288288
NormalBroadCast
289289
}
290290

291+
impl LeaguesBroadCastType {
292+
pub fn to_broadcast_type(&self) -> BroadcastType {
293+
match self {
294+
LeaguesBroadCastType::AreaUnlock => BroadcastType::AreaUnlock,
295+
LeaguesBroadCastType::LeaguesRank => BroadcastType::LeaguesRank,
296+
LeaguesBroadCastType::CombatMasteries => BroadcastType::CombatMasteries,
297+
LeaguesBroadCastType::RelicTier => BroadcastType::RelicTier,
298+
LeaguesBroadCastType::NormalBroadCast => BroadcastType::Unknown,
299+
}
300+
}
301+
}
302+
291303
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone)]
292304
pub enum BroadcastType {
293305
ItemDrop,

trackscape-discord-shared/src/osrs_broadcast_handler.rs

+18-13
Original file line numberDiff line numberDiff line change
@@ -509,10 +509,6 @@ impl<T: DropLogs, CL: ClanMateCollectionLogTotals, CM: ClanMates, J: JobQueue>
509509
}
510510
}
511511
BroadcastType::PersonalBest => self.personal_best_handler().await,
512-
// BroadcastType::AreaUnlock
513-
// | BroadcastType::LeaguesRank
514-
// | BroadcastType::CombatMasteries
515-
// | BroadcastType::RelicTier => self.leagues_handler().await,
516512
_ => None,
517513
}
518514
}
@@ -851,14 +847,22 @@ impl<T: DropLogs, CL: ClanMateCollectionLogTotals, CM: ClanMates, J: JobQueue>
851847
}
852848

853849
pub async fn extract_leagues_message(&self) -> Option<BroadcastMessageToDiscord> {
854-
let possible_leagues_broad_cast_type =
850+
let possible_leagues_broadcast_type =
855851
leagues_catch_all_broadcast_extractor(self.clan_message.message.clone());
856-
info!(
857-
"possible_leagues_broad_cast_type: {:?}",
858-
possible_leagues_broad_cast_type
859-
);
860-
match possible_leagues_broad_cast_type {
861-
Some(leagues_broadcast_type) => match leagues_broadcast_type {
852+
853+
if let Some(leagues_broadcast_type) = possible_leagues_broadcast_type {
854+
//Bit odd to have same name enums in each but did it to keep commands
855+
let full_broadcast = leagues_broadcast_type.to_broadcast_type();
856+
let is_disallowed = self.check_if_allowed_broad_cast(full_broadcast);
857+
info!(
858+
"Leagues broadcast type: {:?} is disallowed: {}",
859+
leagues_broadcast_type, is_disallowed
860+
);
861+
if is_disallowed {
862+
return None;
863+
}
864+
865+
match leagues_broadcast_type {
862866
LeaguesBroadCastType::AreaUnlock => Some(BroadcastMessageToDiscord {
863867
type_of_broadcast: BroadcastType::AreaUnlock,
864868
player_it_happened_to: "".to_string(),
@@ -893,8 +897,9 @@ impl<T: DropLogs, CL: ClanMateCollectionLogTotals, CM: ClanMates, J: JobQueue>
893897
}),
894898
//Ideally previous broadcast logic should catch this and we just come to leagues for the new types
895899
LeaguesBroadCastType::NormalBroadCast => None,
896-
},
897-
None => None,
900+
}
901+
} else {
902+
None
898903
}
899904
}
900905

0 commit comments

Comments
 (0)