-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
anime.py
45 lines (39 loc) · 1.46 KB
/
anime.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
# Ultroid - UserBot
# Copyright (C) 2021-2022 TeamUltroid
#
# 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}character <character name>`
Fetch anime character details.
"""
import jikanpy
from . import *
@ultroid_cmd(pattern="character ?(.*)")
async def anime_char_search(event):
xx = await event.eor(get_string("com_1"))
char_name = event.pattern_match.group(1)
if not char_name:
await eod(xx, "`Enter the name of a character too please!`", time=5)
jikan = jikanpy.jikan.Jikan()
try:
s = jikan.search("character", char_name)
except jikanpy.exceptions.APIException:
return await eod(xx, "`Couldn't find character!`", time=5)
a = s["results"][0]["mal_id"]
char_json = jikan.character(a)
pic = char_json["image_url"]
msg = f"**[{char_json['name']}]({char_json['url']})**"
if char_json["name_kanji"] != "Japanese":
msg += f" [{char_json['name_kanji']}]\n"
else:
msg += "\n"
if char_json["nicknames"]:
nicknames_string = ", ".join(char_json["nicknames"])
msg += f"\n**Nicknames** : `{nicknames_string}`\n"
about = char_json["about"].split("\n", 1)[0].strip().replace("\n", "")
msg += f"\n**About**: __{about}__"
await event.reply(msg, file=pic, force_document=False)
await xx.delete()