add debug implementations that helped (kinda)
This commit is contained in:
parent
9d94328cd6
commit
fcf4f3f7cf
5 changed files with 38 additions and 5 deletions
|
@ -12,7 +12,7 @@ pub type BotAR = Arc<RwLock<BotInstance>>;
|
||||||
pub type ActAR = Arc<RwLock<BotAction>>;
|
pub type ActAR = Arc<RwLock<BotAction>>;
|
||||||
pub type RoutineAR = Arc<RwLock<Routine>>;
|
pub type RoutineAR = Arc<RwLock<Routine>>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ExecBodyParams {
|
pub struct ExecBodyParams {
|
||||||
pub bot : BotAR,
|
pub bot : BotAR,
|
||||||
pub msg : PrivmsgMessage,
|
pub msg : PrivmsgMessage,
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub struct Channel(pub String);
|
||||||
use super::bot_actions::ExecBodyParams;
|
use super::bot_actions::ExecBodyParams;
|
||||||
use super::botmodules::StatusType;
|
use super::botmodules::StatusType;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct BotManagers {
|
pub struct BotManagers {
|
||||||
pub identity: Arc<RwLock<IdentityManager>>,
|
pub identity: Arc<RwLock<IdentityManager>>,
|
||||||
pub chat: Chat,
|
pub chat: Chat,
|
||||||
|
@ -70,6 +70,7 @@ impl<T: Clone> ArcBox<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct BotInstance {
|
pub struct BotInstance {
|
||||||
pub prefix: char,
|
pub prefix: char,
|
||||||
pub bot_channel: Channel,
|
pub bot_channel: Channel,
|
||||||
|
|
|
@ -28,6 +28,7 @@ use core::panic;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::borrow::BorrowMut;
|
use std::borrow::BorrowMut;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -470,6 +471,7 @@ pub enum StatusType {
|
||||||
Disabled(StatusLvl),
|
Disabled(StatusLvl),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum BotAction {
|
pub enum BotAction {
|
||||||
C(BotCommand),
|
C(BotCommand),
|
||||||
L(Listener),
|
L(Listener),
|
||||||
|
@ -532,6 +534,12 @@ impl BotActionTrait for BotCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for BotCommand {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{:?} {:?} {:?} {:?} {:?}", self.module, self.command, self.alias, self.help, self.required_roles)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Listener {
|
pub struct Listener {
|
||||||
pub module: BotModule,
|
pub module: BotModule,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
@ -579,6 +587,12 @@ impl BotActionTrait for Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for Listener {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{:?} {:?} {:?}", self.module, self.name, self.help)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// #[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
// #[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum RoutineAttr {
|
pub enum RoutineAttr {
|
||||||
|
@ -617,6 +631,7 @@ pub enum RoutineAttr {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// For some key statuses and in particular Stopping to Gracefully stop
|
// For some key statuses and in particular Stopping to Gracefully stop
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum RoutineSignal {
|
pub enum RoutineSignal {
|
||||||
Stopping, // Gracefully Stopping
|
Stopping, // Gracefully Stopping
|
||||||
Stopped, // When cancelling or aborting, this also is represented by Stopped
|
Stopped, // When cancelling or aborting, this also is represented by Stopped
|
||||||
|
@ -624,7 +639,6 @@ pub enum RoutineSignal {
|
||||||
NotStarted,
|
NotStarted,
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[derive(Debug)]
|
|
||||||
pub struct Routine {
|
pub struct Routine {
|
||||||
pub name : String ,
|
pub name : String ,
|
||||||
pub module : BotModule , // from() can determine this if passed parents_params
|
pub module : BotModule , // from() can determine this if passed parents_params
|
||||||
|
@ -641,6 +655,23 @@ pub struct Routine {
|
||||||
pub self_act_ar : Option<ActAR> ,
|
pub self_act_ar : Option<ActAR> ,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// implement Debug manually witouth `exec_body` since you cant debug `ExecBody`.
|
||||||
|
impl Debug for Routine {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{:?}", self.name)?;
|
||||||
|
write!(f, "{:?}", self.module)?;
|
||||||
|
write!(f, "{:?}", self.channel)?;
|
||||||
|
write!(f, "{:?}", self.parent_params)?;
|
||||||
|
write!(f, "{:?}", self.join_handle)?;
|
||||||
|
write!(f, "{:?}", self.start_time)?;
|
||||||
|
write!(f, "{:?}", self.complete_iterations)?;
|
||||||
|
write!(f, "{:?}", self.remaining_iterations)?;
|
||||||
|
write!(f, "{:?}", self.routine_attr)?;
|
||||||
|
write!(f, "{:?}", self.internal_signal)?;
|
||||||
|
write!(f, "{:?}", self.self_routine_ar)?;
|
||||||
|
write!(f, "{:?}", self.self_act_ar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Routine {
|
impl Routine {
|
||||||
|
|
||||||
|
@ -1477,6 +1508,7 @@ impl Routine {
|
||||||
type StatusdbEntry = (ModGroup, Vec<StatusType>);
|
type StatusdbEntry = (ModGroup, Vec<StatusType>);
|
||||||
type ModuleActions = Vec<Arc<RwLock<BotAction>>>;
|
type ModuleActions = Vec<Arc<RwLock<BotAction>>>;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct ModulesManager {
|
pub struct ModulesManager {
|
||||||
statusdb: Arc<RwLock<HashMap<BotModule, StatusdbEntry>>>,
|
statusdb: Arc<RwLock<HashMap<BotModule, StatusdbEntry>>>,
|
||||||
pub botactions: Arc<RwLock<HashMap<BotModule, ModuleActions>>>,
|
pub botactions: Arc<RwLock<HashMap<BotModule, ModuleActions>>>,
|
||||||
|
|
|
@ -27,7 +27,7 @@ use super::identity;
|
||||||
|
|
||||||
use async_recursion::async_recursion;
|
use async_recursion::async_recursion;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Chat {
|
pub struct Chat {
|
||||||
pub ratelimiters: Arc<Mutex<HashMap<Channel, RateLimiter>>>, // used to limit messages sent per channel
|
pub ratelimiters: Arc<Mutex<HashMap<Channel, RateLimiter>>>, // used to limit messages sent per channel
|
||||||
pub client: TwitchIRCClient<TCPTransport<TLS>, StaticLoginCredentials>,
|
pub client: TwitchIRCClient<TCPTransport<TLS>, StaticLoginCredentials>,
|
||||||
|
|
|
@ -698,7 +698,7 @@ pub enum Permissible {
|
||||||
|
|
||||||
type UserRolesDB = HashMap<String, Arc<RwLock<Vec<UserRole>>>>;
|
type UserRolesDB = HashMap<String, Arc<RwLock<Vec<UserRole>>>>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct IdentityManager {
|
pub struct IdentityManager {
|
||||||
special_roles_users: Arc<RwLock<UserRolesDB>>,
|
special_roles_users: Arc<RwLock<UserRolesDB>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue