ложиться бот на хероку
Написал телеграм бота на пайтоне с деплоем на хероку, но из-за неизвестной мне причине он ставит статус crash, а не up
bot.py
import asyncio
import logging
from aiogram import Bot, Dispatcher
from config import BOT_TOKEN
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram import types
import random
logger = logging.getLogger(__name__)
async def main():
logging.basicConfig(
level = logging.INFO,
format = u'%(filename)s:%(lineno)d #%(levelname)-8s [%(asctime)s] - %(name)s - %(message)s'
)
logger.info("Starting bot")
bot = Bot(token=BOT_TOKEN, parse_mode="HTML")
storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)
with open("Compliment_Bot/complimets.txt", "r", encoding="utf-8") as f:
compliments = f.readlines()
@dp.message_handler(content_types=(types.ContentTypes.PHOTO | types.ContentTypes.VIDEO | types.ContentTypes.VIDEO_NOTE))
async def compliment(message: types.Message):
await bot.send_message(
message.from_user.id,
text=random.choice(compliments),
)
try:
await dp.start_polling()
finally:
await dp.storage.close()
await dp.storage.wait_closed()
await bot.session.close()
if __name__ == "__main__":
try:
asyncio.run(main())
except (KeyboardInterrupt, SystemExit):
logger.error("Bot stopped!")
requirements.txt
aiogram==2.20
aiohttp==3.8.1
aiosignal==1.2.0
APScheduler==3.6.3
asgiref==3.5.2
async-timeout==4.0.2
asyncio==3.4.3
attrs==21.4.0
Babel==2.9.1
cachetools==4.2.2
certifi==2021.10.8
charset-normalizer==2.0.12
configparser==5.2.0
Django==4.0.4
frozenlist==1.3.0
idna==3.3
magic-filter==1.0.7
multidict==6.0.2
pydantic==1.9.1
Pygments==2.12.0
python-telegram-bot==13.11
pytz==2022.1
pytz-deprecation-shim==0.1.0.post0
six==1.16.0
sqlparse==0.4.2
telegram==0.0.1
telegramApi==1.5
tornado==6.1
typing_extensions==4.2.0
tzdata==2022.1
tzlocal==4.2
yarl==1.7.2
runtime.txt
python-3.10.4
Procfile
worker: python bot.py
Логи Herocu:
2022-07-24T20:46:30.866988+00:00 heroku[worker.1]: State changed from up to crashed
2022-07-24T20:46:30.876693+00:00 heroku[worker.1]: State changed from crashed to starting
2022-07-24T20:46:36.040469+00:00 heroku[worker.1]: Starting process with command `python bot.py`
2022-07-24T20:46:36.652200+00:00 heroku[worker.1]: State changed from starting to up
2022-07-24T20:46:37.344229+00:00 app[worker.1]: bot.py:21 #INFO [2022-07-24 20:46:37,344] - __main__ - Starting bot
2022-07-24T20:46:37.352943+00:00 app[worker.1]: Traceback (most recent call last):
2022-07-24T20:46:37.352950+00:00 app[worker.1]: File "/app/bot.py", line 49, in <module>
2022-07-24T20:46:37.353033+00:00 app[worker.1]: asyncio.run(main())
2022-07-24T20:46:37.353042+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.10/asyncio/runners.py", line 44, in run
2022-07-24T20:46:37.353110+00:00 app[worker.1]: return loop.run_until_complete(main)
2022-07-24T20:46:37.353118+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
2022-07-24T20:46:37.353273+00:00 app[worker.1]: return future.result()
2022-07-24T20:46:37.353283+00:00 app[worker.1]: File "/app/bot.py", line 27, in main
2022-07-24T20:46:37.353335+00:00 app[worker.1]: with open("Compliment_Bot\complimets.txt", "r", encoding="utf-8") as f:
2022-07-24T20:46:37.353358+00:00 app[worker.1]: FileNotFoundError: [Errno 2] No such file or directory: 'Compliment_Bot\\complimets.txt'
2022-07-24T20:46:37.508075+00:00 heroku[worker.1]: Process exited with status 1
2022-07-24T20:46:37.623719+00:00 heroku[worker.1]: State changed from up to crashed
Подключал хероку через гит