forked from FOSS/AutoShop-Djimbo
refactor: remove Alembic migrations and Discord integration
This commit is contained in:
@@ -29,13 +29,13 @@ def rkb(text: str) -> KeyboardButton:
|
||||
|
||||
# Быстрая сборка inline-кнопки
|
||||
def ikb(
|
||||
text: str,
|
||||
data: Optional[str] = None,
|
||||
url: Optional[str] = None,
|
||||
switch: Optional[str] = None,
|
||||
web: Optional[str] = None,
|
||||
copy: Optional[str] = None,
|
||||
login: Optional[str] = None,
|
||||
text: str,
|
||||
data: Optional[str] = None,
|
||||
url: Optional[str] = None,
|
||||
switch: Optional[str] = None,
|
||||
web: Optional[str] = None,
|
||||
copy: Optional[str] = None,
|
||||
login: Optional[str] = None,
|
||||
) -> InlineKeyboardButton:
|
||||
if data is not None:
|
||||
return InlineKeyboardButton(text=text, callback_data=data)
|
||||
@@ -61,36 +61,27 @@ async def del_message(message: Message) -> None:
|
||||
bot_logger.debug("Не удалось удалить сообщение", exc_info=True)
|
||||
|
||||
|
||||
# Отправка фото или обычного сообщения
|
||||
# Отправка обычного сообщения
|
||||
async def smart_message(
|
||||
bot: Bot,
|
||||
user_id: int,
|
||||
text: str,
|
||||
keyboard: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = None,
|
||||
photo: Optional[str] = None,
|
||||
bot: Bot,
|
||||
user_id: int,
|
||||
text: str,
|
||||
keyboard: Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup]] = None,
|
||||
) -> None:
|
||||
if photo is not None and photo.title() != "None":
|
||||
await bot.send_photo(
|
||||
chat_id=user_id,
|
||||
photo=photo,
|
||||
caption=text,
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
else:
|
||||
await bot.send_message(
|
||||
chat_id=user_id,
|
||||
text=text,
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
await bot.send_message(
|
||||
chat_id=user_id,
|
||||
text=text,
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
|
||||
|
||||
# Отправка сообщения всем админам
|
||||
async def send_admins(
|
||||
bot: Bot,
|
||||
text: str,
|
||||
keyboard: Optional[InlineKeyboardMarkup] = None,
|
||||
markup: Optional[InlineKeyboardMarkup] = None,
|
||||
not_me: int = 0,
|
||||
bot: Bot,
|
||||
text: str,
|
||||
keyboard: Optional[InlineKeyboardMarkup] = None,
|
||||
markup: Optional[InlineKeyboardMarkup] = None,
|
||||
not_me: int = 0,
|
||||
) -> None:
|
||||
reply_markup = markup or keyboard
|
||||
|
||||
@@ -104,7 +95,9 @@ async def send_admins(
|
||||
disable_web_page_preview=True,
|
||||
)
|
||||
except Exception:
|
||||
bot_logger.warning("Не удалось отправить сообщение админу %s", admin, exc_info=True)
|
||||
bot_logger.warning(
|
||||
"Не удалось отправить сообщение админу %s", admin, exc_info=True
|
||||
)
|
||||
|
||||
|
||||
# Логирование ошибки и отправка админам
|
||||
@@ -120,8 +113,10 @@ def ded(get_text: str) -> str:
|
||||
if get_text is not None:
|
||||
split_text = get_text.split("\n")
|
||||
|
||||
if split_text[0] == "": split_text.pop(0)
|
||||
if split_text[-1] == "": split_text.pop()
|
||||
if split_text[0] == "":
|
||||
split_text.pop(0)
|
||||
if split_text[-1] == "":
|
||||
split_text.pop()
|
||||
save_text = []
|
||||
|
||||
for text in split_text:
|
||||
@@ -163,7 +158,7 @@ def convert_list(get_lists: List[list]) -> list:
|
||||
|
||||
# Разделение списка на части нужного размера
|
||||
def split_list(get_list: list, count: int) -> List[list]:
|
||||
return [get_list[i:i + count] for i in range(0, len(get_list), count)]
|
||||
return [get_list[i : i + count] for i in range(0, len(get_list), count)]
|
||||
|
||||
|
||||
# Старое имя для разделения сообщений
|
||||
@@ -198,9 +193,13 @@ def convert_date(from_time, full=True, second=True) -> Union[str, int]:
|
||||
from_timestamp = int(from_time)
|
||||
|
||||
if full:
|
||||
return datetime.fromtimestamp(from_timestamp, bot_timezone).strftime("%d.%m.%Y %H:%M:%S")
|
||||
return datetime.fromtimestamp(from_timestamp, bot_timezone).strftime(
|
||||
"%d.%m.%Y %H:%M:%S"
|
||||
)
|
||||
if second:
|
||||
return datetime.fromtimestamp(from_timestamp, bot_timezone).strftime("%d.%m.%Y %H:%M")
|
||||
return datetime.fromtimestamp(from_timestamp, bot_timezone).strftime(
|
||||
"%d.%m.%Y %H:%M"
|
||||
)
|
||||
|
||||
return datetime.fromtimestamp(from_timestamp, bot_timezone).strftime("%d.%m.%Y")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user