2024.02.12 - WORKS
This commit is contained in:
parent
8d4db0c657
commit
2a7b53ddf8
6 changed files with 422 additions and 143 deletions
src/core
|
@ -20,15 +20,20 @@ use std::cell::RefCell;
|
|||
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use super::botmodules::bot_actions::actions_util::BotAR;
|
||||
|
||||
|
||||
fn adminvector() -> Vec<String> {
|
||||
vec![String::from("ModulatingForce")]
|
||||
}
|
||||
|
||||
|
||||
// pub fn init(mgr:&mut ModulesManager)
|
||||
pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
||||
pub fn init(mgr:Arc<ModulesManager>)
|
||||
{
|
||||
|
||||
let a = actions_util::asyncbox(cmd_promote) ;
|
||||
|
||||
BotCommand {
|
||||
module : BotModule(String::from("identity")),
|
||||
command : String::from("promote"), // command call name
|
||||
|
@ -41,9 +46,11 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
UserRole::Broadcaster,
|
||||
UserRole::BotAdmin,
|
||||
],
|
||||
}.add_to_modmgr(mgr);
|
||||
}.add_to_modmgr(Arc::clone(&mgr));
|
||||
|
||||
async fn cmd_promote(mut bot:Arc<Mutex<BotInstance>>,msg:PrivmsgMessage)
|
||||
// async fn cmd_promote(mut bot:Arc<Mutex<BotInstance>>,msg:PrivmsgMessage)
|
||||
// async fn cmd_promote(mut bot:&BotInstance,msg:PrivmsgMessage) -> &BotInstance
|
||||
async fn cmd_promote(bot:BotAR,msg:PrivmsgMessage) -> ()
|
||||
{
|
||||
//println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
println!("Called cmd promote");
|
||||
|
@ -133,9 +140,11 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
// if let Some(a) = ta {
|
||||
|
||||
|
||||
let p = bot.lock().await.get_identity();
|
||||
let mut p = p.lock().await;
|
||||
let ta = p.getspecialuserroles(String::from("Hello"), Some(ChType::Channel(msg.channel_login.to_lowercase()))).await;
|
||||
// let p = bot.lock().await.get_identity();
|
||||
// let mut p = p.lock().await;
|
||||
// let ta = p.getspecialuserroles(String::from("Hello"), Some(ChType::Channel(msg.channel_login.to_lowercase()))).await;
|
||||
let botlock = bot.read().await;
|
||||
let ta = botlock.get_identity().read().await.getspecialuserroles(String::from("Hello"), Some(ChType::Channel(msg.channel_login.to_lowercase()))).await;
|
||||
|
||||
if let Some(a) = ta {
|
||||
|
||||
|
@ -183,9 +192,13 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
// let mut mutex2 = Arc::clone(&mutex).into_inner().get_identity();
|
||||
// let a = (*bot).lock().await.get_identity();
|
||||
// let mut a = a.lock().await;
|
||||
let p = bot.lock().await.get_identity();
|
||||
let mut p = p.lock().await;
|
||||
let ta = p.promote(msg.sender.name.to_lowercase(), None, Some(UserRole::BotAdmin)).await;
|
||||
// let p = bot.lock().await.get_identity();
|
||||
// let mut p = p.lock().await;
|
||||
// let ta = p.promote(msg.sender.name.to_lowercase(), None, Some(UserRole::BotAdmin)).await;
|
||||
let botlock = Arc::clone(&bot.read().await.get_identity());
|
||||
let idlock = botlock.write().await;
|
||||
// let mut idlock = *idlock;
|
||||
let ta = idlock.promote(msg.sender.name.to_lowercase(), None, Some(UserRole::BotAdmin)).await;
|
||||
|
||||
match ta {
|
||||
// Success(_) => {
|
||||
|
@ -227,7 +240,7 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
|
||||
|
||||
|
||||
|
||||
// bot
|
||||
|
||||
|
||||
|
||||
|
@ -245,10 +258,11 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
UserRole::Broadcaster,
|
||||
UserRole::BotAdmin,
|
||||
],
|
||||
}.add_to_modmgr(mgr);
|
||||
}.add_to_modmgr(Arc::clone(&mgr));
|
||||
|
||||
|
||||
async fn cmd_demote(mut _chat:Arc<Mutex<BotInstance>>,_msg:PrivmsgMessage) {
|
||||
// async fn cmd_demote(mut _chat:Arc<Mutex<BotInstance>>,_msg:PrivmsgMessage) {
|
||||
async fn cmd_demote(mut _chat:BotAR,_msg:PrivmsgMessage) {
|
||||
println!("Called cmd demote");
|
||||
}
|
||||
|
||||
|
@ -266,10 +280,11 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
UserRole::Broadcaster,
|
||||
UserRole::BotAdmin,
|
||||
],
|
||||
}.add_to_modmgr(mgr);
|
||||
}.add_to_modmgr(Arc::clone(&mgr));
|
||||
|
||||
|
||||
async fn getroles(bot:Arc<Mutex<BotInstance>>,msg:PrivmsgMessage) {
|
||||
// async fn getroles(bot:Arc<Mutex<BotInstance>>,msg:PrivmsgMessage) {
|
||||
async fn getroles(bot:BotAR,msg:PrivmsgMessage) {
|
||||
println!("Called cmd getroles");
|
||||
|
||||
/*
|
||||
|
@ -337,10 +352,14 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
// let a = a.into_inner();
|
||||
// let a = a.identity;
|
||||
// let a = a.into_inner();
|
||||
let a = bot.clone();
|
||||
let a = a.lock().await;
|
||||
let a = a.get_identity().await;
|
||||
// let a = bot.clone();
|
||||
// let a = a.lock().await;
|
||||
// let a = a.get_identity();
|
||||
// let a = a.lock().await;
|
||||
// let a = bot.get_identity();
|
||||
let botlock = bot.read().await;
|
||||
let idlock = botlock.get_identity();
|
||||
let idlock = idlock.read().await;
|
||||
let sproles = match targetchnl {
|
||||
None => {
|
||||
// let bot = Rc::clone(&bot);
|
||||
|
@ -352,7 +371,8 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
// let a = a.ok().getspecialuserroles(String::from(targetuser),None);
|
||||
// let a = bot.read().ok().unwrap().rIdentity().getspecialuserroles(String::from(targetuser),None);
|
||||
// println!("Retrieved User Roles >> {:?}",a);
|
||||
a.lock().await.getspecialuserroles(String::from(targetuser),None).await
|
||||
// let a = idlock.read().await;
|
||||
idlock.getspecialuserroles(String::from(targetuser),None).await
|
||||
},
|
||||
Some(targetchnl) => {
|
||||
// let bot = Rc::clone(&bot);
|
||||
|
@ -365,7 +385,8 @@ pub fn init(mgr:Arc<Mutex<ModulesManager>>)
|
|||
// let a = bot.read().ok().unwrap().rIdentity().getspecialuserroles(String::from(targetuser),None);
|
||||
// println!("Retrieved User Roles >> {:?}",a);
|
||||
// bot.read().ok().unwrap().rIdentity().getspecialuserroles(String::from(targetuser),None)
|
||||
a.lock().await.getspecialuserroles(String::from(targetuser),None).await
|
||||
// let a = a.read().await;
|
||||
idlock.getspecialuserroles(String::from(targetuser),None).await
|
||||
|
||||
},
|
||||
};
|
||||
|
@ -445,7 +466,8 @@ impl IdentityManager {
|
|||
|
||||
// pub fn can_user_run_PRVMSG(self,msg:&PrivmsgMessage,cmdreqroles:Vec<UserRole>) -> Result<Permissible,Box<dyn Error>>
|
||||
// pub fn can_user_run_PRVMSG(&self,msg:&PrivmsgMessage,cmdreqroles:Vec<UserRole>) -> Permissible
|
||||
pub async fn can_user_run_PRVMSG(self,msg:&PrivmsgMessage,cmdreqroles:Vec<UserRole>) -> Permissible
|
||||
// pub async fn can_user_run_PRVMSG(self,msg:&PrivmsgMessage,cmdreqroles:Vec<UserRole>) -> Permissible
|
||||
pub fn can_user_run_PRVMSG(&self,msg:&PrivmsgMessage,cmdreqroles:Vec<UserRole>) -> Permissible
|
||||
{
|
||||
// println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||
|
||||
|
@ -497,9 +519,11 @@ impl IdentityManager {
|
|||
|
||||
|
||||
// [ ] Call can_user_run()
|
||||
// (self,Permissible::Block)
|
||||
Permissible::Block
|
||||
}
|
||||
|
||||
|
||||
pub async fn can_user_run(&self,
|
||||
usr:String,
|
||||
channelname:ChType,
|
||||
|
@ -661,7 +685,8 @@ impl IdentityManager {
|
|||
Permissible::Block
|
||||
}
|
||||
|
||||
pub async fn promote(&mut self,trgchatter:String,channel:Option<ChType>,trg_role:Option<UserRole>) -> ChangeResult {
|
||||
// pub async fn promote(&mut self,trgchatter:String,channel:Option<ChType>,trg_role:Option<UserRole>) -> ChangeResult {
|
||||
pub async fn promote(&self,trgchatter:String,channel:Option<ChType>,trg_role:Option<UserRole>) -> ChangeResult {
|
||||
|
||||
// Note : If channel is none, getspecialuserroles() returns all roles for the user
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue