繁体   English   中英

python 脚本无法在 heroku 上托管的其他 python 脚本中调用 fn

[英]python script unable to call fn in other python scripts hosted on heroku

我使用 Python 制作了 Discord 机器人,并使用内置的 Z0BCC70105ADF27956B63 命令在 Heroku 上托管了相同的机器人。 它运行主脚本,即 DiscordBot.py,该脚本从 topGainer.py 调用另一个 fn topGainer

当我在我的系统上本地运行 DiscordBot.py 时,机器人功能完美,但在 Heroku 上它无法调用 topGainer.py Function topGainer 返回使用制表法制作的列表

这是 discord 机器人的代码

if message.author == client.user:
    return

if message.content.startswith('$gainer'):
    tg=topGainer()
    await message.channel.send(tg)
    
if message.content.startswith('$loser'):
    tl=topLoser()
    await message.channel.send(tl)
    
if message.content.startswith('$get'):
    scrip = msg.split("$get ",1)[1]
    info=basic(scrip)
    await message.channel.send(info)
    
if message.content.startswith('$AnotherFunction'):
    await message.channel.send('Coming Soon :')

同样在 Heroku Procfile 我有worker: python DiscordBot.py

在 heroku 上,此代码确实在 discord 机器人和 function $AnotherFunction 上登录。

众所周知,Heroku 在托管 discord 机器人方面表现不佳,原因有很多。 我建议使用不同的主机(AWS 提供一年的免费托管),因为制作 discord.py(Danny) 的主要人物之一已经说过不要使用它。 为什么 Herkou 对不和谐机器人不利

  • 机器人也不是该平台的设计目的。 Heroku 旨在提供 web 服务器(如 Django、Z9784E91C7B26577917226BC82ZAF、等) 这就是为什么他们给你一个域名并在他们的本地模拟器上打开一个端口。 (引用自 discord.py discord 服务器)

如果 Heroku 在本地运行完美,可能会导致您的错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM