altvmasterlist.enum

  1#!/usr/bin/env python3
  2from dataclasses import dataclass
  3from enum import Enum
  4import secrets
  5
  6
  7class MasterlistUrls(Enum):
  8    """This class is used for the masterlist submodule. It provides all urls needed."""
  9
 10    all_server_stats = "https://api.alt-mp.com/servers/info"
 11    all_servers = "https://api.alt-mp.com/servers"
 12    specific_server = "https://api.alt-mp.com/servers/{}"
 13    specific_server_average = "https://api.alt-mp.com/servers/{}/avg/{}"
 14    specific_server_maximum = "https://api.alt-mp.com/servers/{}/max/{}"
 15
 16
 17class Extra(Enum):
 18    """This class defines extra values."""
 19
 20    user_agent = "AltPublicAgent"
 21    default_password = "17241709254077376921"
 22
 23
 24@dataclass
 25class Group:
 26    """This defines the group"""
 27
 28    id: str
 29    name: str
 30    iconUrl: str
 31    pinned: bool
 32
 33
 34@dataclass
 35class RequestHeaders:
 36    """These are the common request headers used by the request function.
 37    They are commonly used to emulate an alt:V client.
 38    """
 39
 40    host: str = ""
 41    user_agent: str = Extra.user_agent.value
 42    accept: str = "*/*"
 43    alt_debug: str = "false"
 44    alt_password: str = Extra.default_password.value
 45    alt_branch: str = ""
 46    alt_version: str = ""
 47    alt_player_name: str = secrets.token_urlsafe(10)
 48    alt_social_id: int = "0"
 49    alt_hardware_id2: str = secrets.token_hex(19)
 50    alt_hardware_id: str = secrets.token_hex(19)
 51
 52    def __init__(self, server):
 53        self.alt_branch = server.branch
 54        self.alt_version = server.version
 55        self.host = server.address
 56
 57    def to_dict(self):
 58        return {
 59            "Host": self.host,
 60            "Alt-Branch": self.alt_branch,
 61            "Alt-Debug": self.alt_debug,
 62            "Alt-Hardware-ID": self.alt_hardware_id,
 63            "Alt-Hardware-ID2": self.alt_hardware_id2,
 64            "Alt-Password": self.alt_password,
 65            "Alt-Player-Name": self.alt_player_name,
 66            "Alt-Social-ID": self.alt_social_id,
 67            "Alt-Version": self.alt_version,
 68            "User-Agent": self.user_agent,
 69            "Accept": self.accept,
 70            "Origin": f"http://{self.host}",
 71            "Connection": "close",
 72        }
 73
 74
 75class Permissions:
 76    """This is the Permission class used by get_permissions.
 77
 78    Returns:
 79        Required: The required permissions of an alt:V server. Without them, you can not play on the server.
 80        Optional: The optional permissions of an alt:V server. You can play without them.
 81    """
 82
 83    @dataclass
 84    class Required:
 85        """Required Permissions of an alt:V server.
 86
 87        Attributes:
 88        ----------
 89            screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
 90            webrtc (bool): This allows peer-to-peer RTC inside JS
 91            clipboard_access (bool): This allows to copy content to users clipboard
 92        """
 93
 94        screen_capture: bool = False
 95        webrtc: bool = False
 96        clipboard_access: bool = False
 97
 98    @dataclass
 99    class Optional:
100        """Optional Permissions of an alt:V server.
101
102        Attributes:
103        ----------
104            screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
105            webrtc (bool): This allows peer-to-peer RTC inside JS
106            clipboard_access (bool): This allows to copy content to users clipboard
107        """
108
109        screen_capture: bool = False
110        webrtc: bool = False
111        clipboard_access: bool = False
class MasterlistUrls(enum.Enum):
 8class MasterlistUrls(Enum):
 9    """This class is used for the masterlist submodule. It provides all urls needed."""
10
11    all_server_stats = "https://api.alt-mp.com/servers/info"
12    all_servers = "https://api.alt-mp.com/servers"
13    specific_server = "https://api.alt-mp.com/servers/{}"
14    specific_server_average = "https://api.alt-mp.com/servers/{}/avg/{}"
15    specific_server_maximum = "https://api.alt-mp.com/servers/{}/max/{}"

This class is used for the masterlist submodule. It provides all urls needed.

all_server_stats = <MasterlistUrls.all_server_stats: 'https://api.alt-mp.com/servers/info'>
all_servers = <MasterlistUrls.all_servers: 'https://api.alt-mp.com/servers'>
specific_server = <MasterlistUrls.specific_server: 'https://api.alt-mp.com/servers/{}'>
specific_server_average = <MasterlistUrls.specific_server_average: 'https://api.alt-mp.com/servers/{}/avg/{}'>
specific_server_maximum = <MasterlistUrls.specific_server_maximum: 'https://api.alt-mp.com/servers/{}/max/{}'>
class Extra(enum.Enum):
18class Extra(Enum):
19    """This class defines extra values."""
20
21    user_agent = "AltPublicAgent"
22    default_password = "17241709254077376921"

This class defines extra values.

user_agent = <Extra.user_agent: 'AltPublicAgent'>
default_password = <Extra.default_password: '17241709254077376921'>
@dataclass
class Group:
25@dataclass
26class Group:
27    """This defines the group"""
28
29    id: str
30    name: str
31    iconUrl: str
32    pinned: bool

This defines the group

Group(id: str, name: str, iconUrl: str, pinned: bool)
id: str
name: str
iconUrl: str
pinned: bool
@dataclass
class RequestHeaders:
35@dataclass
36class RequestHeaders:
37    """These are the common request headers used by the request function.
38    They are commonly used to emulate an alt:V client.
39    """
40
41    host: str = ""
42    user_agent: str = Extra.user_agent.value
43    accept: str = "*/*"
44    alt_debug: str = "false"
45    alt_password: str = Extra.default_password.value
46    alt_branch: str = ""
47    alt_version: str = ""
48    alt_player_name: str = secrets.token_urlsafe(10)
49    alt_social_id: int = "0"
50    alt_hardware_id2: str = secrets.token_hex(19)
51    alt_hardware_id: str = secrets.token_hex(19)
52
53    def __init__(self, server):
54        self.alt_branch = server.branch
55        self.alt_version = server.version
56        self.host = server.address
57
58    def to_dict(self):
59        return {
60            "Host": self.host,
61            "Alt-Branch": self.alt_branch,
62            "Alt-Debug": self.alt_debug,
63            "Alt-Hardware-ID": self.alt_hardware_id,
64            "Alt-Hardware-ID2": self.alt_hardware_id2,
65            "Alt-Password": self.alt_password,
66            "Alt-Player-Name": self.alt_player_name,
67            "Alt-Social-ID": self.alt_social_id,
68            "Alt-Version": self.alt_version,
69            "User-Agent": self.user_agent,
70            "Accept": self.accept,
71            "Origin": f"http://{self.host}",
72            "Connection": "close",
73        }

These are the common request headers used by the request function. They are commonly used to emulate an alt:V client.

RequestHeaders(server)
53    def __init__(self, server):
54        self.alt_branch = server.branch
55        self.alt_version = server.version
56        self.host = server.address
host: str = ''
user_agent: str = 'AltPublicAgent'
accept: str = '*/*'
alt_debug: str = 'false'
alt_password: str = '17241709254077376921'
alt_branch: str = ''
alt_version: str = ''
alt_player_name: str = 'Bwy8UuItO4QkDA'
alt_social_id: int = '0'
alt_hardware_id2: str = 'f3fb38e31a3be8ed89e940e26053869728d9e9'
alt_hardware_id: str = 'c57d85698207d0837a1e36139c1407d261efbd'
def to_dict(self):
58    def to_dict(self):
59        return {
60            "Host": self.host,
61            "Alt-Branch": self.alt_branch,
62            "Alt-Debug": self.alt_debug,
63            "Alt-Hardware-ID": self.alt_hardware_id,
64            "Alt-Hardware-ID2": self.alt_hardware_id2,
65            "Alt-Password": self.alt_password,
66            "Alt-Player-Name": self.alt_player_name,
67            "Alt-Social-ID": self.alt_social_id,
68            "Alt-Version": self.alt_version,
69            "User-Agent": self.user_agent,
70            "Accept": self.accept,
71            "Origin": f"http://{self.host}",
72            "Connection": "close",
73        }
class Permissions:
 76class Permissions:
 77    """This is the Permission class used by get_permissions.
 78
 79    Returns:
 80        Required: The required permissions of an alt:V server. Without them, you can not play on the server.
 81        Optional: The optional permissions of an alt:V server. You can play without them.
 82    """
 83
 84    @dataclass
 85    class Required:
 86        """Required Permissions of an alt:V server.
 87
 88        Attributes:
 89        ----------
 90            screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
 91            webrtc (bool): This allows peer-to-peer RTC inside JS
 92            clipboard_access (bool): This allows to copy content to users clipboard
 93        """
 94
 95        screen_capture: bool = False
 96        webrtc: bool = False
 97        clipboard_access: bool = False
 98
 99    @dataclass
100    class Optional:
101        """Optional Permissions of an alt:V server.
102
103        Attributes:
104        ----------
105            screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
106            webrtc (bool): This allows peer-to-peer RTC inside JS
107            clipboard_access (bool): This allows to copy content to users clipboard
108        """
109
110        screen_capture: bool = False
111        webrtc: bool = False
112        clipboard_access: bool = False

This is the Permission class used by get_permissions.

Returns: Required: The required permissions of an alt:V server. Without them, you can not play on the server. Optional: The optional permissions of an alt:V server. You can play without them.

@dataclass
class Permissions.Required:
84    @dataclass
85    class Required:
86        """Required Permissions of an alt:V server.
87
88        Attributes:
89        ----------
90            screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
91            webrtc (bool): This allows peer-to-peer RTC inside JS
92            clipboard_access (bool): This allows to copy content to users clipboard
93        """
94
95        screen_capture: bool = False
96        webrtc: bool = False
97        clipboard_access: bool = False

Required Permissions of an alt:V server.

Attributes:

screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
webrtc (bool): This allows peer-to-peer RTC inside JS
clipboard_access (bool): This allows to copy content to users clipboard
Permissions.Required( screen_capture: bool = False, webrtc: bool = False, clipboard_access: bool = False)
screen_capture: bool = False
webrtc: bool = False
clipboard_access: bool = False
@dataclass
class Permissions.Optional:
 99    @dataclass
100    class Optional:
101        """Optional Permissions of an alt:V server.
102
103        Attributes:
104        ----------
105            screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
106            webrtc (bool): This allows peer-to-peer RTC inside JS
107            clipboard_access (bool): This allows to copy content to users clipboard
108        """
109
110        screen_capture: bool = False
111        webrtc: bool = False
112        clipboard_access: bool = False

Optional Permissions of an alt:V server.

Attributes:

screen_capture (bool): This allows a screenshot to be taken of the alt:V process (just GTA) and any webview
webrtc (bool): This allows peer-to-peer RTC inside JS
clipboard_access (bool): This allows to copy content to users clipboard
Permissions.Optional( screen_capture: bool = False, webrtc: bool = False, clipboard_access: bool = False)
screen_capture: bool = False
webrtc: bool = False
clipboard_access: bool = False