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

Method check

telebot/asyncio_filters.py:396–431  ·  view source on GitHub ↗

:meta private:

(self, message, text)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

resolve_contextFunction · 0.90
get_stateMethod · 0.45

Tested by

no test coverage detected