【发布时间】:2021-06-13 15:21:26
【问题描述】:
我在 heroku 服务器上的应用程序在运行 1 分钟后停止。然后它运行并随时听到发送给它自己的命令。我想知道它是否可以从 30 分钟的限制开始,但它从来没有那么长时间。
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import commands as c
TOKEN = "--------------"
def main():
updater = Updater(TOKEN, use_context=True)
dp = updater.dispatcher
#my commands
dp.add_handler(CommandHandler("start", c.start_command))
#while I write unknown word that the bot doesnt know
dp.add_handler(MessageHandler(Filters.text, c.wrong_command))
updater.start_polling()
updater.idle()
if __name__ == "__main__":
main()
#commands.py
from telegram.ext import Updater
def start_command(update, context):
message = "hi!"
return update.message.reply_text(message)
def wrong_command(update, context):
message = "/start only"
return update.message.reply_text(message)
requirements.txt """
python-telegram-bot
过程文件
web: python main.py
【问题讨论】: