【发布时间】:2018-03-12 09:19:04
【问题描述】:
我正在开发一个电报机器人,在我的个人机器 (Mac) 上运行 该机器人在 python 上运行,在特定环境中安装了模块
既然机器人很好,我想把它放在一个运行 Apache 的网络服务器上。但我有一些问题。
1) 我必须在服务器上为每个人安装每个模块,或者我可以为这个特定的机器人创建一个环境,然后 apache 在那个环境中运行那个机器人?
2) 我正在使用 getUpdates(使我的机器非常慢,但更好地调试错误),现在我想使用 webhook 运行。如果 webhook 而不是 getUpdates 去电报服务器,那么必须做出什么改变才能让他工作?今天开始并继续运行的代码是:
def main():
updater = Updater(bot_token)
dp = updater.dispatcher
# Commands
dp.add_handler(CommandHandler("info", ranking_putaria))
dp.add_handler(CommandHandler("start", start))
# Start checking updates
dp.add_handler(MessageHandler(Filters.text,echo_msg))
dp.add_handler(MessageHandler(Filters.video | Filters.photo | Filters.document, echo_file))
dp.add_handler(MessageHandler(Filters.sticker, echo_sticker))
# Log errors
#dp.add_error_handler(error)
# start the bot
updater.start_polling()
# Run the bot until you press Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT. This should be used most of the time, since
# start_polling() is non-blocking and will stop the bot gracefully.
updater.idle()
if __name__ == '__main__':
main()
【问题讨论】:
标签: python python-telegram-bot