UserFlag
Represents a user's flags.
The implemented user flags are the following:
Respective name | Bitwise position |
---|---|
staff | 0 |
partner | 1 |
hypesquad | 2 |
bug_hunter_level_1 | 3 |
mfa_sms | 4 |
premium_promo_dismissed | 5 |
hypesquad_bravery | 6 |
hypesquad_brilliance | 7 |
hypesquad_balance | 8 |
early_supporter | 9 |
team_user | 10 |
team_pseudo_user | 11 |
system | 12 |
has_unread_urgent_messages | 13 |
bug_hunter_level_2 | 14 |
underage_deleted | 15 |
verified_bot | 16 |
early_verified_developer | 17 |
certified_moderator | 18 |
bot_http_interactions | 19 |
spammer | 20 |
premium_disabled | 21 |
active_developer | 22 |
quarantined | 44 |
collaborator | 50 |
collaborator_restricted | 51 |
Properties
active_developer
bot_http_interactions
bug_hunter_level_1
bug_hunter_level_2
certified_moderator
collaborator
collaborator_restricted
early_supporter
early_verified_developer
has_unread_urgent_messages
hypesquad
hypesquad_balance
hypesquad_bravery
hypesquad_brilliance
mfa_sms
partner
premium_disabled
premium_promo_dismissed
quarantined
spammer
staff
system
team_pseudo_user
team_user
underage_deleted
verified_bot
Methods
()
is_strict_subsetReturns whether self has more flags disabled than other.
()
is_strict_supersetReturns whether self has more flags enabled than other.
()
is_subsetReturns whether self has the same amount or more flags disabled than other.
()
is_supersetReturns whether self has the same amount or more flags enabled than other.
()
itemsYields the items of the flag.
This method is a generator.
Yields
name : str
The name of the specific flag
enabled : int
(0
, 1
)
Whether the specific bitwise value is enabled.
()
keysYields the name of the bitwise flags, which are enabled.
This method is a generator.
Yields
name : str
(...)
update_by_keysUpdates the source value with the given flags and returns a new one.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
**keyword_parameters | Keyword parameters |
|
Returns
flag : FlagBase
Raises
LookupError
If a keyword is invalid.
Examples
>>> from hata import Permission
>>> perm = Permission().update_by_keys(kick_users = True, ban_users = True)
>>> list(perm)
['kick_users', 'ban_users']
>>> perm = perm.update_by_keys(manage_roles = True, kick_users = False)
>>> list(perm)
['ban_users', 'manage_roles']
()
valuesYields the shift values of the flags, under which shift value the flag is enabled.
This method is a generator.
Yields
shift : int
(keys)
_get_shift_ofGets the shift value for the given keys.
Parameter | Type | Description |
---|---|---|
keys |
| The key's name. |
Returns
shift : int
Raises
LookupError
- Invalid key given.
()
__contains__Returns whether the specific flag of the given name is enabled.
(name, shift, deprecation_info)
__disabler_factory__Creates a flag disabler function.
Parameter | Type | Description |
---|---|---|
name |
| The flag's name. |
shift |
| Bit shift value. |
deprecation_info |
| Deprecation info for the field if deprecated. |
Returns
flag_disabler : FunctionType
(name, shift, deprecation_info)
__enabler_factory__Creates a flag enabler function.
Parameter | Type | Description |
---|---|---|
name |
| The flag's name. |
shift |
| Bit shift value. |
deprecation_info |
| Deprecation info for the field if deprecated. |
Returns
flag_enabler : FunctionType
()
__ge__Returns whether self has the same amount or more flags enabled than other.
()
__getitem__Returns whether a specific flag of the given name is enabled.
(name, shift, deprecation_info)
__getter_factory__Creates a flag getter function.
Parameter | Type | Description |
---|---|---|
name |
| The flag's name. |
shift |
| Bit shift value. |
deprecation_info |
| Deprecation info for the field if deprecated. |
Returns
flag_getter : FunctionType
()
__gt__Returns whether self has more flags enabled than other.
()
__iter__Yields the name of the bitwise flags, which are enabled.
This method is a generator.
Yields
name : str
()
__le__Returns whether self has the same amount or more flags disabled than other.
()
__lt__Returns whether self has more flags disabled than other.
()
__repr__Returns the representation of the flag.