(cont) work on identity module
This commit is contained in:
parent
422cd93303
commit
e1535aef2a
4 changed files with 51 additions and 5 deletions
|
@ -222,7 +222,7 @@ impl BotInstance
|
||||||
|
|
||||||
while let Some(message) = self.incoming_messages.recv().await {
|
while let Some(message) = self.incoming_messages.recv().await {
|
||||||
// Below can be used to debug if I want to capture all messages
|
// Below can be used to debug if I want to capture all messages
|
||||||
//println!("Received message: {:?}", message);
|
println!("Received message: {:?}", message);
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
ServerMessage::Notice(msg) => {
|
ServerMessage::Notice(msg) => {
|
||||||
|
|
|
@ -3,6 +3,8 @@ use std::error::Error;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use crate::core::identity;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@ -89,6 +91,7 @@ pub struct BotCommand {
|
||||||
// bot_prefix : char, // although should be global?
|
// bot_prefix : char, // although should be global?
|
||||||
pub exec_body : bot_actions::actions_util::ExecBody,
|
pub exec_body : bot_actions::actions_util::ExecBody,
|
||||||
pub help : String,
|
pub help : String,
|
||||||
|
pub required_roles : Vec<identity::UserRole>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BotCommand
|
impl BotCommand
|
||||||
|
|
|
@ -1,12 +1,53 @@
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
|
||||||
|
use crate::core::botmodules::{ModulesManager,Listener,BotModule,BotActionTrait, BotCommand};
|
||||||
|
use crate::core::botmodules::bot_actions::actions_util;
|
||||||
|
|
||||||
|
use crate::core::botinstance::{self};
|
||||||
|
use twitch_irc::message::PrivmsgMessage;
|
||||||
|
|
||||||
fn adminvector() -> Vec<String> {
|
fn adminvector() -> Vec<String> {
|
||||||
vec![String::from("ModulatingForce")]
|
vec![String::from("ModulatingForce")]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum userRole {
|
pub fn init(mgr:&mut ModulesManager)
|
||||||
|
{
|
||||||
|
|
||||||
|
BotCommand {
|
||||||
|
module : BotModule(String::from("identity")),
|
||||||
|
command : String::from("promote"), // command call name
|
||||||
|
alias : vec![], // String of alternative names
|
||||||
|
exec_body : actions_util::asyncbox(cmd_promote) ,
|
||||||
|
help : String::from("promote"),
|
||||||
|
required_roles : vec![],
|
||||||
|
}.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
async fn cmd_promote(mut _chat:botinstance::Chat,_msg:PrivmsgMessage) {
|
||||||
|
//println!("(#{}) {}: {}", msg.channel_login, msg.sender.name, msg.message_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
BotCommand {
|
||||||
|
module : BotModule(String::from("identity")),
|
||||||
|
command : String::from("demote"), // command call name
|
||||||
|
alias : vec![], // String of alternative names
|
||||||
|
exec_body : actions_util::asyncbox(cmd_demote) ,
|
||||||
|
help : String::from("demote"),
|
||||||
|
required_roles : vec![],
|
||||||
|
}.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
|
async fn cmd_demote(mut _chat:botinstance::Chat,_msg:PrivmsgMessage) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub enum UserRole {
|
||||||
Chatter,
|
Chatter,
|
||||||
Mod(String), // String specifies Channel
|
Mod(String), // String specifies Channel
|
||||||
SupMod(String), // String specifies Channel
|
SupMod(String), // String specifies Channel
|
||||||
|
@ -16,7 +57,7 @@ enum userRole {
|
||||||
|
|
||||||
|
|
||||||
pub struct IdentityManager {
|
pub struct IdentityManager {
|
||||||
specialRolesUsers : HashMap<String,Vec<userRole>>,
|
special_roles_users : HashMap<String,Vec<UserRole>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,11 +66,11 @@ impl IdentityManager {
|
||||||
pub fn init() -> IdentityManager {
|
pub fn init() -> IdentityManager {
|
||||||
let mut a = HashMap::new();
|
let mut a = HashMap::new();
|
||||||
for admn in adminvector() {
|
for admn in adminvector() {
|
||||||
a.insert(admn.to_lowercase(),vec![userRole::BotAdmin]);
|
a.insert(admn.to_lowercase(),vec![UserRole::BotAdmin]);
|
||||||
};
|
};
|
||||||
|
|
||||||
IdentityManager {
|
IdentityManager {
|
||||||
specialRolesUsers : a,
|
special_roles_users : a,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ pub fn init(mgr:&mut ModulesManager)
|
||||||
alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names
|
alias : vec![String::from("tester1"),String::from("testy1")], // String of alternative names
|
||||||
exec_body : actions_util::asyncbox(testy) ,
|
exec_body : actions_util::asyncbox(testy) ,
|
||||||
help : String::from("DUPCMD4 tester"),
|
help : String::from("DUPCMD4 tester"),
|
||||||
|
required_roles : vec![],
|
||||||
}.add_to_modmgr(mgr);
|
}.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ pub fn init(mgr:&mut ModulesManager)
|
||||||
alias : vec![String::from("tester2"),String::from("testy2")], // String of alternative names
|
alias : vec![String::from("tester2"),String::from("testy2")], // String of alternative names
|
||||||
exec_body : actions_util::asyncbox(testy) ,
|
exec_body : actions_util::asyncbox(testy) ,
|
||||||
help : String::from("DUPCMD4 tester"),
|
help : String::from("DUPCMD4 tester"),
|
||||||
|
required_roles : vec![],
|
||||||
}.add_to_modmgr(mgr);
|
}.add_to_modmgr(mgr);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue