cargo fmt

This commit is contained in:
Akulij 2025-04-10 20:55:32 +09:00
parent 1006fbe5c1
commit 412a54d647
3 changed files with 23 additions and 7 deletions

View File

@ -72,7 +72,9 @@ pub async fn secret_command_handler(
) -> Result<(), teloxide::RequestError> {
println!("Admin Pass: {}", admin_password);
let tguser = msg.from.clone().unwrap();
let user = db.get_or_init_user(tguser.id.0 as i64, &tguser.first_name).await;
let user = db
.get_or_init_user(tguser.id.0 as i64, &tguser.first_name)
.await;
println!("MSG: {}", msg.html_text().unwrap());
match cmd {
SecretCommands::Secret { pass } => {

View File

@ -76,7 +76,11 @@ impl DB {
match user {
Some(existing_user) => existing_user,
None => diesel::insert_into(users)
.values((id.eq(userid as i64), is_admin.eq(false), first_name.eq(firstname)))
.values((
id.eq(userid as i64),
is_admin.eq(false),
first_name.eq(firstname),
))
.get_result(connection)
.await
.unwrap(),

View File

@ -98,13 +98,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Update::filter_message()
.filter_async(async |msg: Message, mut db: DB| {
let tguser = msg.from.unwrap();
let user = db.get_or_init_user(tguser.id.0 as i64, &tguser.first_name).await;
let user = db
.get_or_init_user(tguser.id.0 as i64, &tguser.first_name)
.await;
user.is_admin
})
.enter_dialogue::<Message, PostgresStorage<Json>, State>()
.branch(
Update::filter_message()
.filter(|msg: Message| msg.text().unwrap_or("").to_lowercase().as_str() == "edit")
.filter(|msg: Message| {
msg.text().unwrap_or("").to_lowercase().as_str() == "edit"
})
.endpoint(edit_msg_cmd_handler),
)
.branch(dptree::case![State::Edit { literal, lang }].endpoint(edit_msg_handler)),
@ -250,7 +254,9 @@ fn command_handler(
dptree::entry()
.filter_async(async |msg: Message, mut db: DB| {
let tguser = msg.from.unwrap();
let user = db.get_or_init_user(tguser.id.0 as i64, &tguser.first_name).await;
let user = db
.get_or_init_user(tguser.id.0 as i64, &tguser.first_name)
.await;
user.is_admin
})
.filter_command::<AdminCommands>()
@ -265,7 +271,9 @@ async fn user_command_handler(
cmd: UserCommands,
) -> Result<(), teloxide::RequestError> {
let tguser = msg.from.clone().unwrap();
let user = db.get_or_init_user(tguser.id.0 as i64, &tguser.first_name).await;
let user = db
.get_or_init_user(tguser.id.0 as i64, &tguser.first_name)
.await;
println!("MSG: {}", msg.html_text().unwrap());
match cmd {
UserCommands::Start => {
@ -304,7 +312,9 @@ async fn answer_message<RM: Into<ReplyMarkup>>(
Some(kbd) => msg.reply_markup(kbd),
None => msg,
};
let msg = msg.parse_mode(teloxide::types::ParseMode::Html).await?;
let msg = msg.parse_mode(teloxide::types::ParseMode::Html);
println!("ENTS: {:?}", msg.entities);
let msg = msg.await?;
db.set_message_literal(msg.chat.id.0, msg.id.0, literal)
.await
.unwrap();