M
M
Matvey Kot2021-09-09 17:29:06
Python
Matvey Kot, 2021-09-09 17:29:06

How to link fuzzywuzzy and discord.py?

There is such a code (or rather, its fragment):

import discord
from mctools import QUERYClient
import config

class MyClient(discord.Client):
    async def on_ready(self):
        print(self.user.name + ' is login.')

    async def on_message(self, message):
        if message.author.id == self.user.id:
            return

        # Онлайн сервера
        if message.content.startswith(config.online):
            query = QUERYClient('95.000.92.218', 20040)
            stats = query.get_basic_stats()
            await message.reply('Текущий онлайн `' + stats['numplayers'] + '` из `' + stats['maxplayers'] + '` игроков на сервере.', mention_author=True)

And it is necessary that when the user writes, for example: "Miaa, what online server", then fuzzywuzzy checks this text and if it is >= 70% similar to the original, then the bot sends a command.
I thought the structure would be like this:
ppp = Wazzy checks the message
if ppp >= 70:
send a reply.
But message returns either the message id or True (I don’t remember which, in which case).

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