async def check(self, obj: TelegramObject): if self.intent_state_group is None: return True data = ctx_data.get() context: Context = data.get(CONTEXT_KEY) if not context: return False return context and context.state.group == self.intent_state_group
async def bot_search(message: Message, state: FSMContext): if await state.get_state(): return await message.delete() if len(message.text) >= 1228: return await message.answer( "Ваш Запрос Привысил Огранечение в 1227 букв. И он отклоняется") data = ctx_data.get() user: User = data["user"] try: result = await dbc.search_query(user, message.text) except ValueError: return await message.reply("Ошибка, Нечего Не было Показано") except KeyError: return await message.answer("Результатов Не найдено((") except QuotaExceededError: return await message.answer("Бот Исчерпал лимит в 100 запросов в день") return await message.answer(result, disable_web_page_preview=True)
async def check(self, msg: Message): """ Check is user is superuser If command in list USER_ARG_COMMANDS: Get second argument, check if argument it's user id, transfer to handler user obj with id from argument """ db: Connection = ctx_data.get()["db"] db_user = await User.create(db, msg.from_user.id) check = db_user.is_superuser and await super().check(msg) if self.command in USER_ARG_COMMANDS and check: try: second_arg = msg.text.split()[1] user_arg = await msg.bot.get_chat(second_arg) check = {"user_arg": user_arg} except (IndexError, ChatNotFound): await msg.answer("Chat not found") return return check
async def check(self, obj) -> bool: data = ctx_data.get() user = await crud.user.get(data["user"]) return user.is_superuser
async def check(self, obj) -> bool: data = ctx_data.get() user: User = data["user"] return user.is_superuser or user.id in config.BOT_SU
async def check(self, obj: TelegramObject): if self.is_admin is None: return True data = ctx_data.get() return (data.get("role") is UserRole.ADMIN) == self.is_admin
async def check(self, obj: TelegramObject): if self.roles is None: return True data = ctx_data.get() return data.get("role") in self.roles
async def check(self, obj) -> bool: data = ctx_data.get() subscriber = await crud.subscriber.get(data["user"].id) return subscriber.expiration_dt.date() <= datetime.date(datetime.now())
async def check(self, message: Union[Message, CallbackQuery]) -> bool: data = ctx_data.get() return not data['user_data']
async def check(self, obj: TelegramObject): data = ctx_data.get() user = data["user"] return (user.is_admin()) == self.is_admin
async def check(self, obj) -> bool: data = ctx_data.get() user: User = data["user"] return user.tg_id in config.SUPERUSERS
async def check(self, obj: TelegramObject) -> bool: data: dict = ctx_data.get() db = data["db"] db_user: User = await User.create(db, obj.from_user.id) return db_user.is_superuser
async def check(self, obj) -> bool: data = ctx_data.get() chat: Chat = data["chat"] return getattr(chat, self.chat_property, False)
async def check(self, superusers: Iterable[int], event) -> bool: data = ctx_data.get() user: User = data["user"] return user.tg_id in superusers
async def check(self, obj) -> bool: data = ctx_data.get() user: User = data["user"] return user.is_superuser == self.is_superuser
def is_reg_user(handlers) -> bool: data = ctx_data.get() user: User = data['user'] return user.registered
def is_new_user(handlers) -> bool: data = ctx_data.get() user: User = data['user'] return False if user.registered else True
async def check(self, message: types.Message) -> dict[str, dict[str, float]]: data = ctx_data.get() settings: ChatSettings = data.get("chat_settings", None) if settings is None or not settings.karma_counting: return {} return await check(message)