我目前正在使用Python语言创建一个不和谐机器人--特别是通过JetBrains的PyCharms集成开发环境。我使用PyCharm作为集成开发环境的问题是,Heroku没有集成,使用带有Github的控制台命令是所有噩梦的噩梦。
我在github上发布了我的代码,该应用程序通过Heroku成功部署,但应用程序离线。我已经检查了所有地方,但没有一个解决方案对我有效。
以下是我目前的文件和内容:
main.py
import discord
from urllib.request import urlopen
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
token = "***********************"
client = discord.Client()
URL = "https://www.surrenderat20.net/search/label/PBE/"
page = urlopen(URL)
soup = BeautifulSoup(page, 'html.parser')
pbe_titles = soup.find_all('h1', attrs={'class': 'news-title'})
links = []
for tag in pbe_titles:
for anchor in tag.find_all('a'):
links.append(tag.text.strip())
links.append(anchor['href'])
output = '\n'.join(str(line) for line in links[:2])
print(output)
@bot.command(name='pbe')
async def peebeeee(ctx):
response = output
await ctx.send(response)
bot.run(token)我把我的令牌码去掉了。如果我有兴趣分享代码,我会做一个.env,但是.env在Pycharm中似乎不能很好地工作。
Procfile文件:worker: python bot/main.py Requirements.txt:discord.py Runtime.txt:python-3.8.7
我目前的github的结构是这样的,所有列出的文件都在主页上,包括:存放main.py的文件夹: bot **我将Git列为私人自动取款机
如果有人能解释一下为什么我的不和谐机器人即使Heroku成功部署也不能保持在线,那就太好了。谢谢。
发布于 2021-08-11 01:40:03
此可能会有所帮助,因为它提供了一些关于创建机器人并将其托管在Heroku上的洞察力。
我能想到的唯一一件事,你可能没有做,就是你没有让工人开机:
在“资源”下,执行以下操作:单击“铅笔”图标。将worker从off切换到on。单击“确认”以最终确定决定。
https://stackoverflow.com/questions/66132292
复制相似问题