【发布时间】:2020-11-14 19:49:14
【问题描述】:
每个人。我需要 Telebot 来接收 POST 并回答。我决定使用 Flask。 我有代码:
import telebot
from flask import Flask, request
bot = telebot.TeleBot('dddd')
print("1")
app = Flask(__name__)
print("2")
@bot.message_handler(commands=['start'])
def start_message(message):
print("5")
bot.send_message(message.chat.id, message.chat.id)
bot.send_message(message.chat.id, message.chat.username)
print("3")
@app.route('/', methods=['POST'])
def result():
dt = request.args.to_dict(flat=False)
print("6")
for i in dt["chatIds"]:
print(i)
bot.send_message(i, "tema loh")
return "0"
print("4")
bot.polling()
当我启动 Flask 时,我看到:
F:\Desktop\backend\bot_14_11>flask run
* Serving Flask app "bot.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Bot 正在工作,但我无法将 POST 发送到我的本地主机。 我按 ctrl+c 看看:
- 在http://127.0.0.1:5000/ 上运行(按 CTRL+C 退出)
然后我可以发送 POST,但机器人对“启动”命令没有响应
我需要他们一起工作
【问题讨论】:
-
在 2 个不同的线程上运行
bot和app -
能否请您命名一个库或提供提示?