help me figure out what the error is. I redesigned the bot to work from a webhook I will receive a reply from a telegram POST /webhook/ 200 OK but the bot stopped responding to commands when I press /start the bot is silent. Tell me where I went wrong? thanks in advance
I start everything on django for port 8050
from telegram import *
from telegram.ext import *
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from decouple import config
import json
TOKEN = config('TELEGRAM_TOKEN')
bot = Bot(token=TOKEN)
updater = Updater(token=TOKEN)
dp = updater.dispatcher
@csrf_exempt
def webhook(request):
print('this is webhook')
if request.method == 'POST':
update = Update.de_json(json.loads(request.body), bot)
dp.process_update(update)
return HttpResponse('ok')
def start(update: Update, context: CallbackContext) -> None:
print('this is start')
update.message.reply_text('Hello World!')
def echo(update: Update, context: CallbackContext) -> None:
print('this is echo')
update.message.reply_text(update.message.text)
if __name__ == '__main__':
print('this is main')
dp.add_handler(CommandHandler('start', start))
dp.add_handler(MessageHandler(Filters.text, echo))
updater.start_webhook(
listen="0.0.0.0",
port=8050,
)
updater.idle()
dp.add_handler(CommandHandler('start', start))
dp.add_handler(MessageHandler(Filters.text, echo))
if __name__ == '__main__':
print('this is main')
updater.start_webhook(
listen="0.0.0.0",
port=8443,
)
updater.idle()
I just moved the commands from main above and everything worked