Fix add_conf

This commit is contained in:
AB
2020-12-10 17:11:09 +03:00
parent 72a35058a8
commit 7aedf69839

View File

@ -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(())