1
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
2
|
|
|
# MIT License |
3
|
|
|
# |
4
|
|
|
# Copyright (c) 2021 Pincer |
5
|
|
|
# |
6
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining |
7
|
|
|
# a copy of this software and associated documentation files |
8
|
|
|
# (the "Software"), to deal in the Software without restriction, |
9
|
|
|
# including without limitation the rights to use, copy, modify, merge, |
10
|
|
|
# publish, distribute, sublicense, and/or sell copies of the Software, |
11
|
|
|
# and to permit persons to whom the Software is furnished to do so, |
12
|
|
|
# subject to the following conditions: |
13
|
|
|
# |
14
|
|
|
# The above copyright notice and this permission notice shall be |
15
|
|
|
# included in all copies or substantial portions of the Software. |
16
|
|
|
# |
17
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
18
|
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
19
|
|
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
20
|
|
|
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
21
|
|
|
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
22
|
|
|
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
23
|
|
|
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
24
|
|
|
from __future__ import annotations |
25
|
|
|
|
26
|
|
|
from dataclasses import dataclass |
27
|
|
|
from enum import Enum |
28
|
|
|
from typing import Optional, Union |
29
|
|
|
|
30
|
|
|
from websockets.typing import Data |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
class PremiumTypes(Enum): |
|
|
|
|
34
|
|
|
# TODO: Write documentation |
|
|
|
|
35
|
|
|
NONE = 0 |
36
|
|
|
NITRO_CLASSIC = 1 |
37
|
|
|
NITRO = 2 |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
@dataclass |
|
|
|
|
41
|
|
|
class User: |
42
|
|
|
# TODO: Write documentation |
|
|
|
|
43
|
|
|
id: int |
|
|
|
|
44
|
|
|
flags: int |
45
|
|
|
username: str |
46
|
|
|
discriminator: str |
47
|
|
|
bot: Optional[bool] = False |
48
|
|
|
email: Optional[str] = None |
49
|
|
|
banner: Optional[str] = None |
50
|
|
|
locale: Optional[str] = None |
51
|
|
|
avatar: Optional[str] = None |
52
|
|
|
system: Optional[bool] = False |
53
|
|
|
accent_color: Optional[int] = 0 |
54
|
|
|
public_flags: Optional[int] = 0 |
55
|
|
|
verified: Optional[bool] = False |
56
|
|
|
avatar_url: Optional[str] = None |
57
|
|
|
mfa_enabled: Optional[bool] = False |
58
|
|
|
premium_type: Optional[int] = 0 |
59
|
|
|
|
60
|
|
|
@classmethod |
61
|
|
|
def from_dict(cls, data: Data[str, Union[str, bool, int]]) -> User: |
|
|
|
|
62
|
|
|
# TODO: Write documentation |
|
|
|
|
63
|
|
|
return cls(**data) |
64
|
|
|
|
65
|
|
|
@property |
66
|
|
|
def premium(self) -> PremiumTypes: |
|
|
|
|
67
|
|
|
# TODO: Write documentation |
|
|
|
|
68
|
|
|
return PremiumTypes(self.premium_type) |
69
|
|
|
|
70
|
|
|
@property |
71
|
|
|
def user(self) -> str: |
|
|
|
|
72
|
|
|
return self.username + '#' + self.discriminator |
73
|
|
|
|
74
|
|
|
def __repr__(self): |
75
|
|
|
return self.user |
76
|
|
|
|