Когда передаю два слова в функцию происходит ошибка(находится ниже), если же одно слово, то ошибки не происходит. В чём может быть проблема? Вот ошибка:
2020-08-02 10:50:42,507 (util.py:68 WorkerThread1) 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: message text is empty"}\']',)
Traceback (most recent call last):
File "C:\Users\Stepan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 62, in run
task(*args, **kwargs)
File "C:/Users/Stepan/Desktop/stslinvestbot.py", line 164, in get_text_messages
token_bot.send_message(message.chat.id, other_stock(message))
File "C:\Users\Stepan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 624, in send_message
apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,
File "C:\Users\Stepan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 159, in send_message
return _make_request(token, method_url, params=payload, method='post')
File "C:\Users\Stepan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 65, in _make_request
return _check_result(method_name, result)['result']
File "C:\Users\Stepan\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 84, 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: message text is empty"}']
"
2020-08-02 10:50:42,508 (__init__.py:443 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: message text is empty"}']"
Вот код:
def other_stock(message): # другая акция
line_words = message.text.split()
if len(line_words) == 2:
ticker = line_words[1]
else:
ticker = message.text
instr = client_invest.market.market_search_by_ticker_get_with_http_info(ticker)
if ticker == "Назад":
token_bot.send_message(message.from_user.id, "Хорошо, назад.", reply_markup=user_markup)
token_bot.register_next_step_handler(message, get_text_messages)
elif str(instr[0].payload.instruments) == "[]":
msg = token_bot.send_message(message.chat.id, 'Ошибка! Такой тикер не найден!\nВведите другой тикер:')
token_bot.register_next_step_handler(msg, other_stock)
return
if str(instr[0].payload.instruments) != "[]" and ticker != "Назад":
token_bot.send_message(message.from_user.id, data_stock(ticker), reply_markup=user_markup)