access control and command handling with regex

This commit is contained in:
2021-08-22 01:50:07 +02:00
parent 5a631f785e
commit 99d9b83c68
7 changed files with 793 additions and 113 deletions
+1 -97
View File
@@ -24,6 +24,7 @@ use elefren::debug::NotificationDisplay;
mod store;
mod group_handle;
mod utils;
mod command;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
@@ -78,104 +79,7 @@ async fn main() -> anyhow::Result<()> {
futures::future::join_all(handles).await;
/*
let client = if let Ok(data) = elefren::helpers::toml::from_file("group-actor-data.toml") {
FediClient::from(data)
} else {
register().await?
};
let you = client.verify_credentials().await?;
println!("{:#?}", you);
let mut events = client.streaming_user().await?;
while let Some(event) = events.next().await {
match event {
Event::Update(status) => {
info!("Status: {:?}", status);
},
Event::Notification(notification) => {
info!("Notification: {:?}", notification.notification_type);
debug!("{:?}", notification);
/*
match notification.notification_type {
NotificationType::Mention => {
if let Some(status) = notification.status {
if status.content.contains("/gi") {
debug!("GRPIGNORE!");
} else if status.content.contains("/gb") {
debug!("GROUP BOOST PREV!");
if let Some(id) = status.in_reply_to_id {
let _ = client.reblog(&id);
}
}
// else if status.content.contains("/gping") {
// let post = StatusBuilder::new()
// .status(format!("@{} hello", &notification.account.acct))
// .content_type("text/markdown")
// //.in_reply_to(status.id)
// .visibility(Visibility::Unlisted)
// .build().expect("error build status");
//
// let _ = client.new_status(post);
// }
else {
info!("BOOSTING");
let _ = client.reblog(&status.id);
}
}
}
NotificationType::Follow => {
info!("New follower!");
let post = StatusBuilder::new()
.status(format!("@{} welcome to the group!", &notification.account.acct))
.content_type("text/markdown")
.visibility(Visibility::Unlisted)
.build().expect("error build status");
let _ = client.new_status(post).await;
}
_ => {}
}
*/
},
Event::Delete(id) => {
info!("Delete: {}", id);
},
Event::FiltersChanged => {
info!("FiltersChanged");
// ???
},
}
}
*/
println!("Main loop ended!");
Ok(())
}
/*
async fn register() -> anyhow::Result<FediClient> {
let registration = Registration::new("https://piggo.space")
.client_name("group-actor")
.force_login(true)
.scopes(
Scopes::read(scopes::Read::Accounts)
| Scopes::read(scopes::Read::Notifications)
| Scopes::read(scopes::Read::Statuses)
| Scopes::read(scopes::Read::Follows)
| Scopes::write(scopes::Write::Statuses)
| Scopes::write(scopes::Write::Media)
)
.build().await?;
let client = elefren::helpers::cli::authenticate(registration).await?;
elefren::helpers::toml::to_file(&*client, "group-actor-data.toml")?;
Ok(client)
}
*/