I've got a simple Telegram bot, I don't think the code matters but I used telebot library.
I uploaded it to pythonanywhere, installed virtual environment and all libraries that needed. 
Whenever I type python.script.py in the bash console, script works for, say, 5 hours, then it stops. How do I make it run forever?
PythonAnywhere does not keep consoles running forever. They need to be stopped on occasion to manage the service. See the PythonAnywhere documentation for details about keeping tasks running.
Telegram bot stops after a few hours on pythonanywhere