Simplifying enums

I hope this doesn't explode everything Prayge
This commit is contained in:
haruyuumei 2024-03-22 16:55:56 -03:00 committed by ModulatingForce
commit 960cd5724c
5 changed files with 132 additions and 126 deletions

View file

@ -35,11 +35,15 @@ pub enum ChangeResult {
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum ChType {
Channel(String),
}
pub use ChType::Channel;
// pub enum ChType {
// Channel(String),
// }
//
// pub use ChType::Channel;
//
//simplifying from enum to struct
pub struct Channel(pub String);
use super::botmodules::StatusType;
@ -51,7 +55,7 @@ pub struct BotManagers {
impl BotManagers {
pub fn init(
ratelimiters: HashMap<ChType, RateLimiter>,
ratelimiters: HashMap<Channel, RateLimiter>,
client: TwitchIRCClient<TCPTransport<TLS>, StaticLoginCredentials>,
) -> BotManagers {
BotManagers {
@ -75,11 +79,11 @@ impl<T: Clone> ArcBox<T> {
pub struct BotInstance {
pub prefix: char,
pub bot_channel: ChType,
pub bot_channel: Channel,
pub incoming_messages: Arc<RwLock<UnboundedReceiver<ServerMessage>>>,
pub botmodules: Arc<ModulesManager>,
pub twitch_oauth: String,
pub bot_channels: Vec<ChType>,
pub bot_channels: Vec<Channel>,
pub botmgrs: BotManagers,
//modesmgr : ModesManager, // [FUTURE] Silent/Quiet , uwu , frisky/horny
}
@ -299,7 +303,7 @@ impl BotInstance {
let modmgr = Arc::clone(&botlock.botmodules);
let modstatus = modmgr.modstatus(
c.module.clone(),
ChType::Channel(msg.channel_login.to_string())).await;
Channel(msg.channel_login.to_string())).await;
if let StatusType::Disabled(a) = modstatus {
@ -314,7 +318,7 @@ impl BotInstance {
);
const OF_CMD_CHANNEL:ChType = Channel(String::new());
const OF_CMD_CHANNEL:Channel = Channel(String::new());
let elevated_access = {
let mut idlock = id.write().await;
@ -417,7 +421,7 @@ impl BotInstance {
let modmgr = Arc::clone(&botlock.botmodules);
let modstatus = modmgr.modstatus(
l.module.clone(),
ChType::Channel(msg.channel_login.to_string())).await;
Channel(msg.channel_login.to_string())).await;
if let StatusType::Disabled(a) = modstatus {