Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moderation tools #425

Open
TheDevMinerTV opened this issue May 13, 2024 · 2 comments
Open

Moderation tools #425

TheDevMinerTV opened this issue May 13, 2024 · 2 comments
Labels
help wanted 🫂 Extra attention is needed

Comments

@TheDevMinerTV
Copy link

TheDevMinerTV commented May 13, 2024

Be it IP bans or user bans, these will be useful during the event.

[edited by Andrew]

  • ban {player}
  • mute {player} if chat is supported
@andrewgazelka
Copy link
Owner

yea definitely want this 👍

@andrewgazelka andrewgazelka added the help wanted 🫂 Extra attention is needed label Nov 3, 2024
@andrewgazelka
Copy link
Owner

andrewgazelka commented Nov 3, 2024

want potentially use LMDB for this

#[derive(Component, Debug, Clone, Deref)]
pub struct LocalDb {
env: Env,
}

see

#[derive(Component)]
pub struct PermissionStorage {
env: Env,
perms: Database<types::U128<NativeEndian>, types::U8>,
}
impl PermissionStorage {
pub fn new(db: &LocalDb) -> anyhow::Result<Self> {
// We open the default unnamed database
let perms = {
let mut wtxn = db.write_txn()?;
let db = db.create_database(&mut wtxn, Some("uuid-to-perms"))?;
wtxn.commit()?;
db
};
Ok(Self {
env: (**db).clone(),
perms,
})
}
pub fn get(&self, uuid: uuid::Uuid) -> Group {
let uuid = uuid.as_u128();
let rtxn = self.env.read_txn().unwrap();
let Some(perms) = self.perms.get(&rtxn, &uuid).unwrap() else {
return Group::default();
};
let Some(group) = Group::from_u8(perms) else {
tracing::error!("invalid group {perms:?}");
return Group::default();
};
group
}
pub fn set(&self, uuid: uuid::Uuid, group: Group) -> anyhow::Result<()> {
let uuid = uuid.as_u128();
let mut wtxn = self.env.write_txn()?;
self.perms.put(&mut wtxn, &uuid, &group.to_u8().unwrap())?;
wtxn.commit()?;
Ok(())
}
}

can also use rkyv potentially

could also use something like

https://github.com/nats-io/nats.rs

with jetstream? cause we might want people to be able to ban people even if cannot execute commands 🤷


in general worth talking about

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted 🫂 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants