This commit is contained in:
dj
2023-11-11 05:35:49 +03:00
parent 5ccbcee782
commit c29bb3d9b8
+25 -1
View File
@@ -7,7 +7,8 @@ from typing import Union
import pytz import pytz
from aiogram import Bot from aiogram import Bot
from aiogram.types import InlineKeyboardButton, KeyboardButton, WebAppInfo, Message from aiogram.types import InlineKeyboardButton, KeyboardButton, WebAppInfo, Message, InlineKeyboardMarkup, \
ReplyKeyboardMarkup
from tgbot.data.config import get_admins, BOT_TIMEZONE from tgbot.data.config import get_admins, BOT_TIMEZONE
@@ -38,6 +39,29 @@ async def del_message(message: Message):
... ...
# Умная отправка сообщений (автоотправка сообщения с фото или без)
async def smart_message(
bot: Bot,
user_id: int,
text: str,
keyboard: Union[InlineKeyboardMarkup, ReplyKeyboardMarkup] = None,
photo: Union[str, 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,
)
# Отправка сообщения всем админам # Отправка сообщения всем админам
async def send_admins(bot: Bot, text: str, markup=None, not_me=0): async def send_admins(bot: Bot, text: str, markup=None, not_me=0):
for admin in get_admins(): for admin in get_admins():