practical-python-org / ZorakBot

The house bot of Practical Python
MIT License
17 stars 18 forks source link

Feature/react-based auto-translate #438

Closed pennybelle closed 4 months ago

pennybelle commented 4 months ago

I've rewritten some and refactored most of the auto translator functions and abstracted most checks to functions for multi-use and readability. I've made the detection much more robust and better at passing on false translations, as well as adding a reaction function. This means when the cog detects a message that should be translated, it'll add a reaction to the message, and only when the reaction is interacted with by a user will the bot send the translation embed.

I've also refactored the translate and blacklist(add/remove) commands to squash a few more bugs.

Formatted with Black.

Known Problems: blacklistremove() is broken, it clears the entire blacklist when used. Honestly idk why this is happening, for some reason list.remove(item) is returning None instead of the list minus item, cant figure out why. I'm not gonna spend too much time worrying about this however since the end goal is to move all this to a database.

TODO: add logic where the bot wont translate if there isnt a present reaction made by the bot that matches the reaction needed to send the embed. This can prevent people from spamming chats with repeated translations by adding the reaction again manually.

Peregrine05 commented 4 months ago

list.remove always mutates the list in-place and returns None.