-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsearch_for_guilds.py
More file actions
66 lines (53 loc) · 2.51 KB
/
Copy pathsearch_for_guilds.py
File metadata and controls
66 lines (53 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
search_for_guilds.py
Sample script to search for guilds by various criteria using the async Comlink client
"""
import asyncio
# Place module imports below this line
from swgoh_comlink import SwgohComlinkAsync
async def main():
# Create instance of SwgohComlinkAsync
async with SwgohComlinkAsync() as comlink:
"""
There are two ways in which guilds can be searched via Comlink. Hence, there are two methods available in the
SwgohComlinkAsync library to call upon. One provides searching for guilds by name. The other provides searching
for guilds by criteria.
Searching for guilds by name requires at least one argument, a string to search on. The search is very lazy, so
the more characters provided, the better the match will be. Searching for the string 'a' will return all guilds
(up to the maximum value of the 'count' parameter) with the letter 'a' anywhere in the name. The default
maximum response record count is 10.
"""
# Search for a guild by name
guilds_by_name = await comlink.get_guilds_by_name(name='guild')
# Print the names of the maximum 10 guilds matched
for guild in guilds_by_name['guild']:
print(f'{guild["name"]=}')
"""
Searching for guilds by criteria offers the ability to find guilds based by characteristics other than name.
The 'search_criteria' argument to get_guilds_by_criteria() method should be a dictionary using the following
template:
search_criteria_template = {
"minMemberCount": 1,
"maxMemberCount": 50,
"includeInviteOnly": True,
"minGuildGalacticPower": 1,
"maxGuildGalacticPower": 500000000,
"recentTbParticipatedIn": []
}
"""
# Search for guilds by criteria
guild_search_criteria = {
"minMemberCount": 48,
"maxMemberCount": 50,
"includeInviteOnly": True,
"minGuildGalacticPower": 500000000,
"maxGuildGalacticPower": 600000000,
"recentTbParticipatedIn": []
}
guilds_by_criteria = await comlink.get_guilds_by_criteria(
search_criteria=guild_search_criteria, count=1000
)
# Check the actual number of guilds over 500m GP with 48 players minimum to compare against the max
# count of 1000
print(len(guilds_by_criteria['guild']))
asyncio.run(main())