mirror of
https://github.com/house-of-vanity/desubot.git
synced 2025-07-08 13:04:06 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
77dec205f1 | |||
6c761d7576 | |||
865fd3bbe4 | |||
30bdb23a32 |
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "desubot"
|
||||
version = "0.5.1"
|
||||
version = "0.5.4"
|
||||
authors = ["AB <ab@hexor.ru>"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -192,7 +192,7 @@ impl Execute for Sql {
|
||||
#[async_trait]
|
||||
impl Execute for Here {
|
||||
async fn exec(&self, api: &Api, message: &Message) -> Result<(), Error> {
|
||||
let members: Vec<telegram_bot::User> = db::get_members(message.chat.id()).unwrap();
|
||||
let members: Vec<telegram_bot::User> = db::get_members(message.chat.id(), 60).unwrap();
|
||||
for u in &members {
|
||||
debug!("Found user {:?} in chat {}", u, message.chat.id());
|
||||
}
|
||||
|
18
src/db.rs
18
src/db.rs
@ -180,17 +180,27 @@ pub(crate) async fn get_messages_user_all(
|
||||
Ok(messages)
|
||||
}
|
||||
|
||||
pub(crate) fn get_members(id: telegram_bot::ChatId) -> Result<Vec<telegram_bot::User>> {
|
||||
pub(crate) fn get_members(id: telegram_bot::ChatId, limit: u32) -> Result<Vec<telegram_bot::User>> {
|
||||
let where_statement = if limit > 0 {
|
||||
format!("and days_seen <= {}", limit)
|
||||
} else {
|
||||
"".into()
|
||||
};
|
||||
debug!("{}", where_statement);
|
||||
let conn = open()?;
|
||||
let mut stmt = conn.prepare_cached(
|
||||
"
|
||||
SELECT DISTINCT(u.username), u.id, u.first_name, u.last_name, u.date
|
||||
&format!("
|
||||
SELECT DISTINCT(u.username), u.id, u.first_name, u.last_name, u.date,
|
||||
(strftime('%s','now')-r.date)/60/60/24 as days_seen
|
||||
FROM relations r
|
||||
JOIN user u
|
||||
ON u.id = r.user_id
|
||||
LEFT JOIN conf c
|
||||
ON r.conf_id = c.id
|
||||
WHERE c.id = :id",
|
||||
WHERE c.id = :id
|
||||
{}
|
||||
GROUP BY u.id
|
||||
ORDER BY r.date DESC", where_statement),
|
||||
)?;
|
||||
let mut rows = stmt.query_named(&[(":id", &id.to_string())])?;
|
||||
let mut users = Vec::new();
|
||||
|
@ -53,7 +53,7 @@ pub async fn handler(
|
||||
}
|
||||
}
|
||||
}
|
||||
s if s.contains("/here") => {
|
||||
s if s.contains("/here") || s.contains("@here") => {
|
||||
db::add_sentence(&message, mystem).await?;
|
||||
Here {
|
||||
data: "".to_string(),
|
||||
|
Reference in New Issue
Block a user