forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokedex.py
141 lines (130 loc) · 4.04 KB
/
pokedex.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Creator - @THE_BL_ACK_HAT @Shivam_Patel
#
# Ultroid - UserBot
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available -
• `{i}pokemon <query>`
Send details of Pokemon.
• `{i}pokecard <query>`
Send Card of Pokemon.
"""
from pokedex import pokedex as badhiya
from . import ultroid_cmd, async_searcher
@ultroid_cmd(pattern="pokemon ?(.*)")
async def pokedex(event):
pokemon = event.pattern_match.group(1).lower()
if not pokemon:
await event.eor("`Give a Pokemon Name`")
return
xx = await event.eor("`Booting up the pokedex.......`")
move = await async_searcher(
f"https://pokeapi.co/api/v2/pokemon/{pokemon}", re_json=True
)["moves"]
rw = f"https://some-random-api.ml/pokedex?pokemon={pokemon}"
lol = await async_searcher(
f"https://api.pokemontcg.io/v1/cards?name={pokemon}", re_json=True
)
a = await async_searcher(rw, re_json=True)
try:
name = a["name"]
except Exception:
await event.eor("`Be sure To give correct Name`")
return
typ = a["type"]
species = a["species"]
abilities = a["abilities"]
height = a["height"]
weight = a["weight"]
esatge = a["family"]["evolutionStage"]
try:
weaknesses = lol["cards"][0]["weaknesses"][0]["type"]
except BaseException:
weaknesses = None
l = a["family"]["evolutionLine"]
# ambiguous variable name 'l' flake8(E741)
if not l:
line = "None"
else:
line = ", ".join(map(str, l))
gen = a["generation"]
try:
move1 = move[0]["move"]["name"]
except IndexError:
move1 = None
try:
move2 = move[1]["move"]["name"]
except IndexError:
move2 = None
try:
move3 = move[2]["move"]["name"]
except IndexError:
move3 = None
try:
move4 = move[3]["move"]["name"]
except IndexError:
move4 = None
try:
move5 = move[4]["move"]["name"]
except IndexError:
move5 = None
try:
move6 = move[5]["move"]["name"]
except IndexError:
move6 = None
try:
move7 = move[6]["move"]["name"]
except IndexError:
move7 = None
description = a["description"]
typ = ", ".join(map(str, typ))
Stats = a["stats"]
species = ", ".join(map(str, species))
abilities = ", ".join(map(str, abilities))
poli = badhiya.Pokedex()
pname = poli.get_pokemon_by_name(pokemon)
pokemon = pname[0]
lst = pokemon.get("sprite")
cap = f"""
**NAME** : `{name}`
**TYPE** : `{typ}`
**SPECIES** : `{species}`
**Evolution Line** : `{line}`
**Evolution Stage** : `{esatge}`
**Generation** : `{gen}`
**ABILITIES** : `{abilities}`
**WEAKNESSES** :`{weaknesses}`
**HEIGHT** : `{height}`
**WEIGHT** : `{weight}`
**Stats** **Moves**
**Hp** : `{Stats['hp']}` `(1){move1}`
**Attack** : `{Stats['attack']}` `(2){move2}`
**Defense** : `{Stats['defense']}` `(3){move3}`
**Sp_atk** : `{Stats['sp_atk']}` `(4){move4}`
**Sp_def** : `{Stats['sp_def']}` `(5){move5}`
**Speed** : `{Stats['speed']}` `(6){move6}`
**Total** : `{Stats['total']}` `(7){move7}`
**DESCRIPTION** : `{description}`
"""
await event.client.send_file(event.chat_id, lst, caption=cap)
await xx.delete()
@ultroid_cmd(pattern="pokecard ?(.*)")
async def pokecard(event):
pokename = event.pattern_match.group(1).lower()
if not pokename:
await event.eor("`Give A Pokemon name`")
return
rw = f"https://api.pokemontcg.io/v1/cards?name={pokename}"
a = await async_searcher(rw, re_json=True)
try:
o = a["cards"][0]["imageUrlHiRes"]
await event.client.send_file(
await event.client.get_input_entity(event.chat_id), o
)
await event.delete()
except BaseException:
await event.eor("`Be sure To give correct Name`")
return