Simplify SQL command. Add limit.

This commit is contained in:
AB
2021-01-05 03:30:21 +03:00
parent 83a6045b18
commit 47906fe22d
3 changed files with 136 additions and 185 deletions

View File

@ -1,5 +1,5 @@
//use crate::commands::Command;
use crate::commands::{Execute, Here, Markov, MarkovAll, Omedeto, Sql, Top};
use crate::commands::{Code, Execute, Here, Markov, MarkovAll, Omedeto, Sql, Top};
use crate::db;
use crate::errors;
use crate::utils;
@ -31,49 +31,60 @@ pub async fn handler(
Here {
data: "".to_string(),
}
.run(api, message)
.run(&api, &message)
.await?
}
s if s.to_string().starts_with("/sql") => {
s if s.to_string().starts_with("/sql") => match {
Sql {
data: s.replace("/sql ", ""),
}
.run(api, message)
.await?
}
.run(&api, &message)
.await
} {
Ok(_) => debug!("/sql command sent to {}", message.chat.id()),
Err(e) => {
api.send(
message
.text_reply(format!("Error: {:#?}", e))
.parse_mode(ParseMode::Html),
)
.await?;
()
}
},
"/top" => {
Top {
data: "".to_string(),
}
.run(api, message)
.run(&api, &message)
.await?
}
"/stat" => {
Top {
data: "".to_string(),
}
.run(api, message)
.run(&api, &message)
.await?
}
"/markov_all" => {
MarkovAll {
data: "".to_string(),
}
.run(api, message)
.run(&api, &message)
.await?
}
"/markov" => {
Markov {
data: "".to_string(),
}
.run(api, message)
.run(&api, &message)
.await?
}
"/omedeto" => {
Omedeto {
data: "".to_string(),
}
.run_mystem(api, message, mystem)
.run_mystem(&api, &message, mystem)
.await?
}
_ => (),