2

I am trying to make a simple tg bot in python using django and pyTelegramBotApi, which is answering "Hello" on a /start. I've set webhook, and bot is getting updates correctly, but when it comes to send_message it just goes trough and sends nothing.

@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"))

And the console output is

sending message
[24/Dec/2020 10:54:46] "POST /bot/imagesmanager/ HTTP/1.1" 200 4
sudden_appearance
  • 1,968
  • 1
  • 4
  • 15

2 Answers2

0

I'm not sure what the error is because the message is not being printed, but I have been using this: https://api.telegram.org/{bot_id}/sendMessage since a long time now and it works perfectly. The documentation is very informative on how to use the api in this form.

Prateek Jain
  • 231
  • 1
  • 11
0

I've solved the issue. I have just read my token with \n at the end (found with repr(token)), idk why update worked properly, but simple strip helped me well enough)

sudden_appearance
  • 1,968
  • 1
  • 4
  • 15