S
S
shuzzixd2021-08-17 18:36:23
Python
shuzzixd, 2021-08-17 18:36:23

How to implement this in a telegram bot?

For example: If the following message contains some character, the bot does not respond in response. I know it's simple.
If it's easier to say how to make a list of forbidden characters?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-08-17
@Vindicar

Well, if it's single characters, not substrings...

forbidden = frozenset('XYZ') #список запрещённых символов
text: str = message.text #берём сообщение
message_is_ok: bool = forbidden.isdisjoint(text) 
#True - сообщение не содержит запрещённых символов

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question