mc5-api-client 1.0.20__py3-none-any.whl → 1.0.22__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mc5_api_client/__init__.py +44 -4
- mc5_api_client/client.py +386 -0
- {mc5_api_client-1.0.20.dist-info → mc5_api_client-1.0.22.dist-info}/METADATA +270 -17
- {mc5_api_client-1.0.20.dist-info → mc5_api_client-1.0.22.dist-info}/RECORD +8 -8
- {mc5_api_client-1.0.20.dist-info → mc5_api_client-1.0.22.dist-info}/WHEEL +0 -0
- {mc5_api_client-1.0.20.dist-info → mc5_api_client-1.0.22.dist-info}/entry_points.txt +0 -0
- {mc5_api_client-1.0.20.dist-info → mc5_api_client-1.0.22.dist-info}/licenses/LICENSE +0 -0
- {mc5_api_client-1.0.20.dist-info → mc5_api_client-1.0.22.dist-info}/top_level.txt +0 -0
mc5_api_client/__init__.py
CHANGED
|
@@ -15,7 +15,7 @@ messaging, and more.
|
|
|
15
15
|
|
|
16
16
|
from typing import Optional, Dict, Any
|
|
17
17
|
|
|
18
|
-
__version__ = "1.0.
|
|
18
|
+
__version__ = "1.0.22"
|
|
19
19
|
__author__ = "Chizoba"
|
|
20
20
|
__email__ = "chizoba2026@hotmail.com"
|
|
21
21
|
__license__ = "MIT"
|
|
@@ -88,6 +88,37 @@ from .auth import TokenGenerator
|
|
|
88
88
|
from .exceptions import MC5APIError, AuthenticationError, RateLimitError
|
|
89
89
|
from .help import help, examples, quick_reference
|
|
90
90
|
|
|
91
|
+
# Automatic Squad Management (NEW!)
|
|
92
|
+
from .client import MC5Client
|
|
93
|
+
|
|
94
|
+
# Add automatic squad management methods as standalone functions
|
|
95
|
+
def get_my_squad_id(client=None, **kwargs):
|
|
96
|
+
"""Get user's squad ID automatically."""
|
|
97
|
+
if client is None:
|
|
98
|
+
client = MC5Client(**kwargs)
|
|
99
|
+
return client.get_my_squad_id()
|
|
100
|
+
|
|
101
|
+
def get_my_squad_info(client=None, **kwargs):
|
|
102
|
+
"""Get user's squad information automatically."""
|
|
103
|
+
if client is None:
|
|
104
|
+
client = MC5Client(**kwargs)
|
|
105
|
+
return client.get_my_squad_info()
|
|
106
|
+
|
|
107
|
+
def update_my_squad_info(client=None, **squad_kwargs):
|
|
108
|
+
"""Update user's squad information automatically."""
|
|
109
|
+
client_kwargs = {k: v for k, v in squad_kwargs.items() if k in ['username', 'password', 'client_id']}
|
|
110
|
+
update_kwargs = {k: v for k, v in squad_kwargs.items() if k not in ['username', 'password', 'client_id']}
|
|
111
|
+
|
|
112
|
+
if client is None:
|
|
113
|
+
client = MC5Client(**client_kwargs)
|
|
114
|
+
return client.update_my_squad_info(**update_kwargs)
|
|
115
|
+
|
|
116
|
+
def get_my_squad_members(client=None, **kwargs):
|
|
117
|
+
"""Get user's squad members automatically."""
|
|
118
|
+
if client is None:
|
|
119
|
+
client = MC5Client(**kwargs)
|
|
120
|
+
return client.get_my_squad_members()
|
|
121
|
+
|
|
91
122
|
# Add MC5ApiClient as an alias for backward compatibility
|
|
92
123
|
MC5ApiClient = MC5Client
|
|
93
124
|
from .admin_client import (
|
|
@@ -399,9 +430,18 @@ __all__ = [
|
|
|
399
430
|
"MC5Easy",
|
|
400
431
|
"quick_connect",
|
|
401
432
|
"check_my_daily_tasks",
|
|
402
|
-
"
|
|
403
|
-
"
|
|
404
|
-
"
|
|
433
|
+
"get_server_status",
|
|
434
|
+
"get_online_players",
|
|
435
|
+
"get_server_info",
|
|
436
|
+
"get_my_squad_id",
|
|
437
|
+
"get_my_squad_info",
|
|
438
|
+
"update_my_squad_info",
|
|
439
|
+
"get_my_squad_members",
|
|
440
|
+
"calculate_xp_for_level",
|
|
441
|
+
"get_color_value",
|
|
442
|
+
"customize_squad_theme",
|
|
443
|
+
"set_squad_level",
|
|
444
|
+
"customize_squad_complete",
|
|
405
445
|
"generate_device_id",
|
|
406
446
|
"create_federation_session",
|
|
407
447
|
"locate_service",
|
mc5_api_client/client.py
CHANGED
|
@@ -1652,6 +1652,392 @@ class MC5Client(SquadBattleMixin, FederationMixin, AlertsMixin, AccountMixin, Tr
|
|
|
1652
1652
|
"timestamp": time.time()
|
|
1653
1653
|
}
|
|
1654
1654
|
|
|
1655
|
+
# Automatic Squad Management (NEW!)
|
|
1656
|
+
|
|
1657
|
+
def get_my_squad_id(self) -> Optional[str]:
|
|
1658
|
+
"""
|
|
1659
|
+
Automatically fetch the user's squad ID from their profile.
|
|
1660
|
+
|
|
1661
|
+
This method eliminates the need to manually specify squad ID for squad operations.
|
|
1662
|
+
It fetches the user's profile and extracts the squad/group ID from their groups.
|
|
1663
|
+
|
|
1664
|
+
Returns:
|
|
1665
|
+
Squad ID if found, None otherwise
|
|
1666
|
+
"""
|
|
1667
|
+
try:
|
|
1668
|
+
# Get user profile which contains groups information
|
|
1669
|
+
profile = self.get_profile()
|
|
1670
|
+
|
|
1671
|
+
if not profile:
|
|
1672
|
+
return None
|
|
1673
|
+
|
|
1674
|
+
# Check if user has groups
|
|
1675
|
+
groups = profile.get('groups', [])
|
|
1676
|
+
if not groups:
|
|
1677
|
+
return None
|
|
1678
|
+
|
|
1679
|
+
# Extract squad ID from groups (usually the first group is the squad)
|
|
1680
|
+
# Groups can be in different formats, handle multiple cases
|
|
1681
|
+
for group in groups:
|
|
1682
|
+
if isinstance(group, str):
|
|
1683
|
+
# Simple string ID
|
|
1684
|
+
return group
|
|
1685
|
+
elif isinstance(group, dict):
|
|
1686
|
+
# Dictionary with ID field
|
|
1687
|
+
if 'id' in group:
|
|
1688
|
+
return group['id']
|
|
1689
|
+
elif '_id' in group:
|
|
1690
|
+
return group['_id']
|
|
1691
|
+
elif 'group_id' in group:
|
|
1692
|
+
return group['group_id']
|
|
1693
|
+
|
|
1694
|
+
# If no group found in the expected format, try to extract from the groups string
|
|
1695
|
+
if groups and isinstance(groups[0], str):
|
|
1696
|
+
return groups[0]
|
|
1697
|
+
|
|
1698
|
+
return None
|
|
1699
|
+
|
|
1700
|
+
except Exception as e:
|
|
1701
|
+
print(f"🔴 Error fetching squad ID: {e}")
|
|
1702
|
+
return None
|
|
1703
|
+
|
|
1704
|
+
def get_my_squad_info(self) -> Dict[str, Any]:
|
|
1705
|
+
"""
|
|
1706
|
+
Get complete squad information using automatically fetched squad ID.
|
|
1707
|
+
|
|
1708
|
+
Returns:
|
|
1709
|
+
Dictionary with squad information or error details
|
|
1710
|
+
"""
|
|
1711
|
+
try:
|
|
1712
|
+
squad_id = self.get_my_squad_id()
|
|
1713
|
+
if not squad_id:
|
|
1714
|
+
return {
|
|
1715
|
+
"error": "No squad found for this user",
|
|
1716
|
+
"message": "User is not in any squad",
|
|
1717
|
+
"timestamp": time.time()
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
# Get squad information using the fetched ID
|
|
1721
|
+
squad_info = self.get_clan_settings(squad_id)
|
|
1722
|
+
|
|
1723
|
+
if squad_info:
|
|
1724
|
+
squad_info['auto_fetched_squad_id'] = squad_id
|
|
1725
|
+
squad_info['fetch_method'] = 'automatic'
|
|
1726
|
+
return squad_info
|
|
1727
|
+
else:
|
|
1728
|
+
return {
|
|
1729
|
+
"error": "Failed to fetch squad details",
|
|
1730
|
+
"squad_id": squad_id,
|
|
1731
|
+
"message": "Squad ID found but could not fetch details",
|
|
1732
|
+
"timestamp": time.time()
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
except Exception as e:
|
|
1736
|
+
return {
|
|
1737
|
+
"error": str(e),
|
|
1738
|
+
"message": "Failed to get squad information",
|
|
1739
|
+
"timestamp": time.time()
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
def update_my_squad_info(self, **kwargs) -> Dict[str, Any]:
|
|
1743
|
+
"""
|
|
1744
|
+
Update squad information using automatically fetched squad ID.
|
|
1745
|
+
|
|
1746
|
+
This is a convenience method that combines get_my_squad_id() and update_clan_settings().
|
|
1747
|
+
Users don't need to specify squad ID - it's automatically fetched from their profile.
|
|
1748
|
+
|
|
1749
|
+
Args:
|
|
1750
|
+
**kwargs: Squad settings to update (same as update_clan_settings)
|
|
1751
|
+
- name: Squad name
|
|
1752
|
+
- description: Squad description
|
|
1753
|
+
- rating: Squad rating
|
|
1754
|
+
- min_join_value: Minimum join value
|
|
1755
|
+
- logo: Squad logo ID
|
|
1756
|
+
- logo_clr_prim: Primary logo color
|
|
1757
|
+
- logo_clr_sec: Secondary logo color
|
|
1758
|
+
|
|
1759
|
+
Returns:
|
|
1760
|
+
Dictionary with update result or error details
|
|
1761
|
+
"""
|
|
1762
|
+
try:
|
|
1763
|
+
squad_id = self.get_my_squad_id()
|
|
1764
|
+
if not squad_id:
|
|
1765
|
+
return {
|
|
1766
|
+
"error": "No squad found for this user",
|
|
1767
|
+
"message": "Cannot update squad - user is not in any squad",
|
|
1768
|
+
"timestamp": time.time()
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
# Update squad using the fetched ID
|
|
1772
|
+
result = self.update_clan_settings(squad_id, **kwargs)
|
|
1773
|
+
|
|
1774
|
+
if result:
|
|
1775
|
+
result['auto_fetched_squad_id'] = squad_id
|
|
1776
|
+
result['update_method'] = 'automatic'
|
|
1777
|
+
return result
|
|
1778
|
+
else:
|
|
1779
|
+
return {
|
|
1780
|
+
"error": "Failed to update squad",
|
|
1781
|
+
"squad_id": squad_id,
|
|
1782
|
+
"message": "Squad ID found but update failed",
|
|
1783
|
+
"timestamp": time.time()
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
except Exception as e:
|
|
1787
|
+
return {
|
|
1788
|
+
"error": str(e),
|
|
1789
|
+
"message": "Failed to update squad information",
|
|
1790
|
+
"timestamp": time.time()
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
def get_my_squad_members(self) -> Dict[str, Any]:
|
|
1794
|
+
"""
|
|
1795
|
+
Get squad members using automatically fetched squad ID.
|
|
1796
|
+
|
|
1797
|
+
Returns:
|
|
1798
|
+
Dictionary with squad members or error details
|
|
1799
|
+
"""
|
|
1800
|
+
try:
|
|
1801
|
+
squad_id = self.get_my_squad_id()
|
|
1802
|
+
if not squad_id:
|
|
1803
|
+
return {
|
|
1804
|
+
"error": "No squad found for this user",
|
|
1805
|
+
"message": "Cannot get squad members - user is not in any squad",
|
|
1806
|
+
"timestamp": time.time()
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
# Get squad members using the fetched ID
|
|
1810
|
+
members = self.get_clan_members(squad_id)
|
|
1811
|
+
|
|
1812
|
+
if members:
|
|
1813
|
+
return {
|
|
1814
|
+
"squad_id": squad_id,
|
|
1815
|
+
"members": members,
|
|
1816
|
+
"member_count": len(members) if isinstance(members, list) else 0,
|
|
1817
|
+
"fetch_method": "automatic",
|
|
1818
|
+
"timestamp": time.time()
|
|
1819
|
+
}
|
|
1820
|
+
else:
|
|
1821
|
+
return {
|
|
1822
|
+
"error": "Failed to fetch squad members",
|
|
1823
|
+
"squad_id": squad_id,
|
|
1824
|
+
"message": "Squad ID found but could not fetch members",
|
|
1825
|
+
"timestamp": time.time()
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
except Exception as e:
|
|
1829
|
+
return {
|
|
1830
|
+
"error": str(e),
|
|
1831
|
+
"message": "Failed to get squad members",
|
|
1832
|
+
"timestamp": time.time()
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
# Squad Customization Helpers (NEW!)
|
|
1836
|
+
|
|
1837
|
+
def calculate_xp_for_level(self, level: int) -> int:
|
|
1838
|
+
"""
|
|
1839
|
+
Calculate XP required for a specific squad level.
|
|
1840
|
+
|
|
1841
|
+
Level System:
|
|
1842
|
+
- Level 1: 1000 XP
|
|
1843
|
+
- Level 2: 2000 XP
|
|
1844
|
+
- ...
|
|
1845
|
+
- Level 10: 10000 XP (maximum)
|
|
1846
|
+
|
|
1847
|
+
Args:
|
|
1848
|
+
level: Desired level (1-10)
|
|
1849
|
+
|
|
1850
|
+
Returns:
|
|
1851
|
+
XP value for the level
|
|
1852
|
+
"""
|
|
1853
|
+
if level < 1:
|
|
1854
|
+
level = 1
|
|
1855
|
+
elif level > 10:
|
|
1856
|
+
level = 10
|
|
1857
|
+
|
|
1858
|
+
return level * 1000
|
|
1859
|
+
|
|
1860
|
+
def get_color_value(self, color_name: str) -> str:
|
|
1861
|
+
"""
|
|
1862
|
+
Get color value for common colors.
|
|
1863
|
+
|
|
1864
|
+
Args:
|
|
1865
|
+
color_name: Name of the color
|
|
1866
|
+
|
|
1867
|
+
Returns:
|
|
1868
|
+
Color value in decimal format
|
|
1869
|
+
"""
|
|
1870
|
+
colors = {
|
|
1871
|
+
'black': '0',
|
|
1872
|
+
'white': '16777215',
|
|
1873
|
+
'red': '16711680',
|
|
1874
|
+
'green': '65280',
|
|
1875
|
+
'blue': '255',
|
|
1876
|
+
'yellow': '16776960',
|
|
1877
|
+
'purple': '16711808',
|
|
1878
|
+
'orange': '16753920',
|
|
1879
|
+
'pink': '16761035',
|
|
1880
|
+
'cyan': '65535',
|
|
1881
|
+
'lime': '65280',
|
|
1882
|
+
'navy': '128',
|
|
1883
|
+
'gold': '16766720',
|
|
1884
|
+
'silver': '12632256',
|
|
1885
|
+
'maroon': '8388608',
|
|
1886
|
+
'teal': '32768',
|
|
1887
|
+
'olive': '8421376'
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
return colors.get(color_name.lower(), '0')
|
|
1891
|
+
|
|
1892
|
+
def customize_squad_theme(self, theme_name: str, squad_name: str = None) -> Dict[str, Any]:
|
|
1893
|
+
"""
|
|
1894
|
+
Apply a predefined color theme to your squad.
|
|
1895
|
+
|
|
1896
|
+
Args:
|
|
1897
|
+
theme_name: Name of the theme ('dark', 'fire', 'ice', 'nature')
|
|
1898
|
+
squad_name: Optional custom squad name
|
|
1899
|
+
|
|
1900
|
+
Returns:
|
|
1901
|
+
Dictionary with update result or error details
|
|
1902
|
+
"""
|
|
1903
|
+
themes = {
|
|
1904
|
+
'dark': {
|
|
1905
|
+
'_logo_clr_prim': self.get_color_value('black'),
|
|
1906
|
+
'_logo_clr_sec': self.get_color_value('white'),
|
|
1907
|
+
'name': squad_name or 'Dark Knights'
|
|
1908
|
+
},
|
|
1909
|
+
'fire': {
|
|
1910
|
+
'_logo_clr_prim': self.get_color_value('red'),
|
|
1911
|
+
'_logo_clr_sec': self.get_color_value('orange'),
|
|
1912
|
+
'name': squad_name or 'Fire Warriors'
|
|
1913
|
+
},
|
|
1914
|
+
'ice': {
|
|
1915
|
+
'_logo_clr_prim': self.get_color_value('blue'),
|
|
1916
|
+
'_logo_clr_sec': self.get_color_value('cyan'),
|
|
1917
|
+
'name': squad_name or 'Ice Legion'
|
|
1918
|
+
},
|
|
1919
|
+
'nature': {
|
|
1920
|
+
'_logo_clr_prim': self.get_color_value('green'),
|
|
1921
|
+
'_logo_clr_sec': self.get_color_value('lime'),
|
|
1922
|
+
'name': squad_name or 'Nature Guardians'
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
theme = themes.get(theme_name.lower())
|
|
1927
|
+
if not theme:
|
|
1928
|
+
return {
|
|
1929
|
+
"error": f"Unknown theme: {theme_name}",
|
|
1930
|
+
"available_themes": list(themes.keys()),
|
|
1931
|
+
"timestamp": time.time()
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
return self.update_my_squad_info(**theme)
|
|
1935
|
+
|
|
1936
|
+
def set_squad_level(self, level: int, squad_name: str = None) -> Dict[str, Any]:
|
|
1937
|
+
"""
|
|
1938
|
+
Set squad to a specific level with appropriate settings.
|
|
1939
|
+
|
|
1940
|
+
Args:
|
|
1941
|
+
level: Desired level (1-10)
|
|
1942
|
+
squad_name: Optional custom squad name
|
|
1943
|
+
|
|
1944
|
+
Returns:
|
|
1945
|
+
Dictionary with update result or error details
|
|
1946
|
+
"""
|
|
1947
|
+
if level < 1 or level > 10:
|
|
1948
|
+
return {
|
|
1949
|
+
"error": "Level must be between 1 and 10",
|
|
1950
|
+
"timestamp": time.time()
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
updates = {
|
|
1954
|
+
"name": squad_name or f"Level {level} Squad",
|
|
1955
|
+
"_xp": self.calculate_xp_for_level(level),
|
|
1956
|
+
"rating": level * 500,
|
|
1957
|
+
"_min_join_value": level * 100,
|
|
1958
|
+
"member_limit": 20 + (level * 5),
|
|
1959
|
+
"description": f"Elite squad at Level {level}!"
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
return self.update_my_squad_info(**updates)
|
|
1963
|
+
|
|
1964
|
+
def customize_squad_complete(self, **kwargs) -> Dict[str, Any]:
|
|
1965
|
+
"""
|
|
1966
|
+
Customize squad with any parameters and validation.
|
|
1967
|
+
|
|
1968
|
+
Args:
|
|
1969
|
+
**kwargs: Any squad parameters to update
|
|
1970
|
+
|
|
1971
|
+
Available parameters:
|
|
1972
|
+
- name: Squad name
|
|
1973
|
+
- description: Squad description
|
|
1974
|
+
- rating: Squad rating
|
|
1975
|
+
- score: Squad score
|
|
1976
|
+
- member_limit: Maximum members (1-300)
|
|
1977
|
+
- membership: Membership type ('open' or 'owner_approved')
|
|
1978
|
+
- _logo: Logo ID
|
|
1979
|
+
- _logo_clr_prim: Primary color (RGB decimal 0-16777215)
|
|
1980
|
+
- _logo_clr_sec: Secondary color (RGB decimal 0-16777215)
|
|
1981
|
+
- _min_join_value: Minimum join value
|
|
1982
|
+
- _xp: Squad XP (1000-10000, determines level)
|
|
1983
|
+
- _killsig_id: Kill signature ID
|
|
1984
|
+
- currency: Squad currency
|
|
1985
|
+
- active_clan_label: Active clan label
|
|
1986
|
+
- active_clan_threshold: Active clan threshold
|
|
1987
|
+
|
|
1988
|
+
Returns:
|
|
1989
|
+
Dictionary with update result or error details
|
|
1990
|
+
"""
|
|
1991
|
+
# Validate data
|
|
1992
|
+
errors = []
|
|
1993
|
+
|
|
1994
|
+
# Validate XP/Level
|
|
1995
|
+
if '_xp' in kwargs:
|
|
1996
|
+
try:
|
|
1997
|
+
xp = int(kwargs['_xp'])
|
|
1998
|
+
if xp < 1000 or xp > 10000:
|
|
1999
|
+
errors.append("XP must be between 1000 (Level 1) and 10000 (Level 10)")
|
|
2000
|
+
except ValueError:
|
|
2001
|
+
errors.append("_xp must be a valid number")
|
|
2002
|
+
|
|
2003
|
+
# Validate member limit
|
|
2004
|
+
if 'member_limit' in kwargs:
|
|
2005
|
+
try:
|
|
2006
|
+
limit = int(kwargs['member_limit'])
|
|
2007
|
+
if limit < 1 or limit > 300:
|
|
2008
|
+
errors.append("Member limit must be between 1 and 300")
|
|
2009
|
+
except ValueError:
|
|
2010
|
+
errors.append("member_limit must be a valid number")
|
|
2011
|
+
|
|
2012
|
+
# Validate colors
|
|
2013
|
+
for color_key in ['_logo_clr_prim', '_logo_clr_sec']:
|
|
2014
|
+
if color_key in kwargs:
|
|
2015
|
+
try:
|
|
2016
|
+
color = int(kwargs[color_key])
|
|
2017
|
+
if color < 0 or color > 16777215: # RGB max value
|
|
2018
|
+
errors.append(f"{color_key} must be between 0 and 16777215")
|
|
2019
|
+
except ValueError:
|
|
2020
|
+
errors.append(f"{color_key} must be a valid number")
|
|
2021
|
+
|
|
2022
|
+
# Validate rating
|
|
2023
|
+
if 'rating' in kwargs:
|
|
2024
|
+
try:
|
|
2025
|
+
rating = int(kwargs['rating'])
|
|
2026
|
+
if rating < 0 or rating > 99999:
|
|
2027
|
+
errors.append("Rating must be between 0 and 99999")
|
|
2028
|
+
except ValueError:
|
|
2029
|
+
errors.append("rating must be a valid number")
|
|
2030
|
+
|
|
2031
|
+
if errors:
|
|
2032
|
+
return {
|
|
2033
|
+
"error": "Validation failed",
|
|
2034
|
+
"validation_errors": errors,
|
|
2035
|
+
"timestamp": time.time()
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
# Apply updates
|
|
2039
|
+
return self.update_my_squad_info(**kwargs)
|
|
2040
|
+
|
|
1655
2041
|
# Events API
|
|
1656
2042
|
|
|
1657
2043
|
def get_events(self, event_type: str = None, status: str = None) -> List[Dict[str, Any]]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mc5_api_client
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.22
|
|
4
4
|
Summary: A comprehensive Python library for interacting with the Modern Combat 5 API
|
|
5
5
|
Home-page: https://pypi.org/project/mc5-api-client/
|
|
6
6
|
Author: Chizoba
|
|
@@ -81,22 +81,27 @@ Dynamic: requires-python
|
|
|
81
81
|
[](https://python.org)
|
|
82
82
|
[](LICENSE)
|
|
83
83
|
[](mailto:chizoba2026@hotmail.com)
|
|
84
|
-
[](https://pypi.org/project/mc5-api-client/)
|
|
85
85
|
[](https://pypi.org/project/mc5-api-client/)
|
|
86
86
|
|
|
87
87
|
Hey there! 👋 Welcome to the **Modern Combat 5 API Client** - Comprehensive Python library for interacting with Modern Combat 5 game servers
|
|
88
88
|
|
|
89
|
-
## ✨ **New in v1.0.
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
- 🚀 **
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
89
|
+
## ✨ **New in v1.0.21: Revolutionary Automatic Squad Management!**
|
|
90
|
+
|
|
91
|
+
- 🎮 **REVOLUTIONARY: Automatic Squad Management** - No more manual squad IDs! Automatically detect and manage your squad from your profile
|
|
92
|
+
- 🚀 **Zero Configuration Squad Operations** - `get_my_squad_info()`, `update_my_squad_info()`, `get_my_squad_members()` - all work without squad IDs
|
|
93
|
+
- 🔄 **Squad Switching Support** - Automatically adapts when you change squads
|
|
94
|
+
- 🛡️ **Intelligent Error Handling** - Graceful handling for users without squads
|
|
95
|
+
- 📱 **Perfect for Mobile/Web Apps** - Standalone functions work without client instances
|
|
96
|
+
- 🎯 **MC5Easy** - Super simple one-line functions for everyday tasks
|
|
97
|
+
- 🚀 **One-Liner Functions** - `check_my_daily_tasks()`, `get_my_mc5_profile()`, `find_mc5_player()`
|
|
98
|
+
- 📝 **Context Manager** - Auto-connect and auto-cleanup with `with MC5Easy()`
|
|
99
|
+
- 🔧 **Environment Variables** - Secure credential management with `MC5_USERNAME` and `MC5_PASSWORD`
|
|
100
|
+
- 🌐 **Service Location** - Dynamic MC5 service endpoint discovery
|
|
101
|
+
- 🎮 **Federation Sessions** - Complete game launch preparation
|
|
102
|
+
- 🌍 **Global ID Management** - Device tracking and identification
|
|
103
|
+
- 🔗 **Connection Monitoring** - Service health and status tracking
|
|
104
|
+
- 🏠 **Room Discovery** - Find available game rooms
|
|
100
105
|
- 🏰 **PC Storage Admin** - Complete squad management with storage scopes
|
|
101
106
|
- 🔧 **StorageAdminMixin** - Core storage functionality for advanced operations
|
|
102
107
|
- 👤 **System Account Access** - 5 working system accounts discovered
|
|
@@ -140,12 +145,84 @@ Think of this as your remote control for Modern Combat 5! Here's what you can do
|
|
|
140
145
|
|
|
141
146
|
## 🚀 Installation
|
|
142
147
|
|
|
143
|
-
### 🎉 MC5 API Client v1.0.
|
|
148
|
+
### 🎉 MC5 API Client v1.0.21 - Revolutionary Automatic Squad Management!
|
|
144
149
|
|
|
145
150
|
```bash
|
|
146
|
-
pip install mc5_api_client==1.0.
|
|
151
|
+
pip install mc5_api_client==1.0.21
|
|
147
152
|
```
|
|
148
153
|
|
|
154
|
+
## 🎮 **🚀 REVOLUTIONARY FEATURE: Automatic Squad Management**
|
|
155
|
+
|
|
156
|
+
### **🎯 The Problem We Solved:**
|
|
157
|
+
Previously, users had to manually specify squad IDs for squad operations:
|
|
158
|
+
```python
|
|
159
|
+
# ❌ OLD METHOD - Complex and error-prone
|
|
160
|
+
squad_id = "d1e7437c-0156-11f1-ad07-b8ca3a709038" # Hard to remember!
|
|
161
|
+
squad_info = client.get_clan_settings(squad_id) # Manual ID required
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### **✅ Our Solution - Automatic Detection:**
|
|
165
|
+
```python
|
|
166
|
+
# ✅ NEW METHOD - Simple and automatic
|
|
167
|
+
squad_info = client.get_my_squad_info() # Auto-fetched from profile!
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### **🎮 Key Benefits:**
|
|
171
|
+
- 🎯 **No Squad ID Memorization** - Automatically detected from your profile
|
|
172
|
+
- 🔄 **Squad Switching Support** - Works when you change squads
|
|
173
|
+
- 🛡️ **Intelligent Error Handling** - Graceful handling for users without squads
|
|
174
|
+
- 📱 **Perfect for Mobile/Web Apps** - Standalone functions work without client instances
|
|
175
|
+
- 🚀 **Zero Configuration** - Just call the methods, no setup required
|
|
176
|
+
|
|
177
|
+
### **🔧 Available Methods:**
|
|
178
|
+
|
|
179
|
+
#### **Client Methods:**
|
|
180
|
+
```python
|
|
181
|
+
from mc5_api_client import MC5Client
|
|
182
|
+
|
|
183
|
+
client = MC5Client(username, password)
|
|
184
|
+
|
|
185
|
+
# Get squad ID automatically
|
|
186
|
+
squad_id = client.get_my_squad_id()
|
|
187
|
+
|
|
188
|
+
# Get complete squad information
|
|
189
|
+
squad_info = client.get_my_squad_info()
|
|
190
|
+
|
|
191
|
+
# Get squad members
|
|
192
|
+
members = client.get_my_squad_members()
|
|
193
|
+
|
|
194
|
+
# Update squad (no squad ID needed!)
|
|
195
|
+
client.update_my_squad_info(
|
|
196
|
+
name="Elite Squad",
|
|
197
|
+
description="Best squad in MC5!",
|
|
198
|
+
rating=2000
|
|
199
|
+
)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### **Standalone Functions:**
|
|
203
|
+
```python
|
|
204
|
+
from mc5_api_client import get_my_squad_info, update_my_squad_info
|
|
205
|
+
|
|
206
|
+
# Work without creating a client!
|
|
207
|
+
squad_info = get_my_squad_info(
|
|
208
|
+
username="your_credential",
|
|
209
|
+
password="your_password"
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
# Update squad without client
|
|
213
|
+
result = update_my_squad_info(
|
|
214
|
+
username="your_credential",
|
|
215
|
+
password="your_password",
|
|
216
|
+
name="New Squad Name"
|
|
217
|
+
)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### **🔄 Real-World Impact:**
|
|
221
|
+
- **10x easier** squad management
|
|
222
|
+
- **Zero configuration** required
|
|
223
|
+
- **Automatic adaptation** to squad changes
|
|
224
|
+
- **Perfect for** modern applications
|
|
225
|
+
|
|
149
226
|
## 🎯 **Usage Examples**
|
|
150
227
|
|
|
151
228
|
### **🎮 Basic Usage (MC5Client)**
|
|
@@ -245,6 +322,179 @@ with MC5Easy(username, password) as mc5:
|
|
|
245
322
|
print(f"Device: {device_info}")
|
|
246
323
|
```
|
|
247
324
|
|
|
325
|
+
### **🎮 Automatic Squad Management (REVOLUTIONARY!)**
|
|
326
|
+
```python
|
|
327
|
+
from mc5_api_client import MC5Client, get_my_squad_info, update_my_squad_info
|
|
328
|
+
|
|
329
|
+
# Initialize client
|
|
330
|
+
client = MC5Client(username, password)
|
|
331
|
+
|
|
332
|
+
# 🚀 NO MORE SQUAD ID NEEDED! Automatically detected from your profile!
|
|
333
|
+
|
|
334
|
+
# Get your squad information automatically
|
|
335
|
+
squad_info = client.get_my_squad_info()
|
|
336
|
+
print(f"Squad Name: {squad_info['name']}")
|
|
337
|
+
print(f"Squad Rating: {squad_info['rating']}")
|
|
338
|
+
print(f"Description: {squad_info['description']}")
|
|
339
|
+
|
|
340
|
+
# Get squad members automatically
|
|
341
|
+
members = client.get_my_squad_members()
|
|
342
|
+
print(f"Member Count: {members['member_count']}")
|
|
343
|
+
for member in members['members'][:3]:
|
|
344
|
+
print(f" - {member['name']}")
|
|
345
|
+
|
|
346
|
+
# Update squad automatically (no squad ID required!)
|
|
347
|
+
client.update_my_squad_info(
|
|
348
|
+
name="Elite Squad",
|
|
349
|
+
description="Best squad in MC5!",
|
|
350
|
+
rating=2000,
|
|
351
|
+
min_join_value=1000
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
# 🔄 Works even when you switch squads!
|
|
355
|
+
# The methods automatically detect your current squad
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### **🚀 Standalone Squad Management (No Client Required!)**
|
|
359
|
+
```python
|
|
360
|
+
from mc5_api_client import get_my_squad_id, get_my_squad_info, update_my_squad_info
|
|
361
|
+
|
|
362
|
+
# Get squad ID without creating client
|
|
363
|
+
squad_id = get_my_squad_id(
|
|
364
|
+
username="your_credential",
|
|
365
|
+
password="your_password"
|
|
366
|
+
)
|
|
367
|
+
print(f"Your Squad ID: {squad_id}")
|
|
368
|
+
|
|
369
|
+
# Get squad info without creating client
|
|
370
|
+
squad_info = get_my_squad_info(
|
|
371
|
+
username="your_credential",
|
|
372
|
+
password="your_password"
|
|
373
|
+
)
|
|
374
|
+
print(f"Squad: {squad_info['name']}")
|
|
375
|
+
|
|
376
|
+
# Update squad without creating client
|
|
377
|
+
result = update_my_squad_info(
|
|
378
|
+
username="your_credential",
|
|
379
|
+
password="your_password",
|
|
380
|
+
name="New Squad Name",
|
|
381
|
+
description="Updated description"
|
|
382
|
+
)
|
|
383
|
+
print(f"Update Result: {result}")
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### **🔄 Traditional vs Automatic Squad Management**
|
|
387
|
+
```python
|
|
388
|
+
# ❌ OLD METHOD - Manual squad ID required
|
|
389
|
+
squad_id = "d1e7437c-0156-11f1-ad07-b8ca3a709038" # Hard to remember!
|
|
390
|
+
squad_info = client.get_clan_settings(squad_id) # Manual ID required
|
|
391
|
+
members = client.get_clan_members(squad_id) # Manual ID required
|
|
392
|
+
client.update_clan_settings(squad_id, name="New") # Manual ID required
|
|
393
|
+
|
|
394
|
+
# ✅ NEW METHOD - Automatic detection
|
|
395
|
+
squad_info = client.get_my_squad_info() # Auto-fetched!
|
|
396
|
+
members = client.get_my_squad_members() # Auto-fetched!
|
|
397
|
+
client.update_my_squad_info(name="New") # Auto-fetched!
|
|
398
|
+
|
|
399
|
+
# Benefits:
|
|
400
|
+
# 🎯 No squad ID memorization
|
|
401
|
+
# 🔄 Works when switching squads
|
|
402
|
+
# 🛡️ Error handling for users without squads
|
|
403
|
+
# 🚀 Simpler API for everyday use
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### **🎨 Complete Squad Customization (NEW!)**
|
|
407
|
+
```python
|
|
408
|
+
from mc5_api_client import MC5Client
|
|
409
|
+
|
|
410
|
+
client = MC5Client(username, password)
|
|
411
|
+
|
|
412
|
+
# 🎯 Set squad to specific level (1-10)
|
|
413
|
+
client.set_squad_level(8, "Level 8 Elite")
|
|
414
|
+
# Automatically sets XP, rating, member limit, etc.
|
|
415
|
+
|
|
416
|
+
# 🎨 Apply color themes
|
|
417
|
+
client.customize_squad_theme('fire', 'Fire Warriors') # Red/Orange theme
|
|
418
|
+
client.customize_squad_theme('ice', 'Ice Legion') # Blue/Cyan theme
|
|
419
|
+
client.customize_squad_theme('dark', 'Dark Knights') # Black/White theme
|
|
420
|
+
client.customize_squad_theme('nature', 'Nature Guardians') # Green/Lime theme
|
|
421
|
+
|
|
422
|
+
# 🔧 Complete customization with validation
|
|
423
|
+
client.customize_squad_complete(
|
|
424
|
+
name="452e55e84897+",
|
|
425
|
+
description="Professional squad with active members!",
|
|
426
|
+
rating=3573,
|
|
427
|
+
score=5200,
|
|
428
|
+
member_limit=300,
|
|
429
|
+
membership="owner_approved",
|
|
430
|
+
_logo="1",
|
|
431
|
+
_logo_clr_prim=client.get_color_value("red"), # Red color
|
|
432
|
+
_logo_clr_sec=client.get_color_value("white"), # White color
|
|
433
|
+
_min_join_value=996699,
|
|
434
|
+
_xp=client.calculate_xp_for_level(9), # Level 9 = 9000 XP
|
|
435
|
+
_killsig_id="default_killsig_01",
|
|
436
|
+
currency="10000",
|
|
437
|
+
active_clan_label="true",
|
|
438
|
+
active_clan_threshold="50"
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
# 🎯 Helper functions
|
|
442
|
+
xp = client.calculate_xp_for_level(5) # Returns 5000
|
|
443
|
+
color = client.get_color_value('blue') # Returns '255'
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### **📊 Squad Parameters You Can Customize:**
|
|
447
|
+
```python
|
|
448
|
+
# 📝 Basic Information
|
|
449
|
+
name: "Your Squad Name"
|
|
450
|
+
description: "Your squad description"
|
|
451
|
+
rating: 5000
|
|
452
|
+
score: 5200
|
|
453
|
+
|
|
454
|
+
# 👥 Member Settings
|
|
455
|
+
member_limit: 300 # 1-300 members
|
|
456
|
+
membership: "owner_approved" # or "open"
|
|
457
|
+
_min_join_value: 1000 # Minimum score to join
|
|
458
|
+
|
|
459
|
+
# 🎨 Visual Customization
|
|
460
|
+
_logo: "1" # Logo ID
|
|
461
|
+
_logo_clr_prim: "16711680" # Primary color (RGB decimal)
|
|
462
|
+
_logo_clr_sec: "16777215" # Secondary color (RGB decimal)
|
|
463
|
+
# Colors: black=0, white=16777215, red=16711680, blue=255, green=65280
|
|
464
|
+
|
|
465
|
+
# ⭐ Level & Progress
|
|
466
|
+
_xp: "5000" # Level 5 (1000-10000, Level 1-10)
|
|
467
|
+
# Level 1: 1000, Level 2: 2000, ..., Level 10: 10000
|
|
468
|
+
|
|
469
|
+
# 💰 Economy
|
|
470
|
+
currency: "10000"
|
|
471
|
+
_killsig_id: "default_killsig_01"
|
|
472
|
+
|
|
473
|
+
# 🏃 Activity Settings
|
|
474
|
+
active_clan_label: "true"
|
|
475
|
+
active_clan_threshold: "50"
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### **🎮 Quick Customization Examples:**
|
|
479
|
+
```python
|
|
480
|
+
# 🚀 One-line level upgrades
|
|
481
|
+
client.set_squad_level(10) # Max level squad
|
|
482
|
+
client.set_squad_level(5, "Level 5 Warriors") # Custom name
|
|
483
|
+
|
|
484
|
+
# 🎨 One-line theme applications
|
|
485
|
+
client.customize_squad_theme('fire') # Fire theme
|
|
486
|
+
client.customize_squad_theme('ice', 'Ice Squad') # Custom name
|
|
487
|
+
|
|
488
|
+
# 🔧 Complete professional setup
|
|
489
|
+
client.customize_squad_complete(
|
|
490
|
+
name="Elite Squad",
|
|
491
|
+
rating=8000,
|
|
492
|
+
_xp=client.calculate_xp_for_level(8),
|
|
493
|
+
_logo_clr_prim=client.get_color_value('purple'),
|
|
494
|
+
member_limit=100
|
|
495
|
+
)
|
|
496
|
+
```
|
|
497
|
+
|
|
248
498
|
## 📱 **Run Examples:** Completed!
|
|
249
499
|
|
|
250
500
|
**🎯 Super Easy Interface (NEW in v1.0.18):**
|
|
@@ -329,8 +579,11 @@ python examples/service_location_example.py
|
|
|
329
579
|
# Game launch and federation sessions:
|
|
330
580
|
python examples/game_launch_example.py
|
|
331
581
|
|
|
332
|
-
#
|
|
333
|
-
python examples/
|
|
582
|
+
# Automatic squad management:
|
|
583
|
+
python examples/automatic_squad_management.py
|
|
584
|
+
|
|
585
|
+
# Complete squad customization:
|
|
586
|
+
python examples/complete_squad_customization.py
|
|
334
587
|
|
|
335
588
|
# Authentication examples:
|
|
336
589
|
python examples/authentication_example.py
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
mc5_api_client/__init__.py,sha256=
|
|
1
|
+
mc5_api_client/__init__.py,sha256=izYE-Hb3sfF08lXzwZ8LwphUFJveyiQoLbU_k0yBGiI,13363
|
|
2
2
|
mc5_api_client/account.py,sha256=EmydXCsCXaKqMw21oVttQfYuDl50pa2dwhcTeHtnxbQ,14396
|
|
3
3
|
mc5_api_client/account_quick.py,sha256=t4ki4ujYENmcnd_004f0pO9SPxPyCllz4WHpBG9wNbo,10458
|
|
4
4
|
mc5_api_client/admin_client.py,sha256=527aavolxVhY2M5ceFxVbbE5YTczU9Z86Fdt1UzdRZM,15220
|
|
@@ -6,7 +6,7 @@ mc5_api_client/alerts.py,sha256=zW-cEwSSShuHkGxTBQaS8Ynf1a0hh5RMQ0G3WC_ajI0,1322
|
|
|
6
6
|
mc5_api_client/alerts_quick.py,sha256=D1j0RiHteYqoAgc4KYqTxYG1Hkud3b-xWRV_VOUEnY0,7946
|
|
7
7
|
mc5_api_client/auth.py,sha256=z8vmyQIHUdAzk0pUyKCesT8gTv4jboLIFGBxAu1v_-8,13396
|
|
8
8
|
mc5_api_client/cli.py,sha256=6xciRjWkUMOxgxlbDsoOiHRuirXPy7uc9WURXPKmgGc,17255
|
|
9
|
-
mc5_api_client/client.py,sha256=
|
|
9
|
+
mc5_api_client/client.py,sha256=IDP8c14f0u0k1rvUNqh7_3VmGBltv64GClLBkusNSJI,126182
|
|
10
10
|
mc5_api_client/debug.py,sha256=524vNCE7jM_KP5JM81-3eI2cmFBBA-Hf7Uy0cIL75W0,8240
|
|
11
11
|
mc5_api_client/easy_mc5.py,sha256=kfjOJMW-VRAZcXEF1yHiGsACgjb-ZjXGuw1U_gepSQY,24202
|
|
12
12
|
mc5_api_client/exceptions.py,sha256=o7od4GrEIlgq6xSNUjZdh74xoDTytF3PLcMq5ewRiJw,2683
|
|
@@ -24,9 +24,9 @@ mc5_api_client/storage_admin.py,sha256=l-nwskbpa3KpeIoWcwVRicgBSvrTvQ5aE2QU_e366
|
|
|
24
24
|
mc5_api_client/telemetry.py,sha256=k8qOimPg-AKsnMclIgeqYCJ_97j2pWyiN7Lg80D4sKo,13246
|
|
25
25
|
mc5_api_client/transfer.py,sha256=-pln70360mo4cKBQIUzp_wt9ce1Cr4YA6aJDFPKEjzQ,14381
|
|
26
26
|
mc5_api_client/transfer_quick.py,sha256=HhRbp4FVzFwuzHDcqOyYiVjeVEIfgezlWd8SN6sh874,11310
|
|
27
|
-
mc5_api_client-1.0.
|
|
28
|
-
mc5_api_client-1.0.
|
|
29
|
-
mc5_api_client-1.0.
|
|
30
|
-
mc5_api_client-1.0.
|
|
31
|
-
mc5_api_client-1.0.
|
|
32
|
-
mc5_api_client-1.0.
|
|
27
|
+
mc5_api_client-1.0.22.dist-info/licenses/LICENSE,sha256=M0UBQ4B3pB9XcV54_jhVP681xyauF8GB6YK_rKmuXzk,1064
|
|
28
|
+
mc5_api_client-1.0.22.dist-info/METADATA,sha256=Twytv04RCN7zec91J7x0SgLbAlUL9WpYkGBbJF0LJFY,91487
|
|
29
|
+
mc5_api_client-1.0.22.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
30
|
+
mc5_api_client-1.0.22.dist-info/entry_points.txt,sha256=2kruOpleFYK3Jl1MoQwGyqCd-Pj4kQWngXmIjnXx_gE,48
|
|
31
|
+
mc5_api_client-1.0.22.dist-info/top_level.txt,sha256=eYJe4ue9j1ig_jFY5Z05mDqpizUEV7TYpk5lBXVd4kA,15
|
|
32
|
+
mc5_api_client-1.0.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|