mirror of
https://github.com/djimboy/djimbo_template_aio3.git
synced 2026-07-25 09:44:29 +00:00
Update aiogram 3 template
This commit is contained in:
@@ -2,24 +2,28 @@
|
||||
from aiogram import Bot
|
||||
from aiogram.types import FSInputFile
|
||||
|
||||
from tgbot.data.config import get_admins, PATH_DATABASE, BOT_STATUS_NOTIFICATION
|
||||
from tgbot.data.config import BOT_DATABASE_EXPORT, BOT_STATUS_NOTIFICATION, PATH_DATABASE, get_admins
|
||||
from tgbot.utils.const_functions import get_date, send_admins
|
||||
from tgbot.utils.misc.bot_logging import bot_logger
|
||||
|
||||
|
||||
# Notification after run bot (for all admins)
|
||||
# Уведомление админам после запуска
|
||||
async def startup_notify(bot: Bot):
|
||||
if len(get_admins()) >= 1 and BOT_STATUS_NOTIFICATION:
|
||||
await send_admins(bot, "<b>✅ Bot was started</b>")
|
||||
await send_admins(bot, "<b>✅ Бот запущен</b>")
|
||||
|
||||
|
||||
# Autobackup Database
|
||||
# Автобэкап базы для админов
|
||||
async def autobackup_admin(bot: Bot):
|
||||
if not BOT_DATABASE_EXPORT:
|
||||
return
|
||||
|
||||
for admin in get_admins():
|
||||
try:
|
||||
await bot.send_document(
|
||||
admin,
|
||||
FSInputFile(PATH_DATABASE),
|
||||
caption=f"<b>📦 #AUTOBACKUP | <code>{get_date()}</code></b>",
|
||||
caption=f"<b>📦 #АВТОБЭКАП | <code>{get_date()}</code></b>",
|
||||
)
|
||||
except:
|
||||
...
|
||||
except Exception:
|
||||
bot_logger.warning("Не удалось отправить автобэкап админу %s", admin, exc_info=True)
|
||||
|
||||
Reference in New Issue
Block a user