clashy.py 25.12.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clashy_py-25.12.0/LICENSE +20 -0
- clashy_py-25.12.0/MANIFEST.in +5 -0
- clashy_py-25.12.0/PKG-INFO +194 -0
- clashy_py-25.12.0/README.rst +167 -0
- clashy_py-25.12.0/clashy.py.egg-info/PKG-INFO +194 -0
- clashy_py-25.12.0/clashy.py.egg-info/SOURCES.txt +58 -0
- clashy_py-25.12.0/clashy.py.egg-info/dependency_links.txt +1 -0
- clashy_py-25.12.0/clashy.py.egg-info/requires.txt +8 -0
- clashy_py-25.12.0/clashy.py.egg-info/top_level.txt +1 -0
- clashy_py-25.12.0/coc/__init__.py +87 -0
- clashy_py-25.12.0/coc/__main__.py +0 -0
- clashy_py-25.12.0/coc/abc.py +271 -0
- clashy_py-25.12.0/coc/buildings.py +510 -0
- clashy_py-25.12.0/coc/characters.py +144 -0
- clashy_py-25.12.0/coc/clans.py +286 -0
- clashy_py-25.12.0/coc/client.py +2726 -0
- clashy_py-25.12.0/coc/constants.py +327 -0
- clashy_py-25.12.0/coc/cosmetics.py +198 -0
- clashy_py-25.12.0/coc/entry_logs.py +256 -0
- clashy_py-25.12.0/coc/enums.py +183 -0
- clashy_py-25.12.0/coc/errors.py +133 -0
- clashy_py-25.12.0/coc/events.py +1100 -0
- clashy_py-25.12.0/coc/events.pyi +232 -0
- clashy_py-25.12.0/coc/ext/discordlinks/__init__.py +279 -0
- clashy_py-25.12.0/coc/ext/triggers/__init__.py +15 -0
- clashy_py-25.12.0/coc/ext/triggers/cron.py +215 -0
- clashy_py-25.12.0/coc/ext/triggers/triggers.py +503 -0
- clashy_py-25.12.0/coc/game_data.py +686 -0
- clashy_py-25.12.0/coc/hero.py +381 -0
- clashy_py-25.12.0/coc/http.py +598 -0
- clashy_py-25.12.0/coc/iterators.py +215 -0
- clashy_py-25.12.0/coc/miscmodels.py +846 -0
- clashy_py-25.12.0/coc/player_clan.py +18 -0
- clashy_py-25.12.0/coc/players.py +755 -0
- clashy_py-25.12.0/coc/raid.py +499 -0
- clashy_py-25.12.0/coc/spell.py +115 -0
- clashy_py-25.12.0/coc/static/.DS_Store +0 -0
- clashy_py-25.12.0/coc/static/static_data.json +63468 -0
- clashy_py-25.12.0/coc/static/translations.json +29954 -0
- clashy_py-25.12.0/coc/static/update_static.py +1481 -0
- clashy_py-25.12.0/coc/troop.py +177 -0
- clashy_py-25.12.0/coc/utils.py +562 -0
- clashy_py-25.12.0/coc/war_attack.py +102 -0
- clashy_py-25.12.0/coc/war_clans.py +196 -0
- clashy_py-25.12.0/coc/war_members.py +140 -0
- clashy_py-25.12.0/coc/wars.py +535 -0
- clashy_py-25.12.0/pyproject.toml +37 -0
- clashy_py-25.12.0/requirements.txt +3 -0
- clashy_py-25.12.0/setup.cfg +4 -0
- clashy_py-25.12.0/setup.py +6 -0
- clashy_py-25.12.0/tests/test_capitalraidseasons.py +160 -0
- clashy_py-25.12.0/tests/test_clans.py +290 -0
- clashy_py-25.12.0/tests/test_clash_meta.py +104 -0
- clashy_py-25.12.0/tests/test_client.py +0 -0
- clashy_py-25.12.0/tests/test_enums.py +0 -0
- clashy_py-25.12.0/tests/test_login.py +0 -0
- clashy_py-25.12.0/tests/test_miscmodels.py +0 -0
- clashy_py-25.12.0/tests/test_players.py +239 -0
- clashy_py-25.12.0/tests/test_troop_levels.py +53 -0
- clashy_py-25.12.0/tests/test_wars.py +98 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ClashKingInc
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clashy.py
|
|
3
|
+
Version: 25.12.0
|
|
4
|
+
Summary: A python wrapper for the Clash of Clans API
|
|
5
|
+
Author: ClashKing
|
|
6
|
+
Maintainer: MagicTheDev
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: documentation, https://clashy.clashk.ing/en/latest/
|
|
9
|
+
Project-URL: repository, https://github.com/ClashKingInc/clashy.py
|
|
10
|
+
Project-URL: changelog, https://clashy.clashk.ing/en/latest/miscellaneous/changelog.html
|
|
11
|
+
Keywords: coc,clash of clans,clashy.py,clash api
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.10.0
|
|
17
|
+
Description-Content-Type: text/x-rst
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: aiohttp
|
|
20
|
+
Requires-Dist: orjson
|
|
21
|
+
Provides-Extra: docs
|
|
22
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
23
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
24
|
+
Requires-Dist: sphinxcontrib_trio; extra == "docs"
|
|
25
|
+
Requires-Dist: autodocsumm; extra == "docs"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
clashy.py
|
|
29
|
+
=========
|
|
30
|
+
|
|
31
|
+
.. image:: https://discordapp.com/api/guilds/566451504332931073/embed.png
|
|
32
|
+
:target: https://discord.gg/Eaja7gJ
|
|
33
|
+
:alt: Discord Server Invite
|
|
34
|
+
.. image:: https://img.shields.io/pypi/v/clashy.py.svg
|
|
35
|
+
:target: https://pypi.python.org/pypi/clashy.py
|
|
36
|
+
:alt: PyPI version info
|
|
37
|
+
.. image:: https://img.shields.io/pypi/pyversions/clashy.py.svg
|
|
38
|
+
:target: https://pypi.python.org/pypi/clashy.py
|
|
39
|
+
:alt: PyPI supported Python versions
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Easy to use asynchronous Clash of Clans API wrapper in Python.
|
|
43
|
+
|
|
44
|
+
Key Features
|
|
45
|
+
-------------
|
|
46
|
+
- Asynchronous code
|
|
47
|
+
- Entire coverage of the official Clash of Clans API
|
|
48
|
+
- Email/password login removes the stress of managing tokens
|
|
49
|
+
- Optimised for speed, memory and performance
|
|
50
|
+
|
|
51
|
+
Getting Started
|
|
52
|
+
================
|
|
53
|
+
|
|
54
|
+
Installing
|
|
55
|
+
-----------
|
|
56
|
+
**Python 3.10 or higher is required**
|
|
57
|
+
|
|
58
|
+
.. code:: sh
|
|
59
|
+
|
|
60
|
+
# Linux/macOS
|
|
61
|
+
python3 -m pip install -U clashy.py
|
|
62
|
+
|
|
63
|
+
# Windows
|
|
64
|
+
py -3 -m pip install -U clashy.py
|
|
65
|
+
|
|
66
|
+
# to install the development version:
|
|
67
|
+
python3 -m pip install -U git+https://github.com/ClashKingInc/clashy.py
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
Quick Example
|
|
71
|
+
--------------
|
|
72
|
+
This is the basic usage of the library.
|
|
73
|
+
This example will get a player with a certain tag, and search for 5 clans with a name.
|
|
74
|
+
|
|
75
|
+
.. code:: py
|
|
76
|
+
|
|
77
|
+
import asyncio
|
|
78
|
+
import coc
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
async def main():
|
|
82
|
+
async with coc.Client() as coc_client:
|
|
83
|
+
try:
|
|
84
|
+
await coc_client.login("email", "password")
|
|
85
|
+
except coc.InvalidCredentials as error:
|
|
86
|
+
exit(error)
|
|
87
|
+
|
|
88
|
+
player = await coc_client.get_player("tag")
|
|
89
|
+
print(f"{player.name} has {player.trophies} trophies!")
|
|
90
|
+
|
|
91
|
+
clans = await coc_client.search_clans(name="best clan ever", limit=5)
|
|
92
|
+
for clan in clans:
|
|
93
|
+
print(f"{clan.name} ({clan.tag}) has {clan.member_count} members")
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
war = await coc_client.get_current_war("#clantag")
|
|
97
|
+
print(f"{war.clan_tag} is currently in {war.state} state.")
|
|
98
|
+
except coc.privatewarlog:
|
|
99
|
+
print("uh oh, they have a private war log!")
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
try:
|
|
103
|
+
asyncio.run(main())
|
|
104
|
+
except KeyboardInterrupt:
|
|
105
|
+
pass
|
|
106
|
+
|
|
107
|
+
Basic Events Example
|
|
108
|
+
---------------------
|
|
109
|
+
This script will run forever, printing to the terminal
|
|
110
|
+
whenever someone joins the clan or a member of the clan donates troops.
|
|
111
|
+
|
|
112
|
+
.. code:: py
|
|
113
|
+
|
|
114
|
+
import asyncio
|
|
115
|
+
import logging
|
|
116
|
+
|
|
117
|
+
import coc
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@coc.ClanEvents.member_join()
|
|
121
|
+
async def foo(player, clan):
|
|
122
|
+
print(f"{player.name} ({player.tag}) just joined {clan.name} ({clan.tag})")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@coc.ClanEvents.member_donations()
|
|
126
|
+
async def bar(old_member, member):
|
|
127
|
+
troops_donated = member.donations - old_member.donations
|
|
128
|
+
print(f"{member.name} just donated {troops_donated} troops!")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
async def main():
|
|
132
|
+
coc_client = coc.EVentsClient()
|
|
133
|
+
try:
|
|
134
|
+
await coc.login("email", "password")
|
|
135
|
+
except coc.InvalidCredentials as error:
|
|
136
|
+
exit(error)
|
|
137
|
+
|
|
138
|
+
# Register all the clans you want to monitor
|
|
139
|
+
list_of_clan_tags = ["tag1", "tag2", "tag3"]
|
|
140
|
+
coc_client.add_clan_updates(*list_of_clan_tags)
|
|
141
|
+
|
|
142
|
+
# Register the callbacks for each of the events you are monitoring
|
|
143
|
+
coc_client.add_events(
|
|
144
|
+
foo,
|
|
145
|
+
bar
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if __name__ == "__main__":
|
|
150
|
+
logging.basicConfig(level=logging.INFO)
|
|
151
|
+
log = logging.getLogger()
|
|
152
|
+
|
|
153
|
+
loop = asyncio.get_event_loop()
|
|
154
|
+
try:
|
|
155
|
+
loop.run_until_complete(main())
|
|
156
|
+
loop.run_forever()
|
|
157
|
+
except KeyboardInterrupt:
|
|
158
|
+
pass
|
|
159
|
+
|
|
160
|
+
For more examples see the examples directory
|
|
161
|
+
|
|
162
|
+
Contributing
|
|
163
|
+
--------------
|
|
164
|
+
Contributing is fantastic and much welcomed! If you have an issue, feel free to open an issue and start working on it.
|
|
165
|
+
|
|
166
|
+
If you wish to run, setup or work on documentation, you will need to install ``sphinx`` and a few related dependencies.
|
|
167
|
+
These can be installed with:
|
|
168
|
+
|
|
169
|
+
.. code:: sh
|
|
170
|
+
|
|
171
|
+
pip install -r doc_requirements.txt
|
|
172
|
+
cd docs
|
|
173
|
+
make html
|
|
174
|
+
|
|
175
|
+
If you wish to run linting, pylint, black and flake8 have been setup and can be run with:
|
|
176
|
+
|
|
177
|
+
.. code:: sh
|
|
178
|
+
|
|
179
|
+
python setup.py lint
|
|
180
|
+
|
|
181
|
+
Links
|
|
182
|
+
------
|
|
183
|
+
- `clashy.py Documentation <https://clashy.clashk.ing/en/latest/?>`_
|
|
184
|
+
- `Official Clash of Clans API Page <https://developer.clashofclans.com/>`_
|
|
185
|
+
- `Clash of Clans API Discord Server <https://discord.gg/Eaja7gJ>`_
|
|
186
|
+
|
|
187
|
+
Disclaimer
|
|
188
|
+
-----------
|
|
189
|
+
This content is not affiliated with, endorsed, sponsored, or specifically
|
|
190
|
+
approved by Supercell and Supercell is not responsible for it.
|
|
191
|
+
For more information see `Supercell's Fan Content Policy. <https://www.supercell.com/fan-content-policy.>`_
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
clashy.py
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
.. image:: https://discordapp.com/api/guilds/566451504332931073/embed.png
|
|
5
|
+
:target: https://discord.gg/Eaja7gJ
|
|
6
|
+
:alt: Discord Server Invite
|
|
7
|
+
.. image:: https://img.shields.io/pypi/v/clashy.py.svg
|
|
8
|
+
:target: https://pypi.python.org/pypi/clashy.py
|
|
9
|
+
:alt: PyPI version info
|
|
10
|
+
.. image:: https://img.shields.io/pypi/pyversions/clashy.py.svg
|
|
11
|
+
:target: https://pypi.python.org/pypi/clashy.py
|
|
12
|
+
:alt: PyPI supported Python versions
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Easy to use asynchronous Clash of Clans API wrapper in Python.
|
|
16
|
+
|
|
17
|
+
Key Features
|
|
18
|
+
-------------
|
|
19
|
+
- Asynchronous code
|
|
20
|
+
- Entire coverage of the official Clash of Clans API
|
|
21
|
+
- Email/password login removes the stress of managing tokens
|
|
22
|
+
- Optimised for speed, memory and performance
|
|
23
|
+
|
|
24
|
+
Getting Started
|
|
25
|
+
================
|
|
26
|
+
|
|
27
|
+
Installing
|
|
28
|
+
-----------
|
|
29
|
+
**Python 3.10 or higher is required**
|
|
30
|
+
|
|
31
|
+
.. code:: sh
|
|
32
|
+
|
|
33
|
+
# Linux/macOS
|
|
34
|
+
python3 -m pip install -U clashy.py
|
|
35
|
+
|
|
36
|
+
# Windows
|
|
37
|
+
py -3 -m pip install -U clashy.py
|
|
38
|
+
|
|
39
|
+
# to install the development version:
|
|
40
|
+
python3 -m pip install -U git+https://github.com/ClashKingInc/clashy.py
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Quick Example
|
|
44
|
+
--------------
|
|
45
|
+
This is the basic usage of the library.
|
|
46
|
+
This example will get a player with a certain tag, and search for 5 clans with a name.
|
|
47
|
+
|
|
48
|
+
.. code:: py
|
|
49
|
+
|
|
50
|
+
import asyncio
|
|
51
|
+
import coc
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
async def main():
|
|
55
|
+
async with coc.Client() as coc_client:
|
|
56
|
+
try:
|
|
57
|
+
await coc_client.login("email", "password")
|
|
58
|
+
except coc.InvalidCredentials as error:
|
|
59
|
+
exit(error)
|
|
60
|
+
|
|
61
|
+
player = await coc_client.get_player("tag")
|
|
62
|
+
print(f"{player.name} has {player.trophies} trophies!")
|
|
63
|
+
|
|
64
|
+
clans = await coc_client.search_clans(name="best clan ever", limit=5)
|
|
65
|
+
for clan in clans:
|
|
66
|
+
print(f"{clan.name} ({clan.tag}) has {clan.member_count} members")
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
war = await coc_client.get_current_war("#clantag")
|
|
70
|
+
print(f"{war.clan_tag} is currently in {war.state} state.")
|
|
71
|
+
except coc.privatewarlog:
|
|
72
|
+
print("uh oh, they have a private war log!")
|
|
73
|
+
|
|
74
|
+
if __name__ == "__main__":
|
|
75
|
+
try:
|
|
76
|
+
asyncio.run(main())
|
|
77
|
+
except KeyboardInterrupt:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
Basic Events Example
|
|
81
|
+
---------------------
|
|
82
|
+
This script will run forever, printing to the terminal
|
|
83
|
+
whenever someone joins the clan or a member of the clan donates troops.
|
|
84
|
+
|
|
85
|
+
.. code:: py
|
|
86
|
+
|
|
87
|
+
import asyncio
|
|
88
|
+
import logging
|
|
89
|
+
|
|
90
|
+
import coc
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@coc.ClanEvents.member_join()
|
|
94
|
+
async def foo(player, clan):
|
|
95
|
+
print(f"{player.name} ({player.tag}) just joined {clan.name} ({clan.tag})")
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@coc.ClanEvents.member_donations()
|
|
99
|
+
async def bar(old_member, member):
|
|
100
|
+
troops_donated = member.donations - old_member.donations
|
|
101
|
+
print(f"{member.name} just donated {troops_donated} troops!")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
async def main():
|
|
105
|
+
coc_client = coc.EVentsClient()
|
|
106
|
+
try:
|
|
107
|
+
await coc.login("email", "password")
|
|
108
|
+
except coc.InvalidCredentials as error:
|
|
109
|
+
exit(error)
|
|
110
|
+
|
|
111
|
+
# Register all the clans you want to monitor
|
|
112
|
+
list_of_clan_tags = ["tag1", "tag2", "tag3"]
|
|
113
|
+
coc_client.add_clan_updates(*list_of_clan_tags)
|
|
114
|
+
|
|
115
|
+
# Register the callbacks for each of the events you are monitoring
|
|
116
|
+
coc_client.add_events(
|
|
117
|
+
foo,
|
|
118
|
+
bar
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
logging.basicConfig(level=logging.INFO)
|
|
124
|
+
log = logging.getLogger()
|
|
125
|
+
|
|
126
|
+
loop = asyncio.get_event_loop()
|
|
127
|
+
try:
|
|
128
|
+
loop.run_until_complete(main())
|
|
129
|
+
loop.run_forever()
|
|
130
|
+
except KeyboardInterrupt:
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
For more examples see the examples directory
|
|
134
|
+
|
|
135
|
+
Contributing
|
|
136
|
+
--------------
|
|
137
|
+
Contributing is fantastic and much welcomed! If you have an issue, feel free to open an issue and start working on it.
|
|
138
|
+
|
|
139
|
+
If you wish to run, setup or work on documentation, you will need to install ``sphinx`` and a few related dependencies.
|
|
140
|
+
These can be installed with:
|
|
141
|
+
|
|
142
|
+
.. code:: sh
|
|
143
|
+
|
|
144
|
+
pip install -r doc_requirements.txt
|
|
145
|
+
cd docs
|
|
146
|
+
make html
|
|
147
|
+
|
|
148
|
+
If you wish to run linting, pylint, black and flake8 have been setup and can be run with:
|
|
149
|
+
|
|
150
|
+
.. code:: sh
|
|
151
|
+
|
|
152
|
+
python setup.py lint
|
|
153
|
+
|
|
154
|
+
Links
|
|
155
|
+
------
|
|
156
|
+
- `clashy.py Documentation <https://clashy.clashk.ing/en/latest/?>`_
|
|
157
|
+
- `Official Clash of Clans API Page <https://developer.clashofclans.com/>`_
|
|
158
|
+
- `Clash of Clans API Discord Server <https://discord.gg/Eaja7gJ>`_
|
|
159
|
+
|
|
160
|
+
Disclaimer
|
|
161
|
+
-----------
|
|
162
|
+
This content is not affiliated with, endorsed, sponsored, or specifically
|
|
163
|
+
approved by Supercell and Supercell is not responsible for it.
|
|
164
|
+
For more information see `Supercell's Fan Content Policy. <https://www.supercell.com/fan-content-policy.>`_
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clashy.py
|
|
3
|
+
Version: 25.12.0
|
|
4
|
+
Summary: A python wrapper for the Clash of Clans API
|
|
5
|
+
Author: ClashKing
|
|
6
|
+
Maintainer: MagicTheDev
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: documentation, https://clashy.clashk.ing/en/latest/
|
|
9
|
+
Project-URL: repository, https://github.com/ClashKingInc/clashy.py
|
|
10
|
+
Project-URL: changelog, https://clashy.clashk.ing/en/latest/miscellaneous/changelog.html
|
|
11
|
+
Keywords: coc,clash of clans,clashy.py,clash api
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.10.0
|
|
17
|
+
Description-Content-Type: text/x-rst
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: aiohttp
|
|
20
|
+
Requires-Dist: orjson
|
|
21
|
+
Provides-Extra: docs
|
|
22
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
23
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
24
|
+
Requires-Dist: sphinxcontrib_trio; extra == "docs"
|
|
25
|
+
Requires-Dist: autodocsumm; extra == "docs"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
clashy.py
|
|
29
|
+
=========
|
|
30
|
+
|
|
31
|
+
.. image:: https://discordapp.com/api/guilds/566451504332931073/embed.png
|
|
32
|
+
:target: https://discord.gg/Eaja7gJ
|
|
33
|
+
:alt: Discord Server Invite
|
|
34
|
+
.. image:: https://img.shields.io/pypi/v/clashy.py.svg
|
|
35
|
+
:target: https://pypi.python.org/pypi/clashy.py
|
|
36
|
+
:alt: PyPI version info
|
|
37
|
+
.. image:: https://img.shields.io/pypi/pyversions/clashy.py.svg
|
|
38
|
+
:target: https://pypi.python.org/pypi/clashy.py
|
|
39
|
+
:alt: PyPI supported Python versions
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Easy to use asynchronous Clash of Clans API wrapper in Python.
|
|
43
|
+
|
|
44
|
+
Key Features
|
|
45
|
+
-------------
|
|
46
|
+
- Asynchronous code
|
|
47
|
+
- Entire coverage of the official Clash of Clans API
|
|
48
|
+
- Email/password login removes the stress of managing tokens
|
|
49
|
+
- Optimised for speed, memory and performance
|
|
50
|
+
|
|
51
|
+
Getting Started
|
|
52
|
+
================
|
|
53
|
+
|
|
54
|
+
Installing
|
|
55
|
+
-----------
|
|
56
|
+
**Python 3.10 or higher is required**
|
|
57
|
+
|
|
58
|
+
.. code:: sh
|
|
59
|
+
|
|
60
|
+
# Linux/macOS
|
|
61
|
+
python3 -m pip install -U clashy.py
|
|
62
|
+
|
|
63
|
+
# Windows
|
|
64
|
+
py -3 -m pip install -U clashy.py
|
|
65
|
+
|
|
66
|
+
# to install the development version:
|
|
67
|
+
python3 -m pip install -U git+https://github.com/ClashKingInc/clashy.py
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
Quick Example
|
|
71
|
+
--------------
|
|
72
|
+
This is the basic usage of the library.
|
|
73
|
+
This example will get a player with a certain tag, and search for 5 clans with a name.
|
|
74
|
+
|
|
75
|
+
.. code:: py
|
|
76
|
+
|
|
77
|
+
import asyncio
|
|
78
|
+
import coc
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
async def main():
|
|
82
|
+
async with coc.Client() as coc_client:
|
|
83
|
+
try:
|
|
84
|
+
await coc_client.login("email", "password")
|
|
85
|
+
except coc.InvalidCredentials as error:
|
|
86
|
+
exit(error)
|
|
87
|
+
|
|
88
|
+
player = await coc_client.get_player("tag")
|
|
89
|
+
print(f"{player.name} has {player.trophies} trophies!")
|
|
90
|
+
|
|
91
|
+
clans = await coc_client.search_clans(name="best clan ever", limit=5)
|
|
92
|
+
for clan in clans:
|
|
93
|
+
print(f"{clan.name} ({clan.tag}) has {clan.member_count} members")
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
war = await coc_client.get_current_war("#clantag")
|
|
97
|
+
print(f"{war.clan_tag} is currently in {war.state} state.")
|
|
98
|
+
except coc.privatewarlog:
|
|
99
|
+
print("uh oh, they have a private war log!")
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
try:
|
|
103
|
+
asyncio.run(main())
|
|
104
|
+
except KeyboardInterrupt:
|
|
105
|
+
pass
|
|
106
|
+
|
|
107
|
+
Basic Events Example
|
|
108
|
+
---------------------
|
|
109
|
+
This script will run forever, printing to the terminal
|
|
110
|
+
whenever someone joins the clan or a member of the clan donates troops.
|
|
111
|
+
|
|
112
|
+
.. code:: py
|
|
113
|
+
|
|
114
|
+
import asyncio
|
|
115
|
+
import logging
|
|
116
|
+
|
|
117
|
+
import coc
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@coc.ClanEvents.member_join()
|
|
121
|
+
async def foo(player, clan):
|
|
122
|
+
print(f"{player.name} ({player.tag}) just joined {clan.name} ({clan.tag})")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@coc.ClanEvents.member_donations()
|
|
126
|
+
async def bar(old_member, member):
|
|
127
|
+
troops_donated = member.donations - old_member.donations
|
|
128
|
+
print(f"{member.name} just donated {troops_donated} troops!")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
async def main():
|
|
132
|
+
coc_client = coc.EVentsClient()
|
|
133
|
+
try:
|
|
134
|
+
await coc.login("email", "password")
|
|
135
|
+
except coc.InvalidCredentials as error:
|
|
136
|
+
exit(error)
|
|
137
|
+
|
|
138
|
+
# Register all the clans you want to monitor
|
|
139
|
+
list_of_clan_tags = ["tag1", "tag2", "tag3"]
|
|
140
|
+
coc_client.add_clan_updates(*list_of_clan_tags)
|
|
141
|
+
|
|
142
|
+
# Register the callbacks for each of the events you are monitoring
|
|
143
|
+
coc_client.add_events(
|
|
144
|
+
foo,
|
|
145
|
+
bar
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if __name__ == "__main__":
|
|
150
|
+
logging.basicConfig(level=logging.INFO)
|
|
151
|
+
log = logging.getLogger()
|
|
152
|
+
|
|
153
|
+
loop = asyncio.get_event_loop()
|
|
154
|
+
try:
|
|
155
|
+
loop.run_until_complete(main())
|
|
156
|
+
loop.run_forever()
|
|
157
|
+
except KeyboardInterrupt:
|
|
158
|
+
pass
|
|
159
|
+
|
|
160
|
+
For more examples see the examples directory
|
|
161
|
+
|
|
162
|
+
Contributing
|
|
163
|
+
--------------
|
|
164
|
+
Contributing is fantastic and much welcomed! If you have an issue, feel free to open an issue and start working on it.
|
|
165
|
+
|
|
166
|
+
If you wish to run, setup or work on documentation, you will need to install ``sphinx`` and a few related dependencies.
|
|
167
|
+
These can be installed with:
|
|
168
|
+
|
|
169
|
+
.. code:: sh
|
|
170
|
+
|
|
171
|
+
pip install -r doc_requirements.txt
|
|
172
|
+
cd docs
|
|
173
|
+
make html
|
|
174
|
+
|
|
175
|
+
If you wish to run linting, pylint, black and flake8 have been setup and can be run with:
|
|
176
|
+
|
|
177
|
+
.. code:: sh
|
|
178
|
+
|
|
179
|
+
python setup.py lint
|
|
180
|
+
|
|
181
|
+
Links
|
|
182
|
+
------
|
|
183
|
+
- `clashy.py Documentation <https://clashy.clashk.ing/en/latest/?>`_
|
|
184
|
+
- `Official Clash of Clans API Page <https://developer.clashofclans.com/>`_
|
|
185
|
+
- `Clash of Clans API Discord Server <https://discord.gg/Eaja7gJ>`_
|
|
186
|
+
|
|
187
|
+
Disclaimer
|
|
188
|
+
-----------
|
|
189
|
+
This content is not affiliated with, endorsed, sponsored, or specifically
|
|
190
|
+
approved by Supercell and Supercell is not responsible for it.
|
|
191
|
+
For more information see `Supercell's Fan Content Policy. <https://www.supercell.com/fan-content-policy.>`_
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.rst
|
|
4
|
+
pyproject.toml
|
|
5
|
+
requirements.txt
|
|
6
|
+
setup.py
|
|
7
|
+
clashy.py.egg-info/PKG-INFO
|
|
8
|
+
clashy.py.egg-info/SOURCES.txt
|
|
9
|
+
clashy.py.egg-info/dependency_links.txt
|
|
10
|
+
clashy.py.egg-info/requires.txt
|
|
11
|
+
clashy.py.egg-info/top_level.txt
|
|
12
|
+
coc/__init__.py
|
|
13
|
+
coc/__main__.py
|
|
14
|
+
coc/abc.py
|
|
15
|
+
coc/buildings.py
|
|
16
|
+
coc/characters.py
|
|
17
|
+
coc/clans.py
|
|
18
|
+
coc/client.py
|
|
19
|
+
coc/constants.py
|
|
20
|
+
coc/cosmetics.py
|
|
21
|
+
coc/entry_logs.py
|
|
22
|
+
coc/enums.py
|
|
23
|
+
coc/errors.py
|
|
24
|
+
coc/events.py
|
|
25
|
+
coc/events.pyi
|
|
26
|
+
coc/game_data.py
|
|
27
|
+
coc/hero.py
|
|
28
|
+
coc/http.py
|
|
29
|
+
coc/iterators.py
|
|
30
|
+
coc/miscmodels.py
|
|
31
|
+
coc/player_clan.py
|
|
32
|
+
coc/players.py
|
|
33
|
+
coc/raid.py
|
|
34
|
+
coc/spell.py
|
|
35
|
+
coc/troop.py
|
|
36
|
+
coc/utils.py
|
|
37
|
+
coc/war_attack.py
|
|
38
|
+
coc/war_clans.py
|
|
39
|
+
coc/war_members.py
|
|
40
|
+
coc/wars.py
|
|
41
|
+
coc/ext/discordlinks/__init__.py
|
|
42
|
+
coc/ext/triggers/__init__.py
|
|
43
|
+
coc/ext/triggers/cron.py
|
|
44
|
+
coc/ext/triggers/triggers.py
|
|
45
|
+
coc/static/.DS_Store
|
|
46
|
+
coc/static/static_data.json
|
|
47
|
+
coc/static/translations.json
|
|
48
|
+
coc/static/update_static.py
|
|
49
|
+
tests/test_capitalraidseasons.py
|
|
50
|
+
tests/test_clans.py
|
|
51
|
+
tests/test_clash_meta.py
|
|
52
|
+
tests/test_client.py
|
|
53
|
+
tests/test_enums.py
|
|
54
|
+
tests/test_login.py
|
|
55
|
+
tests/test_miscmodels.py
|
|
56
|
+
tests/test_players.py
|
|
57
|
+
tests/test_troop_levels.py
|
|
58
|
+
tests/test_wars.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
coc
|