forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pokedex.py
141 lines (130 loc) · 4.08 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.
"""
import requests
from pokedex import pokedex as badhiya
from . import *
@ultroid_cmd(pattern="pokemon ?(.*)")
async def pokedex(event):
pokemon = event.pattern_match.group(1).lower()
if not pokemon:
await eor(event, "`Give a Pokemon Name`")
return
xx = await eor(event, "`Booting up the pokedex.......`")
move = requests.get(f"https://pokeapi.co/api/v2/pokemon/{pokemon}")
rw = f"https://some-random-api.ml/pokedex?pokemon={pokemon}"
w = requests.get(f"https://api.pokemontcg.io/v1/cards?name={pokemon}")
lol = w.json()
r = requests.get(rw)
a = r.json()
try:
name = a["name"]
except Exception:
await eor(event, "`Be sure To give correct Name`")
return
typ = a["type"]
species = a["species"]
abilities = a["abilities"]
height = a["height"]
weight = a["weight"]
esatge = r.json()["family"]["evolutionStage"]
try:
weaknesses = lol["cards"][0]["weaknesses"][0]["type"]
except BaseException:
weaknesses = None
l = r.json()["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.json()["moves"][0]["move"]["name"]
except IndexError:
move1 = None
try:
move2 = move.json()["moves"][1]["move"]["name"]
except IndexError:
move2 = None
try:
move3 = move.json()["moves"][2]["move"]["name"]
except IndexError:
move3 = None
try:
move4 = move.json()["moves"][3]["move"]["name"]
except IndexError:
move4 = None
try:
move5 = move.json()["moves"][4]["move"]["name"]
except IndexError:
move5 = None
try:
move6 = move.json()["moves"][5]["move"]["name"]
except IndexError:
move6 = None
try:
move7 = move.json()["moves"][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 eor(event, "`Give A Pokemon name`")
return
rw = f"https://api.pokemontcg.io/v1/cards?name={pokename}"
r = requests.get(rw)
a = r.json()
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 eor(event, "`Be sure To give correct Name`")
return