Add loli
This commit is contained in:
parent
1395649a31
commit
399d8a206c
|
@ -12,6 +12,7 @@ config:
|
||||||
log_chat: -1001278205033
|
log_chat: -1001278205033
|
||||||
spamwatch_api: https://t.me/SpamWatchBot
|
spamwatch_api: https://t.me/SpamWatchBot
|
||||||
saucenao_api: https://saucenao.com/user.php?page=search-api
|
saucenao_api: https://saucenao.com/user.php?page=search-api
|
||||||
|
lolicon_api: https://t.me/setu_robot
|
||||||
log_user_joins: false
|
log_user_joins: false
|
||||||
log_user_adds: true
|
log_user_adds: true
|
||||||
log_reports: true
|
log_reports: true
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
from pyrogram import Client, filters
|
||||||
|
from pyrogram.errors.exceptions.forbidden_403 import Forbidden
|
||||||
|
from .. import slave, config, help_dict, log_errors, public_log_errors
|
||||||
|
|
||||||
|
@Client.on_message(~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['loli', 'sfwloli', 'sloli', 'nsfwloli', 'nloli'], prefixes=config['config']['prefixes']))
|
||||||
|
@log_errors
|
||||||
|
@public_log_errors
|
||||||
|
async def loli(client, message):
|
||||||
|
bot = await slave.get_me()
|
||||||
|
query = ' '.join(message.command)
|
||||||
|
results = await client.get_inline_bot_results(bot.username or bot.id, query)
|
||||||
|
try:
|
||||||
|
await message.reply_inline_bot_result(results.query_id, results.results[0].id)
|
||||||
|
except Forbidden:
|
||||||
|
await message.reply_text({'message': results.results[0].send_message.message, 'entities': results.results[0].send_message.entities}, disable_web_page_preview=True, parse_mode='through')
|
||||||
|
|
||||||
|
help_dict['loli'] = ('Loli',
|
||||||
|
'''{prefix}loli <i>[keywords]</i> - Gets a possibly nsfw image of a loli, thanks to lolicon.app
|
||||||
|
Can also be activated inline with: @{bot} loli <i>[keywords]</i>
|
||||||
|
|
||||||
|
{prefix}sfwloli <i>[keywords]</i> - Gets a sfw image of a loli, thanks to lolicon.app
|
||||||
|
Aliases: {prefix}sloli
|
||||||
|
Can also be activated inline with: @{bot} sfwloli <i>[keywords]</i> or @{bot} sloli <i>[keywords]</i>
|
||||||
|
|
||||||
|
{prefix}nsfwloli <i>[keywords]</i> - Gets an nsfw image of a loli, thanks to lolicon.app
|
||||||
|
Aliases: {prefix}nloli
|
||||||
|
Can also be activated inline with: @{bot} nsfwloli <i>[keywords]</i> or @{bot} nloli <i>[keywords]</i>''')
|
|
@ -0,0 +1,34 @@
|
||||||
|
import html
|
||||||
|
from urllib.parse import quote as urlencode
|
||||||
|
from pyrogram import Client, filters
|
||||||
|
from pyrogram.types import InputTextMessageContent, InlineQueryResultArticle, InlineQueryResultPhoto
|
||||||
|
from .. import log_errors, session, app_user_ids, config
|
||||||
|
|
||||||
|
@Client.on_inline_query(filters.regex(f'^(s(?:fw)?|n(?:sfw)?)?loli(.*)$'))
|
||||||
|
@log_errors
|
||||||
|
async def loli(client, inline_query):
|
||||||
|
if inline_query.from_user.id not in app_user_ids:
|
||||||
|
await inline_query.answer([InlineQueryResultArticle('...no', InputTextMessageContent('...no'))], cache_time=3600, is_personal=True)
|
||||||
|
return
|
||||||
|
match = inline_query.matches[0]
|
||||||
|
if mode := match.group(1):
|
||||||
|
if mode.startswith('s'):
|
||||||
|
mode = 0
|
||||||
|
else:
|
||||||
|
mode = 1
|
||||||
|
else:
|
||||||
|
mode = 2
|
||||||
|
async with session.get(f'https://api.lolicon.app/setu?num=1&r18={mode}&keyword={urlencode(match.group(2).strip())}&apikey={urlencode(config["config"].get("lollicon_api", ""))}') as resp:
|
||||||
|
data = await resp.json()
|
||||||
|
if data['code'] or data['msg']:
|
||||||
|
item = InlineQueryResultArticle(f'Error {data["code"]}', InputTextMessageContent(f'<b>{html.escape(str(data["code"]))}:</b> {html.escape(data["msg"])}', description=data['msg'] or None, parse_mode='html'))
|
||||||
|
else:
|
||||||
|
data = data['data'][0]
|
||||||
|
title = f'{data["title"]} by {data["author"]}'
|
||||||
|
description = None
|
||||||
|
caption = f'<a href="https://pixiv.net/artworks/{data["pid"]}">{html.escape(data["title"])}</a> by <a href="https://pixiv.net/users/{data["uid"]}">{html.escape(data["author"]}</a>\n'
|
||||||
|
if data['tags']:
|
||||||
|
caption += f'<b>Tags:</b> {html.escape(", ".join(data["tags"]))}'
|
||||||
|
description = f'Tags: {", ".join(data["tags"])}'
|
||||||
|
item = InlineQueryResultPhoto(data['url'], title=title, description=description, caption=caption, parse_mode='html')
|
||||||
|
await inline_query.answer([item], cache_time=0)
|
Loading…
Reference in New Issue