【发布时间】:2020-12-24 08:17:12
【问题描述】:
我正在尝试使用 django 和 pyTelegramBotApi 在 python 中制作一个简单的 tg bot,它在 /start 上回答“Hello”。我已经设置了 webhook,并且 bot 正在正确获取更新,但是当涉及到 send_message 时,它只是进入了低谷并且什么也没发送。
@csrf_exempt
def update_bot(request):
json_str = request.body.decode("UTF-8")
update = types.Update.de_json(json_str)
tele_bot.process_new_updates([update])
return HttpResponse({'code': 200})
@tele_bot.message_handler(commands=['start'])
def start_message(message):
print("sending message")
print(tele_bot.send_message(message.chat.id, "Hello"))
控制台输出是
sending message
[24/Dec/2020 10:54:46] "POST /bot/imagesmanager/ HTTP/1.1" 200 4
【问题讨论】:
标签: python python-3.x python-telegram-bot django-2.2