如何解决Heroku 上的 Telegram Bot,找不到应用 URL
我正在尝试在 Heroku 上托管一个电报机器人。我现在已经在 main
部署了它。这是我第一次在 Heroku 上工作,我想我在这一步搞砸了。当我运行此命令时。
git push heroku master
我明白
error: src refspec master does not match any
error: failed to push some refs to 'https://git.heroku.com/abhisjokebot.git'
我猜这就是我的应用程序出现 404 Not Found 的原因,尽管所有其他信息似乎都是正确的。
user.email= my email
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.heroku.url=git@heroku.com:abhisjokebot.git #Correct
remote.heroku.fetch=+refs/heads/*:refs/remotes/heroku/*
这是我向机器人发送 /start
时的错误。
updater.bot.setWebhook('https://abhisjokebot.herokuapp.com' + TOKEN)
2021-01-02T13:06:32.714939+00:00 app[web.1]: File "<decorator-gen-32>",line 2,in set_webhook
2021-01-02T13:06:32.714944+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/telegram/bot.py",line 70,in decorator
2021-01-02T13:06:32.714945+00:00 app[web.1]: result = func(*args,**kwargs)
2021-01-02T13:06:32.714951+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/telegram/bot.py",line 2240,in set_webhook
2021-01-02T13:06:32.714952+00:00 app[web.1]: result = self._request.post(url_,data,timeout=timeout)
2021-01-02T13:06:32.714952+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/telegram/utils/request.py",line 334,in post
2021-01-02T13:06:32.714957+00:00 app[web.1]: **urlopen_kwargs)
2021-01-02T13:06:32.714961+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/telegram/utils/request.py",line 245,in _request_wrapper
2021-01-02T13:06:32.714962+00:00 app[web.1]: raise BadRequest(message)
2021-01-02T13:06:32.714962+00:00 app[web.1]: telegram.error.BadRequest: Bad webhook: failed to resolve host: name or service not known
我将它用作网络钩子。端口设置为 5000
updater.start_webhook(listen="0.0.0.0",port=int(PORT),url_path=TOKEN)
updater.bot.setWebhook('https://abhisjokebot.herokuapp.com' + TOKEN)
解决方法
您需要在 TOKEN
前加一个斜杠
updater.bot.setWebhook('https://abhisjokebot.herokuapp.com/' + TOKEN)
git push 是一个不同的问题,似乎你不能推送更改(你提交了最新的更改吗?)。你可以尝试重新创建你的 git repo。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。