MCPcopy Create free account
hub / github.com/eternnoir/pyTelegramBotAPI / check

Method check

telebot/custom_filters.py:402–437  ·  view source on GitHub ↗

:meta private:

(self, message, text)

Source from the content-addressed store, hash-verified

400 key = 'state'
401
402 def check(self, message, text):
403 """
404 :meta private:
405 """
406
407 chat_id, user_id, business_connection_id, bot_id, message_thread_id = resolve_context(message, self.bot.bot_id)
408
409 if chat_id is None:
410 chat_id = user_id # May change in future
411
412 if isinstance(text, list):
413 new_text = []
414 for i in text:
415 if isinstance(i, State): i = i.name
416 new_text.append(i)
417 text = new_text
418 elif isinstance(text, State):
419 text = text.name
420
421 user_state = self.bot.current_states.get_state(
422 chat_id=chat_id,
423 user_id=user_id,
424 business_connection_id=business_connection_id,
425 bot_id=bot_id,
426 message_thread_id=message_thread_id
427 )
428
429 # CHANGED BEHAVIOUR
430 if text == "*" and user_state is not None:
431 return True
432
433 if user_state == text:
434 return True
435 elif type(text) is list and user_state in text:
436 return True
437 return False
438
439class IsDigitFilter(SimpleCustomFilter):
440 """

Callers

nothing calls this directly

Calls 2

resolve_contextFunction · 0.90
get_stateMethod · 0.45

Tested by

no test coverage detected