pyrobloxbot.decorators

Note

You don’t need to apply these decorators to pyrobloxbot functions. They are already applied to the functions that need them.

You should use them in case you’re making your own custom methods and need them to exibit one of these behaviours.

pyrobloxbot.decorators.apply_cooldown(per_key: bool = False)

Decorator that applies a cooldown after the decorated function is executed

Parameters:

per_key (bool, optional) –

Defaults to False.

If set to False, the applied delay will be the one set in pyrobloxbot.options.action_cooldown. In this case, there is also a failsafe to ensure that nested calls to functions using this decorator don’t cause multiple cooldowns to be applied. The cooldown is only applied to the first decorated function that’s called.

If set to True, the applied delay will be the one set in pyrobloxbot.options.key_press_cooldown.

pyrobloxbot.decorators.require_focus(fn)

Decorator that ensures the Roblox window is in focus before running the decorated function.

It is affected by the options force_focus and maximize_roblox_window.

If maximize_roblox_window is set to True, the decorator will maximize the Roblox window on top of activating it before running the decorated function.

If force_focus is set to False, instead of activating the Roblox window, the decorator will only check if it is already in focus. If it is, it runs the decorated function. If it isn’t it doesn’t run anything.

Important

Be aware that if force_focus is False and the decorator skips the function because Roblox isn’t in focus, the function’s return value will be None.

Raises:

NoRobloxWindowException – Raised if the decorator can’t find the Roblox window to activate.

pyrobloxbot.decorators.requires_ui_navigation_mode(fn)

This decorator ensures ui navigation mode is enabled on Roblox before running the decorated function.

After the function is done, it returns to the original state, meaning if ui navigation was disabled before the function was called it’ll go back to being disabled, if it was already enabled it’ll stay enabled.

All functions in pyrobloxbot.core.ui use this decorator.

pyrobloxbot.decorators.resets_state(fn)

Decorator that resets the bot’s internal state after running the decorated function.

Used for methods like pyrobloxbot.leave_game() and pyrobloxbot.join_game(), that cause the characters state to be reset ingame. This needs to be replicated in the bot’s internal state.