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

View File

@ -27,31 +27,31 @@ pub fn user_agent(username: String) -> String {
)
}
#[command]
pub async fn search_impl(ctx: &FwContext, msg: &Message, args: &str) -> CommandResult {
let data = ctx.data_lock_read().await;
let client = data.get::<ClientKey>().unwrap().clone();
let client = client.lock().await;
// #[command]
// pub async fn search_impl(ctx: &FwContext, msg: &Message) -> CommandResult {
// let data = ctx.data_lock_read().await;
// let client = data.get::<ClientKey>().unwrap().clone();
// 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() {
post.tags.sort();
post.tags.truncate(8);
// for mut post in imgs.into_iter() {
// post.tags.sort();
// post.tags.truncate(8);
response.push_str(&format!(
"<{}> - {} - <{}>\n",
format!("http://furbooru.org/{}", post.id),
post.tags.join(", "),
post.view_url,
));
}
// response.push_str(&format!(
// "<{}> - {} - <{}>\n",
// format!("http://furbooru.org/{}", post.id),
// post.tags.join(", "),
// 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]
async fn ping(ctx: &FwContext, msg: &Message, _args: &str) -> CommandResult {
async fn ping(ctx: &FwContext, msg: &Message) -> CommandResult {
msg.reply(ctx, "pong").await?;
let data = ctx.data_lock_read().await;
@ -91,7 +91,7 @@ async fn ping(ctx: &FwContext, msg: &Message, _args: &str) -> CommandResult {
}
#[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 counter = data.get::<CommandCounterKey>().unwrap();
let count = counter.fetch_add(1, Ordering::SeqCst);
@ -106,7 +106,7 @@ async fn command_counter(ctx: &FwContext, msg: &Message, _args: &str) -> 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 client = data.get::<ReqwestClientKey>().unwrap().clone();
let client = client.lock().await;