mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
二次元、原神图片增加自动撤回
This commit is contained in:
parent
f3ab0d0c19
commit
398f3fe52b
@ -6,7 +6,7 @@ from nonebot.params import CommandArg, RegexGroup
|
||||
from nonebot.message import event_preprocessor
|
||||
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, MessageEvent, MessageSegment, FriendRequestEvent, \
|
||||
GroupRequestEvent
|
||||
from ..utils.util import FreqLimiter
|
||||
from ..utils.util import FreqLimiter, auto_withdraw
|
||||
from ..utils.config import config
|
||||
from asyncio import sleep
|
||||
import random
|
||||
@ -62,7 +62,8 @@ async def cat_pic_handler(event: Union[GroupMessageEvent, MessageEvent]):
|
||||
|
||||
|
||||
@ecy_pic.handle()
|
||||
async def ecy_pic_handler(event: Union[GroupMessageEvent, MessageEvent], regexGroup=RegexGroup()):
|
||||
@auto_withdraw(15)
|
||||
async def ecy_pic_handler(bot: Bot, event: Union[GroupMessageEvent, MessageEvent], regexGroup=RegexGroup()):
|
||||
urls = [
|
||||
'https://www.dmoe.cc/random.php',
|
||||
'https://acg.toubiec.cn/random.php',
|
||||
@ -89,10 +90,11 @@ async def ecy_pic_handler(event: Union[GroupMessageEvent, MessageEvent], regexGr
|
||||
elif url:
|
||||
await cat_pic.send('派蒙努力找图ing..请稍候...')
|
||||
ecy_lmt.start_cd(event.group_id or event.user_id, config.paimon_ecy_cd)
|
||||
await cat_pic.finish(MessageSegment.image(file=url))
|
||||
return await cat_pic.send(MessageSegment.image(file=url))
|
||||
|
||||
|
||||
@ys_pic.handle()
|
||||
@auto_withdraw(30)
|
||||
async def ys_pic_handler(event: Union[GroupMessageEvent, MessageEvent]):
|
||||
urls = [
|
||||
'https://api.r10086.com/img-api.php?type=%E5%8E%9F%E7%A5%9E%E6%A8%AA%E5%B1%8F%E7%B3%BB%E5%88%971',
|
||||
|
@ -4,20 +4,34 @@ from typing import List
|
||||
|
||||
|
||||
class PluginConfig(BaseModel):
|
||||
# 群组模拟抽卡冷却(秒)
|
||||
paimon_gacha_cd_group: int = 30
|
||||
# 个人模拟抽卡冷却(秒)
|
||||
paimon_gacha_cd_user: int = 60
|
||||
# 树脂提醒停止检查时间(小时)
|
||||
paimon_remind_start: int = 0
|
||||
paimon_remind_end: int = 8
|
||||
# 树脂提醒检查间隔(分钟)
|
||||
paimon_check_interval: int = 16
|
||||
# 树脂提醒每日提醒次数上限
|
||||
paimon_remind_limit: int = 3
|
||||
# 自动签到开始时间(小时)
|
||||
paimon_sign_hour: int = 0
|
||||
# 自动签到开始时间(分钟)
|
||||
paimon_sign_minute: int = 0
|
||||
# 对联冷却(秒)
|
||||
paimon_duilian_cd: int = 6
|
||||
# 猫图冷却(秒)
|
||||
paimon_cat_cd: int = 12
|
||||
# 二次元图冷却(秒)
|
||||
paimon_ecy_cd: int = 6
|
||||
# 原神壁纸图冷却(秒)
|
||||
paimon_ysp_cd: int = 10
|
||||
# 是否自动通过好友请求
|
||||
paimon_add_friend: bool = False
|
||||
# 是否自动通过群组请求
|
||||
paimon_add_group: bool = False
|
||||
# 派蒙聊天开启群组
|
||||
paimon_chat_group: List[int] = []
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ import string
|
||||
import functools
|
||||
import inspect
|
||||
import json
|
||||
import asyncio
|
||||
from json import JSONDecodeError
|
||||
from aiohttp import ClientSession
|
||||
from nonebot import get_bot
|
||||
@ -23,6 +24,24 @@ from .db_util import get_cookie_cache, update_cookie_cache, delete_cookie_cache
|
||||
from .db_util import get_last_query, update_last_query
|
||||
|
||||
|
||||
def auto_withdraw(seconds: int = -1):
|
||||
def wrapper(func):
|
||||
|
||||
@functools.wraps(func)
|
||||
async def wrapped(**kwargs):
|
||||
try:
|
||||
message_id = await func(**kwargs)
|
||||
if message_id and seconds >= 1:
|
||||
await asyncio.sleep(seconds)
|
||||
await get_bot().delete_msg(message_id=message_id['message_id'])
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
return wrapped
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
# 缓存装饰器 ttl为过期时间 参数use_cache决定是否使用缓存,默认为True
|
||||
def cache(ttl=datetime.timedelta(hours=1), **kwargs):
|
||||
def wrap(func):
|
||||
|
Loading…
Reference in New Issue
Block a user