mirror of
https://github.com/djimboy/djimbo_template_aio3.git
synced 2026-07-25 09:44:29 +00:00
-Update
This commit is contained in:
@@ -6,6 +6,7 @@ from aiogram.types import Message, CallbackQuery
|
||||
from tgbot.keyboards.inline_main import menu_finl
|
||||
from tgbot.keyboards.inline_misc import user_inl
|
||||
from tgbot.keyboards.reply_misc import user_rep
|
||||
from tgbot.utils.const_functions import convert_date
|
||||
from tgbot.utils.misc.bot_models import FSM, RS
|
||||
|
||||
router = Router()
|
||||
|
||||
@@ -45,9 +45,9 @@ def add_userx(user_id, user_login, user_name, user_surname, user_fullname):
|
||||
with sqlite3.connect(PATH_DATABASE) as con:
|
||||
con.row_factory = dict_factory
|
||||
con.execute("INSERT INTO storage_users "
|
||||
"(user_id, user_login, user_name, user_surname, user_fullname, user_date, user_unix) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
[user_id, user_login, user_name, user_surname, user_fullname, get_date(), get_unix()])
|
||||
"(user_id, user_login, user_name, user_surname, user_fullname, user_unix) "
|
||||
"VALUES (?, ?, ?, ?, ?, ?)",
|
||||
[user_id, user_login, user_name, user_surname, user_fullname, get_unix()])
|
||||
|
||||
|
||||
# Получение пользователя
|
||||
@@ -102,7 +102,7 @@ def create_dbx():
|
||||
con.row_factory = dict_factory
|
||||
|
||||
# Таблица с хранением пользователей
|
||||
if len(con.execute("PRAGMA table_info(storage_users)").fetchall()) == 8:
|
||||
if len(con.execute("PRAGMA table_info(storage_users)").fetchall()) == 7:
|
||||
print("DB was found(1/1)")
|
||||
else:
|
||||
con.execute("CREATE TABLE storage_users("
|
||||
@@ -112,7 +112,6 @@ def create_dbx():
|
||||
"user_name TEXT,"
|
||||
"user_surname TEXT,"
|
||||
"user_fullname TEXT,"
|
||||
"user_date TIMESTAMP,"
|
||||
"user_unix INTEGER"
|
||||
")")
|
||||
print("DB was not found(1/1) | Creating...")
|
||||
|
||||
@@ -120,18 +120,34 @@ def split_messages(get_list: list, count: int) -> list[list]:
|
||||
|
||||
|
||||
# Получение даты
|
||||
def get_date() -> str:
|
||||
return datetime.now(pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y %H:%M:%S")
|
||||
def get_date(full: bool = True) -> str:
|
||||
if full: # Полная дата с временем
|
||||
return datetime.now(pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y %H:%M:%S")
|
||||
else: # Только дата без времени
|
||||
return datetime.now(pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y")
|
||||
|
||||
|
||||
# Получение юникс даты
|
||||
# Получение unix времени
|
||||
def get_unix(full: bool = False) -> int:
|
||||
if full:
|
||||
if full: # Время в наносекундах
|
||||
return time.time_ns()
|
||||
else:
|
||||
else: # Время в секундах
|
||||
return int(time.time())
|
||||
|
||||
|
||||
# Конвертация unix в дату и наоборот, дату в unix
|
||||
def convert_date(from_time):
|
||||
if str(from_time).isdigit():
|
||||
to_time = datetime.fromtimestamp(from_time, pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y %H:%M:%S")
|
||||
else:
|
||||
if " " in str(from_time):
|
||||
to_time = int(datetime.strptime(from_time, "%d.%m.%Y %H:%M:%S").timestamp())
|
||||
else:
|
||||
to_time = int(datetime.strptime(from_time, "%d.%m.%Y").timestamp())
|
||||
|
||||
return to_time
|
||||
|
||||
|
||||
# Генерация пароля
|
||||
def gen_password(len_password: int = 16, type_password: str = "default") -> str: # default, number, letter, onechar
|
||||
if type_password == "default":
|
||||
|
||||
Reference in New Issue
Block a user