Please help me figure it out. The bot works fine on the local computer, however, when launched from the server, it stops seeing the token, the admin and everything that is located in the env file
from aiogram import Dispatcher, Bot, F
import asyncio
import os
from dotenv import load_dotenv
from aiogram.client.bot import DefaultBotProperties
from aiogram.enums.parse_mode import ParseMode
#Подключаем роутеры
from handlers.start.start import start_router
from handlers.profile.profile import profile_router, process_pre_checkout_query, success_payment
from handlers.search_org.search_org import search_router
from handlers.add_organization.add_organization import create_route
from handlers.history_search.history_search import history_router
from handlers.mailing.mailing import mailing_route
from handlers.view_user.view_user import view_router
load_dotenv()
token = os.getenv('TOKEN_ID')
bot = Bot(token=token, default=DefaultBotProperties(parse_mode=ParseMode.HTML))
dp = Dispatcher()
async def start_bot(bot: Bot):
await bot.send_message(chat_id=321813597, text='Справочник и парсер запущены')
#Регистрируем роутеры
dp.startup.register(start_bot)
dp.include_router(start_router)
dp.include_router(profile_router)
dp.include_router(search_router)
dp.include_router(create_route)
dp.include_router(history_router)
dp.include_router(mailing_route)
dp.include_router(view_router)
dp.pre_checkout_query.register(process_pre_checkout_query)
dp.message.register(success_payment, F.successful_payment)
async def start():
try:
await dp.start_polling(bot, skip_updates=True)
finally:
await bot.session.close()
if __name__ == '__main__':
asyncio.run(start())
The previous ones using this method (with systemd) work fine. Apparently I do not know any subtleties
New contributor
Ирина Брунёва is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.