moving logic from bot.py to adapter.py