From ba7f2b6f993879091406b1e670598146c84f353b Mon Sep 17 00:00:00 2001 From: blank X Date: Fri, 13 Nov 2020 12:24:00 +0700 Subject: [PATCH] Initial commit --- README.md | 3 +++ nhentai-comment-info.py | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 README.md create mode 100644 nhentai-comment-info.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..d16cd64 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Sukuinote Dorei + +Specific-purpose slave plugins for sukuinote that I don't think benefits most people diff --git a/nhentai-comment-info.py b/nhentai-comment-info.py new file mode 100644 index 0000000..8a24791 --- /dev/null +++ b/nhentai-comment-info.py @@ -0,0 +1,46 @@ +import html +from pyrogram import Client, filters +from ... import session, log_errors, public_log_errors, config + +PRETTY_TAG_NAMES = { + 'tag': 'Tags', + 'artist': 'Artists', + 'parody': 'Parodies', + 'character': 'Characters', + 'group': 'Groups', + 'language': 'Languages', + 'category': 'Categories' +} + +@Client.on_message(~filters.sticker & filters.chat(-1001150433131) & filters.linked_channel) +@log_errors +@public_log_errors +async def nhentai_comment_info(client, message): + sent = set() + text = message.text or message.caption or '' + for i in text.split('\n'): + for sauce in i.split(' '): + if sauce.isnumeric() and sauce not in sent: + sent.add(sauce) + async with session.get(f'https://nhentai.net/api/gallery/{sauce}') as resp: + info = await resp.json() + text = f'{sauce}\n' + if info.get('error'): + text += f'Error: {html.escape(info.get("error"))}' + else: + text += 'Title: ' + if info['title']['english']: + text += html.escape(info['title']['english']) + if info['title']['japanese']: + text += '\nJapanese Title: ' + if info['title']['japanese']: + text += html.escape(info['title']['japanese']) + tags = dict() + for i in info['tags']: + if i['type'] not in tags: + tags[i['type']] = [] + tags[i['type']].append(i['name']) + for i in sorted(tags): + text += f'\n{PRETTY_TAG_NAMES.get(i, i)}: {html.escape(", ".join(tags[i]))}' + text += f'\nPages: {info["num_pages"]}' + await message.reply_text(text, disable_web_page_preview=True)