-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBot.py
More file actions
40 lines (27 loc) · 1.3 KB
/
Bot.py
File metadata and controls
40 lines (27 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from aiogram import Bot, Dispatcher, executor
from dotenv import load_dotenv
import callbacks as call
from callbacks import *
if os.path.exists(".env"):
load_dotenv()
print("Environment variables loaded successfully!")
else:
print(".env file not found.\n")
bot = Bot(os.getenv("API_BOT"))
dp = Dispatcher(bot)
@dp.message_handler(commands=['start']) # команда старт
async def process_start_command(message: types.Message):
await message.reply(f"Привет, {message.from_user.first_name}!\n"
"Нажми на /let_us_go_study, чтобы приступить к решению задач.")
@dp.callback_query_handler() # callback данные
async def handle_callback_query(callback_query: types.CallbackQuery):
await call.callback_query_data(callback_query, bot)
@dp.message_handler(commands=['let_us_go_study']) # 'главная' команда для запуска
async def type_list_command(message: types.Message):
await message.answer("Выберите нужный вам тип решения задач", reply_markup=task_type_list)
if __name__ == '__main__':
try:
print("бот запущен")
executor.start_polling(dp, skip_updates=True)
except Exception as e:
print(f"Произошла ошибка: {e}")