Я создаю бота Telegram на Python, который по команде выбирает звезды репозиториев Github организации и отображает их.
Бот запускается и показывает приветственное сообщение, но не отвечает ни на какую команду, а затем падает, сообщая об ошибке,
Ошибка R10 (Тайм-аут загрузки) -> Веб-процессу не удалосьпривязка к $ PORT в течение 60 секунд после запуска 2018-11-17T17: 13: 40.232216 + 00: 00
heroku [web.1]: остановка процесса с помощью SIGKILL
2018-11-17T17: 13: 40.309943 + 00: 00 heroku [web.1]: процесс завершен со статусом 137
2018-11-17T17: 13: 40.370462 + 00: 00 heroku [web.1]: состояние изменилось с началак сбою
2018-11-17T17: 13: 41.899621 + 00: 00 heroku [роутер]: at = код ошибки = H10 desc = метод "Сбой приложения" = GET path = "/" host = gcijbossbot.herokuapp.com request_id = 4cf3c8f0-940b-4c73-aee7-842b1949e395 fwd = "115.97.36.250" dyno = connect = service = status = 503 байта = протокол = https
2018-11-17T17: 13: 44.029680+00: 00 heroku [роутер]: at = код ошибки = H10 desc = метод "приложение упало" = путь GET = "/ favicon.ico" host = gcijbossbot.herokuapp.com request_id = 94937fe2-56d2-4f4c-bad9-1fe679442db4fwd = "115.97.36.250" dyno = connect = service = status = 503 bytes = protocol = https
Я попытался переключить Procfile с
web: python Stars.py
на
worker: python Stars.py
но тогда приложение вообще не работает.
Код Stars.py:
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()
Я не использовал Django или Flask.Просто python-telegram-bot и запросы.