I’m trying to use a custom type of filter like BoundFilter in aiogram 2.x for filtering not allowed characters.
But recommended
class AllowedCharactersFilter(BoundFilter):
async def check(self, message: types.Message):
allowed_characters = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')
entered_text = message.text
return all(char in allowed_characters for char in entered_text)
doesn’t work. Because in aiogram 3.4 neither
from aiogram.dispather.filters import BoundFilter
nor
from aiogram.filters import BoundFilter
work.
Is BoundFilter to be imported in some another fashion?
I found that probably the solution is possible through using a BaseFilter imported from aiogram.filters. With creation of new directory under filters.
But a description of the procedure is not clear. Can comebody shed a light on the subject: How to filter unallowed characters in handlers of aiogram 3.4?