R
R
Ruslan Mordovanech2021-11-11 01:02:14
Python
Ruslan Mordovanech, 2021-11-11 01:02:14

The program does not start, I do not understand why it knocks out errors?

I've tried everything but I don't understand why I get these shells
Unresolved reference 'main'
Unresolved reference 'collect_data'

from aiogram import Bot, Dispatcher, executor, types
from aiogram.dispatcher.filters import Text
from aiogram.utils.markdown import hbold, hlink
from main import collect_data
import json

bot = Bot(token="zzzzzzzzzzzzzzzzzz", parse_mode=types.ParseMode.HTML)

dp = Dispatcher(bot)

@dp.message_handler(commands="start")
async def start(message: types.Message):
    start_buttons = ["перша кнопка1", "друга кнопака2", "третя кнопка3"]
    keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
    keyboard.add(*start_buttons)
    await message.answer("Привіт!", reply_markup=keyboard)

@dp.message_handler(Text(equals="перша кнопка1"))
async def get_discout_sneaker(message: types.Message):
        await message.answer("Please waiting....")

        collect_data()

        with open("304.json") as file:
            data = json.load(file)
        for item in data:
            card = f"{hbold(' ')} {item.get('judge')}\n" \
                   f"{hbold('08.11.2021 09:20')} {item.get('date')}\n" \
                   f"{hbold('304/ /21')} {item.get('number')}"

            await message.answer(card)

def main():
    executor.start_polling(dp)


if __name__ == "__main__":
    main()


thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmshar, 2021-11-11
@Hery1

If main is the name of the code file you are using, then write main.py. And if something else, then explain the purpose of this line
from main import collect_data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question