M
M
mafiosniksalieri2020-11-08 13:58:22
Python
mafiosniksalieri, 2020-11-08 13:58:22

When launching a TG bot for crown stats, it cannot display information, how to fix it?

5fa7ce87b3e5c383258085.png

I am making a bot to view coronavirus statistics in python.
Gives such an error.
And the bot works correctly. That is, it displays the desired message, reacts normally to everything, but when you need to display statistics, it gives an error. Please help me fix it.
Thank you in advance!

import telebot
import COVID19Py
from telebot import types

bot = telebot.TeleBot('Token')
covid19 = COVID19Py.COVID19

@bot.message_handler(commands=['start',])
def send_welcome(message):
  bot.reply_to(message, "Приветсвую Вас!\nЯ бот по статистике COVID-19 в России и мире.\nПожалуйста соблюдайте масочный режим и дистанцию.\nНе болейте :)")

  markup = types.ReplyKeyboardMarkup (resize_keyboard=True)
  item1 = types.KeyboardButton("Статистика COVID-19")

  markup.add(item1)

@bot.message_handler(commands=['help'])
def send_help(message):
  bot.reply_to(message, "Команды для работы со мной\n 1.\"Статистика COVID-19\" ")

@bot.message_handler(content_types = ['text'])
def mees(message):
    if message.text == 'Статистика COVID-19':
    	markup = types.InlineKeyboardMarkup(row_width=2)
    	item1 = types.InlineKeyboardButton("Россия", callback_data='ru')
    	item2 = types.InlineKeyboardButton("США", callback_data='usa')
    	item3 = types.InlineKeyboardButton("Мир", callback_data='world')

    	markup.add(item1, item2, item3)

    	bot.send_message(message.chat.id, 'У какой страны вы хотите узанть статистику?', reply_markup=markup)
    	
    else:
    	bot.send_message(message.chat.id, 'Неверная команда. Для просмотра моих команд используйте / help')

@bot.callback_query_handler(func=lambda call: True)
def callback_data(call):
    try:
        if call.message:
        	if call.data == 'good':
        		location = covid19.getLocationByCountryCode("RU")
        	if call.data == 'bad':
        		location = covid19.getLocationByCountryCode("US")
        	if call.data == 'world':
        		latest = covid19.getLatest()
    except Exception as e:
    	print(e)

bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-11-08
@mafiosniksalieri

Forgot() when instantiating
covid19 = COVID19Py.COVID19()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question