update bot framework

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2021-09-07 18:59:57 -04:00
parent 1e7f19f250
commit 622f150b70
3 changed files with 31 additions and 30 deletions

13
Cargo.lock generated
View File

@ -1231,10 +1231,11 @@ dependencies = [
[[package]] [[package]]
name = "robespierre" name = "robespierre"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/dblanovschi/robespierre#445af603ee43a4878e04310d2028c0347379afc2" source = "git+https://github.com/dblanovschi/robespierre#0806bc28e7cd06f258457f719ceb5d6408c3d010"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",
"futures",
"robespierre-cache", "robespierre-cache",
"robespierre-events", "robespierre-events",
"robespierre-fw-macros", "robespierre-fw-macros",
@ -1251,7 +1252,7 @@ dependencies = [
[[package]] [[package]]
name = "robespierre-cache" name = "robespierre-cache"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/dblanovschi/robespierre#445af603ee43a4878e04310d2028c0347379afc2" source = "git+https://github.com/dblanovschi/robespierre#0806bc28e7cd06f258457f719ceb5d6408c3d010"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"robespierre-models", "robespierre-models",
@ -1261,7 +1262,7 @@ dependencies = [
[[package]] [[package]]
name = "robespierre-events" name = "robespierre-events"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/dblanovschi/robespierre#445af603ee43a4878e04310d2028c0347379afc2" source = "git+https://github.com/dblanovschi/robespierre#0806bc28e7cd06f258457f719ceb5d6408c3d010"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",
@ -1279,7 +1280,7 @@ dependencies = [
[[package]] [[package]]
name = "robespierre-fw-macros" name = "robespierre-fw-macros"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/dblanovschi/robespierre#445af603ee43a4878e04310d2028c0347379afc2" source = "git+https://github.com/dblanovschi/robespierre#0806bc28e7cd06f258457f719ceb5d6408c3d010"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1289,7 +1290,7 @@ dependencies = [
[[package]] [[package]]
name = "robespierre-http" name = "robespierre-http"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/dblanovschi/robespierre#445af603ee43a4878e04310d2028c0347379afc2" source = "git+https://github.com/dblanovschi/robespierre#0806bc28e7cd06f258457f719ceb5d6408c3d010"
dependencies = [ dependencies = [
"reqwest", "reqwest",
"robespierre-models", "robespierre-models",
@ -1301,7 +1302,7 @@ dependencies = [
[[package]] [[package]]
name = "robespierre-models" name = "robespierre-models"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/dblanovschi/robespierre#445af603ee43a4878e04310d2028c0347379afc2" source = "git+https://github.com/dblanovschi/robespierre#0806bc28e7cd06f258457f719ceb5d6408c3d010"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"chrono", "chrono",

View File

@ -27,31 +27,31 @@ pub fn user_agent(username: String) -> String {
) )
} }
#[command] // #[command]
pub async fn search_impl(ctx: &FwContext, msg: &Message, args: &str) -> CommandResult { // pub async fn search_impl(ctx: &FwContext, msg: &Message) -> CommandResult {
let data = ctx.data_lock_read().await; // let data = ctx.data_lock_read().await;
let client = data.get::<ClientKey>().unwrap().clone(); // let client = data.get::<ClientKey>().unwrap().clone();
let client = client.lock().await; // let client = client.lock().await;
let mut imgs = client.image_search(args, 0_u64).await?; // let mut imgs = client.image_search(args, 0_u64).await?;
let mut response = String::new(); // let mut response = String::new();
imgs.truncate(3); // imgs.truncate(3);
for mut post in imgs.into_iter() { // for mut post in imgs.into_iter() {
post.tags.sort(); // post.tags.sort();
post.tags.truncate(8); // post.tags.truncate(8);
response.push_str(&format!( // response.push_str(&format!(
"<{}> - {} - <{}>\n", // "<{}> - {} - <{}>\n",
format!("http://furbooru.org/{}", post.id), // format!("http://furbooru.org/{}", post.id),
post.tags.join(", "), // post.tags.join(", "),
post.view_url, // post.view_url,
)); // ));
} // }
msg.reply(ctx, response).await?; // msg.reply(ctx, response).await?;
Ok(()) // Ok(())
} // }

View File

@ -80,7 +80,7 @@ async fn main() -> Result<()> {
} }
#[command] #[command]
async fn ping(ctx: &FwContext, msg: &Message, _args: &str) -> CommandResult { async fn ping(ctx: &FwContext, msg: &Message) -> CommandResult {
msg.reply(ctx, "pong").await?; msg.reply(ctx, "pong").await?;
let data = ctx.data_lock_read().await; let data = ctx.data_lock_read().await;
@ -91,7 +91,7 @@ async fn ping(ctx: &FwContext, msg: &Message, _args: &str) -> CommandResult {
} }
#[command] #[command]
async fn command_counter(ctx: &FwContext, msg: &Message, _args: &str) -> CommandResult { async fn command_counter(ctx: &FwContext, msg: &Message) -> CommandResult {
let data = ctx.data_lock_read().await; let data = ctx.data_lock_read().await;
let counter = data.get::<CommandCounterKey>().unwrap(); let counter = data.get::<CommandCounterKey>().unwrap();
let count = counter.fetch_add(1, Ordering::SeqCst); let count = counter.fetch_add(1, Ordering::SeqCst);
@ -106,7 +106,7 @@ async fn command_counter(ctx: &FwContext, msg: &Message, _args: &str) -> Command
} }
#[command] #[command]
async fn current_front(ctx: &FwContext, msg: &Message, _args: &str) -> CommandResult { async fn current_front(ctx: &FwContext, msg: &Message) -> CommandResult {
let data = ctx.data_lock_read().await; let data = ctx.data_lock_read().await;
let client = data.get::<ReqwestClientKey>().unwrap().clone(); let client = data.get::<ReqwestClientKey>().unwrap().clone();
let client = client.lock().await; let client = client.lock().await;