19 lines
557 B
Rust
19 lines
557 B
Rust
use sea_orm::prelude::*;
|
|
use teloxide::{adaptors::Throttle, prelude::*};
|
|
|
|
use crate::entity::account;
|
|
|
|
pub async fn add_account(
|
|
bot: Throttle<Bot>,
|
|
msg: Message,
|
|
db: DatabaseConnection,
|
|
(name, login, password, master_pass): (String, String, String, String),
|
|
) -> crate::Result<()> {
|
|
let user_id = msg.from().unwrap().id.0;
|
|
let account =
|
|
account::ActiveModel::from_unencrypted(user_id, name, &login, &password, &master_pass)?;
|
|
account.insert(&db).await?;
|
|
bot.send_message(msg.chat.id, "Success").await?;
|
|
Ok(())
|
|
}
|