Skip to content

Commit 26c2aba

Browse files
Merge pull request #195 from mathsman5133/g8_2.4.0_candidate
Fix bug where keys are not properly handled+ClanEvents.member_count
2 parents d5f0ef7 + e019f67 commit 26c2aba

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

coc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = "2.4.0"
25+
__version__ = "2.4.1"
2626

2727
from .abc import BasePlayer, BaseClan
2828
from .clans import RankedClan, Clan

coc/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __getattr__(self, item: str):
8383
return self.cls.__getattr__(self.cls, item)
8484

8585
# handle member_x events:
86-
if "member_" in item:
86+
if "member_" in item and item != "member_count":
8787
item = item.replace("member_", "")
8888
nested = True
8989
else:

coc/http.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,13 @@ async def initialise_keys(self):
483483

484484
resp = await session.post("https://developer.clashofclans.com/api/apikey/list")
485485
keys = (await resp.json())["keys"]
486-
self._keys.extend(key["key"] for c, key in enumerate(keys) if key["name"] == self.key_names and ip in key[
487-
"cidrRanges"] and c <= self.key_count)
486+
for key in keys:
487+
LOG.debug(f"Key {key}")
488+
if key["name"] != self.key_names or ip not in key["cidrRanges"]:
489+
continue
490+
self._keys.append(key["key"])
491+
if len(self._keys) == self.key_count:
492+
break
488493

489494
LOG.info("Retrieved %s valid keys from the developer site.", len(self._keys))
490495

docs/miscellaneous/changelog.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ Changelog
77
This page keeps a fairly detailed, human readable version
88
of what has changed, and whats new for each version of the lib.
99

10+
11+
v2.4.1
12+
------
13+
14+
Bugs Fixed:
15+
~~~~~~~~~~~
16+
17+
- Fixed a bug with the retrieval of api keys
18+
19+
- Fixed :func:`ClanEvents.member_count`
20+
21+
1022
v2.4.0
1123
------
1224
Additions:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66
name = "coc.py"
77
authors = [{ name = "mathsman5133" }]
88
maintainers = [{ name = "majordoobie" }, { name = "MagicTheDev" }, { name = "Kuchenmampfer" }, { name = "lukasthaler" }, { name = "doluk" }]
9-
version = "2.4.0"
9+
version = "2.4.1"
1010
description = "A python wrapper for the Clash of Clans API"
1111
requires-python = ">=3.7.3"
1212
readme = "README.rst"

0 commit comments

Comments
 (0)