R
R
Roman Komyagin2020-08-15 02:39:36
Python
Roman Komyagin, 2020-08-15 02:39:36

What to do if the variable is not sent to pyTelegramBotAPI?

Here is the code:

import telebot
import requests

response = requests.get(
  'https://api.fortnitetracker.com/v1/profile/pc/Pikachu',
  headers= {'TRN-Api-Key':TRN}
  )
r = response.json()
r2 = r['lifeTimeStats']

# Здесь я пропустил функцию /start, клавиатуру и ещё парочку функций

@bot.message_handler(content_types=['text'])
def static(message):
  if message.text == 'Всего Побед ':
    for x in r2:
      if x.get('key') == 'Wins':
        x2 = x.get('value') 
        bot.send_message(message.chat.id, 'Всего побед: ', x2)


After I activated the bot by sending him: 'Total Wins', the bot just ignores me

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kirillinyakin, 2020-08-15
@kirillinyakin

Because send_message is not similar to print, where you can list variables separated by commas, and they will be displayed, more correctly f"Total wins : {x2}", that is, the finished string must be transferred immediately

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question