I'm building a Telegram bot in Python which fetches stars of Github repos of an organisation on command and displays them.
The bot runs and shows the welcome message but doesn't respond to any command and then crashes giving the error,
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2018-11-17T17:13:40.232216+00:00
heroku[web.1]: Stopping process with SIGKILL
2018-11-17T17:13:40.309943+00:00 heroku[web.1]: Process exited with status 137
2018-11-17T17:13:40.370462+00:00 heroku[web.1]: State changed from starting to crashed
2018-11-17T17:13:41.899621+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gcijbossbot.herokuapp.com request_id=4cf3c8f0-940b-4c73-aee7-842b1949e395 fwd="115.97.36.250" dyno= connect= service= status=503 bytes= protocol=https
2018-11-17T17:13:44.029680+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gcijbossbot.herokuapp.com request_id=94937fe2-56d2-4f4c-bad9-1fe679442db4 fwd="115.97.36.250" dyno= connect= service= status=503 bytes= protocol=https
I tried switching the Procfile from
web: python Stars.py
to
worker: python Stars.py
but then the app doesn't work at all.
Stars.py code:
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import requests
def start(bot, update):
update.message.reply_text('Ahoy {}! Welcome to JBossStarsBot. \n\nTo get started, use the /stars command to fetch the stars from the GitHub repos of JBoss'.format(update.message.from_user.first_name))
def stars(bot, update):
api = requests.get('https://api.github.com/orgs/JBossOutreach/repos')
json = api.json()
stars = ''
for i in range(len(json)):
stars = stars + '\n' + res[i]['name'] + ' : ' + str(res[i]['stargazers_count'])
update.message.reply_text('Here\'s the list of all the JBoss repositories on GitHub along with their respective star count. \n\n' + stars + '\n\nTo get the stars of a specific repository, enter the name of the repository.')
def repo_stars(bot, update):
api = requests.get('https://api.github.com/orgs/JBossOutreach')
json = api.json()
star = ''
for i in range(len(json)):
cur = res[i]['name']
if cur == update.message.text:
star = star + cur + ' : ' + str(res[i]['stargazers_count'])
if cur == '':
star = 'No such repository found.'
bot.send_message(update.message.chat_id, star)
def main():
updater = Updater(token)
dp = updater.dispatcher
dp.add_handler(CommandHandler('start', start))
dp.add_handler(CommandHandler('stars', stars))
dp.add_handler(MessageHandler(Filters.text, repo_stars))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
I haven't used Django, or Flask. Simply python-telegram-bot and requests.
Stars.py
? How do you set up your server to listen? We can't help with code we can't see. – Chris