Skip to content

Commit b6cb5ad

Browse files
committed
[Finished updates]
1 parent de462de commit b6cb5ad

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
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.0.2"
25+
__version__ = "2.1.0"
2626

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

coc/events.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141

4242

4343
class Event:
44-
"""Object that is created for an event. This contains runner functions, tags and type."""
44+
"""
45+
Object that is created for an event. This contains runner functions,
46+
tags and type.
47+
"""
4548

4649
__slots__ = ("runner", "callback", "tags", "type")
4750

@@ -719,13 +722,6 @@ def run_forever(self):
719722
except KeyboardInterrupt:
720723
self.close()
721724

722-
# async def close(self):
723-
# """Closes the client and all running tasks."""
724-
# tasks = {t for t in asyncio.all_tasks(loop=self.loop) if not t.done()}
725-
# for task in tasks:
726-
# task.cancel()
727-
# await super().close()
728-
729725
def dispatch(self, event_name: str, *args, **kwargs):
730726
# pylint: disable=broad-except
731727
registered = self._listeners["client"].get(event_name)

coc/ext/discordlinks/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def extract_expiry_from_jwt_token(token):
4444
return None
4545

4646

47-
def login(username: str, password: str, loop: asyncio.AbstractEventLoop = None) -> "DiscordLinkClient":
47+
async def login(username: str, password: str) -> "DiscordLinkClient":
4848
"""Eases logging into the API client.
4949
5050
For more information on this project, please join the discord server - <discord.gg/Eaja7gJ>
@@ -66,9 +66,8 @@ def login(username: str, password: str, loop: asyncio.AbstractEventLoop = None)
6666
raise TypeError("username and password must both be a string")
6767
if not username or not password:
6868
raise ValueError("username or password must not be an empty string.")
69-
if loop and not isinstance(loop, asyncio.AbstractEventLoop):
70-
raise TypeError("loop must be of type asyncio.AbstractEventLoop, or None.")
7169

70+
loop = asyncio.get_running_loop()
7271
return DiscordLinkClient(username, password, loop)
7372

7473

coc/miscmodels.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class CapitalDistrict:
593593
:class:`int`: The district's hall level
594594
"""
595595

596-
__slots__ = ("id", "name", "_client", "hall_level")
596+
__slots__ = ("id", "name", "hall_level")
597597

598598
def __str__(self):
599599
return self.name
@@ -603,12 +603,12 @@ def __repr__(self):
603603
return "<%s %s>" % (self.__class__.__name__, " ".join("%s=%r" % t for t in attrs),)
604604

605605
def __eq__(self, other):
606-
return isinstance(other, self.__class__) and self.id == other.id
606+
return isinstance(other, self.__class__) and \
607+
self.id == other.id and \
608+
self.hall_level == other.hall_level
607609

608610
def __init__(self, *, data, client):
609611
# pylint: disable=invalid-name
610-
self._client = client
611-
612612
self.id: int = data.get("id")
613613
self.name: str = data.get("name")
614614
self.hall_level: int = data.get("districtHallLevel")

examples/discord_links.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66

77
async def main():
8-
client = discordlinks.login(os.environ["LINKS_API_USERNAME"],
9-
os.environ["LINKS_API_PASSWORD"])
8+
client = await discordlinks.login(os.environ["LINKS_API_USERNAME"],
9+
os.environ["LINKS_API_PASSWORD"])
1010

1111
player_tag = "#JY9J2Y99"
1212
discord_id = 230214242618441728

0 commit comments

Comments
 (0)