Edited docs handler

This commit is contained in:
Nefrace 2022-10-24 10:41:09 +03:00
parent a13d6dc0ca
commit d72ee117e1
2 changed files with 5 additions and 4 deletions

View File

@ -50,7 +50,7 @@ impl Godette {
lazy_static! { lazy_static! {
static ref DOC_RE: Regex = static ref DOC_RE: Regex =
Regex::new(r"(?i)док(ументац[а-я]+|[а-я])? ((п)?о )?(?P<topic>@?[\w\d]{1,32})") Regex::new(r"(?i)док(ументац[а-я]+|[а-я])? ((п)?о )?(?P<topic>@?[\w\d\s]{1,32})")
.unwrap(); .unwrap();
} }

View File

@ -130,12 +130,13 @@ pub async fn documentation(bot: &Bot, msg: &Message, topic: String) -> ResponseR
let results = utils::request_docs(&topic).await; let results = utils::request_docs(&topic).await;
if results.len() > 0 { if results.len() > 0 {
let links = results let mut links = results
.iter() .iter()
.take(10) .take(10)
.map(|res| format!("\\- [{}]({})", escape(&res.title), res.path)) .map(|res| format!("\\- [{}]({})", escape(&res.title), res.path))
.collect::<Vec<String>>() .collect::<Vec<String>>();
.join("\n"); links[0] = bold(&italic(&links[0]));
let links = links.join("\n");
text = format!( text = format!(
"Вот что удалось мне найти в документации по запроу {}:\n\n{}", "Вот что удалось мне найти в документации по запроу {}:\n\n{}",
bold(&escape(&topic)), bold(&escape(&topic)),