Skip to content

Commit

Permalink
don't use hardcoded file_ids in /sex
Browse files Browse the repository at this point in the history
  • Loading branch information
jelni committed Dec 28, 2024
1 parent c2b6c95 commit b5a1be6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/commands/sex.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
use async_trait::async_trait;
use tdlib::enums::{InputFile, InputMessageContent};
use tdlib::enums::{InputFile, InputMessageContent, StickerSet};
use tdlib::functions;
use tdlib::types::{InputFileRemote, InputMessageSticker};

use super::{CommandResult, CommandTrait};
use crate::utilities::command_context::CommandContext;
use crate::utilities::convert_argument::{ConvertArgument, StringGreedy};

const SEX: [&str; 2] = [
"CAACAgQAAxkBAAIHfGOBPouzDkVHO9WAvBrBcMShtX5PAAKxDAACEpVpUwgV5MV2yef8JAQ",
"CAACAgQAAxkBAAIHe2OBPolUMdfqvn_-38aWQ3bJ0NojAAJ_CwACFtZwU-fyDIVsfDCjJAQ",
];

pub struct Sex;

#[async_trait]
Expand All @@ -22,11 +18,18 @@ impl CommandTrait for Sex {
async fn execute(&self, ctx: &CommandContext, arguments: String) -> CommandResult {
let argument = Option::<StringGreedy>::convert(ctx, &arguments).await?.0;
let question_mark = argument.is_some_and(|argument| argument.0.starts_with('?'));
let StickerSet::StickerSet(mut sticker_set) =
functions::search_sticker_set("fratik_sex".into(), false, ctx.client_id).await?;

ctx.reply_custom(
InputMessageContent::InputMessageSticker(InputMessageSticker {
sticker: InputFile::Remote(InputFileRemote {
id: SEX[usize::from(question_mark)].into(),
id: sticker_set
.stickers
.swap_remove(if question_mark { 0 } else { 1 })
.sticker
.remote
.id,
}),
thumbnail: None,
width: 0,
Expand Down

0 comments on commit b5a1be6

Please sign in to comment.