Skip to content

Commit

Permalink
Add links to post and search string with tags.
Browse files Browse the repository at this point in the history
Replace info! to debug!
  • Loading branch information
TOwInOK committed Sep 15, 2024
1 parent 98ecde2 commit e581184
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/image_board.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{paginate, Context, Error};
use shuller::prelude::*;
use tracing::info;
use tracing::debug;

static LEN: usize = 4;
static LEN_MAX: usize = 30;
Expand All @@ -19,12 +19,10 @@ pub async fn porno(
#[description = "let me your favorite tags!"]
#[description_localized("ru", "Дай мне свои любимые теги")]
#[name_localized("ru", "позитивные_теги")]
// #[name_localized("us", "positive tags")]
positive_tags: Option<String>,
#[description = "let me your unfavorite tags!"]
#[description_localized("ru", "Что не нравится?")]
#[name_localized("ru", "негативные_теги")]
// #[name_localized("us", "negative tags")]
negative_tags: Option<String>,
#[description = "Do you wanna some special?!"]
#[description_localized("ru", "Позвони и узнай, как там с деньгами!")]
Expand All @@ -41,14 +39,14 @@ pub async fn porno(
return Err("**Error: TOOO BIG**, max size is 4".into());
}
if let Some(id) = id {
info!("found some id: {}", &id);
debug!("found some id: {}", &id);
let mut data = match R34!(D; id = id) {
Ok(e) => e.data(),
Err(_) => return Err("**Error: Posts** not found".into()),
};
posts.append(&mut data);
} else if positive_tags.is_some() || negative_tags.is_some() {
info!(
debug!(
"found some tags: p = {:#?}, n = {:#?}",
&positive_tags, &negative_tags
);
Expand All @@ -67,7 +65,7 @@ pub async fn porno(
Err(e) => return Err(format!("**Error: Posts** not found\nErr{}", e).into()),
}
} else {
info!("Nothing addition params found");
debug!("Nothing addition params found");
match shuller::rules::rule34::params::R34Params::init()
.page(random_usize!(u16::MAX as usize) as u16)
.limit(size as u16)
Expand Down
37 changes: 28 additions & 9 deletions src/paginate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{phrazes::PHRASES, Context};
use ::serenity::all::{CreateMessage, ReactionType};
use poise::{serenity_prelude as serenity, CreateReply};
use shuller::{prelude::Post, random_usize};
use tracing::info;
use tracing::debug;

pub async fn paginate(ctx: Context<'_>, posts: &[Post]) -> Result<(), crate::Error> {
let ctx_id = ctx.id();
Expand Down Expand Up @@ -35,9 +35,8 @@ pub async fn paginate(ctx: Context<'_>, posts: &[Post]) -> Result<(), crate::Err
);
vec
};

let post = |page: &usize, shared: bool| {
info!("page is: {:#?}", &posts[*page]);
debug!("page is: {:#?}", &posts[*page]);
match shared {
true => serenity::CreateEmbed::default()
.image(&posts[*page].sample_url)
Expand All @@ -49,9 +48,19 @@ pub async fn paginate(ctx: Context<'_>, posts: &[Post]) -> Result<(), crate::Err
random_usize!(255) as u8,
))
.description(format!(
"**Tags:**
{}",
&posts[*page].tags
"
[Post](https://rule34.xxx/index.php?page=post&s=view&id={})
[Tag Link](https://rule34.xxx/index.php?page=post&s=list&tags={})
**Tags:**
```{}```
",
&posts[*page].id,
&posts[*page]
.tags
.split_whitespace()
.collect::<Vec<&str>>()
.join("+"),
&posts[*page].tags,
))
.author(serenity::CreateEmbedAuthor::new(&posts[*page].owner))
.footer(
Expand All @@ -68,9 +77,19 @@ pub async fn paginate(ctx: Context<'_>, posts: &[Post]) -> Result<(), crate::Err
random_usize!(255) as u8,
))
.description(format!(
"**Tags:**
{}",
&posts[*page].tags
"
[Post](https://rule34.xxx/index.php?page=post&s=view&id={})
[Tag Link](https://rule34.xxx/index.php?page=post&s=list&tags={})
**Tags:**
```{}```
",
&posts[*page].id,
&posts[*page]
.tags
.split_whitespace()
.collect::<Vec<&str>>()
.join("+"),
&posts[*page].tags,
))
.author(serenity::CreateEmbedAuthor::new(&posts[*page].owner)),
}
Expand Down

0 comments on commit e581184

Please sign in to comment.