I wrote function that must to filter messages in telegram for certain words and delete message that includes some words of thet list, but code dont work.(I import all files correctly)
(I tried to rewrite all the code in 1 file, still doesn't work)
Thet error I see awter testing my code: set(json.load(open('slova.json')))) != set(): TypeError: unhashable type: 'list'
What can I do to fix thet problem?
import json
import string
from aiogram import types, Dispatcher
async def echo_send(message: types.Message):
if {i.lower().translate(str.maketrans('', '', string.punctuation)) for i in
message.text.split(' ')}.intersection(set(json.load(open('slova.json')))) !=
set():
await message.reply('mat off')
await message.delete()
def register_handlers_client(dp: Dispatcher):
dp.register_message_handler(echo_send)
CodePudding user response:
that error appears because somewhere in your code you are recieving a list when you should be recieving a hashable object, maybe a tuple instead of a list. You should also provide some instructions on how to execute your code as I tried to do it but I could not replicate your problem.