mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-25 21:16:28 +00:00
vip 支持通过图片查找相似动漫。
This commit is contained in:
parent
cfd94e667a
commit
1395c71678
@ -342,13 +342,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vip",
|
"name": "vip",
|
||||||
"version": "0.31",
|
"version": "0.40",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "xtaodada",
|
"maintainer": "xtaodada",
|
||||||
"size": "4.0 kb",
|
"size": "4.0 kb",
|
||||||
"supported": true,
|
"supported": true,
|
||||||
"des-short": "vip 捐赠用户功能",
|
"des-short": "vip 捐赠用户功能",
|
||||||
"des": "命令:天气:weather Pixiv:pixiv 百度:baidu Duckduckgo:duckduckgo。与 weather 插件冲突"
|
"des": "命令:天气:weather Pixiv:pixiv \n百度:baidu Duckduckgo:duckduckgo\n相似动漫:whatanime。与 weather 插件冲突"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "calculator",
|
"name": "calculator",
|
||||||
|
68
vip.py
68
vip.py
@ -1,5 +1,8 @@
|
|||||||
|
import io
|
||||||
|
|
||||||
from requests import get
|
from requests import get
|
||||||
from os import remove
|
from os import remove
|
||||||
|
from telethon.tl.types import MessageMediaPhoto
|
||||||
from pagermaid import bot
|
from pagermaid import bot
|
||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
from pagermaid.utils import obtain_message, alias_command
|
from pagermaid.utils import obtain_message, alias_command
|
||||||
@ -96,3 +99,68 @@ async def pixiv(context):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
await context.edit(pixiv_text)
|
await context.edit(pixiv_text)
|
||||||
|
|
||||||
|
|
||||||
|
@listener(is_plugin=True, outgoing=True, command=alias_command("whatanime"),
|
||||||
|
description="通过图片查找相似动漫。(需要回复图片)")
|
||||||
|
async def whatanime(context):
|
||||||
|
reply = await context.get_reply_message()
|
||||||
|
if reply is not None:
|
||||||
|
if reply.media:
|
||||||
|
if not isinstance(reply.media, MessageMediaPhoto):
|
||||||
|
await context.edit("宁需要回复一张图片")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
await context.edit("宁需要回复一张图片")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
await context.edit("宁需要回复一张图片")
|
||||||
|
return
|
||||||
|
await context.edit("获取中。。。")
|
||||||
|
async with bot.conversation('PagerMaid_Modify_bot') as conversation:
|
||||||
|
await conversation.send_message(message='/whatanime_api', file=reply.photo)
|
||||||
|
chat_response = await conversation.get_response()
|
||||||
|
await bot.send_read_acknowledge(conversation.chat_id)
|
||||||
|
whatanime_text = chat_response.text
|
||||||
|
whatanime_list = whatanime_text.split('|||')
|
||||||
|
if len(whatanime_list) == 1:
|
||||||
|
await context.edit(whatanime_text)
|
||||||
|
return
|
||||||
|
link = whatanime_list[0]
|
||||||
|
name = whatanime_list[1]
|
||||||
|
native = whatanime_list[2]
|
||||||
|
episode = whatanime_list[3]
|
||||||
|
alias = whatanime_list[4]
|
||||||
|
r18 = whatanime_list[5]
|
||||||
|
percent = whatanime_list[6]
|
||||||
|
img = whatanime_list[7]
|
||||||
|
video = whatanime_list[8]
|
||||||
|
text = f'[{name}]({link}) (`{native}`)\n'
|
||||||
|
if bool(episode):
|
||||||
|
text += f'\n**集数:** `{episode}`'
|
||||||
|
if bool(alias):
|
||||||
|
text += f'\n**别名:** `{alias}`'
|
||||||
|
if bool(r18):
|
||||||
|
text += f'\n**R-18**'
|
||||||
|
text += f'\n**相似度:** `{percent}`'
|
||||||
|
|
||||||
|
r = get(img)
|
||||||
|
photo = io.BytesIO(r.content)
|
||||||
|
photo.name = f'{name}.png'
|
||||||
|
msg = await context.client.send_file(context.chat_id,
|
||||||
|
file=photo,
|
||||||
|
caption=text,
|
||||||
|
reply_to=reply.id)
|
||||||
|
|
||||||
|
if not video == '':
|
||||||
|
video_list = video.split('||')
|
||||||
|
video = video_list[0]
|
||||||
|
title = video_list[1]
|
||||||
|
start = video_list[2]
|
||||||
|
end = video_list[3]
|
||||||
|
text = f'`{title}`\n\n`{start}` - `{end}`'
|
||||||
|
await context.client.send_file(context.chat_id,
|
||||||
|
video,
|
||||||
|
caption=text,
|
||||||
|
reply_to=msg.id)
|
||||||
|
await context.delete()
|
||||||
|
Loading…
Reference in New Issue
Block a user