A
A
AruxGame2020-08-23 22:01:52
Python
AruxGame, 2020-08-23 22:01:52

TelegramBOT Call by button?

Why is the error happening?

The code:

@bot.message_handler(commands=['call'])
def call(message):
  markup = types.InlineKeyboardMarkup()
  call = types.InlineKeyboardButton(text="Позвонить!", url="tel:+1234567890")  # Ошибка в этой строке!

  markup.add(call)

  bot.send_message(message.chat.id, "Звонок...", reply_markup=markup)


Here is the log from the console:

2020-08-23 22:00:12,463 (util.py:68 WorkerThread2) ERROR - TeleBot: "ApiException occurred, args=('A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:\n[b\'{"ok":false,"error_code":400,"description":"Bad Request: wrong HTTP URL"}\']',)
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\telebot\util.py", line 62, in run
    task(*args, **kwargs)
  File "C:\Users\User\Desktop\Bots\bot.py", line 33, in start
    bot.send_message(message.chat.id, "Привет! Нажми на кнопку и перейди в поисковик.", reply_markup=markup)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\telebot\__init__.py", line 641, in send_message
    reply_markup, parse_mode, disable_notification, timeout))
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\telebot\apihelper.py", line 166, in send_message
    return _make_request(token, method_url, params=payload, method='post')
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\telebot\apihelper.py", line 69, in _make_request
    return _check_result(method_name, result)['result']
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\telebot\apihelper.py", line 88, in _check_result
    raise ApiException(msg, method_name, result)
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: wrong HTTP URL"}']
"
2020-08-23 22:00:12,469 (__init__.py:455 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: wrong HTTP URL"}']"

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
soremix, 2020-08-23
@AruxGame

Either tg:// protocol or http
Alternatively, you can pass text like this in the message

bot.send_message(message.chat.id, "[Позвонить](tel:+89000000000)", parse_mode='Markdown')

K
kirillinyakin, 2020-08-23
@kirillinyakin

The error itself says that wrong http url, you are trying to enter a phone number in the url, but you need a URL

S
Sergey Karbivnichy, 2020-08-23
@hottabxp

I did not find anything similar in the Telegram Api and pyTelegramBotAPI documentation. In Google on this issue, I found only one mention - A button with a Telegram phone number
If you are too lazy to go, I will retell - they came up with a hack. Create a *.php file with content on your server header("Location: tel:787770099");and pass a link to this file to the InlineKeyboardButton parameter in the url parameter. Of course, the web server must be running.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question