#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::{InlineQueryResult, InlineQueryResultsButton};
use crate::Bot;
impl Bot {
pub fn answer_inline_query(
&self,
inline_query_id: String,
results: Vec<InlineQueryResult>,
) -> AnswerInlineQueryBuilder {
AnswerInlineQueryBuilder::new(self, inline_query_id, results)
}
}
#[derive(Serialize)]
pub struct AnswerInlineQueryBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
pub inline_query_id: String,
pub results: Vec<InlineQueryResult>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cache_time: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_personal: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub next_offset: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub button: Option<InlineQueryResultsButton>,
}
impl<'a> AnswerInlineQueryBuilder<'a> {
pub fn new(bot: &'a Bot, inline_query_id: String, results: Vec<InlineQueryResult>) -> Self {
Self {
bot,
inline_query_id,
results,
cache_time: None,
is_personal: None,
next_offset: None,
button: None,
}
}
pub fn inline_query_id(mut self, inline_query_id: String) -> Self {
self.inline_query_id = inline_query_id;
self
}
pub fn results(mut self, results: Vec<InlineQueryResult>) -> Self {
self.results = results;
self
}
pub fn cache_time(mut self, cache_time: i64) -> Self {
self.cache_time = Some(cache_time);
self
}
pub fn is_personal(mut self, is_personal: bool) -> Self {
self.is_personal = Some(is_personal);
self
}
pub fn next_offset(mut self, next_offset: String) -> Self {
self.next_offset = Some(next_offset);
self
}
pub fn button(mut self, button: InlineQueryResultsButton) -> Self {
self.button = Some(button);
self
}
pub async fn send(self) -> Result<bool> {
let form = serde_json::to_value(&self)?;
self.bot.get("answerInlineQuery", Some(&form)).await
}
}