电报机器人(使用机器人命令在 python 代码中传递变量)

telegram bot(using bot commands to pass variables in python code)

这是我的电报机器人的代码,它检测 amazon.in link 和 returns link 添加到 [=23= 的亚马逊会员标签]],我在 heroku 上托管了这个机器人,并且在 heroku 应用程序的配置变量中声明了这些环境变量(在下面用双引号引起来)并且它工作正常。

现在我希望使用一些命令将这些变量传递给机器人,然后 运行 相应地传递给机器人。 我希望使用一些机器人命令将“TOKEN”、“baseURL”、“affiliate_tag”等环境变量传递给电报机器人。

代码在 'bot.py' 文件中。

This is the github repository link

您可以将参数传递给命令(即 /help a b),这些参数在 CommandHandler 中可用,如 CallbackContext

中的列表
def help_command_handler(update, context):
"""Help handler"""
print(context.args)

baseURL = context.args[0]
affiliate_tag = context.args[1]