mc5-api-client 1.0.20__tar.gz → 1.0.21__tar.gz

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.
Files changed (69) hide show
  1. {mc5_api_client-1.0.20/src/mc5_api_client.egg-info → mc5_api_client-1.0.21}/PKG-INFO +1 -1
  2. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/pyproject.toml +1 -1
  3. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/setup.py +1 -1
  4. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/__init__.py +39 -4
  5. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/client.py +180 -0
  6. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21/src/mc5_api_client.egg-info}/PKG-INFO +1 -1
  7. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/.gitignore +0 -0
  8. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/LICENSE +0 -0
  9. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/MANIFEST.in +0 -0
  10. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/README.md +0 -0
  11. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/admin_squad_management.py +0 -0
  12. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/admin_tools.py +0 -0
  13. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/advanced_automation.py +0 -0
  14. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/advanced_features.py +0 -0
  15. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/authentication_example.py +0 -0
  16. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/basic_usage.py +0 -0
  17. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/clan_management.py +0 -0
  18. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/clan_management_complete.py +0 -0
  19. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/device_id_example.py +0 -0
  20. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/events_and_tasks.py +0 -0
  21. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/everyday_mc5.py +0 -0
  22. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/everyday_mc5_easy.py +0 -0
  23. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/game_launch_example.py +0 -0
  24. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/help_system.py +0 -0
  25. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/message_management.py +0 -0
  26. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/player_stats.py +0 -0
  27. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/private_messaging.py +0 -0
  28. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/quick_help.py +0 -0
  29. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/quick_reference.py +0 -0
  30. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/service_location_example.py +0 -0
  31. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/simple_usage.py +0 -0
  32. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/squad_management.py +0 -0
  33. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/examples/squad_wall_management.py +0 -0
  34. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/requirements.txt +0 -0
  35. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/setup.cfg +0 -0
  36. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/account.py +0 -0
  37. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/account_quick.py +0 -0
  38. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/admin_client.py +0 -0
  39. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/alerts.py +0 -0
  40. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/alerts_quick.py +0 -0
  41. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/auth.py +0 -0
  42. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/cli.py +0 -0
  43. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/debug.py +0 -0
  44. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/easy_mc5.py +0 -0
  45. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/exceptions.py +0 -0
  46. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/federation.py +0 -0
  47. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/federation_quick.py +0 -0
  48. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/help.py +0 -0
  49. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/pc_storage_client.py +0 -0
  50. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/pc_storage_quick.py +0 -0
  51. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/platform.py +0 -0
  52. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/py.typed +0 -0
  53. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/simple_client.py +0 -0
  54. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/squad_battle.py +0 -0
  55. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/squad_battle_quick.py +0 -0
  56. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/storage_admin.py +0 -0
  57. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/telemetry.py +0 -0
  58. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/transfer.py +0 -0
  59. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client/transfer_quick.py +0 -0
  60. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client.egg-info/SOURCES.txt +0 -0
  61. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client.egg-info/dependency_links.txt +0 -0
  62. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client.egg-info/entry_points.txt +0 -0
  63. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client.egg-info/not-zip-safe +0 -0
  64. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client.egg-info/requires.txt +0 -0
  65. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/src/mc5_api_client.egg-info/top_level.txt +0 -0
  66. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/tests/__init__.py +0 -0
  67. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/tests/test_auth.py +0 -0
  68. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/tests/test_cli.py +0 -0
  69. {mc5_api_client-1.0.20 → mc5_api_client-1.0.21}/tests/test_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mc5_api_client
3
- Version: 1.0.20
3
+ Version: 1.0.21
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mc5_api_client"
7
- version = "1.0.20"
7
+ version = "1.0.21"
8
8
  description = "A comprehensive Python library for interacting with the Modern Combat 5 API"
9
9
  readme = "README.md"
10
10
  license = {file = "LICENSE"}
@@ -33,7 +33,7 @@ def read_requirements():
33
33
  setup(
34
34
  name="mc5_api_client",
35
35
  use_scm_version=False,
36
- version="1.0.20",
36
+ version="1.0.21",
37
37
  description="A comprehensive Python library for interacting with the Modern Combat 5 API",
38
38
  long_description=read_readme(),
39
39
  long_description_content_type="text/markdown",
@@ -15,7 +15,7 @@ messaging, and more.
15
15
 
16
16
  from typing import Optional, Dict, Any
17
17
 
18
- __version__ = "1.0.20"
18
+ __version__ = "1.0.21"
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,13 @@ __all__ = [
399
430
  "MC5Easy",
400
431
  "quick_connect",
401
432
  "check_my_daily_tasks",
402
- "get_my_mc5_profile",
403
- "find_mc5_player",
404
- "get_global_id",
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",
405
440
  "generate_device_id",
406
441
  "create_federation_session",
407
442
  "locate_service",
@@ -1652,6 +1652,186 @@ 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
+
1655
1835
  # Events API
1656
1836
 
1657
1837
  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.20
3
+ Version: 1.0.21
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
File without changes