2323"""
2424import asyncio
2525import logging
26+ from enum import Enum
2627
2728from itertools import cycle
2829from pathlib import Path
6768BUILDING_FILE_PATH = Path (__file__ ).parent .joinpath (Path ("static/buildings.json" ))
6869
6970
71+ class ClashAccountScopes (Enum ):
72+ """
73+ Values represent the scope required for each type of user. A USER is
74+ anyone who has access to the API. A REAL user is a user with special
75+ access from SuperCell with realtime scope access.
76+ """
77+ USER = "clash"
78+ REAL = "clash:*:verifytoken,realtime"
79+
80+
7081class Client :
7182 """This is the client connection used to interact with the Clash of Clans API.
7283
@@ -120,6 +131,11 @@ class Client:
120131 load_game_data: :class:`LoadGameData`
121132 The option for how coc.py will load game data. See :ref:`initialising_game_data` for more info.
122133
134+ realtime: :class:`bool`
135+ Some developers are given special access to an uncached API access by
136+ Super Cell. If you are one of those developers, your account will have
137+ special flags that will only be interpreted by coc.py if you set this
138+ bool to True.
123139
124140 Attributes
125141 ----------
@@ -158,7 +174,6 @@ def __init__(
158174 * ,
159175 key_count : int = 1 ,
160176 key_names : str = "Created with coc.py Client" ,
161- key_scopes : str = "clash" ,
162177 throttle_limit : int = 10 ,
163178 loop : asyncio .AbstractEventLoop = None ,
164179 correct_tags : bool = True ,
@@ -168,7 +183,7 @@ def __init__(
168183 cache_max_size : int = 10000 ,
169184 stats_max_size : int = 1000 ,
170185 load_game_data : LoadGameData = LoadGameData (default = True ),
171- realtime = False ,
186+ realtime = False ,
172187 ** _ ,
173188 ):
174189
@@ -180,7 +195,7 @@ def __init__(
180195 raise RuntimeError ("Key count must be within {}-{}" .format (KEY_MINIMUM , KEY_MAXIMUM ))
181196
182197 self .key_names = key_names
183- self .key_scopes = key_scopes
198+ self .key_scopes = ClashAccountScopes . REAL . value if realtime else ClashAccountScopes . USER . value
184199 self .throttle_limit = throttle_limit
185200 self .throttler = throttler
186201 self .connector = connector
@@ -190,6 +205,7 @@ def __init__(
190205
191206 self .http = None # set in method login()
192207 self .realtime = realtime
208+
193209 self .correct_tags = correct_tags
194210 self .load_game_data = load_game_data
195211
@@ -253,6 +269,8 @@ def _create_holders(self):
253269 async def login (self , email : str , password : str ) -> None :
254270 """Retrieves all keys and creates an HTTP connection ready for use.
255271
272+ @Deprecated
273+
256274 Parameters
257275 ----------
258276 email : str
0 commit comments