2022-05-15 20:15:10 +08:00
|
|
|
import random
|
2022-07-03 21:26:33 +08:00
|
|
|
|
|
|
|
from littlepaimon_utils.tools import FreqLimiter
|
2022-05-15 20:15:10 +08:00
|
|
|
from nonebot import on_command, on_regex
|
|
|
|
from nonebot.adapters.onebot.v11 import Bot, MessageEvent, MessageSegment
|
2022-07-03 21:26:33 +08:00
|
|
|
from nonebot.params import RegexGroup
|
2022-06-21 16:26:13 +08:00
|
|
|
from nonebot.plugin import PluginMetadata
|
|
|
|
|
2022-07-03 21:26:33 +08:00
|
|
|
from ..utils.config import config
|
|
|
|
from ..utils.decorator import auto_withdraw
|
|
|
|
from ..utils.message_util import get_message_id
|
2022-06-21 16:26:13 +08:00
|
|
|
|
|
|
|
__plugin_meta__ = PluginMetadata(
|
|
|
|
name="随机图片",
|
|
|
|
description="从各随机图片接口获取一张图片",
|
|
|
|
usage=(
|
|
|
|
"来点猫片\n"
|
|
|
|
"来点二次元图\n"
|
|
|
|
),
|
|
|
|
extra={
|
|
|
|
'type': '娱乐',
|
|
|
|
'range': ['private', 'group', 'guild'],
|
|
|
|
"author": "惜月 <277073121@qq.com>",
|
|
|
|
"version": "1.0.0",
|
|
|
|
},
|
|
|
|
)
|
2022-06-09 21:57:56 +08:00
|
|
|
|
2022-05-15 20:15:10 +08:00
|
|
|
cat_lmt = FreqLimiter(config.paimon_cat_cd)
|
|
|
|
ecy_lmt = FreqLimiter(config.paimon_ecy_cd)
|
|
|
|
ys_lmt = FreqLimiter(config.paimon_ysp_cd)
|
|
|
|
|
|
|
|
cat_img = on_command('猫图', aliases={'来点猫片', '看看猫猫', '来个猫猫'}, priority=13, block=True)
|
2022-06-09 21:57:56 +08:00
|
|
|
cat_img.__paimon_help__ = {
|
|
|
|
"usage": "来点猫片",
|
|
|
|
"introduce": "谁会拒绝可爱的猫猫图呢",
|
|
|
|
"priority": 13
|
|
|
|
}
|
2022-05-15 20:15:10 +08:00
|
|
|
ecy_img = on_regex(r'^来点(二次元|二刺螈|银发|兽耳|星空|竖屏|横屏)图?$', priority=13, block=True)
|
2022-06-09 21:57:56 +08:00
|
|
|
ecy_img.__paimon_help__ = {
|
|
|
|
"usage": "来点<类型>图",
|
|
|
|
"introduce": "懂得都懂,类型有原神|二次元|二刺螈|银发|兽耳|星空|竖屏|横屏",
|
|
|
|
"priority": 13
|
|
|
|
}
|
2022-05-15 20:15:10 +08:00
|
|
|
ys_img = on_command('原神壁纸', aliases={'来点原神图', '来点原神壁纸'}, priority=13, block=True)
|
|
|
|
|
|
|
|
|
|
|
|
@cat_img.handle()
|
|
|
|
async def cat_img_handler(event: MessageEvent):
|
2022-05-20 18:44:18 +08:00
|
|
|
if not cat_lmt.check(get_message_id(event)):
|
|
|
|
await cat_img.finish(f'猫片冷却ing(剩余{cat_lmt.left_time(get_message_id(event))}秒)')
|
2022-05-15 20:15:10 +08:00
|
|
|
else:
|
|
|
|
await cat_img.send('派蒙努力找图ing..请稍候...')
|
2022-05-20 18:44:18 +08:00
|
|
|
cat_lmt.start_cd(get_message_id(event), config.paimon_cat_cd)
|
2022-05-15 20:15:10 +08:00
|
|
|
url = 'http://edgecats.net/'
|
|
|
|
await cat_img.finish(MessageSegment.image(file=url))
|
|
|
|
|
|
|
|
|
|
|
|
@ecy_img.handle()
|
|
|
|
@auto_withdraw(15)
|
|
|
|
async def ecy_img_handler(bot: Bot, event: MessageEvent, regexGroup=RegexGroup()):
|
|
|
|
urls = [
|
|
|
|
'https://www.dmoe.cc/random.php',
|
|
|
|
'https://acg.toubiec.cn/random.php',
|
|
|
|
'https://api.ixiaowai.cn/api/api.php',
|
2022-07-26 21:55:59 +08:00
|
|
|
'https://dev.iw233.cn/api.php?sort=iw233'
|
2022-05-15 20:15:10 +08:00
|
|
|
]
|
|
|
|
img_type = regexGroup[0]
|
|
|
|
if img_type in ['二次元', '二刺螈']:
|
|
|
|
url = random.choice(urls)
|
|
|
|
elif img_type == '银发':
|
2022-07-26 21:55:59 +08:00
|
|
|
url = 'https://dev.iw233.cn/api.php?sort=yin'
|
2022-05-15 20:15:10 +08:00
|
|
|
elif img_type == '兽耳':
|
2022-07-26 21:55:59 +08:00
|
|
|
url = 'https://dev.iw233.cn/api.php?sort=cat'
|
2022-05-15 20:15:10 +08:00
|
|
|
elif img_type == '星空':
|
2022-07-26 21:55:59 +08:00
|
|
|
url = 'https://dev.iw233.cn/api.php?sort=xing'
|
2022-05-15 20:15:10 +08:00
|
|
|
elif img_type == '竖屏':
|
2022-07-26 21:55:59 +08:00
|
|
|
url = 'https://dev.iw233.cn/api.php?sort=mp'
|
2022-05-15 20:15:10 +08:00
|
|
|
elif img_type == '横屏':
|
2022-07-26 21:55:59 +08:00
|
|
|
url = 'https://dev.iw233.cn/api.php?sort=pc'
|
2022-05-15 20:15:10 +08:00
|
|
|
else:
|
|
|
|
url = ''
|
2022-05-20 18:44:18 +08:00
|
|
|
if not ecy_lmt.check(get_message_id(event)):
|
|
|
|
await ecy_img.finish(f'二次元图片冷却ing(剩余{ecy_lmt.left_time(get_message_id(event))}秒)')
|
2022-05-15 20:15:10 +08:00
|
|
|
elif url:
|
|
|
|
await ecy_img.send('派蒙努力找图ing..请稍候...')
|
2022-05-20 18:44:18 +08:00
|
|
|
ecy_lmt.start_cd(get_message_id(event), config.paimon_ecy_cd)
|
2022-05-15 20:15:10 +08:00
|
|
|
return await ecy_img.send(MessageSegment.image(file=url))
|
|
|
|
|
|
|
|
|
|
|
|
@ys_img.handle()
|
|
|
|
@auto_withdraw(30)
|
|
|
|
async def ys_img_handler(event: MessageEvent):
|
|
|
|
urls = [
|
|
|
|
'https://api.dreamofice.cn/random-v0/img.php?game=ys'
|
|
|
|
]
|
2022-05-20 18:44:18 +08:00
|
|
|
if not ys_lmt.check(get_message_id(event)):
|
|
|
|
await ys_img.finish(f'原神壁纸冷却ing(剩余{ys_lmt.left_time(get_message_id(event))}秒)')
|
2022-05-15 20:15:10 +08:00
|
|
|
else:
|
|
|
|
await ys_img.send('派蒙努力找图ing..请稍候...')
|
2022-05-20 18:44:18 +08:00
|
|
|
ys_lmt.start_cd(get_message_id(event), config.paimon_ysp_cd)
|
2022-05-15 20:15:10 +08:00
|
|
|
await ys_img.finish(MessageSegment.image(file=random.choice(urls)))
|