Skip to content

Commit

Permalink
maybe fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
prono69 committed Sep 16, 2024
1 parent e8b9830 commit d87c452
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ hentai
html-telegraph-poster
httpx[http2]
humanize
jikanpy
jikanpy-v4
justwatch
kwot
lottie
Expand Down
23 changes: 13 additions & 10 deletions userbot/plugins/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ async def user(event):
else:
return await edit_delete(event, "__Whom should i search.__")
try:
user = jikan.user(search_query)
user_ = jikan.users(search_query)
user = user_["data"]
except APIException:
return await edit_delete(event, "__No User found with given username__", 5)
date_format = "%Y-%m-%d"
img = user["image_url"] or "https://graph.org/file/9b4205e1b1cc68a4ffd5e.jpg"
img = user["images"]["jpg"]["image_url"] or "https://graph.org/file/9b4205e1b1cc68a4ffd5e.jpg"
try:
user_birthday = datetime.fromisoformat(user["birthday"])
user_birthday_formatted = user_birthday.strftime(date_format)
Expand Down Expand Up @@ -679,11 +680,12 @@ async def character(event):
)
catevent = await edit_or_reply(event, "`Searching Character...`")
try:
search_result = jikan.search("character", search_query)
search_result = jikan.search("characters", search_query)
except APIException:
return await edit_delete(catevent, "`Character not found.`")
first_mal_id = search_result["results"][0]["mal_id"]
character = jikan.character(first_mal_id)
first_mal_id = search_result["data"][0]["mal_id"]
character_ = jikan.characters(first_mal_id)
character = character_["data"]
caption = f"🇯🇵 [{character['name']}]({character['url']})"
if character["name_kanji"] != "Japanese":
caption += f" • `{character['name_kanji']}`\n"
Expand All @@ -698,7 +700,7 @@ async def character(event):
except IndexError:
pass
about_string = " ".join(about)
mal_url = search_result["results"][0]["url"]
mal_url = search_result["data"][0]["url"]
for entity in character:
if character[entity] is None:
character[entity] = "Unknown"
Expand All @@ -707,7 +709,7 @@ async def character(event):
await catevent.delete()
await event.client.send_file(
event.chat_id,
file=character["image_url"],
file=character["images"]["jpg"]["image_url"],
caption=replace_text(caption),
reply_to=reply_to,
)
Expand Down Expand Up @@ -948,7 +950,7 @@ async def manga(event):
res = ""
manga = ""
try:
res = jikan.search("manga", query).get("results")[0].get("mal_id")
res = jikan.search("manga", query).get("data")[0].get("mal_id")
except APIException:
await edit_delete(event, "Error connecting to the API. Please try again!", 5)
return ""
Expand Down Expand Up @@ -1020,15 +1022,16 @@ async def get_anime(message):
try:
jikan = jikanpy.AioJikan()
search_res = await jikan.search("anime", query)
f_mal_id = search_res["results"][0]["mal_id"]
f_mal_id = search_res["data"][0]["mal_id"]
except IndexError:
await p_rm.edit(f"No Results Found for {query}")
return
except Exception as err:
await p_rm.edit(f"**Encountered an Unknown Exception**: \n{err}")
return

results_ = await jikan.anime(f_mal_id)
results_k = await jikan.anime(f_mal_id)
results_ = results_k["data"]
await jikan.close()

# Get All Info of anime
Expand Down
10 changes: 5 additions & 5 deletions userbot/plugins/corecmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def plug_checker(plugin):


@catub.cat_cmd(
pattern="install(?:\s|$)([\s\S]*)",
pattern="(install|i) (?:\s|$)([\s\S]*)",
command=("install", plugin_category),
info={
"header": "To install an external plugin.",
Expand All @@ -56,7 +56,7 @@ def plug_checker(plugin):
)
async def install(event):
"To install an external plugin."
install_path = event.pattern_match.group(1) or "userbot/plugins"
install_path = event.pattern_match.group(2) or "userbot/plugins"
if event.reply_to_msg_id:
try:
downloaded_file_name = await event.client.download_media(
Expand Down Expand Up @@ -173,7 +173,7 @@ async def unload(event):


@catub.cat_cmd(
pattern="uninstall(?:\s|$)([\s\S]*)",
pattern="(uninstall|ui) (?:\s|$)([\s\S]*)",
command=("uninstall", plugin_category),
info={
"header": "To uninstall a plugin temporarily.",
Expand All @@ -185,7 +185,7 @@ async def unload(event):
)
async def unload(event):
"To uninstall a plugin."
shortname = event.pattern_match.group(1)
shortname = event.pattern_match.group(2)
path = plug_checker(shortname)
if not os.path.exists(path):
return await edit_delete(
Expand Down Expand Up @@ -270,7 +270,7 @@ async def app_log(event):
flag = event.pattern_match.group(1)
flag = [*flag]
if flag and (
flag[0] != "-" or any(i not in ["-", "f", "r", "t", "o"] for i in flag)
flag[0] != any(i not in ["f", "r", "t", "o"] for i in flag)
):
return await edit_delete(event, "**Invalid flag...**")

Expand Down

0 comments on commit d87c452

Please sign in to comment.