mirror of
https://github.com/house-of-vanity/desubot.git
synced 2025-07-09 05:14:07 +00:00
Fix add_conf
This commit is contained in:
16
src/db.rs
16
src/db.rs
@ -149,6 +149,7 @@ pub(crate) async fn add_conf(message: Message) -> Result<(), Error> {
|
|||||||
|
|
||||||
match get_conf(message.chat.id()) {
|
match get_conf(message.chat.id()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
//info!("Group found: {:?}", message.chat.id());
|
||||||
let update = Conf {
|
let update = Conf {
|
||||||
id: message.chat.id(),
|
id: message.chat.id(),
|
||||||
title,
|
title,
|
||||||
@ -162,9 +163,11 @@ pub(crate) async fn add_conf(message: Message) -> Result<(), Error> {
|
|||||||
id = :id",
|
id = :id",
|
||||||
)?;
|
)?;
|
||||||
stmt.execute_named(&[(":id", &update.id.to_string()), (":title", &update.title)])?;
|
stmt.execute_named(&[(":id", &update.id.to_string()), (":title", &update.title)])?;
|
||||||
info!("Conf {:?} updated: {:?}", update.title, get_conf(update.id));
|
//info!("Conf {:?} updated: {:?}", update.title, get_conf(update.id));
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
//info!("Group didn't found: {:?}", message.chat.id());
|
||||||
|
|
||||||
let update = Conf {
|
let update = Conf {
|
||||||
id: message.chat.id(),
|
id: message.chat.id(),
|
||||||
title,
|
title,
|
||||||
@ -173,19 +176,16 @@ pub(crate) async fn add_conf(message: Message) -> Result<(), Error> {
|
|||||||
let unix_time = utils::unixtime().await;
|
let unix_time = utils::unixtime().await;
|
||||||
|
|
||||||
let mut stmt = conn.prepare_cached(
|
let mut stmt = conn.prepare_cached(
|
||||||
"INSERT OR IGNORE INTO conf
|
"INSERT OR IGNORE INTO
|
||||||
SET
|
conf('id', 'title', 'date')
|
||||||
title = :title,
|
VALUES (:id, :title, :date)",
|
||||||
date = :date
|
|
||||||
WHERE
|
|
||||||
id = :id",
|
|
||||||
)?;
|
)?;
|
||||||
stmt.execute_named(&[
|
stmt.execute_named(&[
|
||||||
(":id", &update.id.to_string()),
|
(":id", &update.id.to_string()),
|
||||||
(":title", &update.title),
|
(":title", &update.title),
|
||||||
(":date", &unix_time),
|
(":date", &unix_time),
|
||||||
])?;
|
])?;
|
||||||
//println!("Conf {:?} added: {:?}", update.title, get_conf(update.id));
|
//info!("Conf {:?} added: {:?}", update.title, get_conf(update.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Reference in New Issue
Block a user