Skip to content

Commit

Permalink
unify booru modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick80835 committed Oct 3, 2020
1 parent 94fa7c1 commit 2fa1285
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 120 deletions.
30 changes: 30 additions & 0 deletions ubot/modules/booru.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-License-Identifier: GPL-2.0-or-later

from asyncbooru import Danbooru, Gelbooru, Konachan, Sankaku, Yandere
from ubot import ldr

commands = {
("dan", "danx", "danq", "dans"): Danbooru(ldr.aioclient),
("gel", "gelx", "gelq", "gels"): Gelbooru(ldr.aioclient),
("kon", "konx", "konq", "kons"): Konachan(ldr.aioclient),
("san", "sanx", "sanq", "sans"): Sankaku(ldr.aioclient),
("yan", "yanx", "yanq", "yans"): Yandere(ldr.aioclient)
}


@ldr.add_dict(commands, pattern_extra="(f|)", help="Fetches images from Danbooru, Gelbooru, Konachan, Sankaku Complex and Yandere, takes tags as arguments.")
async def booru(event):
await event.edit(f"`Processing…`")
safety_arg = event.command[-1]
as_file = bool(event.other_args[0])
post = await event.extra.get_random_post(event.args, safety_arg)

if not post or not post.file_url:
await event.edit(f"`No results for query: `**{event.args}**")
return

try:
await event.client.send_message(event.chat_id, f"[sauce]({post.sauce})", file=post.file_url, force_document=as_file)
await event.delete()
except:
await event.edit(f"`Failed to fetch media for query: `**{event.args}**")
24 changes: 0 additions & 24 deletions ubot/modules/danbooru.py

This file was deleted.

24 changes: 0 additions & 24 deletions ubot/modules/gelbooru.py

This file was deleted.

24 changes: 0 additions & 24 deletions ubot/modules/konachan.py

This file was deleted.

24 changes: 0 additions & 24 deletions ubot/modules/sankaku.py

This file was deleted.

24 changes: 0 additions & 24 deletions ubot/modules/yandere.py

This file was deleted.

0 comments on commit 2fa1285

Please sign in to comment.