Compare commits
No commits in common. "cc13b3528212d3a38c99a2efabdc552908a6e910" and "a61deca6faccb25c8269f06bdc800f5204070a8f" have entirely different histories.
cc13b35282
...
a61deca6fa
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from sqlalchemy.future import Engine
|
||||||
|
|
||||||
from . import bot, cryptography, database
|
from . import bot, cryptography, database
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@ from .utils import (
|
|||||||
Message = telebot.types.Message
|
Message = telebot.types.Message
|
||||||
|
|
||||||
|
|
||||||
def get_accounts(bot: telebot.TeleBot, engine: Engine, mes: Message) -> None:
|
def get_accounts(
|
||||||
|
bot: telebot.TeleBot, engine: Engine, mes: telebot.types.Message
|
||||||
|
) -> None:
|
||||||
base_handler(bot, mes)
|
base_handler(bot, mes)
|
||||||
accounts = database.get.get_accounts(engine, mes.from_user.id)
|
accounts = database.get.get_accounts(engine, mes.from_user.id)
|
||||||
if not accounts:
|
if not accounts:
|
||||||
@ -40,7 +42,9 @@ def get_accounts(bot: telebot.TeleBot, engine: Engine, mes: Message) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete_all(bot: telebot.TeleBot, engine: Engine, mes: Message) -> None:
|
def delete_all(
|
||||||
|
bot: telebot.TeleBot, engine: Engine, mes: telebot.types.Message
|
||||||
|
) -> None:
|
||||||
base_handler(bot, mes)
|
base_handler(bot, mes)
|
||||||
bot_mes = bot.send_message(
|
bot_mes = bot.send_message(
|
||||||
mes.chat.id,
|
mes.chat.id,
|
||||||
@ -329,7 +333,7 @@ def _delete_account2(
|
|||||||
send_tmp_message(bot, mes.chat.id, "Аккаунт удалён")
|
send_tmp_message(bot, mes.chat.id, "Аккаунт удалён")
|
||||||
|
|
||||||
|
|
||||||
def help(bot: telebot.TeleBot, mes: Message) -> None:
|
def help(bot: telebot.TeleBot, mes: telebot.types.Message) -> None:
|
||||||
message = """Команды:
|
message = """Команды:
|
||||||
/set_master_pass - установить мастер пароль
|
/set_master_pass - установить мастер пароль
|
||||||
/add_account - создать аккаунт
|
/add_account - создать аккаунт
|
||||||
|
@ -11,7 +11,7 @@ from sqlalchemy.future import Engine
|
|||||||
from .. import cryptography, database
|
from .. import cryptography, database
|
||||||
|
|
||||||
|
|
||||||
class _Account(pydantic.BaseModel):
|
class Account(pydantic.BaseModel):
|
||||||
name: str
|
name: str
|
||||||
login: str
|
login: str
|
||||||
passwd: str
|
passwd: str
|
||||||
@ -25,11 +25,11 @@ class _Account(pydantic.BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class _Accounts(pydantic.BaseModel):
|
class _Accounts(pydantic.BaseModel):
|
||||||
accounts: list[_Account] = pydantic.Field(default_factory=list)
|
accounts: list[Account] = pydantic.Field(default_factory=list)
|
||||||
|
|
||||||
|
|
||||||
def _accounts_list_to_json(accounts: list[tuple[str, str, str]]) -> str:
|
def _accounts_list_to_json(accounts: list[tuple[str, str, str]]) -> str:
|
||||||
accounts = _Accounts(accounts=[_Account.from_tuple(i) for i in accounts])
|
accounts = _Accounts(accounts=[Account.from_tuple(i) for i in accounts])
|
||||||
return accounts.json()
|
return accounts.json()
|
||||||
|
|
||||||
|
|
||||||
@ -106,17 +106,17 @@ def check_account(name: str, login: str, passwd: str) -> bool:
|
|||||||
def gen_passwd() -> str:
|
def gen_passwd() -> str:
|
||||||
"""Generates password of length 32"""
|
"""Generates password of length 32"""
|
||||||
choices = SystemRandom().choices
|
choices = SystemRandom().choices
|
||||||
# Remove backtick and pipe from pucntuation
|
chars = frozenset(string.ascii_letters + string.digits + string.punctuation)
|
||||||
punctuation = set(string.punctuation).difference("`|")
|
# Remove backtick and pipe characters and convert into tuple
|
||||||
chars = tuple(string.ascii_letters + string.digits + "".join(punctuation))
|
chars = tuple(chars.difference("`|"))
|
||||||
while True:
|
while True:
|
||||||
passwd = "".join(choices(chars, k=32))
|
passwd = "".join(choices(chars, k=32))
|
||||||
|
passwd_chars = frozenset(passwd)
|
||||||
# If there is at least one lowercase character, uppercase character
|
# If there is at least one lowercase character, uppercase character
|
||||||
# and one punctuation character
|
# and one punctuation character
|
||||||
if (
|
if (
|
||||||
any(c.islower() for c in passwd)
|
passwd_chars.intersection(string.ascii_lowercase)
|
||||||
and any(c.isupper() for c in passwd)
|
and passwd_chars.intersection(string.ascii_uppercase)
|
||||||
and any(c.isdigit() for c in passwd)
|
and passwd_chars.intersection(string.punctuation)
|
||||||
and any(c in punctuation for c in passwd)
|
|
||||||
):
|
):
|
||||||
return passwd
|
return passwd
|
||||||
|
Reference in New Issue
Block a user