hosting python telegram bot on heroku
<p>I have a <code>.py</code> file with some code to run a <code>telegram bot</code> and it works fine on my local machine but when i push my code into <code>heroku</code> it doesn't work, i mean the file is not running to receive and send messages but when i enter the bash in <code>heroku</code> and run the <code>.py</code> file manually it works fine.<br>
I apply some changes in <code>Procfile</code> but i do not know how to tell <code>heroku</code> to run the <code>.py</code> file automatically.<br>
I also tried to wrap my <code>bot</code> code inside a flask app and again it works perfect on local machine, but on the <code>heroku</code> the flask requests handled successfully but the bot inside the code doesn't work again.<br>
Here is the code:</p>

<pre><code>from flask import Flask
import time
import os
import telepot
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine, Column, Integer, PickleType, String
from sqlalchemy.orm import sessionmaker
from flask.ext.heroku import Heroku

app = Flask(__name__)
app.config['SECRET_KEY'] = "random string"
heroku = Heroku(app)

@app.route('/')  # the requests handled successfully!
def hello_world():
    return 'Hello World!'

# the bot code deleted to simplify

uri = os.environ.get('DATABASE_URL')
engine = create_engine(uri)
Base = declarative_base()


if __name__ == '__main__':
    Base.metadata.create_all(engine)
    global session
    Session = sessionmaker(bind=engine)
    session = Session()

    TOKEN = 'token'

    bot = MyBot(TOKEN)  # the bot stuff here
    bot.message_loop()  # but the bot stuff just doesn't work

    # i also removed incoming 2 lines and let it be the default but has no effect 
    port = int(os.environ.get("PORT", 5000))  

    app.run(host='0.0.0.0', port=port)
    while 1:
        time.sleep(10)

    engine.dispose()
</code></pre>

<p>I checked the log from <code>heroku</code> there was no error, but the <code>bot</code> code doesn't work.<br>
So what is the problem in the "flask wrapped" <code>bot</code> AND how can i just simply tell the <code>heroku</code> to run a python file and let it be?</p>