Skip to content

Commit 83a67d6

Browse files
committed
Final fixes and version bump to v0.2.0
1 parent 55b45c9 commit 83a67d6

File tree

6 files changed

+75
-7
lines changed

6 files changed

+75
-7
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Quick Example
3636
import coc
3737
import asyncio
3838
39-
client = coc.Client('email', 'password')
39+
client = coc.login('email', 'password')
4040
4141
async def get_some_player(tag):
4242
player = await client.get_player(tag)

coc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
__version__ = '0.2.0a'
3+
__version__ = '0.2.0'
44

55
from .clans import (
66
Clan,

coc/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ def run_forever(self):
14041404
14051405
Roughly equivilant to:
14061406
1407-
..code-block:: python3
1407+
.. code-block:: python3
14081408
14091409
try:
14101410
client.loop.run_forever()
@@ -1515,6 +1515,7 @@ def start_updates(self, event_type='all'):
15151515
"""Starts an, or all, events.
15161516
15171517
.. note::
1518+
15181519
This method **must** be called before any events are run.
15191520
15201521
The lookup for event_name is as follows:
@@ -1563,13 +1564,12 @@ def start_updates(self, event_type='all'):
15631564
15641565
Example
15651566
--------
1566-
..code-block:: python3
1567+
.. code-block:: python3
15671568
15681569
client.start_updates('clan')
15691570
# or, for all events:
15701571
client.start_updates('all')
15711572
1572-
15731573
"""
15741574
lookup = {
15751575
'clan': [self._clan_update_event, [cache_current_wars]],
@@ -1600,7 +1600,7 @@ def stop_updates(self, event_type='all'):
16001600
16011601
Example
16021602
--------
1603-
..code-block:: python3
1603+
.. code-block:: python3
16041604
16051605
client.stop_updates('clan')
16061606
# or, for all events:

coc/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def predicate(elem):
6060
def from_timestamp(timestamp):
6161
return datetime.strptime(timestamp, '%Y%m%dT%H%M%S.000Z')
6262

63+
6364
def correct_tag(tag, prefix='#'):
6465
"""Attempts to correct malformed Clash of Clans tags
6566
to match how they are formatted in game

docs/changelog.rst

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

9+
v0.2.0
10+
--------
11+
EventsClient
12+
~~~~~~~~~~~~~~
13+
- :class:`EventsClient`
14+
- Provides all functionality of :class:`Client`, as well as an events-like system.
15+
- It will constantly request to the API every X seconds and detect indifferences between the cached and new results
16+
returned by API. It will then send out 'events', basically calling functions that you must register, to tell you that
17+
these things have happened
18+
- Split into 3 categories: player, clan and war
19+
20+
Player
21+
22+
- All events regarding anything in the API that can change.
23+
- E.g, name, troop levels (and unlocking), spells, heroes, donations, trophies etc.
24+
25+
Clans
26+
27+
- All events regarding anything in the API that can change.
28+
- E.g. description, type (invite only etc.), ranks, donations etc. of members, levelups.
29+
30+
Wars
31+
32+
- All events regarding anything in the API that can change.
33+
- E.g. new war attack, war state change
34+
35+
- You must register the funtions events will call with :meth:`EventsClient.add_events`
36+
- You must 'subscribe' any clans, players or (clans in) wars you want to get with :meth:`EventsClient.add_clan_updates`,
37+
:meth:`EventsClient.add_player_update`, :meth:`EventsClient.add_war_update`.
38+
39+
- This can be a script that you run and will continue to run forever, calling your functions as events come through,
40+
it doesn't have to be integrated into a bot. To ease this use-case, :meth:`EventsClient.run_forever` is handy.
41+
42+
Other Importants
43+
~~~~~~~~~~~~~~~~~
44+
- Cache has had another overhaul about how it works, is called and default operational use.
45+
46+
- From above, ``default_cache`` is a kwarg, and method of :class:`Client`. It defaults to the inbuilt method,
47+
however you can pass your own function into this.
48+
49+
- Logging in: the new recommended way of logging in is via ``client = coc.login(email, pass, **kwargs)`` with ``client``
50+
being one of these kwargs: pass in either :class:`EventsClient` or :class:`Client` to use respective clients. This
51+
makes both Client class creation and HTTP logging in easy through one function. Any additional kwargs passed will become
52+
kwargs for the client you are using.
53+
54+
- ``CurrentWar`` has been renamed, revamped and relooked at. A regular clan-war is now a :class:`ClanWar`, with
55+
``WarIterator`` being renamed to ``ClanWarIterator``. ``LeagueWarIterator`` and ``CurrentWarIterator`` now exist,
56+
Current wars being a mix of either clan or league wars.
57+
58+
- :meth:`Client.get_clan_war` now retrieves the current :class:`ClanWar`
59+
60+
- :meth:`Client.get_current_war` now attempts to retrieve the current :class:`ClanWar`, and if in the ``notInWar`` state,
61+
will attempt to search for a leauge war and return that, if found. This makes getting league wars and
62+
clan wars from the API much easier than before.
63+
- :attr:`ClanWar.type` and :attr:`LeagueWar.type` now return a string of either ``cwl, friendly, random`` - which war type it is.
64+
- :attr:`Timestamp.time` has been renamed to :attr:`Timestamp.raw_time`, and replaced with :attr:`Timestamp.utc_timestamp` (now called :attr:`Timestamp.time`)
65+
- Add :attr:`ClanWar.status` returns a string ``winning, losing, tied, won, lost, tie`` depending on stars + destruction.
66+
67+
BugFixes
68+
~~~~~~~~~
69+
- Lots of little ones with cache
70+
- Performance upgrades with use of ``__slots__`` on more classes
71+
- Trying to iterate over used up iterators
72+
- Only log requests throttled as debug
73+
- Trying to pop a cache item failed
74+
- Few little regex and other bugs in cache.
75+
976
v0.1.3
1077
--------
1178
BugFixes

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
with open(os.path.join(os.getcwd(), 'requirements.txt')) as f:
66
requirements = f.read().splitlines()
77

8-
version = '0.2.0a'
8+
version = '0.2.0'
99

1010
readme = ''
1111
with open('README.rst') as f:

0 commit comments

Comments
 (0)