Q
Q
qwwwwwty2021-10-28 19:27:22
Python
qwwwwwty, 2021-10-28 19:27:22

How can I make the bot select a random word from the Python Aiogram name.txt list?

we need the bot to select a random word from the list name.txt and combine it with the list of other words name2.txt. example situation:

name.txt: Hello, How are you?
name2.txt: World!, How are you?

the bot sent to the conversation: Hello World!

I already have a little code so that the bot would select words from the LIST in Sublime itself, but for convenience I want to do it in two txt files.
I don't know if this will be useful, but here is my code:

a = ["Привет", "Как дела?"]
b = ["Мир!", "Как ты?"]

async def helloworld(dp: Dispatcher):
        bot_info = await bot.get_me()
        print(bot_info.username)
        await dp.bot.send_message(config.GROUP_ID, text = (random.choice(a) +" "+ random.choice(b)))
        print(random.choice(a))
        print(random.choice(b))
    
    
def scedule_jobs():
    scheduler.add_job(helloworld, "interval", seconds = 100, args=(dp, ))

scedule_jobs()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question