Skip to content

Commit 4827ee5

Browse files
committed
New Events: on_clan_member_donation and on_clan_member_donation_received
When donations given + received respectively.
1 parent 1e6ed01 commit 4827ee5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

coc/client.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from .cache import Cache
3535
from .clans import Clan, SearchClan
3636
from .enums import ACHIEVEMENT_ORDER
37-
from .errors import ClashOfClansException, Forbidden, HTTPException, NotFound
37+
from .errors import Forbidden, NotFound
3838
from .miscmodels import Location, League
3939
from .http import HTTPClient
4040
from .iterators import PlayerIterator, ClanIterator, ClanWarIterator, LeagueWarIterator, CurrentWarIterator
@@ -1704,7 +1704,7 @@ async def _update_clans(self):
17041704

17051705
self.dispatch('on_clan_update', cached_clan, clan)
17061706

1707-
if clan.member_count != cached_clan:
1707+
if clan.member_count != cached_clan.member_count:
17081708
await self._check_member_count(cached_clan, clan)
17091709

17101710
cached_clan._data['memberCount'] = clan.member_count # hack for next line
@@ -1713,6 +1713,19 @@ async def _update_clans(self):
17131713
cache_search_clans.add(clan.tag, clan)
17141714
continue
17151715

1716+
if clan.members != cached_clan.members: # check for member donations and received
1717+
for m, c in cached_clan._members, clan._members:
1718+
if m.donations != c.donations:
1719+
self.dispatch('on_clan_member_donation', m.donations, c.donations, m, clan)
1720+
cached_clan._data['members'][cached_clan.members.index(c)]['donations'] = m.donations
1721+
if m.received != c.received:
1722+
self.dispatch('on_clan_member_donation_received', m.received, c.received, m, clan)
1723+
cached_clan._data['members'][cached_clan.members.index(c)]['donationsReceived'] = m.received
1724+
1725+
if clan._data == cached_clan._data:
1726+
cache_search_clans.add(clan.tag, clan)
1727+
continue
1728+
17161729
self.dispatch('on_clan_settings_update', cached_clan, clan)
17171730
cache_search_clans.add(clan.tag, clan)
17181731

0 commit comments

Comments
 (0)