S
S
ShockerJP2021-11-07 12:47:49
In contact with
ShockerJP, 2021-11-07 12:47:49

How to use dataset for VK bot (vkbottle)?

Hello, I am writing a VK bot using vkbottle, I want to teach it to check the incoming message for a match from the file and respond in accordance with the text.
#I have a dataset file dialog.txt with the content:

hello\hello\0
hello\darova\0
hello\ku\0
hello\shalom\0
hello\salaam\0
hello\darova how are you\0
etc #At the
moment the bot responds like this:
@bot.on.message(text=["Hello", "Hello"])
async def message_handler(message: Message):
user = await bot.api.users.get(message.from_id)
await message. answer(f"Hello to you too, {user[0].first_name}")

Thanks in advance for your help, if anyone can help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LXSTVAYNE, 2021-11-07
@lxstvayne

You need to read the file and build a dictionary where the key is the word you are replying to and the value is an array of words you are replying to. In the program, you simply match the key and select a random value from the list.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question