This commit is contained in:
dj
2023-09-24 13:04:45 +03:00
parent fc98213031
commit edc617bb38
14 changed files with 114 additions and 92 deletions
+10 -2
View File
@@ -6,7 +6,7 @@ from typing import Union
import pytz
from aiogram import Bot, types
from aiogram.types import InlineKeyboardButton, KeyboardButton, WebAppInfo
from aiogram.types import InlineKeyboardButton, KeyboardButton, WebAppInfo, Message
from tgbot.data.config import get_admins, BOT_TIMEZONE
@@ -29,6 +29,14 @@ def ikb(text: str, data: str = None, url: str = None, switch: str = None, web: s
return InlineKeyboardButton(text=text, web_app=WebAppInfo(url=web))
# Удаление сообщений с обработкой ошибки от телеграма
async def del_message(message: Message):
try:
await message.delete()
except:
...
# Отправка сообщения всем админам
async def send_admins(bot: Bot, text: str, markup=None, not_me=0):
for admin in get_admins():
@@ -36,7 +44,7 @@ async def send_admins(bot: Bot, text: str, markup=None, not_me=0):
if str(admin) != str(not_me):
await bot.send_message(admin, text, reply_markup=markup, disable_web_page_preview=True)
except:
pass
...
# Умная отправка сообщений
+6 -6
View File
@@ -6,16 +6,16 @@ from tgbot.data.config import get_admins
# Команды для юзеров
user_commands = [
BotCommand(command="start", description=" Перезапустить бота"),
BotCommand(command="inline", description="🌀 Получить Inline клавиатуру"),
BotCommand(command="start", description=" Restart bot"),
BotCommand(command="inline", description="🌀 Get Inline keyboard"),
]
# Команды для админов
admin_commands = [
BotCommand(command="start", description=" Перезапустить бота"),
BotCommand(command="inline", description="🌀 Получить Inline клавиатуру"),
BotCommand(command="log", description="🖨 Получить Логи"),
BotCommand(command="db", description="📦 Получить Базу Данных"),
BotCommand(command="start", description=" Restart bot"),
BotCommand(command="inline", description="🌀 Get Inline keyboard"),
BotCommand(command="log", description="🖨 Get Logs"),
BotCommand(command="db", description="📦 Get Database"),
]
+1 -1
View File
@@ -9,7 +9,7 @@ from tgbot.utils.const_functions import get_date, send_admins
# Выполнение функции после запуска бота (рассылка админам о запуске бота)
async def startup_notify(bot: Bot):
if len(get_admins()) >= 1 and start_status:
await send_admins(bot, "<b>✅ Бот был запущен</b>")
await send_admins(bot, "<b>✅ Bot was started</b>")
# Автоматические бэкапы БД