impl Display for User so logging would be easy

This commit is contained in:
mykola2312 2024-03-02 18:55:23 +02:00
parent 8d50da9ead
commit 197429a422
2 changed files with 9 additions and 7 deletions

View file

@ -33,12 +33,7 @@ pub async fn cmd_op(bot: Bot, msg: Message, db: DbPool) -> HandlerResult {
.execute(&db) .execute(&db)
.await?; .await?;
event!( event!(Level::INFO, "opped {}", target);
Level::INFO,
"opped {} - {}",
target.tg_id,
target.username_or_name()
);
bot.send_message(msg.chat.id, "opped").await?; bot.send_message(msg.chat.id, "opped").await?;
} else { } else {
bot.send_message(msg.chat.id, "You have to reply on target's message") bot.send_message(msg.chat.id, "You have to reply on target's message")

View file

@ -1,6 +1,6 @@
use sqlx::migrate::MigrateDatabase; use sqlx::migrate::MigrateDatabase;
use sqlx::{Sqlite, SqlitePool}; use sqlx::{Sqlite, SqlitePool};
use std::sync::Arc; use std::fmt;
use super::util::make_database_url; use super::util::make_database_url;
@ -15,6 +15,13 @@ pub struct User {
pub last_name: Option<String>, pub last_name: Option<String>,
pub can_download: i64, pub can_download: i64,
pub is_admin: i64, pub is_admin: i64,
pub has_private_chat: i64,
}
impl fmt::Display for User {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} - {}", self.tg_id, self.username_or_name())
}
} }
impl User { impl User {